babylon.max.js 6.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs", [], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs"] = factory();
  8. else
  9. root["BABYLON"] = factory();
  10. })(window, function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./Legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../node_modules/tslib/tslib.es6.js":
  99. /*!******************************************!*\
  100. !*** ../node_modules/tslib/tslib.es6.js ***!
  101. \******************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  272. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../node_modules/webpack/buildin/global.js":
  291. /*!*************************************************!*\
  292. !*** ../node_modules/webpack/buildin/global.js ***!
  293. \*************************************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./Actions/abstractActionManager.ts":
  314. /*!******************************************!*\
  315. !*** ./Actions/abstractActionManager.ts ***!
  316. \******************************************/
  317. /*! exports provided: AbstractActionManager */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractActionManager", function() { return AbstractActionManager; });
  322. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  323. /**
  324. * Abstract class used to decouple action Manager from scene and meshes.
  325. * Do not instantiate.
  326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  327. */
  328. var AbstractActionManager = /** @class */ (function () {
  329. function AbstractActionManager() {
  330. /** Gets the cursor to use when hovering items */
  331. this.hoverCursor = '';
  332. /** Gets the list of actions */
  333. this.actions = new Array();
  334. }
  335. Object.defineProperty(AbstractActionManager, "HasTriggers", {
  336. /**
  337. * Does exist one action manager with at least one trigger
  338. **/
  339. get: function () {
  340. for (var t in AbstractActionManager.Triggers) {
  341. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  342. return true;
  343. }
  344. }
  345. return false;
  346. },
  347. enumerable: true,
  348. configurable: true
  349. });
  350. Object.defineProperty(AbstractActionManager, "HasPickTriggers", {
  351. /**
  352. * Does exist one action manager with at least one pick trigger
  353. **/
  354. get: function () {
  355. for (var t in AbstractActionManager.Triggers) {
  356. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  357. var t_int = parseInt(t);
  358. if (t_int >= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickTrigger && t_int <= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickUpTrigger) {
  359. return true;
  360. }
  361. }
  362. }
  363. return false;
  364. },
  365. enumerable: true,
  366. configurable: true
  367. });
  368. /**
  369. * Does exist one action manager that handles actions of a given trigger
  370. * @param trigger defines the trigger to be tested
  371. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  372. **/
  373. AbstractActionManager.HasSpecificTrigger = function (trigger) {
  374. for (var t in AbstractActionManager.Triggers) {
  375. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  376. var t_int = parseInt(t);
  377. if (t_int === trigger) {
  378. return true;
  379. }
  380. }
  381. }
  382. return false;
  383. };
  384. /** Gets the list of active triggers */
  385. AbstractActionManager.Triggers = {};
  386. return AbstractActionManager;
  387. }());
  388. /***/ }),
  389. /***/ "./Actions/action.ts":
  390. /*!***************************!*\
  391. !*** ./Actions/action.ts ***!
  392. \***************************/
  393. /*! exports provided: Action */
  394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  395. "use strict";
  396. __webpack_require__.r(__webpack_exports__);
  397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return Action; });
  398. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  399. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  400. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  401. /**
  402. * The action to be carried out following a trigger
  403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  404. */
  405. var Action = /** @class */ (function () {
  406. /**
  407. * Creates a new Action
  408. * @param triggerOptions the trigger, with or without parameters, for the action
  409. * @param condition an optional determinant of action
  410. */
  411. function Action(
  412. /** the trigger, with or without parameters, for the action */
  413. triggerOptions, condition) {
  414. this.triggerOptions = triggerOptions;
  415. /**
  416. * An event triggered prior to action being executed.
  417. */
  418. this.onBeforeExecuteObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  419. if (triggerOptions.parameter) {
  420. this.trigger = triggerOptions.trigger;
  421. this._triggerParameter = triggerOptions.parameter;
  422. }
  423. else if (triggerOptions.trigger) {
  424. this.trigger = triggerOptions.trigger;
  425. }
  426. else {
  427. this.trigger = triggerOptions;
  428. }
  429. this._nextActiveAction = this;
  430. this._condition = condition;
  431. }
  432. /**
  433. * Internal only
  434. * @hidden
  435. */
  436. Action.prototype._prepare = function () {
  437. };
  438. /**
  439. * Gets the trigger parameters
  440. * @returns the trigger parameters
  441. */
  442. Action.prototype.getTriggerParameter = function () {
  443. return this._triggerParameter;
  444. };
  445. /**
  446. * Internal only - executes current action event
  447. * @hidden
  448. */
  449. Action.prototype._executeCurrent = function (evt) {
  450. if (this._nextActiveAction._condition) {
  451. var condition = this._nextActiveAction._condition;
  452. var currentRenderId = this._actionManager.getScene().getRenderId();
  453. // We cache the current evaluation for the current frame
  454. if (condition._evaluationId === currentRenderId) {
  455. if (!condition._currentResult) {
  456. return;
  457. }
  458. }
  459. else {
  460. condition._evaluationId = currentRenderId;
  461. if (!condition.isValid()) {
  462. condition._currentResult = false;
  463. return;
  464. }
  465. condition._currentResult = true;
  466. }
  467. }
  468. this.onBeforeExecuteObservable.notifyObservers(this);
  469. this._nextActiveAction.execute(evt);
  470. this.skipToNextActiveAction();
  471. };
  472. /**
  473. * Execute placeholder for child classes
  474. * @param evt optional action event
  475. */
  476. Action.prototype.execute = function (evt) {
  477. };
  478. /**
  479. * Skips to next active action
  480. */
  481. Action.prototype.skipToNextActiveAction = function () {
  482. if (this._nextActiveAction._child) {
  483. if (!this._nextActiveAction._child._actionManager) {
  484. this._nextActiveAction._child._actionManager = this._actionManager;
  485. }
  486. this._nextActiveAction = this._nextActiveAction._child;
  487. }
  488. else {
  489. this._nextActiveAction = this;
  490. }
  491. };
  492. /**
  493. * Adds action to chain of actions, may be a DoNothingAction
  494. * @param action defines the next action to execute
  495. * @returns The action passed in
  496. * @see https://www.babylonjs-playground.com/#1T30HR#0
  497. */
  498. Action.prototype.then = function (action) {
  499. this._child = action;
  500. action._actionManager = this._actionManager;
  501. action._prepare();
  502. return action;
  503. };
  504. /**
  505. * Internal only
  506. * @hidden
  507. */
  508. Action.prototype._getProperty = function (propertyPath) {
  509. return this._actionManager._getProperty(propertyPath);
  510. };
  511. /**
  512. * Internal only
  513. * @hidden
  514. */
  515. Action.prototype._getEffectiveTarget = function (target, propertyPath) {
  516. return this._actionManager._getEffectiveTarget(target, propertyPath);
  517. };
  518. /**
  519. * Serialize placeholder for child classes
  520. * @param parent of child
  521. * @returns the serialized object
  522. */
  523. Action.prototype.serialize = function (parent) {
  524. };
  525. /**
  526. * Internal only called by serialize
  527. * @hidden
  528. */
  529. Action.prototype._serialize = function (serializedAction, parent) {
  530. var serializationObject = {
  531. type: 1,
  532. children: [],
  533. name: serializedAction.name,
  534. properties: serializedAction.properties || []
  535. };
  536. // Serialize child
  537. if (this._child) {
  538. this._child.serialize(serializationObject);
  539. }
  540. // Check if "this" has a condition
  541. if (this._condition) {
  542. var serializedCondition = this._condition.serialize();
  543. serializedCondition.children.push(serializationObject);
  544. if (parent) {
  545. parent.children.push(serializedCondition);
  546. }
  547. return serializedCondition;
  548. }
  549. if (parent) {
  550. parent.children.push(serializationObject);
  551. }
  552. return serializationObject;
  553. };
  554. /**
  555. * Internal only
  556. * @hidden
  557. */
  558. Action._SerializeValueAsString = function (value) {
  559. if (typeof value === "number") {
  560. return value.toString();
  561. }
  562. if (typeof value === "boolean") {
  563. return value ? "true" : "false";
  564. }
  565. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]) {
  566. return value.x + ", " + value.y;
  567. }
  568. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  569. return value.x + ", " + value.y + ", " + value.z;
  570. }
  571. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  572. return value.r + ", " + value.g + ", " + value.b;
  573. }
  574. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  575. return value.r + ", " + value.g + ", " + value.b + ", " + value.a;
  576. }
  577. return value; // string
  578. };
  579. /**
  580. * Internal only
  581. * @hidden
  582. */
  583. Action._GetTargetProperty = function (target) {
  584. return {
  585. name: "target",
  586. targetType: target._isMesh ? "MeshProperties"
  587. : target._isLight ? "LightProperties"
  588. : target._isCamera ? "CameraProperties"
  589. : "SceneProperties",
  590. value: target._isScene ? "Scene" : target.name
  591. };
  592. };
  593. return Action;
  594. }());
  595. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.Action"] = Action;
  596. /***/ }),
  597. /***/ "./Actions/actionEvent.ts":
  598. /*!********************************!*\
  599. !*** ./Actions/actionEvent.ts ***!
  600. \********************************/
  601. /*! exports provided: ActionEvent */
  602. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  603. "use strict";
  604. __webpack_require__.r(__webpack_exports__);
  605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return ActionEvent; });
  606. /**
  607. * ActionEvent is the event being sent when an action is triggered.
  608. */
  609. var ActionEvent = /** @class */ (function () {
  610. /**
  611. * Creates a new ActionEvent
  612. * @param source The mesh or sprite that triggered the action
  613. * @param pointerX The X mouse cursor position at the time of the event
  614. * @param pointerY The Y mouse cursor position at the time of the event
  615. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  616. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  617. * @param additionalData additional data for the event
  618. */
  619. function ActionEvent(
  620. /** The mesh or sprite that triggered the action */
  621. source,
  622. /** The X mouse cursor position at the time of the event */
  623. pointerX,
  624. /** The Y mouse cursor position at the time of the event */
  625. pointerY,
  626. /** The mesh that is currently pointed at (can be null) */
  627. meshUnderPointer,
  628. /** the original (browser) event that triggered the ActionEvent */
  629. sourceEvent,
  630. /** additional data for the event */
  631. additionalData) {
  632. this.source = source;
  633. this.pointerX = pointerX;
  634. this.pointerY = pointerY;
  635. this.meshUnderPointer = meshUnderPointer;
  636. this.sourceEvent = sourceEvent;
  637. this.additionalData = additionalData;
  638. }
  639. /**
  640. * Helper function to auto-create an ActionEvent from a source mesh.
  641. * @param source The source mesh that triggered the event
  642. * @param evt The original (browser) event
  643. * @param additionalData additional data for the event
  644. * @returns the new ActionEvent
  645. */
  646. ActionEvent.CreateNew = function (source, evt, additionalData) {
  647. var scene = source.getScene();
  648. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  649. };
  650. /**
  651. * Helper function to auto-create an ActionEvent from a source sprite
  652. * @param source The source sprite that triggered the event
  653. * @param scene Scene associated with the sprite
  654. * @param evt The original (browser) event
  655. * @param additionalData additional data for the event
  656. * @returns the new ActionEvent
  657. */
  658. ActionEvent.CreateNewFromSprite = function (source, scene, evt, additionalData) {
  659. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  660. };
  661. /**
  662. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  663. * @param scene the scene where the event occurred
  664. * @param evt The original (browser) event
  665. * @returns the new ActionEvent
  666. */
  667. ActionEvent.CreateNewFromScene = function (scene, evt) {
  668. return new ActionEvent(null, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt);
  669. };
  670. /**
  671. * Helper function to auto-create an ActionEvent from a primitive
  672. * @param prim defines the target primitive
  673. * @param pointerPos defines the pointer position
  674. * @param evt The original (browser) event
  675. * @param additionalData additional data for the event
  676. * @returns the new ActionEvent
  677. */
  678. ActionEvent.CreateNewFromPrimitive = function (prim, pointerPos, evt, additionalData) {
  679. return new ActionEvent(prim, pointerPos.x, pointerPos.y, null, evt, additionalData);
  680. };
  681. return ActionEvent;
  682. }());
  683. /***/ }),
  684. /***/ "./Actions/actionManager.ts":
  685. /*!**********************************!*\
  686. !*** ./Actions/actionManager.ts ***!
  687. \**********************************/
  688. /*! exports provided: ActionManager */
  689. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  690. "use strict";
  691. __webpack_require__.r(__webpack_exports__);
  692. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return ActionManager; });
  693. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  694. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  695. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  696. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  697. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  698. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  699. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  700. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  701. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  702. /* harmony import */ var _abstractActionManager__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./abstractActionManager */ "./Actions/abstractActionManager.ts");
  703. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  704. /**
  705. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  706. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  708. */
  709. var ActionManager = /** @class */ (function (_super) {
  710. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ActionManager, _super);
  711. /**
  712. * Creates a new action manager
  713. * @param scene defines the hosting scene
  714. */
  715. function ActionManager(scene) {
  716. var _this = _super.call(this) || this;
  717. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  718. scene.actionManagers.push(_this);
  719. return _this;
  720. }
  721. // Methods
  722. /**
  723. * Releases all associated resources
  724. */
  725. ActionManager.prototype.dispose = function () {
  726. var index = this._scene.actionManagers.indexOf(this);
  727. for (var i = 0; i < this.actions.length; i++) {
  728. var action = this.actions[i];
  729. ActionManager.Triggers[action.trigger]--;
  730. if (ActionManager.Triggers[action.trigger] === 0) {
  731. delete ActionManager.Triggers[action.trigger];
  732. }
  733. }
  734. if (index > -1) {
  735. this._scene.actionManagers.splice(index, 1);
  736. }
  737. };
  738. /**
  739. * Gets hosting scene
  740. * @returns the hosting scene
  741. */
  742. ActionManager.prototype.getScene = function () {
  743. return this._scene;
  744. };
  745. /**
  746. * Does this action manager handles actions of any of the given triggers
  747. * @param triggers defines the triggers to be tested
  748. * @return a boolean indicating whether one (or more) of the triggers is handled
  749. */
  750. ActionManager.prototype.hasSpecificTriggers = function (triggers) {
  751. for (var index = 0; index < this.actions.length; index++) {
  752. var action = this.actions[index];
  753. if (triggers.indexOf(action.trigger) > -1) {
  754. return true;
  755. }
  756. }
  757. return false;
  758. };
  759. /**
  760. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  761. * speed.
  762. * @param triggerA defines the trigger to be tested
  763. * @param triggerB defines the trigger to be tested
  764. * @return a boolean indicating whether one (or more) of the triggers is handled
  765. */
  766. ActionManager.prototype.hasSpecificTriggers2 = function (triggerA, triggerB) {
  767. for (var index = 0; index < this.actions.length; index++) {
  768. var action = this.actions[index];
  769. if (triggerA == action.trigger || triggerB == action.trigger) {
  770. return true;
  771. }
  772. }
  773. return false;
  774. };
  775. /**
  776. * Does this action manager handles actions of a given trigger
  777. * @param trigger defines the trigger to be tested
  778. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  779. * @return whether the trigger is handled
  780. */
  781. ActionManager.prototype.hasSpecificTrigger = function (trigger, parameterPredicate) {
  782. for (var index = 0; index < this.actions.length; index++) {
  783. var action = this.actions[index];
  784. if (action.trigger === trigger) {
  785. if (parameterPredicate) {
  786. if (parameterPredicate(action.getTriggerParameter())) {
  787. return true;
  788. }
  789. }
  790. else {
  791. return true;
  792. }
  793. }
  794. }
  795. return false;
  796. };
  797. Object.defineProperty(ActionManager.prototype, "hasPointerTriggers", {
  798. /**
  799. * Does this action manager has pointer triggers
  800. */
  801. get: function () {
  802. for (var index = 0; index < this.actions.length; index++) {
  803. var action = this.actions[index];
  804. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPointerOutTrigger) {
  805. return true;
  806. }
  807. }
  808. return false;
  809. },
  810. enumerable: true,
  811. configurable: true
  812. });
  813. Object.defineProperty(ActionManager.prototype, "hasPickTriggers", {
  814. /**
  815. * Does this action manager has pick triggers
  816. */
  817. get: function () {
  818. for (var index = 0; index < this.actions.length; index++) {
  819. var action = this.actions[index];
  820. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPickUpTrigger) {
  821. return true;
  822. }
  823. }
  824. return false;
  825. },
  826. enumerable: true,
  827. configurable: true
  828. });
  829. /**
  830. * Registers an action to this action manager
  831. * @param action defines the action to be registered
  832. * @return the action amended (prepared) after registration
  833. */
  834. ActionManager.prototype.registerAction = function (action) {
  835. if (action.trigger === ActionManager.OnEveryFrameTrigger) {
  836. if (this.getScene().actionManager !== this) {
  837. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Warn("OnEveryFrameTrigger can only be used with scene.actionManager");
  838. return null;
  839. }
  840. }
  841. this.actions.push(action);
  842. if (ActionManager.Triggers[action.trigger]) {
  843. ActionManager.Triggers[action.trigger]++;
  844. }
  845. else {
  846. ActionManager.Triggers[action.trigger] = 1;
  847. }
  848. action._actionManager = this;
  849. action._prepare();
  850. return action;
  851. };
  852. /**
  853. * Unregisters an action to this action manager
  854. * @param action defines the action to be unregistered
  855. * @return a boolean indicating whether the action has been unregistered
  856. */
  857. ActionManager.prototype.unregisterAction = function (action) {
  858. var index = this.actions.indexOf(action);
  859. if (index !== -1) {
  860. this.actions.splice(index, 1);
  861. ActionManager.Triggers[action.trigger] -= 1;
  862. if (ActionManager.Triggers[action.trigger] === 0) {
  863. delete ActionManager.Triggers[action.trigger];
  864. }
  865. delete action._actionManager;
  866. return true;
  867. }
  868. return false;
  869. };
  870. /**
  871. * Process a specific trigger
  872. * @param trigger defines the trigger to process
  873. * @param evt defines the event details to be processed
  874. */
  875. ActionManager.prototype.processTrigger = function (trigger, evt) {
  876. for (var index = 0; index < this.actions.length; index++) {
  877. var action = this.actions[index];
  878. if (action.trigger === trigger) {
  879. if (evt) {
  880. if (trigger === ActionManager.OnKeyUpTrigger
  881. || trigger === ActionManager.OnKeyDownTrigger) {
  882. var parameter = action.getTriggerParameter();
  883. if (parameter && parameter !== evt.sourceEvent.keyCode) {
  884. if (!parameter.toLowerCase) {
  885. continue;
  886. }
  887. var lowerCase = parameter.toLowerCase();
  888. if (lowerCase !== evt.sourceEvent.key) {
  889. var unicode = evt.sourceEvent.charCode ? evt.sourceEvent.charCode : evt.sourceEvent.keyCode;
  890. var actualkey = String.fromCharCode(unicode).toLowerCase();
  891. if (actualkey !== lowerCase) {
  892. continue;
  893. }
  894. }
  895. }
  896. }
  897. }
  898. action._executeCurrent(evt);
  899. }
  900. }
  901. };
  902. /** @hidden */
  903. ActionManager.prototype._getEffectiveTarget = function (target, propertyPath) {
  904. var properties = propertyPath.split(".");
  905. for (var index = 0; index < properties.length - 1; index++) {
  906. target = target[properties[index]];
  907. }
  908. return target;
  909. };
  910. /** @hidden */
  911. ActionManager.prototype._getProperty = function (propertyPath) {
  912. var properties = propertyPath.split(".");
  913. return properties[properties.length - 1];
  914. };
  915. /**
  916. * Serialize this manager to a JSON object
  917. * @param name defines the property name to store this manager
  918. * @returns a JSON representation of this manager
  919. */
  920. ActionManager.prototype.serialize = function (name) {
  921. var root = {
  922. children: new Array(),
  923. name: name,
  924. type: 3,
  925. properties: new Array() // Empty for root but required
  926. };
  927. for (var i = 0; i < this.actions.length; i++) {
  928. var triggerObject = {
  929. type: 0,
  930. children: new Array(),
  931. name: ActionManager.GetTriggerName(this.actions[i].trigger),
  932. properties: new Array()
  933. };
  934. var triggerOptions = this.actions[i].triggerOptions;
  935. if (triggerOptions && typeof triggerOptions !== "number") {
  936. if (triggerOptions.parameter instanceof Node) {
  937. triggerObject.properties.push(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(triggerOptions.parameter));
  938. }
  939. else {
  940. var parameter = {};
  941. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__["DeepCopier"].DeepCopy(triggerOptions.parameter, parameter, ["mesh"]);
  942. if (triggerOptions.parameter && triggerOptions.parameter.mesh) {
  943. parameter._meshId = triggerOptions.parameter.mesh.id;
  944. }
  945. triggerObject.properties.push({ name: "parameter", targetType: null, value: parameter });
  946. }
  947. }
  948. // Serialize child action, recursively
  949. this.actions[i].serialize(triggerObject);
  950. // Add serialized trigger
  951. root.children.push(triggerObject);
  952. }
  953. return root;
  954. };
  955. /**
  956. * Creates a new ActionManager from a JSON data
  957. * @param parsedActions defines the JSON data to read from
  958. * @param object defines the hosting mesh
  959. * @param scene defines the hosting scene
  960. */
  961. ActionManager.Parse = function (parsedActions, object, scene) {
  962. var actionManager = new ActionManager(scene);
  963. if (object === null) {
  964. scene.actionManager = actionManager;
  965. }
  966. else {
  967. object.actionManager = actionManager;
  968. }
  969. // instanciate a new object
  970. var instanciate = function (name, params) {
  971. var internalClassType = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON." + name);
  972. if (internalClassType) {
  973. var newInstance = Object.create(internalClassType.prototype);
  974. newInstance.constructor.apply(newInstance, params);
  975. return newInstance;
  976. }
  977. };
  978. var parseParameter = function (name, value, target, propertyPath) {
  979. if (propertyPath === null) {
  980. // String, boolean or float
  981. var floatValue = parseFloat(value);
  982. if (value === "true" || value === "false") {
  983. return value === "true";
  984. }
  985. else {
  986. return isNaN(floatValue) ? value : floatValue;
  987. }
  988. }
  989. var effectiveTarget = propertyPath.split(".");
  990. var values = value.split(",");
  991. // Get effective Target
  992. for (var i = 0; i < effectiveTarget.length; i++) {
  993. target = target[effectiveTarget[i]];
  994. }
  995. // Return appropriate value with its type
  996. if (typeof (target) === "boolean") {
  997. return values[0] === "true";
  998. }
  999. if (typeof (target) === "string") {
  1000. return values[0];
  1001. }
  1002. // Parameters with multiple values such as Vector3 etc.
  1003. var split = new Array();
  1004. for (var i = 0; i < values.length; i++) {
  1005. split.push(parseFloat(values[i]));
  1006. }
  1007. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  1008. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(split);
  1009. }
  1010. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]) {
  1011. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"].FromArray(split);
  1012. }
  1013. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  1014. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(split);
  1015. }
  1016. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  1017. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(split);
  1018. }
  1019. return parseFloat(values[0]);
  1020. };
  1021. // traverse graph per trigger
  1022. var traverse = function (parsedAction, trigger, condition, action, combineArray) {
  1023. if (combineArray === void 0) { combineArray = null; }
  1024. if (parsedAction.detached) {
  1025. return;
  1026. }
  1027. var parameters = new Array();
  1028. var target = null;
  1029. var propertyPath = null;
  1030. var combine = parsedAction.combine && parsedAction.combine.length > 0;
  1031. // Parameters
  1032. if (parsedAction.type === 2) {
  1033. parameters.push(actionManager);
  1034. }
  1035. else {
  1036. parameters.push(trigger);
  1037. }
  1038. if (combine) {
  1039. var actions = new Array();
  1040. for (var j = 0; j < parsedAction.combine.length; j++) {
  1041. traverse(parsedAction.combine[j], ActionManager.NothingTrigger, condition, action, actions);
  1042. }
  1043. parameters.push(actions);
  1044. }
  1045. else {
  1046. for (var i = 0; i < parsedAction.properties.length; i++) {
  1047. var value = parsedAction.properties[i].value;
  1048. var name = parsedAction.properties[i].name;
  1049. var targetType = parsedAction.properties[i].targetType;
  1050. if (name === "target") {
  1051. if (targetType !== null && targetType === "SceneProperties") {
  1052. value = target = scene;
  1053. }
  1054. else {
  1055. value = target = scene.getNodeByName(value);
  1056. }
  1057. }
  1058. else if (name === "parent") {
  1059. value = scene.getNodeByName(value);
  1060. }
  1061. else if (name === "sound") {
  1062. // Can not externalize to component, so only checks for the presence off the API.
  1063. if (scene.getSoundByName) {
  1064. value = scene.getSoundByName(value);
  1065. }
  1066. }
  1067. else if (name !== "propertyPath") {
  1068. if (parsedAction.type === 2 && name === "operator") {
  1069. value = _condition__WEBPACK_IMPORTED_MODULE_2__["ValueCondition"][value];
  1070. }
  1071. else {
  1072. value = parseParameter(name, value, target, name === "value" ? propertyPath : null);
  1073. }
  1074. }
  1075. else {
  1076. propertyPath = value;
  1077. }
  1078. parameters.push(value);
  1079. }
  1080. }
  1081. if (combineArray === null) {
  1082. parameters.push(condition);
  1083. }
  1084. else {
  1085. parameters.push(null);
  1086. }
  1087. // If interpolate value action
  1088. if (parsedAction.name === "InterpolateValueAction") {
  1089. var param = parameters[parameters.length - 2];
  1090. parameters[parameters.length - 1] = param;
  1091. parameters[parameters.length - 2] = condition;
  1092. }
  1093. // Action or condition(s) and not CombineAction
  1094. var newAction = instanciate(parsedAction.name, parameters);
  1095. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"] && condition !== null) {
  1096. var nothing = new _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"](trigger, condition);
  1097. if (action) {
  1098. action.then(nothing);
  1099. }
  1100. else {
  1101. actionManager.registerAction(nothing);
  1102. }
  1103. action = nothing;
  1104. }
  1105. if (combineArray === null) {
  1106. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"]) {
  1107. condition = newAction;
  1108. newAction = action;
  1109. }
  1110. else {
  1111. condition = null;
  1112. if (action) {
  1113. action.then(newAction);
  1114. }
  1115. else {
  1116. actionManager.registerAction(newAction);
  1117. }
  1118. }
  1119. }
  1120. else {
  1121. combineArray.push(newAction);
  1122. }
  1123. for (var i = 0; i < parsedAction.children.length; i++) {
  1124. traverse(parsedAction.children[i], trigger, condition, newAction, null);
  1125. }
  1126. };
  1127. // triggers
  1128. for (var i = 0; i < parsedActions.children.length; i++) {
  1129. var triggerParams;
  1130. var trigger = parsedActions.children[i];
  1131. if (trigger.properties.length > 0) {
  1132. var param = trigger.properties[0].value;
  1133. var value = trigger.properties[0].targetType === null ? param : scene.getMeshByName(param);
  1134. if (value._meshId) {
  1135. value.mesh = scene.getMeshByID(value._meshId);
  1136. }
  1137. triggerParams = { trigger: ActionManager[trigger.name], parameter: value };
  1138. }
  1139. else {
  1140. triggerParams = ActionManager[trigger.name];
  1141. }
  1142. for (var j = 0; j < trigger.children.length; j++) {
  1143. if (!trigger.detached) {
  1144. traverse(trigger.children[j], triggerParams, null, null);
  1145. }
  1146. }
  1147. }
  1148. };
  1149. /**
  1150. * Get a trigger name by index
  1151. * @param trigger defines the trigger index
  1152. * @returns a trigger name
  1153. */
  1154. ActionManager.GetTriggerName = function (trigger) {
  1155. switch (trigger) {
  1156. case 0: return "NothingTrigger";
  1157. case 1: return "OnPickTrigger";
  1158. case 2: return "OnLeftPickTrigger";
  1159. case 3: return "OnRightPickTrigger";
  1160. case 4: return "OnCenterPickTrigger";
  1161. case 5: return "OnPickDownTrigger";
  1162. case 6: return "OnPickUpTrigger";
  1163. case 7: return "OnLongPressTrigger";
  1164. case 8: return "OnPointerOverTrigger";
  1165. case 9: return "OnPointerOutTrigger";
  1166. case 10: return "OnEveryFrameTrigger";
  1167. case 11: return "OnIntersectionEnterTrigger";
  1168. case 12: return "OnIntersectionExitTrigger";
  1169. case 13: return "OnKeyDownTrigger";
  1170. case 14: return "OnKeyUpTrigger";
  1171. case 15: return "OnPickOutTrigger";
  1172. default: return "";
  1173. }
  1174. };
  1175. /**
  1176. * Nothing
  1177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1178. */
  1179. ActionManager.NothingTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_NothingTrigger;
  1180. /**
  1181. * On pick
  1182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1183. */
  1184. ActionManager.OnPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickTrigger;
  1185. /**
  1186. * On left pick
  1187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1188. */
  1189. ActionManager.OnLeftPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLeftPickTrigger;
  1190. /**
  1191. * On right pick
  1192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1193. */
  1194. ActionManager.OnRightPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnRightPickTrigger;
  1195. /**
  1196. * On center pick
  1197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1198. */
  1199. ActionManager.OnCenterPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnCenterPickTrigger;
  1200. /**
  1201. * On pick down
  1202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1203. */
  1204. ActionManager.OnPickDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickDownTrigger;
  1205. /**
  1206. * On double pick
  1207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1208. */
  1209. ActionManager.OnDoublePickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnDoublePickTrigger;
  1210. /**
  1211. * On pick up
  1212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1213. */
  1214. ActionManager.OnPickUpTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickUpTrigger;
  1215. /**
  1216. * On pick out.
  1217. * This trigger will only be raised if you also declared a OnPickDown
  1218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1219. */
  1220. ActionManager.OnPickOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickOutTrigger;
  1221. /**
  1222. * On long press
  1223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1224. */
  1225. ActionManager.OnLongPressTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLongPressTrigger;
  1226. /**
  1227. * On pointer over
  1228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1229. */
  1230. ActionManager.OnPointerOverTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOverTrigger;
  1231. /**
  1232. * On pointer out
  1233. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1234. */
  1235. ActionManager.OnPointerOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOutTrigger;
  1236. /**
  1237. * On every frame
  1238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1239. */
  1240. ActionManager.OnEveryFrameTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnEveryFrameTrigger;
  1241. /**
  1242. * On intersection enter
  1243. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1244. */
  1245. ActionManager.OnIntersectionEnterTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionEnterTrigger;
  1246. /**
  1247. * On intersection exit
  1248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1249. */
  1250. ActionManager.OnIntersectionExitTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionExitTrigger;
  1251. /**
  1252. * On key down
  1253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1254. */
  1255. ActionManager.OnKeyDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnKeyDownTrigger;
  1256. /**
  1257. * On key up
  1258. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1259. */
  1260. ActionManager.OnKeyUpTrigger = 15;
  1261. return ActionManager;
  1262. }(_abstractActionManager__WEBPACK_IMPORTED_MODULE_9__["AbstractActionManager"]));
  1263. /***/ }),
  1264. /***/ "./Actions/condition.ts":
  1265. /*!******************************!*\
  1266. !*** ./Actions/condition.ts ***!
  1267. \******************************/
  1268. /*! exports provided: Condition, ValueCondition, PredicateCondition, StateCondition */
  1269. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1270. "use strict";
  1271. __webpack_require__.r(__webpack_exports__);
  1272. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return Condition; });
  1273. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return ValueCondition; });
  1274. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return PredicateCondition; });
  1275. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return StateCondition; });
  1276. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1277. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1278. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1279. /**
  1280. * A Condition applied to an Action
  1281. */
  1282. var Condition = /** @class */ (function () {
  1283. /**
  1284. * Creates a new Condition
  1285. * @param actionManager the manager of the action the condition is applied to
  1286. */
  1287. function Condition(actionManager) {
  1288. this._actionManager = actionManager;
  1289. }
  1290. /**
  1291. * Check if the current condition is valid
  1292. * @returns a boolean
  1293. */
  1294. Condition.prototype.isValid = function () {
  1295. return true;
  1296. };
  1297. /**
  1298. * Internal only
  1299. * @hidden
  1300. */
  1301. Condition.prototype._getProperty = function (propertyPath) {
  1302. return this._actionManager._getProperty(propertyPath);
  1303. };
  1304. /**
  1305. * Internal only
  1306. * @hidden
  1307. */
  1308. Condition.prototype._getEffectiveTarget = function (target, propertyPath) {
  1309. return this._actionManager._getEffectiveTarget(target, propertyPath);
  1310. };
  1311. /**
  1312. * Serialize placeholder for child classes
  1313. * @returns the serialized object
  1314. */
  1315. Condition.prototype.serialize = function () {
  1316. };
  1317. /**
  1318. * Internal only
  1319. * @hidden
  1320. */
  1321. Condition.prototype._serialize = function (serializedCondition) {
  1322. return {
  1323. type: 2,
  1324. children: [],
  1325. name: serializedCondition.name,
  1326. properties: serializedCondition.properties
  1327. };
  1328. };
  1329. return Condition;
  1330. }());
  1331. /**
  1332. * Defines specific conditional operators as extensions of Condition
  1333. */
  1334. var ValueCondition = /** @class */ (function (_super) {
  1335. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ValueCondition, _super);
  1336. /**
  1337. * Creates a new ValueCondition
  1338. * @param actionManager manager for the action the condition applies to
  1339. * @param target for the action
  1340. * @param propertyPath path to specify the property of the target the conditional operator uses
  1341. * @param value the value compared by the conditional operator against the current value of the property
  1342. * @param operator the conditional operator, default ValueCondition.IsEqual
  1343. */
  1344. function ValueCondition(actionManager, target,
  1345. /** path to specify the property of the target the conditional operator uses */
  1346. propertyPath,
  1347. /** the value compared by the conditional operator against the current value of the property */
  1348. value,
  1349. /** the conditional operator, default ValueCondition.IsEqual */
  1350. operator) {
  1351. if (operator === void 0) { operator = ValueCondition.IsEqual; }
  1352. var _this = _super.call(this, actionManager) || this;
  1353. _this.propertyPath = propertyPath;
  1354. _this.value = value;
  1355. _this.operator = operator;
  1356. _this._target = target;
  1357. _this._effectiveTarget = _this._getEffectiveTarget(target, _this.propertyPath);
  1358. _this._property = _this._getProperty(_this.propertyPath);
  1359. return _this;
  1360. }
  1361. Object.defineProperty(ValueCondition, "IsEqual", {
  1362. /**
  1363. * returns the number for IsEqual
  1364. */
  1365. get: function () {
  1366. return ValueCondition._IsEqual;
  1367. },
  1368. enumerable: true,
  1369. configurable: true
  1370. });
  1371. Object.defineProperty(ValueCondition, "IsDifferent", {
  1372. /**
  1373. * Returns the number for IsDifferent
  1374. */
  1375. get: function () {
  1376. return ValueCondition._IsDifferent;
  1377. },
  1378. enumerable: true,
  1379. configurable: true
  1380. });
  1381. Object.defineProperty(ValueCondition, "IsGreater", {
  1382. /**
  1383. * Returns the number for IsGreater
  1384. */
  1385. get: function () {
  1386. return ValueCondition._IsGreater;
  1387. },
  1388. enumerable: true,
  1389. configurable: true
  1390. });
  1391. Object.defineProperty(ValueCondition, "IsLesser", {
  1392. /**
  1393. * Returns the number for IsLesser
  1394. */
  1395. get: function () {
  1396. return ValueCondition._IsLesser;
  1397. },
  1398. enumerable: true,
  1399. configurable: true
  1400. });
  1401. /**
  1402. * Compares the given value with the property value for the specified conditional operator
  1403. * @returns the result of the comparison
  1404. */
  1405. ValueCondition.prototype.isValid = function () {
  1406. switch (this.operator) {
  1407. case ValueCondition.IsGreater:
  1408. return this._effectiveTarget[this._property] > this.value;
  1409. case ValueCondition.IsLesser:
  1410. return this._effectiveTarget[this._property] < this.value;
  1411. case ValueCondition.IsEqual:
  1412. case ValueCondition.IsDifferent:
  1413. var check;
  1414. if (this.value.equals) {
  1415. check = this.value.equals(this._effectiveTarget[this._property]);
  1416. }
  1417. else {
  1418. check = this.value === this._effectiveTarget[this._property];
  1419. }
  1420. return this.operator === ValueCondition.IsEqual ? check : !check;
  1421. }
  1422. return false;
  1423. };
  1424. /**
  1425. * Serialize the ValueCondition into a JSON compatible object
  1426. * @returns serialization object
  1427. */
  1428. ValueCondition.prototype.serialize = function () {
  1429. return this._serialize({
  1430. name: "ValueCondition",
  1431. properties: [
  1432. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1433. { name: "propertyPath", value: this.propertyPath },
  1434. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  1435. { name: "operator", value: ValueCondition.GetOperatorName(this.operator) }
  1436. ]
  1437. });
  1438. };
  1439. /**
  1440. * Gets the name of the conditional operator for the ValueCondition
  1441. * @param operator the conditional operator
  1442. * @returns the name
  1443. */
  1444. ValueCondition.GetOperatorName = function (operator) {
  1445. switch (operator) {
  1446. case ValueCondition._IsEqual: return "IsEqual";
  1447. case ValueCondition._IsDifferent: return "IsDifferent";
  1448. case ValueCondition._IsGreater: return "IsGreater";
  1449. case ValueCondition._IsLesser: return "IsLesser";
  1450. default: return "";
  1451. }
  1452. };
  1453. /**
  1454. * Internal only
  1455. * @hidden
  1456. */
  1457. ValueCondition._IsEqual = 0;
  1458. /**
  1459. * Internal only
  1460. * @hidden
  1461. */
  1462. ValueCondition._IsDifferent = 1;
  1463. /**
  1464. * Internal only
  1465. * @hidden
  1466. */
  1467. ValueCondition._IsGreater = 2;
  1468. /**
  1469. * Internal only
  1470. * @hidden
  1471. */
  1472. ValueCondition._IsLesser = 3;
  1473. return ValueCondition;
  1474. }(Condition));
  1475. /**
  1476. * Defines a predicate condition as an extension of Condition
  1477. */
  1478. var PredicateCondition = /** @class */ (function (_super) {
  1479. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PredicateCondition, _super);
  1480. /**
  1481. * Creates a new PredicateCondition
  1482. * @param actionManager manager for the action the condition applies to
  1483. * @param predicate defines the predicate function used to validate the condition
  1484. */
  1485. function PredicateCondition(actionManager,
  1486. /** defines the predicate function used to validate the condition */
  1487. predicate) {
  1488. var _this = _super.call(this, actionManager) || this;
  1489. _this.predicate = predicate;
  1490. return _this;
  1491. }
  1492. /**
  1493. * @returns the validity of the predicate condition
  1494. */
  1495. PredicateCondition.prototype.isValid = function () {
  1496. return this.predicate();
  1497. };
  1498. return PredicateCondition;
  1499. }(Condition));
  1500. /**
  1501. * Defines a state condition as an extension of Condition
  1502. */
  1503. var StateCondition = /** @class */ (function (_super) {
  1504. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StateCondition, _super);
  1505. /**
  1506. * Creates a new StateCondition
  1507. * @param actionManager manager for the action the condition applies to
  1508. * @param target of the condition
  1509. * @param value to compare with target state
  1510. */
  1511. function StateCondition(actionManager, target,
  1512. /** Value to compare with target state */
  1513. value) {
  1514. var _this = _super.call(this, actionManager) || this;
  1515. _this.value = value;
  1516. _this._target = target;
  1517. return _this;
  1518. }
  1519. /**
  1520. * Gets a boolean indicating if the current condition is met
  1521. * @returns the validity of the state
  1522. */
  1523. StateCondition.prototype.isValid = function () {
  1524. return this._target.state === this.value;
  1525. };
  1526. /**
  1527. * Serialize the StateCondition into a JSON compatible object
  1528. * @returns serialization object
  1529. */
  1530. StateCondition.prototype.serialize = function () {
  1531. return this._serialize({
  1532. name: "StateCondition",
  1533. properties: [
  1534. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1535. { name: "value", value: this.value }
  1536. ]
  1537. });
  1538. };
  1539. return StateCondition;
  1540. }(Condition));
  1541. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.ValueCondition"] = ValueCondition;
  1542. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PredicateCondition"] = PredicateCondition;
  1543. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StateCondition"] = StateCondition;
  1544. /***/ }),
  1545. /***/ "./Actions/directActions.ts":
  1546. /*!**********************************!*\
  1547. !*** ./Actions/directActions.ts ***!
  1548. \**********************************/
  1549. /*! exports provided: SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction */
  1550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1551. "use strict";
  1552. __webpack_require__.r(__webpack_exports__);
  1553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return SwitchBooleanAction; });
  1554. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return SetStateAction; });
  1555. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return SetValueAction; });
  1556. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return IncrementValueAction; });
  1557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return PlayAnimationAction; });
  1558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return StopAnimationAction; });
  1559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return DoNothingAction; });
  1560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return CombineAction; });
  1561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return ExecuteCodeAction; });
  1562. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return SetParentAction; });
  1563. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1564. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  1565. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  1566. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1567. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  1568. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1569. /**
  1570. * This defines an action responsible to toggle a boolean once triggered.
  1571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1572. */
  1573. var SwitchBooleanAction = /** @class */ (function (_super) {
  1574. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SwitchBooleanAction, _super);
  1575. /**
  1576. * Instantiate the action
  1577. * @param triggerOptions defines the trigger options
  1578. * @param target defines the object containing the boolean
  1579. * @param propertyPath defines the path to the boolean property in the target object
  1580. * @param condition defines the trigger related conditions
  1581. */
  1582. function SwitchBooleanAction(triggerOptions, target, propertyPath, condition) {
  1583. var _this = _super.call(this, triggerOptions, condition) || this;
  1584. _this.propertyPath = propertyPath;
  1585. _this._target = _this._effectiveTarget = target;
  1586. return _this;
  1587. }
  1588. /** @hidden */
  1589. SwitchBooleanAction.prototype._prepare = function () {
  1590. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1591. this._property = this._getProperty(this.propertyPath);
  1592. };
  1593. /**
  1594. * Execute the action toggle the boolean value.
  1595. */
  1596. SwitchBooleanAction.prototype.execute = function () {
  1597. this._effectiveTarget[this._property] = !this._effectiveTarget[this._property];
  1598. };
  1599. /**
  1600. * Serializes the actions and its related information.
  1601. * @param parent defines the object to serialize in
  1602. * @returns the serialized object
  1603. */
  1604. SwitchBooleanAction.prototype.serialize = function (parent) {
  1605. return _super.prototype._serialize.call(this, {
  1606. name: "SwitchBooleanAction",
  1607. properties: [
  1608. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1609. { name: "propertyPath", value: this.propertyPath }
  1610. ]
  1611. }, parent);
  1612. };
  1613. return SwitchBooleanAction;
  1614. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1615. /**
  1616. * This defines an action responsible to set a the state field of the target
  1617. * to a desired value once triggered.
  1618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1619. */
  1620. var SetStateAction = /** @class */ (function (_super) {
  1621. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetStateAction, _super);
  1622. /**
  1623. * Instantiate the action
  1624. * @param triggerOptions defines the trigger options
  1625. * @param target defines the object containing the state property
  1626. * @param value defines the value to store in the state field
  1627. * @param condition defines the trigger related conditions
  1628. */
  1629. function SetStateAction(triggerOptions, target, value, condition) {
  1630. var _this = _super.call(this, triggerOptions, condition) || this;
  1631. _this.value = value;
  1632. _this._target = target;
  1633. return _this;
  1634. }
  1635. /**
  1636. * Execute the action and store the value on the target state property.
  1637. */
  1638. SetStateAction.prototype.execute = function () {
  1639. this._target.state = this.value;
  1640. };
  1641. /**
  1642. * Serializes the actions and its related information.
  1643. * @param parent defines the object to serialize in
  1644. * @returns the serialized object
  1645. */
  1646. SetStateAction.prototype.serialize = function (parent) {
  1647. return _super.prototype._serialize.call(this, {
  1648. name: "SetStateAction",
  1649. properties: [
  1650. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1651. { name: "value", value: this.value }
  1652. ]
  1653. }, parent);
  1654. };
  1655. return SetStateAction;
  1656. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1657. /**
  1658. * This defines an action responsible to set a property of the target
  1659. * to a desired value once triggered.
  1660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1661. */
  1662. var SetValueAction = /** @class */ (function (_super) {
  1663. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetValueAction, _super);
  1664. /**
  1665. * Instantiate the action
  1666. * @param triggerOptions defines the trigger options
  1667. * @param target defines the object containing the property
  1668. * @param propertyPath defines the path of the property to set in the target
  1669. * @param value defines the value to set in the property
  1670. * @param condition defines the trigger related conditions
  1671. */
  1672. function SetValueAction(triggerOptions, target, propertyPath, value, condition) {
  1673. var _this = _super.call(this, triggerOptions, condition) || this;
  1674. _this.propertyPath = propertyPath;
  1675. _this.value = value;
  1676. _this._target = _this._effectiveTarget = target;
  1677. return _this;
  1678. }
  1679. /** @hidden */
  1680. SetValueAction.prototype._prepare = function () {
  1681. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1682. this._property = this._getProperty(this.propertyPath);
  1683. };
  1684. /**
  1685. * Execute the action and set the targetted property to the desired value.
  1686. */
  1687. SetValueAction.prototype.execute = function () {
  1688. this._effectiveTarget[this._property] = this.value;
  1689. if (this._target.markAsDirty) {
  1690. this._target.markAsDirty(this._property);
  1691. }
  1692. };
  1693. /**
  1694. * Serializes the actions and its related information.
  1695. * @param parent defines the object to serialize in
  1696. * @returns the serialized object
  1697. */
  1698. SetValueAction.prototype.serialize = function (parent) {
  1699. return _super.prototype._serialize.call(this, {
  1700. name: "SetValueAction",
  1701. properties: [
  1702. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1703. { name: "propertyPath", value: this.propertyPath },
  1704. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1705. ]
  1706. }, parent);
  1707. };
  1708. return SetValueAction;
  1709. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1710. /**
  1711. * This defines an action responsible to increment the target value
  1712. * to a desired value once triggered.
  1713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1714. */
  1715. var IncrementValueAction = /** @class */ (function (_super) {
  1716. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IncrementValueAction, _super);
  1717. /**
  1718. * Instantiate the action
  1719. * @param triggerOptions defines the trigger options
  1720. * @param target defines the object containing the property
  1721. * @param propertyPath defines the path of the property to increment in the target
  1722. * @param value defines the value value we should increment the property by
  1723. * @param condition defines the trigger related conditions
  1724. */
  1725. function IncrementValueAction(triggerOptions, target, propertyPath, value, condition) {
  1726. var _this = _super.call(this, triggerOptions, condition) || this;
  1727. _this.propertyPath = propertyPath;
  1728. _this.value = value;
  1729. _this._target = _this._effectiveTarget = target;
  1730. return _this;
  1731. }
  1732. /** @hidden */
  1733. IncrementValueAction.prototype._prepare = function () {
  1734. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1735. this._property = this._getProperty(this.propertyPath);
  1736. if (typeof this._effectiveTarget[this._property] !== "number") {
  1737. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Warning: IncrementValueAction can only be used with number values");
  1738. }
  1739. };
  1740. /**
  1741. * Execute the action and increment the target of the value amount.
  1742. */
  1743. IncrementValueAction.prototype.execute = function () {
  1744. this._effectiveTarget[this._property] += this.value;
  1745. if (this._target.markAsDirty) {
  1746. this._target.markAsDirty(this._property);
  1747. }
  1748. };
  1749. /**
  1750. * Serializes the actions and its related information.
  1751. * @param parent defines the object to serialize in
  1752. * @returns the serialized object
  1753. */
  1754. IncrementValueAction.prototype.serialize = function (parent) {
  1755. return _super.prototype._serialize.call(this, {
  1756. name: "IncrementValueAction",
  1757. properties: [
  1758. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1759. { name: "propertyPath", value: this.propertyPath },
  1760. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1761. ]
  1762. }, parent);
  1763. };
  1764. return IncrementValueAction;
  1765. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1766. /**
  1767. * This defines an action responsible to start an animation once triggered.
  1768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1769. */
  1770. var PlayAnimationAction = /** @class */ (function (_super) {
  1771. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlayAnimationAction, _super);
  1772. /**
  1773. * Instantiate the action
  1774. * @param triggerOptions defines the trigger options
  1775. * @param target defines the target animation or animation name
  1776. * @param from defines from where the animation should start (animation frame)
  1777. * @param end defines where the animation should stop (animation frame)
  1778. * @param loop defines if the animation should loop or stop after the first play
  1779. * @param condition defines the trigger related conditions
  1780. */
  1781. function PlayAnimationAction(triggerOptions, target, from, to, loop, condition) {
  1782. var _this = _super.call(this, triggerOptions, condition) || this;
  1783. _this.from = from;
  1784. _this.to = to;
  1785. _this.loop = loop;
  1786. _this._target = target;
  1787. return _this;
  1788. }
  1789. /** @hidden */
  1790. PlayAnimationAction.prototype._prepare = function () {
  1791. };
  1792. /**
  1793. * Execute the action and play the animation.
  1794. */
  1795. PlayAnimationAction.prototype.execute = function () {
  1796. var scene = this._actionManager.getScene();
  1797. scene.beginAnimation(this._target, this.from, this.to, this.loop);
  1798. };
  1799. /**
  1800. * Serializes the actions and its related information.
  1801. * @param parent defines the object to serialize in
  1802. * @returns the serialized object
  1803. */
  1804. PlayAnimationAction.prototype.serialize = function (parent) {
  1805. return _super.prototype._serialize.call(this, {
  1806. name: "PlayAnimationAction",
  1807. properties: [
  1808. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1809. { name: "from", value: String(this.from) },
  1810. { name: "to", value: String(this.to) },
  1811. { name: "loop", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.loop) || false }
  1812. ]
  1813. }, parent);
  1814. };
  1815. return PlayAnimationAction;
  1816. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1817. /**
  1818. * This defines an action responsible to stop an animation once triggered.
  1819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1820. */
  1821. var StopAnimationAction = /** @class */ (function (_super) {
  1822. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopAnimationAction, _super);
  1823. /**
  1824. * Instantiate the action
  1825. * @param triggerOptions defines the trigger options
  1826. * @param target defines the target animation or animation name
  1827. * @param condition defines the trigger related conditions
  1828. */
  1829. function StopAnimationAction(triggerOptions, target, condition) {
  1830. var _this = _super.call(this, triggerOptions, condition) || this;
  1831. _this._target = target;
  1832. return _this;
  1833. }
  1834. /** @hidden */
  1835. StopAnimationAction.prototype._prepare = function () {
  1836. };
  1837. /**
  1838. * Execute the action and stop the animation.
  1839. */
  1840. StopAnimationAction.prototype.execute = function () {
  1841. var scene = this._actionManager.getScene();
  1842. scene.stopAnimation(this._target);
  1843. };
  1844. /**
  1845. * Serializes the actions and its related information.
  1846. * @param parent defines the object to serialize in
  1847. * @returns the serialized object
  1848. */
  1849. StopAnimationAction.prototype.serialize = function (parent) {
  1850. return _super.prototype._serialize.call(this, {
  1851. name: "StopAnimationAction",
  1852. properties: [_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target)]
  1853. }, parent);
  1854. };
  1855. return StopAnimationAction;
  1856. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1857. /**
  1858. * This defines an action responsible that does nothing once triggered.
  1859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1860. */
  1861. var DoNothingAction = /** @class */ (function (_super) {
  1862. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DoNothingAction, _super);
  1863. /**
  1864. * Instantiate the action
  1865. * @param triggerOptions defines the trigger options
  1866. * @param condition defines the trigger related conditions
  1867. */
  1868. function DoNothingAction(triggerOptions, condition) {
  1869. if (triggerOptions === void 0) { triggerOptions = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_NothingTrigger; }
  1870. return _super.call(this, triggerOptions, condition) || this;
  1871. }
  1872. /**
  1873. * Execute the action and do nothing.
  1874. */
  1875. DoNothingAction.prototype.execute = function () {
  1876. };
  1877. /**
  1878. * Serializes the actions and its related information.
  1879. * @param parent defines the object to serialize in
  1880. * @returns the serialized object
  1881. */
  1882. DoNothingAction.prototype.serialize = function (parent) {
  1883. return _super.prototype._serialize.call(this, {
  1884. name: "DoNothingAction",
  1885. properties: []
  1886. }, parent);
  1887. };
  1888. return DoNothingAction;
  1889. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1890. /**
  1891. * This defines an action responsible to trigger several actions once triggered.
  1892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1893. */
  1894. var CombineAction = /** @class */ (function (_super) {
  1895. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CombineAction, _super);
  1896. /**
  1897. * Instantiate the action
  1898. * @param triggerOptions defines the trigger options
  1899. * @param children defines the list of aggregated animations to run
  1900. * @param condition defines the trigger related conditions
  1901. */
  1902. function CombineAction(triggerOptions, children, condition) {
  1903. var _this = _super.call(this, triggerOptions, condition) || this;
  1904. _this.children = children;
  1905. return _this;
  1906. }
  1907. /** @hidden */
  1908. CombineAction.prototype._prepare = function () {
  1909. for (var index = 0; index < this.children.length; index++) {
  1910. this.children[index]._actionManager = this._actionManager;
  1911. this.children[index]._prepare();
  1912. }
  1913. };
  1914. /**
  1915. * Execute the action and executes all the aggregated actions.
  1916. */
  1917. CombineAction.prototype.execute = function (evt) {
  1918. for (var index = 0; index < this.children.length; index++) {
  1919. this.children[index].execute(evt);
  1920. }
  1921. };
  1922. /**
  1923. * Serializes the actions and its related information.
  1924. * @param parent defines the object to serialize in
  1925. * @returns the serialized object
  1926. */
  1927. CombineAction.prototype.serialize = function (parent) {
  1928. var serializationObject = _super.prototype._serialize.call(this, {
  1929. name: "CombineAction",
  1930. properties: [],
  1931. combine: []
  1932. }, parent);
  1933. for (var i = 0; i < this.children.length; i++) {
  1934. serializationObject.combine.push(this.children[i].serialize(null));
  1935. }
  1936. return serializationObject;
  1937. };
  1938. return CombineAction;
  1939. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1940. /**
  1941. * This defines an action responsible to run code (external event) once triggered.
  1942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1943. */
  1944. var ExecuteCodeAction = /** @class */ (function (_super) {
  1945. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExecuteCodeAction, _super);
  1946. /**
  1947. * Instantiate the action
  1948. * @param triggerOptions defines the trigger options
  1949. * @param func defines the callback function to run
  1950. * @param condition defines the trigger related conditions
  1951. */
  1952. function ExecuteCodeAction(triggerOptions, func, condition) {
  1953. var _this = _super.call(this, triggerOptions, condition) || this;
  1954. _this.func = func;
  1955. return _this;
  1956. }
  1957. /**
  1958. * Execute the action and run the attached code.
  1959. */
  1960. ExecuteCodeAction.prototype.execute = function (evt) {
  1961. this.func(evt);
  1962. };
  1963. return ExecuteCodeAction;
  1964. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1965. /**
  1966. * This defines an action responsible to set the parent property of the target once triggered.
  1967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1968. */
  1969. var SetParentAction = /** @class */ (function (_super) {
  1970. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetParentAction, _super);
  1971. /**
  1972. * Instantiate the action
  1973. * @param triggerOptions defines the trigger options
  1974. * @param target defines the target containing the parent property
  1975. * @param parent defines from where the animation should start (animation frame)
  1976. * @param condition defines the trigger related conditions
  1977. */
  1978. function SetParentAction(triggerOptions, target, parent, condition) {
  1979. var _this = _super.call(this, triggerOptions, condition) || this;
  1980. _this._target = target;
  1981. _this._parent = parent;
  1982. return _this;
  1983. }
  1984. /** @hidden */
  1985. SetParentAction.prototype._prepare = function () {
  1986. };
  1987. /**
  1988. * Execute the action and set the parent property.
  1989. */
  1990. SetParentAction.prototype.execute = function () {
  1991. if (this._target.parent === this._parent) {
  1992. return;
  1993. }
  1994. var invertParentWorldMatrix = this._parent.getWorldMatrix().clone();
  1995. invertParentWorldMatrix.invert();
  1996. this._target.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this._target.position, invertParentWorldMatrix);
  1997. this._target.parent = this._parent;
  1998. };
  1999. /**
  2000. * Serializes the actions and its related information.
  2001. * @param parent defines the object to serialize in
  2002. * @returns the serialized object
  2003. */
  2004. SetParentAction.prototype.serialize = function (parent) {
  2005. return _super.prototype._serialize.call(this, {
  2006. name: "SetParentAction",
  2007. properties: [
  2008. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  2009. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._parent),
  2010. ]
  2011. }, parent);
  2012. };
  2013. return SetParentAction;
  2014. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  2015. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2016. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.ExecuteCodeAction"] = ExecuteCodeAction;
  2017. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.DoNothingAction"] = DoNothingAction;
  2018. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.StopAnimationAction"] = StopAnimationAction;
  2019. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PlayAnimationAction"] = PlayAnimationAction;
  2020. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.IncrementValueAction"] = IncrementValueAction;
  2021. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetValueAction"] = SetValueAction;
  2022. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetStateAction"] = SetStateAction;
  2023. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2024. /***/ }),
  2025. /***/ "./Actions/directAudioActions.ts":
  2026. /*!***************************************!*\
  2027. !*** ./Actions/directAudioActions.ts ***!
  2028. \***************************************/
  2029. /*! exports provided: PlaySoundAction, StopSoundAction */
  2030. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2031. "use strict";
  2032. __webpack_require__.r(__webpack_exports__);
  2033. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return PlaySoundAction; });
  2034. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return StopSoundAction; });
  2035. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2036. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2037. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2038. /**
  2039. * This defines an action helpful to play a defined sound on a triggered action.
  2040. */
  2041. var PlaySoundAction = /** @class */ (function (_super) {
  2042. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaySoundAction, _super);
  2043. /**
  2044. * Instantiate the action
  2045. * @param triggerOptions defines the trigger options
  2046. * @param sound defines the sound to play
  2047. * @param condition defines the trigger related conditions
  2048. */
  2049. function PlaySoundAction(triggerOptions, sound, condition) {
  2050. var _this = _super.call(this, triggerOptions, condition) || this;
  2051. _this._sound = sound;
  2052. return _this;
  2053. }
  2054. /** @hidden */
  2055. PlaySoundAction.prototype._prepare = function () {
  2056. };
  2057. /**
  2058. * Execute the action and play the sound.
  2059. */
  2060. PlaySoundAction.prototype.execute = function () {
  2061. if (this._sound !== undefined) {
  2062. this._sound.play();
  2063. }
  2064. };
  2065. /**
  2066. * Serializes the actions and its related information.
  2067. * @param parent defines the object to serialize in
  2068. * @returns the serialized object
  2069. */
  2070. PlaySoundAction.prototype.serialize = function (parent) {
  2071. return _super.prototype._serialize.call(this, {
  2072. name: "PlaySoundAction",
  2073. properties: [{ name: "sound", value: this._sound.name }]
  2074. }, parent);
  2075. };
  2076. return PlaySoundAction;
  2077. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2078. /**
  2079. * This defines an action helpful to stop a defined sound on a triggered action.
  2080. */
  2081. var StopSoundAction = /** @class */ (function (_super) {
  2082. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopSoundAction, _super);
  2083. /**
  2084. * Instantiate the action
  2085. * @param triggerOptions defines the trigger options
  2086. * @param sound defines the sound to stop
  2087. * @param condition defines the trigger related conditions
  2088. */
  2089. function StopSoundAction(triggerOptions, sound, condition) {
  2090. var _this = _super.call(this, triggerOptions, condition) || this;
  2091. _this._sound = sound;
  2092. return _this;
  2093. }
  2094. /** @hidden */
  2095. StopSoundAction.prototype._prepare = function () {
  2096. };
  2097. /**
  2098. * Execute the action and stop the sound.
  2099. */
  2100. StopSoundAction.prototype.execute = function () {
  2101. if (this._sound !== undefined) {
  2102. this._sound.stop();
  2103. }
  2104. };
  2105. /**
  2106. * Serializes the actions and its related information.
  2107. * @param parent defines the object to serialize in
  2108. * @returns the serialized object
  2109. */
  2110. StopSoundAction.prototype.serialize = function (parent) {
  2111. return _super.prototype._serialize.call(this, {
  2112. name: "StopSoundAction",
  2113. properties: [{ name: "sound", value: this._sound.name }]
  2114. }, parent);
  2115. };
  2116. return StopSoundAction;
  2117. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2118. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PlaySoundAction"] = StopSoundAction;
  2119. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StopSoundAction"] = StopSoundAction;
  2120. /***/ }),
  2121. /***/ "./Actions/index.ts":
  2122. /*!**************************!*\
  2123. !*** ./Actions/index.ts ***!
  2124. \**************************/
  2125. /*! exports provided: Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction */
  2126. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2127. "use strict";
  2128. __webpack_require__.r(__webpack_exports__);
  2129. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _action__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  2131. /* harmony import */ var _actionEvent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actionEvent */ "./Actions/actionEvent.ts");
  2132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _actionEvent__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  2133. /* harmony import */ var _actionManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actionManager */ "./Actions/actionManager.ts");
  2134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _actionManager__WEBPACK_IMPORTED_MODULE_2__["ActionManager"]; });
  2135. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  2136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["Condition"]; });
  2137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["ValueCondition"]; });
  2138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["PredicateCondition"]; });
  2139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["StateCondition"]; });
  2140. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  2141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SwitchBooleanAction"]; });
  2142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetStateAction"]; });
  2143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetValueAction"]; });
  2144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["IncrementValueAction"]; });
  2145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["PlayAnimationAction"]; });
  2146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["StopAnimationAction"]; });
  2147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"]; });
  2148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["CombineAction"]; });
  2149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["ExecuteCodeAction"]; });
  2150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetParentAction"]; });
  2151. /* harmony import */ var _directAudioActions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./directAudioActions */ "./Actions/directAudioActions.ts");
  2152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["PlaySoundAction"]; });
  2153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["StopSoundAction"]; });
  2154. /* harmony import */ var _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./interpolateValueAction */ "./Actions/interpolateValueAction.ts");
  2155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__["InterpolateValueAction"]; });
  2156. /***/ }),
  2157. /***/ "./Actions/interpolateValueAction.ts":
  2158. /*!*******************************************!*\
  2159. !*** ./Actions/interpolateValueAction.ts ***!
  2160. \*******************************************/
  2161. /*! exports provided: InterpolateValueAction */
  2162. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2163. "use strict";
  2164. __webpack_require__.r(__webpack_exports__);
  2165. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return InterpolateValueAction; });
  2166. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2167. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2168. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  2169. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2170. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2171. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  2172. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2173. /**
  2174. * This defines an action responsible to change the value of a property
  2175. * by interpolating between its current value and the newly set one once triggered.
  2176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2177. */
  2178. var InterpolateValueAction = /** @class */ (function (_super) {
  2179. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InterpolateValueAction, _super);
  2180. /**
  2181. * Instantiate the action
  2182. * @param triggerOptions defines the trigger options
  2183. * @param target defines the object containing the value to interpolate
  2184. * @param propertyPath defines the path to the property in the target object
  2185. * @param value defines the target value at the end of the interpolation
  2186. * @param duration deines the time it will take for the property to interpolate to the value.
  2187. * @param condition defines the trigger related conditions
  2188. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  2189. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  2190. */
  2191. function InterpolateValueAction(triggerOptions, target, propertyPath, value, duration, condition, stopOtherAnimations, onInterpolationDone) {
  2192. if (duration === void 0) { duration = 1000; }
  2193. var _this = _super.call(this, triggerOptions, condition) || this;
  2194. /**
  2195. * Defines the time it will take for the property to interpolate to the value.
  2196. */
  2197. _this.duration = 1000;
  2198. /**
  2199. * Observable triggered once the interpolation animation has been done.
  2200. */
  2201. _this.onInterpolationDoneObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  2202. _this.propertyPath = propertyPath;
  2203. _this.value = value;
  2204. _this.duration = duration;
  2205. _this.stopOtherAnimations = stopOtherAnimations;
  2206. _this.onInterpolationDone = onInterpolationDone;
  2207. _this._target = _this._effectiveTarget = target;
  2208. return _this;
  2209. }
  2210. /** @hidden */
  2211. InterpolateValueAction.prototype._prepare = function () {
  2212. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  2213. this._property = this._getProperty(this.propertyPath);
  2214. };
  2215. /**
  2216. * Execute the action starts the value interpolation.
  2217. */
  2218. InterpolateValueAction.prototype.execute = function () {
  2219. var _this = this;
  2220. var scene = this._actionManager.getScene();
  2221. var keys = [
  2222. {
  2223. frame: 0,
  2224. value: this._effectiveTarget[this._property]
  2225. }, {
  2226. frame: 100,
  2227. value: this.value
  2228. }
  2229. ];
  2230. var dataType;
  2231. if (typeof this.value === "number") {
  2232. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT;
  2233. }
  2234. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"]) {
  2235. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_COLOR3;
  2236. }
  2237. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"]) {
  2238. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3;
  2239. }
  2240. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]) {
  2241. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_MATRIX;
  2242. }
  2243. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]) {
  2244. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_QUATERNION;
  2245. }
  2246. else {
  2247. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
  2248. return;
  2249. }
  2250. var animation = new _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"]("InterpolateValueAction", this._property, 100 * (1000.0 / this.duration), dataType, _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  2251. animation.setKeys(keys);
  2252. if (this.stopOtherAnimations) {
  2253. scene.stopAnimation(this._effectiveTarget);
  2254. }
  2255. var wrapper = function () {
  2256. _this.onInterpolationDoneObservable.notifyObservers(_this);
  2257. if (_this.onInterpolationDone) {
  2258. _this.onInterpolationDone();
  2259. }
  2260. };
  2261. scene.beginDirectAnimation(this._effectiveTarget, [animation], 0, 100, false, 1, wrapper);
  2262. };
  2263. /**
  2264. * Serializes the actions and its related information.
  2265. * @param parent defines the object to serialize in
  2266. * @returns the serialized object
  2267. */
  2268. InterpolateValueAction.prototype.serialize = function (parent) {
  2269. return _super.prototype._serialize.call(this, {
  2270. name: "InterpolateValueAction",
  2271. properties: [
  2272. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  2273. { name: "propertyPath", value: this.propertyPath },
  2274. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  2275. { name: "duration", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.duration) },
  2276. { name: "stopOtherAnimations", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.stopOtherAnimations) || false }
  2277. ]
  2278. }, parent);
  2279. };
  2280. return InterpolateValueAction;
  2281. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2282. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__["_TypeStore"].RegisteredTypes["BABYLON.InterpolateValueAction"] = _action__WEBPACK_IMPORTED_MODULE_1__["Action"];
  2283. /***/ }),
  2284. /***/ "./Animations/animatable.ts":
  2285. /*!**********************************!*\
  2286. !*** ./Animations/animatable.ts ***!
  2287. \**********************************/
  2288. /*! exports provided: Animatable */
  2289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2290. "use strict";
  2291. __webpack_require__.r(__webpack_exports__);
  2292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return Animatable; });
  2293. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  2294. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  2295. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2296. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  2297. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2298. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/precisionDate */ "./Misc/precisionDate.ts");
  2299. /* harmony import */ var _Bones_bone__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Bones/bone */ "./Bones/bone.ts");
  2300. /**
  2301. * Class used to store an actual running animation
  2302. */
  2303. var Animatable = /** @class */ (function () {
  2304. /**
  2305. * Creates a new Animatable
  2306. * @param scene defines the hosting scene
  2307. * @param target defines the target object
  2308. * @param fromFrame defines the starting frame number (default is 0)
  2309. * @param toFrame defines the ending frame number (default is 100)
  2310. * @param loopAnimation defines if the animation must loop (default is false)
  2311. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  2312. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  2313. * @param animations defines a group of animation to add to the new Animatable
  2314. * @param onAnimationLoop defines a callback to call when animation loops
  2315. */
  2316. function Animatable(scene,
  2317. /** defines the target object */
  2318. target,
  2319. /** defines the starting frame number (default is 0) */
  2320. fromFrame,
  2321. /** defines the ending frame number (default is 100) */
  2322. toFrame,
  2323. /** defines if the animation must loop (default is false) */
  2324. loopAnimation, speedRatio,
  2325. /** defines a callback to call when animation ends if it is not looping */
  2326. onAnimationEnd, animations,
  2327. /** defines a callback to call when animation loops */
  2328. onAnimationLoop) {
  2329. if (fromFrame === void 0) { fromFrame = 0; }
  2330. if (toFrame === void 0) { toFrame = 100; }
  2331. if (loopAnimation === void 0) { loopAnimation = false; }
  2332. if (speedRatio === void 0) { speedRatio = 1.0; }
  2333. this.target = target;
  2334. this.fromFrame = fromFrame;
  2335. this.toFrame = toFrame;
  2336. this.loopAnimation = loopAnimation;
  2337. this.onAnimationEnd = onAnimationEnd;
  2338. this.onAnimationLoop = onAnimationLoop;
  2339. this._localDelayOffset = null;
  2340. this._pausedDelay = null;
  2341. this._runtimeAnimations = new Array();
  2342. this._paused = false;
  2343. this._speedRatio = 1;
  2344. this._weight = -1.0;
  2345. /**
  2346. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  2347. * This will only apply for non looping animation (default is true)
  2348. */
  2349. this.disposeOnEnd = true;
  2350. /**
  2351. * Gets a boolean indicating if the animation has started
  2352. */
  2353. this.animationStarted = false;
  2354. /**
  2355. * Observer raised when the animation ends
  2356. */
  2357. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2358. /**
  2359. * Observer raised when the animation loops
  2360. */
  2361. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2362. this._scene = scene;
  2363. if (animations) {
  2364. this.appendAnimations(target, animations);
  2365. }
  2366. this._speedRatio = speedRatio;
  2367. scene._activeAnimatables.push(this);
  2368. }
  2369. Object.defineProperty(Animatable.prototype, "syncRoot", {
  2370. /**
  2371. * Gets the root Animatable used to synchronize and normalize animations
  2372. */
  2373. get: function () {
  2374. return this._syncRoot;
  2375. },
  2376. enumerable: true,
  2377. configurable: true
  2378. });
  2379. Object.defineProperty(Animatable.prototype, "masterFrame", {
  2380. /**
  2381. * Gets the current frame of the first RuntimeAnimation
  2382. * Used to synchronize Animatables
  2383. */
  2384. get: function () {
  2385. if (this._runtimeAnimations.length === 0) {
  2386. return 0;
  2387. }
  2388. return this._runtimeAnimations[0].currentFrame;
  2389. },
  2390. enumerable: true,
  2391. configurable: true
  2392. });
  2393. Object.defineProperty(Animatable.prototype, "weight", {
  2394. /**
  2395. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2396. */
  2397. get: function () {
  2398. return this._weight;
  2399. },
  2400. set: function (value) {
  2401. if (value === -1) { // -1 is ok and means no weight
  2402. this._weight = -1;
  2403. return;
  2404. }
  2405. // Else weight must be in [0, 1] range
  2406. this._weight = Math.min(Math.max(value, 0), 1.0);
  2407. },
  2408. enumerable: true,
  2409. configurable: true
  2410. });
  2411. Object.defineProperty(Animatable.prototype, "speedRatio", {
  2412. /**
  2413. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2414. */
  2415. get: function () {
  2416. return this._speedRatio;
  2417. },
  2418. set: function (value) {
  2419. for (var index = 0; index < this._runtimeAnimations.length; index++) {
  2420. var animation = this._runtimeAnimations[index];
  2421. animation._prepareForSpeedRatioChange(value);
  2422. }
  2423. this._speedRatio = value;
  2424. },
  2425. enumerable: true,
  2426. configurable: true
  2427. });
  2428. // Methods
  2429. /**
  2430. * Synchronize and normalize current Animatable with a source Animatable
  2431. * This is useful when using animation weights and when animations are not of the same length
  2432. * @param root defines the root Animatable to synchronize with
  2433. * @returns the current Animatable
  2434. */
  2435. Animatable.prototype.syncWith = function (root) {
  2436. this._syncRoot = root;
  2437. if (root) {
  2438. // Make sure this animatable will animate after the root
  2439. var index = this._scene._activeAnimatables.indexOf(this);
  2440. if (index > -1) {
  2441. this._scene._activeAnimatables.splice(index, 1);
  2442. this._scene._activeAnimatables.push(this);
  2443. }
  2444. }
  2445. return this;
  2446. };
  2447. /**
  2448. * Gets the list of runtime animations
  2449. * @returns an array of RuntimeAnimation
  2450. */
  2451. Animatable.prototype.getAnimations = function () {
  2452. return this._runtimeAnimations;
  2453. };
  2454. /**
  2455. * Adds more animations to the current animatable
  2456. * @param target defines the target of the animations
  2457. * @param animations defines the new animations to add
  2458. */
  2459. Animatable.prototype.appendAnimations = function (target, animations) {
  2460. for (var index = 0; index < animations.length; index++) {
  2461. var animation = animations[index];
  2462. this._runtimeAnimations.push(new _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__["RuntimeAnimation"](target, animation, this._scene, this));
  2463. }
  2464. };
  2465. /**
  2466. * Gets the source animation for a specific property
  2467. * @param property defines the propertyu to look for
  2468. * @returns null or the source animation for the given property
  2469. */
  2470. Animatable.prototype.getAnimationByTargetProperty = function (property) {
  2471. var runtimeAnimations = this._runtimeAnimations;
  2472. for (var index = 0; index < runtimeAnimations.length; index++) {
  2473. if (runtimeAnimations[index].animation.targetProperty === property) {
  2474. return runtimeAnimations[index].animation;
  2475. }
  2476. }
  2477. return null;
  2478. };
  2479. /**
  2480. * Gets the runtime animation for a specific property
  2481. * @param property defines the propertyu to look for
  2482. * @returns null or the runtime animation for the given property
  2483. */
  2484. Animatable.prototype.getRuntimeAnimationByTargetProperty = function (property) {
  2485. var runtimeAnimations = this._runtimeAnimations;
  2486. for (var index = 0; index < runtimeAnimations.length; index++) {
  2487. if (runtimeAnimations[index].animation.targetProperty === property) {
  2488. return runtimeAnimations[index];
  2489. }
  2490. }
  2491. return null;
  2492. };
  2493. /**
  2494. * Resets the animatable to its original state
  2495. */
  2496. Animatable.prototype.reset = function () {
  2497. var runtimeAnimations = this._runtimeAnimations;
  2498. for (var index = 0; index < runtimeAnimations.length; index++) {
  2499. runtimeAnimations[index].reset(true);
  2500. }
  2501. this._localDelayOffset = null;
  2502. this._pausedDelay = null;
  2503. };
  2504. /**
  2505. * Allows the animatable to blend with current running animations
  2506. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2507. * @param blendingSpeed defines the blending speed to use
  2508. */
  2509. Animatable.prototype.enableBlending = function (blendingSpeed) {
  2510. var runtimeAnimations = this._runtimeAnimations;
  2511. for (var index = 0; index < runtimeAnimations.length; index++) {
  2512. runtimeAnimations[index].animation.enableBlending = true;
  2513. runtimeAnimations[index].animation.blendingSpeed = blendingSpeed;
  2514. }
  2515. };
  2516. /**
  2517. * Disable animation blending
  2518. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2519. */
  2520. Animatable.prototype.disableBlending = function () {
  2521. var runtimeAnimations = this._runtimeAnimations;
  2522. for (var index = 0; index < runtimeAnimations.length; index++) {
  2523. runtimeAnimations[index].animation.enableBlending = false;
  2524. }
  2525. };
  2526. /**
  2527. * Jump directly to a given frame
  2528. * @param frame defines the frame to jump to
  2529. */
  2530. Animatable.prototype.goToFrame = function (frame) {
  2531. var runtimeAnimations = this._runtimeAnimations;
  2532. if (runtimeAnimations[0]) {
  2533. var fps = runtimeAnimations[0].animation.framePerSecond;
  2534. var currentFrame = runtimeAnimations[0].currentFrame;
  2535. var adjustTime = frame - currentFrame;
  2536. var delay = adjustTime * 1000 / (fps * this.speedRatio);
  2537. if (this._localDelayOffset === null) {
  2538. this._localDelayOffset = 0;
  2539. }
  2540. this._localDelayOffset -= delay;
  2541. }
  2542. for (var index = 0; index < runtimeAnimations.length; index++) {
  2543. runtimeAnimations[index].goToFrame(frame);
  2544. }
  2545. };
  2546. /**
  2547. * Pause the animation
  2548. */
  2549. Animatable.prototype.pause = function () {
  2550. if (this._paused) {
  2551. return;
  2552. }
  2553. this._paused = true;
  2554. };
  2555. /**
  2556. * Restart the animation
  2557. */
  2558. Animatable.prototype.restart = function () {
  2559. this._paused = false;
  2560. };
  2561. Animatable.prototype._raiseOnAnimationEnd = function () {
  2562. if (this.onAnimationEnd) {
  2563. this.onAnimationEnd();
  2564. }
  2565. this.onAnimationEndObservable.notifyObservers(this);
  2566. };
  2567. /**
  2568. * Stop and delete the current animation
  2569. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  2570. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  2571. */
  2572. Animatable.prototype.stop = function (animationName, targetMask) {
  2573. if (animationName || targetMask) {
  2574. var idx = this._scene._activeAnimatables.indexOf(this);
  2575. if (idx > -1) {
  2576. var runtimeAnimations = this._runtimeAnimations;
  2577. for (var index = runtimeAnimations.length - 1; index >= 0; index--) {
  2578. var runtimeAnimation = runtimeAnimations[index];
  2579. if (animationName && runtimeAnimation.animation.name != animationName) {
  2580. continue;
  2581. }
  2582. if (targetMask && !targetMask(runtimeAnimation.target)) {
  2583. continue;
  2584. }
  2585. runtimeAnimation.dispose();
  2586. runtimeAnimations.splice(index, 1);
  2587. }
  2588. if (runtimeAnimations.length == 0) {
  2589. this._scene._activeAnimatables.splice(idx, 1);
  2590. this._raiseOnAnimationEnd();
  2591. }
  2592. }
  2593. }
  2594. else {
  2595. var index = this._scene._activeAnimatables.indexOf(this);
  2596. if (index > -1) {
  2597. this._scene._activeAnimatables.splice(index, 1);
  2598. var runtimeAnimations = this._runtimeAnimations;
  2599. for (var index = 0; index < runtimeAnimations.length; index++) {
  2600. runtimeAnimations[index].dispose();
  2601. }
  2602. this._raiseOnAnimationEnd();
  2603. }
  2604. }
  2605. };
  2606. /**
  2607. * Wait asynchronously for the animation to end
  2608. * @returns a promise which will be fullfilled when the animation ends
  2609. */
  2610. Animatable.prototype.waitAsync = function () {
  2611. var _this = this;
  2612. return new Promise(function (resolve, reject) {
  2613. _this.onAnimationEndObservable.add(function () {
  2614. resolve(_this);
  2615. }, undefined, undefined, _this, true);
  2616. });
  2617. };
  2618. /** @hidden */
  2619. Animatable.prototype._animate = function (delay) {
  2620. var _this = this;
  2621. if (this._paused) {
  2622. this.animationStarted = false;
  2623. if (this._pausedDelay === null) {
  2624. this._pausedDelay = delay;
  2625. }
  2626. return true;
  2627. }
  2628. if (this._localDelayOffset === null) {
  2629. this._localDelayOffset = delay;
  2630. this._pausedDelay = null;
  2631. }
  2632. else if (this._pausedDelay !== null) {
  2633. this._localDelayOffset += delay - this._pausedDelay;
  2634. this._pausedDelay = null;
  2635. }
  2636. if (this._weight === 0) { // We consider that an animation with a weight === 0 is "actively" paused
  2637. return true;
  2638. }
  2639. // Animating
  2640. var running = false;
  2641. var runtimeAnimations = this._runtimeAnimations;
  2642. var index;
  2643. for (index = 0; index < runtimeAnimations.length; index++) {
  2644. var animation = runtimeAnimations[index];
  2645. var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight, function () {
  2646. _this.onAnimationLoopObservable.notifyObservers(_this);
  2647. if (_this.onAnimationLoop) {
  2648. _this.onAnimationLoop();
  2649. }
  2650. });
  2651. running = running || isRunning;
  2652. }
  2653. this.animationStarted = running;
  2654. if (!running) {
  2655. if (this.disposeOnEnd) {
  2656. // Remove from active animatables
  2657. index = this._scene._activeAnimatables.indexOf(this);
  2658. this._scene._activeAnimatables.splice(index, 1);
  2659. // Dispose all runtime animations
  2660. for (index = 0; index < runtimeAnimations.length; index++) {
  2661. runtimeAnimations[index].dispose();
  2662. }
  2663. }
  2664. this._raiseOnAnimationEnd();
  2665. if (this.disposeOnEnd) {
  2666. this.onAnimationEnd = null;
  2667. this.onAnimationLoop = null;
  2668. this.onAnimationLoopObservable.clear();
  2669. this.onAnimationEndObservable.clear();
  2670. }
  2671. }
  2672. return running;
  2673. };
  2674. return Animatable;
  2675. }());
  2676. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._animate = function () {
  2677. if (!this.animationsEnabled || this._activeAnimatables.length === 0) {
  2678. return;
  2679. }
  2680. // Getting time
  2681. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__["PrecisionDate"].Now;
  2682. if (!this._animationTimeLast) {
  2683. if (this._pendingData.length > 0) {
  2684. return;
  2685. }
  2686. this._animationTimeLast = now;
  2687. }
  2688. var deltaTime = this.useConstantAnimationDeltaTime ? 16.0 : (now - this._animationTimeLast) * this.animationTimeScale;
  2689. this._animationTime += deltaTime;
  2690. this._animationTimeLast = now;
  2691. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2692. this._activeAnimatables[index]._animate(this._animationTime);
  2693. }
  2694. // Late animation bindings
  2695. this._processLateAnimationBindings();
  2696. };
  2697. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginWeightedAnimation = function (target, from, to, weight, loop, speedRatio, onAnimationEnd, animatable, targetMask, onAnimationLoop) {
  2698. if (weight === void 0) { weight = 1.0; }
  2699. if (speedRatio === void 0) { speedRatio = 1.0; }
  2700. var returnedAnimatable = this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, false, targetMask, onAnimationLoop);
  2701. returnedAnimatable.weight = weight;
  2702. return returnedAnimatable;
  2703. };
  2704. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2705. if (speedRatio === void 0) { speedRatio = 1.0; }
  2706. if (stopCurrent === void 0) { stopCurrent = true; }
  2707. if (from > to && speedRatio > 0) {
  2708. speedRatio *= -1;
  2709. }
  2710. if (stopCurrent) {
  2711. this.stopAnimation(target, undefined, targetMask);
  2712. }
  2713. if (!animatable) {
  2714. animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, undefined, onAnimationLoop);
  2715. }
  2716. var shouldRunTargetAnimations = targetMask ? targetMask(target) : true;
  2717. // Local animations
  2718. if (target.animations && shouldRunTargetAnimations) {
  2719. animatable.appendAnimations(target, target.animations);
  2720. }
  2721. // Children animations
  2722. if (target.getAnimatables) {
  2723. var animatables = target.getAnimatables();
  2724. for (var index = 0; index < animatables.length; index++) {
  2725. this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop);
  2726. }
  2727. }
  2728. animatable.reset();
  2729. return animatable;
  2730. };
  2731. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginHierarchyAnimation = function (target, directDescendantsOnly, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2732. if (speedRatio === void 0) { speedRatio = 1.0; }
  2733. if (stopCurrent === void 0) { stopCurrent = true; }
  2734. var children = target.getDescendants(directDescendantsOnly);
  2735. var result = [];
  2736. result.push(this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2737. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  2738. var child = children_1[_i];
  2739. result.push(this.beginAnimation(child, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2740. }
  2741. return result;
  2742. };
  2743. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2744. if (speedRatio === undefined) {
  2745. speedRatio = 1.0;
  2746. }
  2747. var animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, animations, onAnimationLoop);
  2748. return animatable;
  2749. };
  2750. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectHierarchyAnimation = function (target, directDescendantsOnly, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2751. var children = target.getDescendants(directDescendantsOnly);
  2752. var result = [];
  2753. result.push(this.beginDirectAnimation(target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2754. for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
  2755. var child = children_2[_i];
  2756. result.push(this.beginDirectAnimation(child, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2757. }
  2758. return result;
  2759. };
  2760. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAnimatableByTarget = function (target) {
  2761. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2762. if (this._activeAnimatables[index].target === target) {
  2763. return this._activeAnimatables[index];
  2764. }
  2765. }
  2766. return null;
  2767. };
  2768. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAllAnimatablesByTarget = function (target) {
  2769. var result = [];
  2770. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2771. if (this._activeAnimatables[index].target === target) {
  2772. result.push(this._activeAnimatables[index]);
  2773. }
  2774. }
  2775. return result;
  2776. };
  2777. /**
  2778. * Will stop the animation of the given target
  2779. * @param target - the target
  2780. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  2781. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  2782. */
  2783. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAnimation = function (target, animationName, targetMask) {
  2784. var animatables = this.getAllAnimatablesByTarget(target);
  2785. for (var _i = 0, animatables_1 = animatables; _i < animatables_1.length; _i++) {
  2786. var animatable = animatables_1[_i];
  2787. animatable.stop(animationName, targetMask);
  2788. }
  2789. };
  2790. /**
  2791. * Stops and removes all animations that have been applied to the scene
  2792. */
  2793. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAllAnimations = function () {
  2794. if (this._activeAnimatables) {
  2795. for (var i = 0; i < this._activeAnimatables.length; i++) {
  2796. this._activeAnimatables[i].stop();
  2797. }
  2798. this._activeAnimatables = [];
  2799. }
  2800. for (var _i = 0, _a = this.animationGroups; _i < _a.length; _i++) {
  2801. var group = _a[_i];
  2802. group.stop();
  2803. }
  2804. };
  2805. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._registerTargetForLateAnimationBinding = function (runtimeAnimation, originalValue) {
  2806. var target = runtimeAnimation.target;
  2807. this._registeredForLateAnimationBindings.pushNoDuplicate(target);
  2808. if (!target._lateAnimationHolders) {
  2809. target._lateAnimationHolders = {};
  2810. }
  2811. if (!target._lateAnimationHolders[runtimeAnimation.targetPath]) {
  2812. target._lateAnimationHolders[runtimeAnimation.targetPath] = {
  2813. totalWeight: 0,
  2814. animations: [],
  2815. originalValue: originalValue
  2816. };
  2817. }
  2818. target._lateAnimationHolders[runtimeAnimation.targetPath].animations.push(runtimeAnimation);
  2819. target._lateAnimationHolders[runtimeAnimation.targetPath].totalWeight += runtimeAnimation.weight;
  2820. };
  2821. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForMatrices = function (holder) {
  2822. var normalizer = 1.0;
  2823. var finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  2824. var finalScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  2825. var finalQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  2826. var startIndex = 0;
  2827. var originalAnimation = holder.animations[0];
  2828. var originalValue = holder.originalValue;
  2829. var scale = 1;
  2830. if (holder.totalWeight < 1.0) {
  2831. // We need to mix the original value in
  2832. originalValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2833. scale = 1.0 - holder.totalWeight;
  2834. }
  2835. else {
  2836. startIndex = 1;
  2837. // We need to normalize the weights
  2838. normalizer = holder.totalWeight;
  2839. originalAnimation.currentValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2840. scale = originalAnimation.weight / normalizer;
  2841. if (scale == 1) {
  2842. return originalAnimation.currentValue;
  2843. }
  2844. }
  2845. finalScaling.scaleInPlace(scale);
  2846. finalPosition.scaleInPlace(scale);
  2847. finalQuaternion.scaleInPlace(scale);
  2848. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2849. var runtimeAnimation = holder.animations[animIndex];
  2850. var scale = runtimeAnimation.weight / normalizer;
  2851. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[2];
  2852. var currentScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[3];
  2853. var currentQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[1];
  2854. runtimeAnimation.currentValue.decompose(currentScaling, currentQuaternion, currentPosition);
  2855. currentScaling.scaleAndAddToRef(scale, finalScaling);
  2856. currentQuaternion.scaleAndAddToRef(scale, finalQuaternion);
  2857. currentPosition.scaleAndAddToRef(scale, finalPosition);
  2858. }
  2859. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(finalScaling, finalQuaternion, finalPosition, originalAnimation._workValue);
  2860. return originalAnimation._workValue;
  2861. };
  2862. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForQuaternions = function (holder, refQuaternion) {
  2863. var originalAnimation = holder.animations[0];
  2864. var originalValue = holder.originalValue;
  2865. if (holder.animations.length === 1) {
  2866. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(originalValue, originalAnimation.currentValue, Math.min(1.0, holder.totalWeight), refQuaternion);
  2867. return refQuaternion;
  2868. }
  2869. var normalizer = 1.0;
  2870. var quaternions;
  2871. var weights;
  2872. if (holder.totalWeight < 1.0) {
  2873. var scale = 1.0 - holder.totalWeight;
  2874. quaternions = [];
  2875. weights = [];
  2876. quaternions.push(originalValue);
  2877. weights.push(scale);
  2878. }
  2879. else {
  2880. if (holder.animations.length === 2) { // Slerp as soon as we can
  2881. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(holder.animations[0].currentValue, holder.animations[1].currentValue, holder.animations[1].weight / holder.totalWeight, refQuaternion);
  2882. return refQuaternion;
  2883. }
  2884. quaternions = [];
  2885. weights = [];
  2886. normalizer = holder.totalWeight;
  2887. }
  2888. for (var animIndex = 0; animIndex < holder.animations.length; animIndex++) {
  2889. var runtimeAnimation = holder.animations[animIndex];
  2890. quaternions.push(runtimeAnimation.currentValue);
  2891. weights.push(runtimeAnimation.weight / normalizer);
  2892. }
  2893. // https://gamedev.stackexchange.com/questions/62354/method-for-interpolation-between-3-quaternions
  2894. var cumulativeAmount = 0;
  2895. var cumulativeQuaternion = null;
  2896. for (var index = 0; index < quaternions.length;) {
  2897. if (!cumulativeQuaternion) {
  2898. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(quaternions[index], quaternions[index + 1], weights[index + 1] / (weights[index] + weights[index + 1]), refQuaternion);
  2899. cumulativeQuaternion = refQuaternion;
  2900. cumulativeAmount = weights[index] + weights[index + 1];
  2901. index += 2;
  2902. continue;
  2903. }
  2904. cumulativeAmount += weights[index];
  2905. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(cumulativeQuaternion, quaternions[index], weights[index] / cumulativeAmount, cumulativeQuaternion);
  2906. index++;
  2907. }
  2908. return cumulativeQuaternion;
  2909. };
  2910. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindings = function () {
  2911. if (!this._registeredForLateAnimationBindings.length) {
  2912. return;
  2913. }
  2914. for (var index = 0; index < this._registeredForLateAnimationBindings.length; index++) {
  2915. var target = this._registeredForLateAnimationBindings.data[index];
  2916. for (var path in target._lateAnimationHolders) {
  2917. var holder = target._lateAnimationHolders[path];
  2918. var originalAnimation = holder.animations[0];
  2919. var originalValue = holder.originalValue;
  2920. var matrixDecomposeMode = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].AllowMatrixDecomposeForInterpolation && originalValue.m; // ie. data is matrix
  2921. var finalValue = target[path];
  2922. if (matrixDecomposeMode) {
  2923. finalValue = this._processLateAnimationBindingsForMatrices(holder);
  2924. }
  2925. else {
  2926. var quaternionMode = originalValue.w !== undefined;
  2927. if (quaternionMode) {
  2928. finalValue = this._processLateAnimationBindingsForQuaternions(holder, finalValue || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity());
  2929. }
  2930. else {
  2931. var startIndex = 0;
  2932. var normalizer = 1.0;
  2933. if (holder.totalWeight < 1.0) {
  2934. // We need to mix the original value in
  2935. if (originalValue.scale) {
  2936. finalValue = originalValue.scale(1.0 - holder.totalWeight);
  2937. }
  2938. else {
  2939. finalValue = originalValue * (1.0 - holder.totalWeight);
  2940. }
  2941. }
  2942. else {
  2943. // We need to normalize the weights
  2944. normalizer = holder.totalWeight;
  2945. var scale_1 = originalAnimation.weight / normalizer;
  2946. if (scale_1 !== 1) {
  2947. if (originalAnimation.currentValue.scale) {
  2948. finalValue = originalAnimation.currentValue.scale(scale_1);
  2949. }
  2950. else {
  2951. finalValue = originalAnimation.currentValue * scale_1;
  2952. }
  2953. }
  2954. else {
  2955. finalValue = originalAnimation.currentValue;
  2956. }
  2957. startIndex = 1;
  2958. }
  2959. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2960. var runtimeAnimation = holder.animations[animIndex];
  2961. var scale = runtimeAnimation.weight / normalizer;
  2962. if (runtimeAnimation.currentValue.scaleAndAddToRef) {
  2963. runtimeAnimation.currentValue.scaleAndAddToRef(scale, finalValue);
  2964. }
  2965. else {
  2966. finalValue += runtimeAnimation.currentValue * scale;
  2967. }
  2968. }
  2969. }
  2970. }
  2971. target[path] = finalValue;
  2972. }
  2973. target._lateAnimationHolders = {};
  2974. }
  2975. this._registeredForLateAnimationBindings.reset();
  2976. };
  2977. _Bones_bone__WEBPACK_IMPORTED_MODULE_6__["Bone"].prototype.copyAnimationRange = function (source, rangeName, frameOffset, rescaleAsRequired, skelDimensionsRatio) {
  2978. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  2979. if (skelDimensionsRatio === void 0) { skelDimensionsRatio = null; }
  2980. // all animation may be coming from a library skeleton, so may need to create animation
  2981. if (this.animations.length === 0) {
  2982. this.animations.push(new _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"](this.name, "_matrix", source.animations[0].framePerSecond, _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONTYPE_MATRIX, 0));
  2983. this.animations[0].setKeys([]);
  2984. }
  2985. // get animation info / verify there is such a range from the source bone
  2986. var sourceRange = source.animations[0].getRange(rangeName);
  2987. if (!sourceRange) {
  2988. return false;
  2989. }
  2990. var from = sourceRange.from;
  2991. var to = sourceRange.to;
  2992. var sourceKeys = source.animations[0].getKeys();
  2993. // rescaling prep
  2994. var sourceBoneLength = source.length;
  2995. var sourceParent = source.getParent();
  2996. var parent = this.getParent();
  2997. var parentScalingReqd = rescaleAsRequired && sourceParent && sourceBoneLength && this.length && sourceBoneLength !== this.length;
  2998. var parentRatio = parentScalingReqd && parent && sourceParent ? parent.length / sourceParent.length : 1;
  2999. var dimensionsScalingReqd = rescaleAsRequired && !parent && skelDimensionsRatio && (skelDimensionsRatio.x !== 1 || skelDimensionsRatio.y !== 1 || skelDimensionsRatio.z !== 1);
  3000. var destKeys = this.animations[0].getKeys();
  3001. // loop vars declaration
  3002. var orig;
  3003. var origTranslation;
  3004. var mat;
  3005. for (var key = 0, nKeys = sourceKeys.length; key < nKeys; key++) {
  3006. orig = sourceKeys[key];
  3007. if (orig.frame >= from && orig.frame <= to) {
  3008. if (rescaleAsRequired) {
  3009. mat = orig.value.clone();
  3010. // scale based on parent ratio, when bone has parent
  3011. if (parentScalingReqd) {
  3012. origTranslation = mat.getTranslation();
  3013. mat.setTranslation(origTranslation.scaleInPlace(parentRatio));
  3014. // scale based on skeleton dimension ratio when root bone, and value is passed
  3015. }
  3016. else if (dimensionsScalingReqd && skelDimensionsRatio) {
  3017. origTranslation = mat.getTranslation();
  3018. mat.setTranslation(origTranslation.multiplyInPlace(skelDimensionsRatio));
  3019. // use original when root bone, and no data for skelDimensionsRatio
  3020. }
  3021. else {
  3022. mat = orig.value;
  3023. }
  3024. }
  3025. else {
  3026. mat = orig.value;
  3027. }
  3028. destKeys.push({ frame: orig.frame + frameOffset, value: mat });
  3029. }
  3030. }
  3031. this.animations[0].createRange(rangeName, from + frameOffset, to + frameOffset);
  3032. return true;
  3033. };
  3034. /***/ }),
  3035. /***/ "./Animations/animation.ts":
  3036. /*!*********************************!*\
  3037. !*** ./Animations/animation.ts ***!
  3038. \*********************************/
  3039. /*! exports provided: Animation */
  3040. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3041. "use strict";
  3042. __webpack_require__.r(__webpack_exports__);
  3043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return Animation; });
  3044. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  3045. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  3046. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  3047. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  3048. /* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  3049. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  3050. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  3051. /**
  3052. * Class used to store any kind of animation
  3053. */
  3054. var Animation = /** @class */ (function () {
  3055. /**
  3056. * Initializes the animation
  3057. * @param name Name of the animation
  3058. * @param targetProperty Property to animate
  3059. * @param framePerSecond The frames per second of the animation
  3060. * @param dataType The data type of the animation
  3061. * @param loopMode The loop mode of the animation
  3062. * @param enableBlending Specifies if blending should be enabled
  3063. */
  3064. function Animation(
  3065. /**Name of the animation */
  3066. name,
  3067. /**Property to animate */
  3068. targetProperty,
  3069. /**The frames per second of the animation */
  3070. framePerSecond,
  3071. /**The data type of the animation */
  3072. dataType,
  3073. /**The loop mode of the animation */
  3074. loopMode,
  3075. /**Specifies if blending should be enabled */
  3076. enableBlending) {
  3077. this.name = name;
  3078. this.targetProperty = targetProperty;
  3079. this.framePerSecond = framePerSecond;
  3080. this.dataType = dataType;
  3081. this.loopMode = loopMode;
  3082. this.enableBlending = enableBlending;
  3083. /**
  3084. * @hidden Internal use only
  3085. */
  3086. this._runtimeAnimations = new Array();
  3087. /**
  3088. * The set of event that will be linked to this animation
  3089. */
  3090. this._events = new Array();
  3091. /**
  3092. * Stores the blending speed of the animation
  3093. */
  3094. this.blendingSpeed = 0.01;
  3095. /**
  3096. * Stores the animation ranges for the animation
  3097. */
  3098. this._ranges = {};
  3099. this.targetPropertyPath = targetProperty.split(".");
  3100. this.dataType = dataType;
  3101. this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
  3102. }
  3103. /**
  3104. * @hidden Internal use
  3105. */
  3106. Animation._PrepareAnimation = function (name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction) {
  3107. var dataType = undefined;
  3108. if (!isNaN(parseFloat(from)) && isFinite(from)) {
  3109. dataType = Animation.ANIMATIONTYPE_FLOAT;
  3110. }
  3111. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]) {
  3112. dataType = Animation.ANIMATIONTYPE_QUATERNION;
  3113. }
  3114. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  3115. dataType = Animation.ANIMATIONTYPE_VECTOR3;
  3116. }
  3117. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"]) {
  3118. dataType = Animation.ANIMATIONTYPE_VECTOR2;
  3119. }
  3120. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"]) {
  3121. dataType = Animation.ANIMATIONTYPE_COLOR3;
  3122. }
  3123. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"]) {
  3124. dataType = Animation.ANIMATIONTYPE_SIZE;
  3125. }
  3126. if (dataType == undefined) {
  3127. return null;
  3128. }
  3129. var animation = new Animation(name, targetProperty, framePerSecond, dataType, loopMode);
  3130. var keys = [{ frame: 0, value: from }, { frame: totalFrame, value: to }];
  3131. animation.setKeys(keys);
  3132. if (easingFunction !== undefined) {
  3133. animation.setEasingFunction(easingFunction);
  3134. }
  3135. return animation;
  3136. };
  3137. /**
  3138. * Sets up an animation
  3139. * @param property The property to animate
  3140. * @param animationType The animation type to apply
  3141. * @param framePerSecond The frames per second of the animation
  3142. * @param easingFunction The easing function used in the animation
  3143. * @returns The created animation
  3144. */
  3145. Animation.CreateAnimation = function (property, animationType, framePerSecond, easingFunction) {
  3146. var animation = new Animation(property + "Animation", property, framePerSecond, animationType, Animation.ANIMATIONLOOPMODE_CONSTANT);
  3147. animation.setEasingFunction(easingFunction);
  3148. return animation;
  3149. };
  3150. /**
  3151. * Create and start an animation on a node
  3152. * @param name defines the name of the global animation that will be run on all nodes
  3153. * @param node defines the root node where the animation will take place
  3154. * @param targetProperty defines property to animate
  3155. * @param framePerSecond defines the number of frame per second yo use
  3156. * @param totalFrame defines the number of frames in total
  3157. * @param from defines the initial value
  3158. * @param to defines the final value
  3159. * @param loopMode defines which loop mode you want to use (off by default)
  3160. * @param easingFunction defines the easing function to use (linear by default)
  3161. * @param onAnimationEnd defines the callback to call when animation end
  3162. * @returns the animatable created for this animation
  3163. */
  3164. Animation.CreateAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3165. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3166. if (!animation) {
  3167. return null;
  3168. }
  3169. return node.getScene().beginDirectAnimation(node, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3170. };
  3171. /**
  3172. * Create and start an animation on a node and its descendants
  3173. * @param name defines the name of the global animation that will be run on all nodes
  3174. * @param node defines the root node where the animation will take place
  3175. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  3176. * @param targetProperty defines property to animate
  3177. * @param framePerSecond defines the number of frame per second to use
  3178. * @param totalFrame defines the number of frames in total
  3179. * @param from defines the initial value
  3180. * @param to defines the final value
  3181. * @param loopMode defines which loop mode you want to use (off by default)
  3182. * @param easingFunction defines the easing function to use (linear by default)
  3183. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3184. * @returns the list of animatables created for all nodes
  3185. * @example https://www.babylonjs-playground.com/#MH0VLI
  3186. */
  3187. Animation.CreateAndStartHierarchyAnimation = function (name, node, directDescendantsOnly, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3188. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3189. if (!animation) {
  3190. return null;
  3191. }
  3192. var scene = node.getScene();
  3193. return scene.beginDirectHierarchyAnimation(node, directDescendantsOnly, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3194. };
  3195. /**
  3196. * Creates a new animation, merges it with the existing animations and starts it
  3197. * @param name Name of the animation
  3198. * @param node Node which contains the scene that begins the animations
  3199. * @param targetProperty Specifies which property to animate
  3200. * @param framePerSecond The frames per second of the animation
  3201. * @param totalFrame The total number of frames
  3202. * @param from The frame at the beginning of the animation
  3203. * @param to The frame at the end of the animation
  3204. * @param loopMode Specifies the loop mode of the animation
  3205. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3206. * @param onAnimationEnd Callback to run once the animation is complete
  3207. * @returns Nullable animation
  3208. */
  3209. Animation.CreateMergeAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3210. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3211. if (!animation) {
  3212. return null;
  3213. }
  3214. node.animations.push(animation);
  3215. return node.getScene().beginAnimation(node, 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3216. };
  3217. /**
  3218. * Transition property of an host to the target Value
  3219. * @param property The property to transition
  3220. * @param targetValue The target Value of the property
  3221. * @param host The object where the property to animate belongs
  3222. * @param scene Scene used to run the animation
  3223. * @param frameRate Framerate (in frame/s) to use
  3224. * @param transition The transition type we want to use
  3225. * @param duration The duration of the animation, in milliseconds
  3226. * @param onAnimationEnd Callback trigger at the end of the animation
  3227. * @returns Nullable animation
  3228. */
  3229. Animation.TransitionTo = function (property, targetValue, host, scene, frameRate, transition, duration, onAnimationEnd) {
  3230. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  3231. if (duration <= 0) {
  3232. host[property] = targetValue;
  3233. if (onAnimationEnd) {
  3234. onAnimationEnd();
  3235. }
  3236. return null;
  3237. }
  3238. var endFrame = frameRate * (duration / 1000);
  3239. transition.setKeys([{
  3240. frame: 0,
  3241. value: host[property].clone ? host[property].clone() : host[property]
  3242. },
  3243. {
  3244. frame: endFrame,
  3245. value: targetValue
  3246. }]);
  3247. if (!host.animations) {
  3248. host.animations = [];
  3249. }
  3250. host.animations.push(transition);
  3251. var animation = scene.beginAnimation(host, 0, endFrame, false);
  3252. animation.onAnimationEnd = onAnimationEnd;
  3253. return animation;
  3254. };
  3255. Object.defineProperty(Animation.prototype, "runtimeAnimations", {
  3256. /**
  3257. * Return the array of runtime animations currently using this animation
  3258. */
  3259. get: function () {
  3260. return this._runtimeAnimations;
  3261. },
  3262. enumerable: true,
  3263. configurable: true
  3264. });
  3265. Object.defineProperty(Animation.prototype, "hasRunningRuntimeAnimations", {
  3266. /**
  3267. * Specifies if any of the runtime animations are currently running
  3268. */
  3269. get: function () {
  3270. for (var _i = 0, _a = this._runtimeAnimations; _i < _a.length; _i++) {
  3271. var runtimeAnimation = _a[_i];
  3272. if (!runtimeAnimation.isStopped) {
  3273. return true;
  3274. }
  3275. }
  3276. return false;
  3277. },
  3278. enumerable: true,
  3279. configurable: true
  3280. });
  3281. // Methods
  3282. /**
  3283. * Converts the animation to a string
  3284. * @param fullDetails support for multiple levels of logging within scene loading
  3285. * @returns String form of the animation
  3286. */
  3287. Animation.prototype.toString = function (fullDetails) {
  3288. var ret = "Name: " + this.name + ", property: " + this.targetProperty;
  3289. ret += ", datatype: " + (["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"])[this.dataType];
  3290. ret += ", nKeys: " + (this._keys ? this._keys.length : "none");
  3291. ret += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  3292. if (fullDetails) {
  3293. ret += ", Ranges: {";
  3294. var first = true;
  3295. for (var name in this._ranges) {
  3296. if (first) {
  3297. ret += ", ";
  3298. first = false;
  3299. }
  3300. ret += name;
  3301. }
  3302. ret += "}";
  3303. }
  3304. return ret;
  3305. };
  3306. /**
  3307. * Add an event to this animation
  3308. * @param event Event to add
  3309. */
  3310. Animation.prototype.addEvent = function (event) {
  3311. this._events.push(event);
  3312. };
  3313. /**
  3314. * Remove all events found at the given frame
  3315. * @param frame The frame to remove events from
  3316. */
  3317. Animation.prototype.removeEvents = function (frame) {
  3318. for (var index = 0; index < this._events.length; index++) {
  3319. if (this._events[index].frame === frame) {
  3320. this._events.splice(index, 1);
  3321. index--;
  3322. }
  3323. }
  3324. };
  3325. /**
  3326. * Retrieves all the events from the animation
  3327. * @returns Events from the animation
  3328. */
  3329. Animation.prototype.getEvents = function () {
  3330. return this._events;
  3331. };
  3332. /**
  3333. * Creates an animation range
  3334. * @param name Name of the animation range
  3335. * @param from Starting frame of the animation range
  3336. * @param to Ending frame of the animation
  3337. */
  3338. Animation.prototype.createRange = function (name, from, to) {
  3339. // check name not already in use; could happen for bones after serialized
  3340. if (!this._ranges[name]) {
  3341. this._ranges[name] = new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  3342. }
  3343. };
  3344. /**
  3345. * Deletes an animation range by name
  3346. * @param name Name of the animation range to delete
  3347. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3348. */
  3349. Animation.prototype.deleteRange = function (name, deleteFrames) {
  3350. if (deleteFrames === void 0) { deleteFrames = true; }
  3351. var range = this._ranges[name];
  3352. if (!range) {
  3353. return;
  3354. }
  3355. if (deleteFrames) {
  3356. var from = range.from;
  3357. var to = range.to;
  3358. // this loop MUST go high to low for multiple splices to work
  3359. for (var key = this._keys.length - 1; key >= 0; key--) {
  3360. if (this._keys[key].frame >= from && this._keys[key].frame <= to) {
  3361. this._keys.splice(key, 1);
  3362. }
  3363. }
  3364. }
  3365. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  3366. };
  3367. /**
  3368. * Gets the animation range by name, or null if not defined
  3369. * @param name Name of the animation range
  3370. * @returns Nullable animation range
  3371. */
  3372. Animation.prototype.getRange = function (name) {
  3373. return this._ranges[name];
  3374. };
  3375. /**
  3376. * Gets the key frames from the animation
  3377. * @returns The key frames of the animation
  3378. */
  3379. Animation.prototype.getKeys = function () {
  3380. return this._keys;
  3381. };
  3382. /**
  3383. * Gets the highest frame rate of the animation
  3384. * @returns Highest frame rate of the animation
  3385. */
  3386. Animation.prototype.getHighestFrame = function () {
  3387. var ret = 0;
  3388. for (var key = 0, nKeys = this._keys.length; key < nKeys; key++) {
  3389. if (ret < this._keys[key].frame) {
  3390. ret = this._keys[key].frame;
  3391. }
  3392. }
  3393. return ret;
  3394. };
  3395. /**
  3396. * Gets the easing function of the animation
  3397. * @returns Easing function of the animation
  3398. */
  3399. Animation.prototype.getEasingFunction = function () {
  3400. return this._easingFunction;
  3401. };
  3402. /**
  3403. * Sets the easing function of the animation
  3404. * @param easingFunction A custom mathematical formula for animation
  3405. */
  3406. Animation.prototype.setEasingFunction = function (easingFunction) {
  3407. this._easingFunction = easingFunction;
  3408. };
  3409. /**
  3410. * Interpolates a scalar linearly
  3411. * @param startValue Start value of the animation curve
  3412. * @param endValue End value of the animation curve
  3413. * @param gradient Scalar amount to interpolate
  3414. * @returns Interpolated scalar value
  3415. */
  3416. Animation.prototype.floatInterpolateFunction = function (startValue, endValue, gradient) {
  3417. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Lerp(startValue, endValue, gradient);
  3418. };
  3419. /**
  3420. * Interpolates a scalar cubically
  3421. * @param startValue Start value of the animation curve
  3422. * @param outTangent End tangent of the animation
  3423. * @param endValue End value of the animation curve
  3424. * @param inTangent Start tangent of the animation curve
  3425. * @param gradient Scalar amount to interpolate
  3426. * @returns Interpolated scalar value
  3427. */
  3428. Animation.prototype.floatInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3429. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3430. };
  3431. /**
  3432. * Interpolates a quaternion using a spherical linear interpolation
  3433. * @param startValue Start value of the animation curve
  3434. * @param endValue End value of the animation curve
  3435. * @param gradient Scalar amount to interpolate
  3436. * @returns Interpolated quaternion value
  3437. */
  3438. Animation.prototype.quaternionInterpolateFunction = function (startValue, endValue, gradient) {
  3439. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Slerp(startValue, endValue, gradient);
  3440. };
  3441. /**
  3442. * Interpolates a quaternion cubically
  3443. * @param startValue Start value of the animation curve
  3444. * @param outTangent End tangent of the animation curve
  3445. * @param endValue End value of the animation curve
  3446. * @param inTangent Start tangent of the animation curve
  3447. * @param gradient Scalar amount to interpolate
  3448. * @returns Interpolated quaternion value
  3449. */
  3450. Animation.prototype.quaternionInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3451. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Hermite(startValue, outTangent, endValue, inTangent, gradient).normalize();
  3452. };
  3453. /**
  3454. * Interpolates a Vector3 linearl
  3455. * @param startValue Start value of the animation curve
  3456. * @param endValue End value of the animation curve
  3457. * @param gradient Scalar amount to interpolate
  3458. * @returns Interpolated scalar value
  3459. */
  3460. Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
  3461. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(startValue, endValue, gradient);
  3462. };
  3463. /**
  3464. * Interpolates a Vector3 cubically
  3465. * @param startValue Start value of the animation curve
  3466. * @param outTangent End tangent of the animation
  3467. * @param endValue End value of the animation curve
  3468. * @param inTangent Start tangent of the animation curve
  3469. * @param gradient Scalar amount to interpolate
  3470. * @returns InterpolatedVector3 value
  3471. */
  3472. Animation.prototype.vector3InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3473. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3474. };
  3475. /**
  3476. * Interpolates a Vector2 linearly
  3477. * @param startValue Start value of the animation curve
  3478. * @param endValue End value of the animation curve
  3479. * @param gradient Scalar amount to interpolate
  3480. * @returns Interpolated Vector2 value
  3481. */
  3482. Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
  3483. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(startValue, endValue, gradient);
  3484. };
  3485. /**
  3486. * Interpolates a Vector2 cubically
  3487. * @param startValue Start value of the animation curve
  3488. * @param outTangent End tangent of the animation
  3489. * @param endValue End value of the animation curve
  3490. * @param inTangent Start tangent of the animation curve
  3491. * @param gradient Scalar amount to interpolate
  3492. * @returns Interpolated Vector2 value
  3493. */
  3494. Animation.prototype.vector2InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3495. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3496. };
  3497. /**
  3498. * Interpolates a size linearly
  3499. * @param startValue Start value of the animation curve
  3500. * @param endValue End value of the animation curve
  3501. * @param gradient Scalar amount to interpolate
  3502. * @returns Interpolated Size value
  3503. */
  3504. Animation.prototype.sizeInterpolateFunction = function (startValue, endValue, gradient) {
  3505. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Lerp(startValue, endValue, gradient);
  3506. };
  3507. /**
  3508. * Interpolates a Color3 linearly
  3509. * @param startValue Start value of the animation curve
  3510. * @param endValue End value of the animation curve
  3511. * @param gradient Scalar amount to interpolate
  3512. * @returns Interpolated Color3 value
  3513. */
  3514. Animation.prototype.color3InterpolateFunction = function (startValue, endValue, gradient) {
  3515. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Lerp(startValue, endValue, gradient);
  3516. };
  3517. /**
  3518. * @hidden Internal use only
  3519. */
  3520. Animation.prototype._getKeyValue = function (value) {
  3521. if (typeof value === "function") {
  3522. return value();
  3523. }
  3524. return value;
  3525. };
  3526. /**
  3527. * @hidden Internal use only
  3528. */
  3529. Animation.prototype._interpolate = function (currentFrame, repeatCount, workValue, loopMode, offsetValue, highLimitValue) {
  3530. if (loopMode === Animation.ANIMATIONLOOPMODE_CONSTANT && repeatCount > 0) {
  3531. return highLimitValue.clone ? highLimitValue.clone() : highLimitValue;
  3532. }
  3533. var keys = this.getKeys();
  3534. if (keys.length === 1) {
  3535. return this._getKeyValue(keys[0].value);
  3536. }
  3537. // Try to get a hash to find the right key
  3538. 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));
  3539. if (keys[startKeyIndex].frame >= currentFrame) {
  3540. while (startKeyIndex - 1 >= 0 && keys[startKeyIndex].frame >= currentFrame) {
  3541. startKeyIndex--;
  3542. }
  3543. }
  3544. for (var key = startKeyIndex; key < keys.length; key++) {
  3545. var endKey = keys[key + 1];
  3546. if (endKey.frame >= currentFrame) {
  3547. var startKey = keys[key];
  3548. var startValue = this._getKeyValue(startKey.value);
  3549. if (startKey.interpolation === _animationKey__WEBPACK_IMPORTED_MODULE_4__["AnimationKeyInterpolation"].STEP) {
  3550. return startValue;
  3551. }
  3552. var endValue = this._getKeyValue(endKey.value);
  3553. var useTangent = startKey.outTangent !== undefined && endKey.inTangent !== undefined;
  3554. var frameDelta = endKey.frame - startKey.frame;
  3555. // gradient : percent of currentFrame between the frame inf and the frame sup
  3556. var gradient = (currentFrame - startKey.frame) / frameDelta;
  3557. // check for easingFunction and correction of gradient
  3558. var easingFunction = this.getEasingFunction();
  3559. if (easingFunction != null) {
  3560. gradient = easingFunction.ease(gradient);
  3561. }
  3562. switch (this.dataType) {
  3563. // Float
  3564. case Animation.ANIMATIONTYPE_FLOAT:
  3565. var floatValue = useTangent ? this.floatInterpolateFunctionWithTangents(startValue, startKey.outTangent * frameDelta, endValue, endKey.inTangent * frameDelta, gradient) : this.floatInterpolateFunction(startValue, endValue, gradient);
  3566. switch (loopMode) {
  3567. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3568. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3569. return floatValue;
  3570. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3571. return offsetValue * repeatCount + floatValue;
  3572. }
  3573. break;
  3574. // Quaternion
  3575. case Animation.ANIMATIONTYPE_QUATERNION:
  3576. var quatValue = useTangent ? this.quaternionInterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.quaternionInterpolateFunction(startValue, endValue, gradient);
  3577. switch (loopMode) {
  3578. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3579. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3580. return quatValue;
  3581. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3582. return quatValue.addInPlace(offsetValue.scale(repeatCount));
  3583. }
  3584. return quatValue;
  3585. // Vector3
  3586. case Animation.ANIMATIONTYPE_VECTOR3:
  3587. var vec3Value = useTangent ? this.vector3InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector3InterpolateFunction(startValue, endValue, gradient);
  3588. switch (loopMode) {
  3589. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3590. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3591. return vec3Value;
  3592. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3593. return vec3Value.add(offsetValue.scale(repeatCount));
  3594. }
  3595. // Vector2
  3596. case Animation.ANIMATIONTYPE_VECTOR2:
  3597. var vec2Value = useTangent ? this.vector2InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector2InterpolateFunction(startValue, endValue, gradient);
  3598. switch (loopMode) {
  3599. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3600. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3601. return vec2Value;
  3602. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3603. return vec2Value.add(offsetValue.scale(repeatCount));
  3604. }
  3605. // Size
  3606. case Animation.ANIMATIONTYPE_SIZE:
  3607. switch (loopMode) {
  3608. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3609. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3610. return this.sizeInterpolateFunction(startValue, endValue, gradient);
  3611. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3612. return this.sizeInterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3613. }
  3614. // Color3
  3615. case Animation.ANIMATIONTYPE_COLOR3:
  3616. switch (loopMode) {
  3617. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3618. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3619. return this.color3InterpolateFunction(startValue, endValue, gradient);
  3620. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3621. return this.color3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3622. }
  3623. // Matrix
  3624. case Animation.ANIMATIONTYPE_MATRIX:
  3625. switch (loopMode) {
  3626. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3627. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3628. if (Animation.AllowMatricesInterpolation) {
  3629. return this.matrixInterpolateFunction(startValue, endValue, gradient, workValue);
  3630. }
  3631. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3632. return startValue;
  3633. }
  3634. default:
  3635. break;
  3636. }
  3637. break;
  3638. }
  3639. }
  3640. return this._getKeyValue(keys[keys.length - 1].value);
  3641. };
  3642. /**
  3643. * Defines the function to use to interpolate matrices
  3644. * @param startValue defines the start matrix
  3645. * @param endValue defines the end matrix
  3646. * @param gradient defines the gradient between both matrices
  3647. * @param result defines an optional target matrix where to store the interpolation
  3648. * @returns the interpolated matrix
  3649. */
  3650. Animation.prototype.matrixInterpolateFunction = function (startValue, endValue, gradient, result) {
  3651. if (Animation.AllowMatrixDecomposeForInterpolation) {
  3652. if (result) {
  3653. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(startValue, endValue, gradient, result);
  3654. return result;
  3655. }
  3656. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(startValue, endValue, gradient);
  3657. }
  3658. if (result) {
  3659. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(startValue, endValue, gradient, result);
  3660. return result;
  3661. }
  3662. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(startValue, endValue, gradient);
  3663. };
  3664. /**
  3665. * Makes a copy of the animation
  3666. * @returns Cloned animation
  3667. */
  3668. Animation.prototype.clone = function () {
  3669. var clone = new Animation(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
  3670. clone.enableBlending = this.enableBlending;
  3671. clone.blendingSpeed = this.blendingSpeed;
  3672. if (this._keys) {
  3673. clone.setKeys(this._keys);
  3674. }
  3675. if (this._ranges) {
  3676. clone._ranges = {};
  3677. for (var name in this._ranges) {
  3678. var range = this._ranges[name];
  3679. if (!range) {
  3680. continue;
  3681. }
  3682. clone._ranges[name] = range.clone();
  3683. }
  3684. }
  3685. return clone;
  3686. };
  3687. /**
  3688. * Sets the key frames of the animation
  3689. * @param values The animation key frames to set
  3690. */
  3691. Animation.prototype.setKeys = function (values) {
  3692. this._keys = values.slice(0);
  3693. };
  3694. /**
  3695. * Serializes the animation to an object
  3696. * @returns Serialized object
  3697. */
  3698. Animation.prototype.serialize = function () {
  3699. var serializationObject = {};
  3700. serializationObject.name = this.name;
  3701. serializationObject.property = this.targetProperty;
  3702. serializationObject.framePerSecond = this.framePerSecond;
  3703. serializationObject.dataType = this.dataType;
  3704. serializationObject.loopBehavior = this.loopMode;
  3705. serializationObject.enableBlending = this.enableBlending;
  3706. serializationObject.blendingSpeed = this.blendingSpeed;
  3707. var dataType = this.dataType;
  3708. serializationObject.keys = [];
  3709. var keys = this.getKeys();
  3710. for (var index = 0; index < keys.length; index++) {
  3711. var animationKey = keys[index];
  3712. var key = {};
  3713. key.frame = animationKey.frame;
  3714. switch (dataType) {
  3715. case Animation.ANIMATIONTYPE_FLOAT:
  3716. key.values = [animationKey.value];
  3717. break;
  3718. case Animation.ANIMATIONTYPE_QUATERNION:
  3719. case Animation.ANIMATIONTYPE_MATRIX:
  3720. case Animation.ANIMATIONTYPE_VECTOR3:
  3721. case Animation.ANIMATIONTYPE_COLOR3:
  3722. key.values = animationKey.value.asArray();
  3723. break;
  3724. }
  3725. serializationObject.keys.push(key);
  3726. }
  3727. serializationObject.ranges = [];
  3728. for (var name in this._ranges) {
  3729. var source = this._ranges[name];
  3730. if (!source) {
  3731. continue;
  3732. }
  3733. var range = {};
  3734. range.name = name;
  3735. range.from = source.from;
  3736. range.to = source.to;
  3737. serializationObject.ranges.push(range);
  3738. }
  3739. return serializationObject;
  3740. };
  3741. Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
  3742. /**
  3743. * Get the float animation type
  3744. */
  3745. get: function () {
  3746. return Animation._ANIMATIONTYPE_FLOAT;
  3747. },
  3748. enumerable: true,
  3749. configurable: true
  3750. });
  3751. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
  3752. /**
  3753. * Get the Vector3 animation type
  3754. */
  3755. get: function () {
  3756. return Animation._ANIMATIONTYPE_VECTOR3;
  3757. },
  3758. enumerable: true,
  3759. configurable: true
  3760. });
  3761. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
  3762. /**
  3763. * Get the Vector2 animation type
  3764. */
  3765. get: function () {
  3766. return Animation._ANIMATIONTYPE_VECTOR2;
  3767. },
  3768. enumerable: true,
  3769. configurable: true
  3770. });
  3771. Object.defineProperty(Animation, "ANIMATIONTYPE_SIZE", {
  3772. /**
  3773. * Get the Size animation type
  3774. */
  3775. get: function () {
  3776. return Animation._ANIMATIONTYPE_SIZE;
  3777. },
  3778. enumerable: true,
  3779. configurable: true
  3780. });
  3781. Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
  3782. /**
  3783. * Get the Quaternion animation type
  3784. */
  3785. get: function () {
  3786. return Animation._ANIMATIONTYPE_QUATERNION;
  3787. },
  3788. enumerable: true,
  3789. configurable: true
  3790. });
  3791. Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
  3792. /**
  3793. * Get the Matrix animation type
  3794. */
  3795. get: function () {
  3796. return Animation._ANIMATIONTYPE_MATRIX;
  3797. },
  3798. enumerable: true,
  3799. configurable: true
  3800. });
  3801. Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
  3802. /**
  3803. * Get the Color3 animation type
  3804. */
  3805. get: function () {
  3806. return Animation._ANIMATIONTYPE_COLOR3;
  3807. },
  3808. enumerable: true,
  3809. configurable: true
  3810. });
  3811. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
  3812. /**
  3813. * Get the Relative Loop Mode
  3814. */
  3815. get: function () {
  3816. return Animation._ANIMATIONLOOPMODE_RELATIVE;
  3817. },
  3818. enumerable: true,
  3819. configurable: true
  3820. });
  3821. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
  3822. /**
  3823. * Get the Cycle Loop Mode
  3824. */
  3825. get: function () {
  3826. return Animation._ANIMATIONLOOPMODE_CYCLE;
  3827. },
  3828. enumerable: true,
  3829. configurable: true
  3830. });
  3831. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
  3832. /**
  3833. * Get the Constant Loop Mode
  3834. */
  3835. get: function () {
  3836. return Animation._ANIMATIONLOOPMODE_CONSTANT;
  3837. },
  3838. enumerable: true,
  3839. configurable: true
  3840. });
  3841. /** @hidden */
  3842. Animation._UniversalLerp = function (left, right, amount) {
  3843. var constructor = left.constructor;
  3844. if (constructor.Lerp) { // Lerp supported
  3845. return constructor.Lerp(left, right, amount);
  3846. }
  3847. else if (constructor.Slerp) { // Slerp supported
  3848. return constructor.Slerp(left, right, amount);
  3849. }
  3850. else if (left.toFixed) { // Number
  3851. return left * (1.0 - amount) + amount * right;
  3852. }
  3853. else { // Blending not supported
  3854. return right;
  3855. }
  3856. };
  3857. /**
  3858. * Parses an animation object and creates an animation
  3859. * @param parsedAnimation Parsed animation object
  3860. * @returns Animation object
  3861. */
  3862. Animation.Parse = function (parsedAnimation) {
  3863. var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
  3864. var dataType = parsedAnimation.dataType;
  3865. var keys = [];
  3866. var data;
  3867. var index;
  3868. if (parsedAnimation.enableBlending) {
  3869. animation.enableBlending = parsedAnimation.enableBlending;
  3870. }
  3871. if (parsedAnimation.blendingSpeed) {
  3872. animation.blendingSpeed = parsedAnimation.blendingSpeed;
  3873. }
  3874. for (index = 0; index < parsedAnimation.keys.length; index++) {
  3875. var key = parsedAnimation.keys[index];
  3876. var inTangent;
  3877. var outTangent;
  3878. switch (dataType) {
  3879. case Animation.ANIMATIONTYPE_FLOAT:
  3880. data = key.values[0];
  3881. if (key.values.length >= 1) {
  3882. inTangent = key.values[1];
  3883. }
  3884. if (key.values.length >= 2) {
  3885. outTangent = key.values[2];
  3886. }
  3887. break;
  3888. case Animation.ANIMATIONTYPE_QUATERNION:
  3889. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values);
  3890. if (key.values.length >= 8) {
  3891. var _inTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(4, 8));
  3892. if (!_inTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3893. inTangent = _inTangent;
  3894. }
  3895. }
  3896. if (key.values.length >= 12) {
  3897. var _outTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(8, 12));
  3898. if (!_outTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3899. outTangent = _outTangent;
  3900. }
  3901. }
  3902. break;
  3903. case Animation.ANIMATIONTYPE_MATRIX:
  3904. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArray(key.values);
  3905. break;
  3906. case Animation.ANIMATIONTYPE_COLOR3:
  3907. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(key.values);
  3908. break;
  3909. case Animation.ANIMATIONTYPE_VECTOR3:
  3910. default:
  3911. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(key.values);
  3912. break;
  3913. }
  3914. var keyData = {};
  3915. keyData.frame = key.frame;
  3916. keyData.value = data;
  3917. if (inTangent != undefined) {
  3918. keyData.inTangent = inTangent;
  3919. }
  3920. if (outTangent != undefined) {
  3921. keyData.outTangent = outTangent;
  3922. }
  3923. keys.push(keyData);
  3924. }
  3925. animation.setKeys(keys);
  3926. if (parsedAnimation.ranges) {
  3927. for (index = 0; index < parsedAnimation.ranges.length; index++) {
  3928. data = parsedAnimation.ranges[index];
  3929. animation.createRange(data.name, data.from, data.to);
  3930. }
  3931. }
  3932. return animation;
  3933. };
  3934. /**
  3935. * Appends the serialized animations from the source animations
  3936. * @param source Source containing the animations
  3937. * @param destination Target to store the animations
  3938. */
  3939. Animation.AppendSerializedAnimations = function (source, destination) {
  3940. _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].AppendSerializedAnimations(source, destination);
  3941. };
  3942. /**
  3943. * Use matrix interpolation instead of using direct key value when animating matrices
  3944. */
  3945. Animation.AllowMatricesInterpolation = false;
  3946. /**
  3947. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3948. */
  3949. Animation.AllowMatrixDecomposeForInterpolation = true;
  3950. // Statics
  3951. /**
  3952. * Float animation type
  3953. */
  3954. Animation._ANIMATIONTYPE_FLOAT = 0;
  3955. /**
  3956. * Vector3 animation type
  3957. */
  3958. Animation._ANIMATIONTYPE_VECTOR3 = 1;
  3959. /**
  3960. * Quaternion animation type
  3961. */
  3962. Animation._ANIMATIONTYPE_QUATERNION = 2;
  3963. /**
  3964. * Matrix animation type
  3965. */
  3966. Animation._ANIMATIONTYPE_MATRIX = 3;
  3967. /**
  3968. * Color3 animation type
  3969. */
  3970. Animation._ANIMATIONTYPE_COLOR3 = 4;
  3971. /**
  3972. * Vector2 animation type
  3973. */
  3974. Animation._ANIMATIONTYPE_VECTOR2 = 5;
  3975. /**
  3976. * Size animation type
  3977. */
  3978. Animation._ANIMATIONTYPE_SIZE = 6;
  3979. /**
  3980. * Relative Loop Mode
  3981. */
  3982. Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
  3983. /**
  3984. * Cycle Loop Mode
  3985. */
  3986. Animation._ANIMATIONLOOPMODE_CYCLE = 1;
  3987. /**
  3988. * Constant Loop Mode
  3989. */
  3990. Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
  3991. return Animation;
  3992. }());
  3993. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Animation"] = Animation;
  3994. _node__WEBPACK_IMPORTED_MODULE_6__["Node"]._AnimationRangeFactory = function (name, from, to) { return new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to); };
  3995. /***/ }),
  3996. /***/ "./Animations/animationEvent.ts":
  3997. /*!**************************************!*\
  3998. !*** ./Animations/animationEvent.ts ***!
  3999. \**************************************/
  4000. /*! exports provided: AnimationEvent */
  4001. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4002. "use strict";
  4003. __webpack_require__.r(__webpack_exports__);
  4004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return AnimationEvent; });
  4005. /**
  4006. * Composed of a frame, and an action function
  4007. */
  4008. var AnimationEvent = /** @class */ (function () {
  4009. /**
  4010. * Initializes the animation event
  4011. * @param frame The frame for which the event is triggered
  4012. * @param action The event to perform when triggered
  4013. * @param onlyOnce Specifies if the event should be triggered only once
  4014. */
  4015. function AnimationEvent(
  4016. /** The frame for which the event is triggered **/
  4017. frame,
  4018. /** The event to perform when triggered **/
  4019. action,
  4020. /** Specifies if the event should be triggered only once**/
  4021. onlyOnce) {
  4022. this.frame = frame;
  4023. this.action = action;
  4024. this.onlyOnce = onlyOnce;
  4025. /**
  4026. * Specifies if the animation event is done
  4027. */
  4028. this.isDone = false;
  4029. }
  4030. /** @hidden */
  4031. AnimationEvent.prototype._clone = function () {
  4032. return new AnimationEvent(this.frame, this.action, this.onlyOnce);
  4033. };
  4034. return AnimationEvent;
  4035. }());
  4036. /***/ }),
  4037. /***/ "./Animations/animationGroup.ts":
  4038. /*!**************************************!*\
  4039. !*** ./Animations/animationGroup.ts ***!
  4040. \**************************************/
  4041. /*! exports provided: TargetedAnimation, AnimationGroup */
  4042. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4043. "use strict";
  4044. __webpack_require__.r(__webpack_exports__);
  4045. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return TargetedAnimation; });
  4046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return AnimationGroup; });
  4047. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4048. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  4049. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  4050. /**
  4051. * This class defines the direct association between an animation and a target
  4052. */
  4053. var TargetedAnimation = /** @class */ (function () {
  4054. function TargetedAnimation() {
  4055. }
  4056. return TargetedAnimation;
  4057. }());
  4058. /**
  4059. * Use this class to create coordinated animations on multiple targets
  4060. */
  4061. var AnimationGroup = /** @class */ (function () {
  4062. /**
  4063. * Instantiates a new Animation Group.
  4064. * This helps managing several animations at once.
  4065. * @see http://doc.babylonjs.com/how_to/group
  4066. * @param name Defines the name of the group
  4067. * @param scene Defines the scene the group belongs to
  4068. */
  4069. function AnimationGroup(
  4070. /** The name of the animation group */
  4071. name, scene) {
  4072. if (scene === void 0) { scene = null; }
  4073. this.name = name;
  4074. this._targetedAnimations = new Array();
  4075. this._animatables = new Array();
  4076. this._from = Number.MAX_VALUE;
  4077. this._to = -Number.MAX_VALUE;
  4078. this._speedRatio = 1;
  4079. /**
  4080. * This observable will notify when one animation have ended
  4081. */
  4082. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4083. /**
  4084. * Observer raised when one animation loops
  4085. */
  4086. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4087. /**
  4088. * This observable will notify when all animations have ended.
  4089. */
  4090. this.onAnimationGroupEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4091. /**
  4092. * This observable will notify when all animations have paused.
  4093. */
  4094. this.onAnimationGroupPauseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4095. /**
  4096. * This observable will notify when all animations are playing.
  4097. */
  4098. this.onAnimationGroupPlayObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4099. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  4100. this.uniqueId = this._scene.getUniqueId();
  4101. this._scene.animationGroups.push(this);
  4102. }
  4103. Object.defineProperty(AnimationGroup.prototype, "from", {
  4104. /**
  4105. * Gets the first frame
  4106. */
  4107. get: function () {
  4108. return this._from;
  4109. },
  4110. enumerable: true,
  4111. configurable: true
  4112. });
  4113. Object.defineProperty(AnimationGroup.prototype, "to", {
  4114. /**
  4115. * Gets the last frame
  4116. */
  4117. get: function () {
  4118. return this._to;
  4119. },
  4120. enumerable: true,
  4121. configurable: true
  4122. });
  4123. Object.defineProperty(AnimationGroup.prototype, "isStarted", {
  4124. /**
  4125. * Define if the animations are started
  4126. */
  4127. get: function () {
  4128. return this._isStarted;
  4129. },
  4130. enumerable: true,
  4131. configurable: true
  4132. });
  4133. Object.defineProperty(AnimationGroup.prototype, "isPlaying", {
  4134. /**
  4135. * Gets a value indicating that the current group is playing
  4136. */
  4137. get: function () {
  4138. return this._isStarted && !this._isPaused;
  4139. },
  4140. enumerable: true,
  4141. configurable: true
  4142. });
  4143. Object.defineProperty(AnimationGroup.prototype, "speedRatio", {
  4144. /**
  4145. * Gets or sets the speed ratio to use for all animations
  4146. */
  4147. get: function () {
  4148. return this._speedRatio;
  4149. },
  4150. /**
  4151. * Gets or sets the speed ratio to use for all animations
  4152. */
  4153. set: function (value) {
  4154. if (this._speedRatio === value) {
  4155. return;
  4156. }
  4157. this._speedRatio = value;
  4158. for (var index = 0; index < this._animatables.length; index++) {
  4159. var animatable = this._animatables[index];
  4160. animatable.speedRatio = this._speedRatio;
  4161. }
  4162. },
  4163. enumerable: true,
  4164. configurable: true
  4165. });
  4166. Object.defineProperty(AnimationGroup.prototype, "targetedAnimations", {
  4167. /**
  4168. * Gets the targeted animations for this animation group
  4169. */
  4170. get: function () {
  4171. return this._targetedAnimations;
  4172. },
  4173. enumerable: true,
  4174. configurable: true
  4175. });
  4176. Object.defineProperty(AnimationGroup.prototype, "animatables", {
  4177. /**
  4178. * returning the list of animatables controlled by this animation group.
  4179. */
  4180. get: function () {
  4181. return this._animatables;
  4182. },
  4183. enumerable: true,
  4184. configurable: true
  4185. });
  4186. /**
  4187. * Add an animation (with its target) in the group
  4188. * @param animation defines the animation we want to add
  4189. * @param target defines the target of the animation
  4190. * @returns the TargetedAnimation object
  4191. */
  4192. AnimationGroup.prototype.addTargetedAnimation = function (animation, target) {
  4193. var targetedAnimation = {
  4194. animation: animation,
  4195. target: target
  4196. };
  4197. var keys = animation.getKeys();
  4198. if (this._from > keys[0].frame) {
  4199. this._from = keys[0].frame;
  4200. }
  4201. if (this._to < keys[keys.length - 1].frame) {
  4202. this._to = keys[keys.length - 1].frame;
  4203. }
  4204. this._targetedAnimations.push(targetedAnimation);
  4205. return targetedAnimation;
  4206. };
  4207. /**
  4208. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4209. * It can add constant keys at begin or end
  4210. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4211. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4212. * @returns the animation group
  4213. */
  4214. AnimationGroup.prototype.normalize = function (beginFrame, endFrame) {
  4215. if (beginFrame === void 0) { beginFrame = null; }
  4216. if (endFrame === void 0) { endFrame = null; }
  4217. if (beginFrame == null) {
  4218. beginFrame = this._from;
  4219. }
  4220. if (endFrame == null) {
  4221. endFrame = this._to;
  4222. }
  4223. for (var index = 0; index < this._targetedAnimations.length; index++) {
  4224. var targetedAnimation = this._targetedAnimations[index];
  4225. var keys = targetedAnimation.animation.getKeys();
  4226. var startKey = keys[0];
  4227. var endKey = keys[keys.length - 1];
  4228. if (startKey.frame > beginFrame) {
  4229. var newKey = {
  4230. frame: beginFrame,
  4231. value: startKey.value,
  4232. inTangent: startKey.inTangent,
  4233. outTangent: startKey.outTangent,
  4234. interpolation: startKey.interpolation
  4235. };
  4236. keys.splice(0, 0, newKey);
  4237. }
  4238. if (endKey.frame < endFrame) {
  4239. var newKey = {
  4240. frame: endFrame,
  4241. value: endKey.value,
  4242. inTangent: endKey.outTangent,
  4243. outTangent: endKey.outTangent,
  4244. interpolation: endKey.interpolation
  4245. };
  4246. keys.push(newKey);
  4247. }
  4248. }
  4249. this._from = beginFrame;
  4250. this._to = endFrame;
  4251. return this;
  4252. };
  4253. /**
  4254. * Start all animations on given targets
  4255. * @param loop defines if animations must loop
  4256. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4257. * @param from defines the from key (optional)
  4258. * @param to defines the to key (optional)
  4259. * @returns the current animation group
  4260. */
  4261. AnimationGroup.prototype.start = function (loop, speedRatio, from, to) {
  4262. var _this = this;
  4263. if (loop === void 0) { loop = false; }
  4264. if (speedRatio === void 0) { speedRatio = 1; }
  4265. if (this._isStarted || this._targetedAnimations.length === 0) {
  4266. return this;
  4267. }
  4268. var _loop_1 = function (targetedAnimation) {
  4269. var animatable = this_1._scene.beginDirectAnimation(targetedAnimation.target, [targetedAnimation.animation], from !== undefined ? from : this_1._from, to !== undefined ? to : this_1._to, loop, speedRatio);
  4270. animatable.onAnimationEnd = function () {
  4271. _this.onAnimationEndObservable.notifyObservers(targetedAnimation);
  4272. _this._checkAnimationGroupEnded(animatable);
  4273. };
  4274. animatable.onAnimationLoop = function () {
  4275. _this.onAnimationLoopObservable.notifyObservers(targetedAnimation);
  4276. };
  4277. this_1._animatables.push(animatable);
  4278. };
  4279. var this_1 = this;
  4280. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4281. var targetedAnimation = _a[_i];
  4282. _loop_1(targetedAnimation);
  4283. }
  4284. this._speedRatio = speedRatio;
  4285. if (from !== undefined && to !== undefined && from > to && this._speedRatio > 0) {
  4286. this._speedRatio = -speedRatio;
  4287. }
  4288. this._isStarted = true;
  4289. this._isPaused = false;
  4290. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4291. return this;
  4292. };
  4293. /**
  4294. * Pause all animations
  4295. * @returns the animation group
  4296. */
  4297. AnimationGroup.prototype.pause = function () {
  4298. if (!this._isStarted) {
  4299. return this;
  4300. }
  4301. this._isPaused = true;
  4302. for (var index = 0; index < this._animatables.length; index++) {
  4303. var animatable = this._animatables[index];
  4304. animatable.pause();
  4305. }
  4306. this.onAnimationGroupPauseObservable.notifyObservers(this);
  4307. return this;
  4308. };
  4309. /**
  4310. * Play all animations to initial state
  4311. * This function will start() the animations if they were not started or will restart() them if they were paused
  4312. * @param loop defines if animations must loop
  4313. * @returns the animation group
  4314. */
  4315. AnimationGroup.prototype.play = function (loop) {
  4316. // only if all animatables are ready and exist
  4317. if (this.isStarted && this._animatables.length === this._targetedAnimations.length) {
  4318. if (loop !== undefined) {
  4319. for (var index = 0; index < this._animatables.length; index++) {
  4320. var animatable = this._animatables[index];
  4321. animatable.loopAnimation = loop;
  4322. }
  4323. }
  4324. this.restart();
  4325. }
  4326. else {
  4327. this.stop();
  4328. this.start(loop, this._speedRatio);
  4329. }
  4330. this._isPaused = false;
  4331. return this;
  4332. };
  4333. /**
  4334. * Reset all animations to initial state
  4335. * @returns the animation group
  4336. */
  4337. AnimationGroup.prototype.reset = function () {
  4338. if (!this._isStarted) {
  4339. return this;
  4340. }
  4341. for (var index = 0; index < this._animatables.length; index++) {
  4342. var animatable = this._animatables[index];
  4343. animatable.reset();
  4344. }
  4345. return this;
  4346. };
  4347. /**
  4348. * Restart animations from key 0
  4349. * @returns the animation group
  4350. */
  4351. AnimationGroup.prototype.restart = function () {
  4352. if (!this._isStarted) {
  4353. return this;
  4354. }
  4355. for (var index = 0; index < this._animatables.length; index++) {
  4356. var animatable = this._animatables[index];
  4357. animatable.restart();
  4358. }
  4359. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4360. return this;
  4361. };
  4362. /**
  4363. * Stop all animations
  4364. * @returns the animation group
  4365. */
  4366. AnimationGroup.prototype.stop = function () {
  4367. if (!this._isStarted) {
  4368. return this;
  4369. }
  4370. var list = this._animatables.slice();
  4371. for (var index = 0; index < list.length; index++) {
  4372. list[index].stop();
  4373. }
  4374. this._isStarted = false;
  4375. return this;
  4376. };
  4377. /**
  4378. * Set animation weight for all animatables
  4379. * @param weight defines the weight to use
  4380. * @return the animationGroup
  4381. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4382. */
  4383. AnimationGroup.prototype.setWeightForAllAnimatables = function (weight) {
  4384. for (var index = 0; index < this._animatables.length; index++) {
  4385. var animatable = this._animatables[index];
  4386. animatable.weight = weight;
  4387. }
  4388. return this;
  4389. };
  4390. /**
  4391. * Synchronize and normalize all animatables with a source animatable
  4392. * @param root defines the root animatable to synchronize with
  4393. * @return the animationGroup
  4394. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4395. */
  4396. AnimationGroup.prototype.syncAllAnimationsWith = function (root) {
  4397. for (var index = 0; index < this._animatables.length; index++) {
  4398. var animatable = this._animatables[index];
  4399. animatable.syncWith(root);
  4400. }
  4401. return this;
  4402. };
  4403. /**
  4404. * Goes to a specific frame in this animation group
  4405. * @param frame the frame number to go to
  4406. * @return the animationGroup
  4407. */
  4408. AnimationGroup.prototype.goToFrame = function (frame) {
  4409. if (!this._isStarted) {
  4410. return this;
  4411. }
  4412. for (var index = 0; index < this._animatables.length; index++) {
  4413. var animatable = this._animatables[index];
  4414. animatable.goToFrame(frame);
  4415. }
  4416. return this;
  4417. };
  4418. /**
  4419. * Dispose all associated resources
  4420. */
  4421. AnimationGroup.prototype.dispose = function () {
  4422. this._targetedAnimations = [];
  4423. this._animatables = [];
  4424. var index = this._scene.animationGroups.indexOf(this);
  4425. if (index > -1) {
  4426. this._scene.animationGroups.splice(index, 1);
  4427. }
  4428. this.onAnimationEndObservable.clear();
  4429. this.onAnimationGroupEndObservable.clear();
  4430. this.onAnimationGroupPauseObservable.clear();
  4431. this.onAnimationGroupPlayObservable.clear();
  4432. this.onAnimationLoopObservable.clear();
  4433. };
  4434. AnimationGroup.prototype._checkAnimationGroupEnded = function (animatable) {
  4435. // animatable should be taken out of the array
  4436. var idx = this._animatables.indexOf(animatable);
  4437. if (idx > -1) {
  4438. this._animatables.splice(idx, 1);
  4439. }
  4440. // all animatables were removed? animation group ended!
  4441. if (this._animatables.length === 0) {
  4442. this._isStarted = false;
  4443. this.onAnimationGroupEndObservable.notifyObservers(this);
  4444. }
  4445. };
  4446. /**
  4447. * Clone the current animation group and returns a copy
  4448. * @param newName defines the name of the new group
  4449. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  4450. * @returns the new aniamtion group
  4451. */
  4452. AnimationGroup.prototype.clone = function (newName, targetConverter) {
  4453. var newGroup = new AnimationGroup(newName || this.name, this._scene);
  4454. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4455. var targetAnimation = _a[_i];
  4456. newGroup.addTargetedAnimation(targetAnimation.animation.clone(), targetConverter ? targetConverter(targetAnimation.target) : targetAnimation.target);
  4457. }
  4458. return newGroup;
  4459. };
  4460. // Statics
  4461. /**
  4462. * Returns a new AnimationGroup object parsed from the source provided.
  4463. * @param parsedAnimationGroup defines the source
  4464. * @param scene defines the scene that will receive the animationGroup
  4465. * @returns a new AnimationGroup
  4466. */
  4467. AnimationGroup.Parse = function (parsedAnimationGroup, scene) {
  4468. var animationGroup = new AnimationGroup(parsedAnimationGroup.name, scene);
  4469. for (var i = 0; i < parsedAnimationGroup.targetedAnimations.length; i++) {
  4470. var targetedAnimation = parsedAnimationGroup.targetedAnimations[i];
  4471. var animation = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].Parse(targetedAnimation.animation);
  4472. var id = targetedAnimation.targetId;
  4473. if (targetedAnimation.animation.property === "influence") { // morph target animation
  4474. var morphTarget = scene.getMorphTargetById(id);
  4475. if (morphTarget) {
  4476. animationGroup.addTargetedAnimation(animation, morphTarget);
  4477. }
  4478. }
  4479. else {
  4480. var targetNode = scene.getNodeByID(id);
  4481. if (targetNode != null) {
  4482. animationGroup.addTargetedAnimation(animation, targetNode);
  4483. }
  4484. }
  4485. }
  4486. if (parsedAnimationGroup.from !== null && parsedAnimationGroup.from !== null) {
  4487. animationGroup.normalize(parsedAnimationGroup.from, parsedAnimationGroup.to);
  4488. }
  4489. return animationGroup;
  4490. };
  4491. /**
  4492. * Returns the string "AnimationGroup"
  4493. * @returns "AnimationGroup"
  4494. */
  4495. AnimationGroup.prototype.getClassName = function () {
  4496. return "AnimationGroup";
  4497. };
  4498. /**
  4499. * Creates a detailled string about the object
  4500. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4501. * @returns a string representing the object
  4502. */
  4503. AnimationGroup.prototype.toString = function (fullDetails) {
  4504. var ret = "Name: " + this.name;
  4505. ret += ", type: " + this.getClassName();
  4506. if (fullDetails) {
  4507. ret += ", from: " + this._from;
  4508. ret += ", to: " + this._to;
  4509. ret += ", isStarted: " + this._isStarted;
  4510. ret += ", speedRatio: " + this._speedRatio;
  4511. ret += ", targetedAnimations length: " + this._targetedAnimations.length;
  4512. ret += ", animatables length: " + this._animatables;
  4513. }
  4514. return ret;
  4515. };
  4516. return AnimationGroup;
  4517. }());
  4518. /***/ }),
  4519. /***/ "./Animations/animationKey.ts":
  4520. /*!************************************!*\
  4521. !*** ./Animations/animationKey.ts ***!
  4522. \************************************/
  4523. /*! exports provided: AnimationKeyInterpolation */
  4524. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4525. "use strict";
  4526. __webpack_require__.r(__webpack_exports__);
  4527. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return AnimationKeyInterpolation; });
  4528. /**
  4529. * Enum for the animation key frame interpolation type
  4530. */
  4531. var AnimationKeyInterpolation;
  4532. (function (AnimationKeyInterpolation) {
  4533. /**
  4534. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4535. */
  4536. AnimationKeyInterpolation[AnimationKeyInterpolation["STEP"] = 1] = "STEP";
  4537. })(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
  4538. /***/ }),
  4539. /***/ "./Animations/animationPropertiesOverride.ts":
  4540. /*!***************************************************!*\
  4541. !*** ./Animations/animationPropertiesOverride.ts ***!
  4542. \***************************************************/
  4543. /*! exports provided: AnimationPropertiesOverride */
  4544. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4545. "use strict";
  4546. __webpack_require__.r(__webpack_exports__);
  4547. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return AnimationPropertiesOverride; });
  4548. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  4549. /**
  4550. * Class used to override all child animations of a given target
  4551. */
  4552. var AnimationPropertiesOverride = /** @class */ (function () {
  4553. function AnimationPropertiesOverride() {
  4554. /**
  4555. * Gets or sets a value indicating if animation blending must be used
  4556. */
  4557. this.enableBlending = false;
  4558. /**
  4559. * Gets or sets the blending speed to use when enableBlending is true
  4560. */
  4561. this.blendingSpeed = 0.01;
  4562. /**
  4563. * Gets or sets the default loop mode to use
  4564. */
  4565. this.loopMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  4566. }
  4567. return AnimationPropertiesOverride;
  4568. }());
  4569. /***/ }),
  4570. /***/ "./Animations/animationRange.ts":
  4571. /*!**************************************!*\
  4572. !*** ./Animations/animationRange.ts ***!
  4573. \**************************************/
  4574. /*! exports provided: AnimationRange */
  4575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4576. "use strict";
  4577. __webpack_require__.r(__webpack_exports__);
  4578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return AnimationRange; });
  4579. /**
  4580. * Represents the range of an animation
  4581. */
  4582. var AnimationRange = /** @class */ (function () {
  4583. /**
  4584. * Initializes the range of an animation
  4585. * @param name The name of the animation range
  4586. * @param from The starting frame of the animation
  4587. * @param to The ending frame of the animation
  4588. */
  4589. function AnimationRange(
  4590. /**The name of the animation range**/
  4591. name,
  4592. /**The starting frame of the animation */
  4593. from,
  4594. /**The ending frame of the animation*/
  4595. to) {
  4596. this.name = name;
  4597. this.from = from;
  4598. this.to = to;
  4599. }
  4600. /**
  4601. * Makes a copy of the animation range
  4602. * @returns A copy of the animation range
  4603. */
  4604. AnimationRange.prototype.clone = function () {
  4605. return new AnimationRange(this.name, this.from, this.to);
  4606. };
  4607. return AnimationRange;
  4608. }());
  4609. /***/ }),
  4610. /***/ "./Animations/easing.ts":
  4611. /*!******************************!*\
  4612. !*** ./Animations/easing.ts ***!
  4613. \******************************/
  4614. /*! exports provided: EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase */
  4615. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4616. "use strict";
  4617. __webpack_require__.r(__webpack_exports__);
  4618. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return EasingFunction; });
  4619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return CircleEase; });
  4620. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return BackEase; });
  4621. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return BounceEase; });
  4622. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return CubicEase; });
  4623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return ElasticEase; });
  4624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return ExponentialEase; });
  4625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return PowerEase; });
  4626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return QuadraticEase; });
  4627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return QuarticEase; });
  4628. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return QuinticEase; });
  4629. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return SineEase; });
  4630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return BezierCurveEase; });
  4631. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  4632. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4633. /**
  4634. * Base class used for every default easing function.
  4635. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4636. */
  4637. var EasingFunction = /** @class */ (function () {
  4638. function EasingFunction() {
  4639. this._easingMode = EasingFunction.EASINGMODE_EASEIN;
  4640. }
  4641. /**
  4642. * Sets the easing mode of the current function.
  4643. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4644. */
  4645. EasingFunction.prototype.setEasingMode = function (easingMode) {
  4646. var n = Math.min(Math.max(easingMode, 0), 2);
  4647. this._easingMode = n;
  4648. };
  4649. /**
  4650. * Gets the current easing mode.
  4651. * @returns the easing mode
  4652. */
  4653. EasingFunction.prototype.getEasingMode = function () {
  4654. return this._easingMode;
  4655. };
  4656. /**
  4657. * @hidden
  4658. */
  4659. EasingFunction.prototype.easeInCore = function (gradient) {
  4660. throw new Error('You must implement this method');
  4661. };
  4662. /**
  4663. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4664. * of the easing function.
  4665. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4666. * @returns the corresponding value on the curve defined by the easing function
  4667. */
  4668. EasingFunction.prototype.ease = function (gradient) {
  4669. switch (this._easingMode) {
  4670. case EasingFunction.EASINGMODE_EASEIN:
  4671. return this.easeInCore(gradient);
  4672. case EasingFunction.EASINGMODE_EASEOUT:
  4673. return (1 - this.easeInCore(1 - gradient));
  4674. }
  4675. if (gradient >= 0.5) {
  4676. return (((1 - this.easeInCore((1 - gradient) * 2)) * 0.5) + 0.5);
  4677. }
  4678. return (this.easeInCore(gradient * 2) * 0.5);
  4679. };
  4680. /**
  4681. * Interpolation follows the mathematical formula associated with the easing function.
  4682. */
  4683. EasingFunction.EASINGMODE_EASEIN = 0;
  4684. /**
  4685. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4686. */
  4687. EasingFunction.EASINGMODE_EASEOUT = 1;
  4688. /**
  4689. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4690. */
  4691. EasingFunction.EASINGMODE_EASEINOUT = 2;
  4692. return EasingFunction;
  4693. }());
  4694. /**
  4695. * Easing function with a circle shape (see link below).
  4696. * @see https://easings.net/#easeInCirc
  4697. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4698. */
  4699. var CircleEase = /** @class */ (function (_super) {
  4700. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleEase, _super);
  4701. function CircleEase() {
  4702. return _super !== null && _super.apply(this, arguments) || this;
  4703. }
  4704. /** @hidden */
  4705. CircleEase.prototype.easeInCore = function (gradient) {
  4706. gradient = Math.max(0, Math.min(1, gradient));
  4707. return (1.0 - Math.sqrt(1.0 - (gradient * gradient)));
  4708. };
  4709. return CircleEase;
  4710. }(EasingFunction));
  4711. /**
  4712. * Easing function with a ease back shape (see link below).
  4713. * @see https://easings.net/#easeInBack
  4714. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4715. */
  4716. var BackEase = /** @class */ (function (_super) {
  4717. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackEase, _super);
  4718. /**
  4719. * Instantiates a back ease easing
  4720. * @see https://easings.net/#easeInBack
  4721. * @param amplitude Defines the amplitude of the function
  4722. */
  4723. function BackEase(
  4724. /** Defines the amplitude of the function */
  4725. amplitude) {
  4726. if (amplitude === void 0) { amplitude = 1; }
  4727. var _this = _super.call(this) || this;
  4728. _this.amplitude = amplitude;
  4729. return _this;
  4730. }
  4731. /** @hidden */
  4732. BackEase.prototype.easeInCore = function (gradient) {
  4733. var num = Math.max(0, this.amplitude);
  4734. return (Math.pow(gradient, 3.0) - ((gradient * num) * Math.sin(3.1415926535897931 * gradient)));
  4735. };
  4736. return BackEase;
  4737. }(EasingFunction));
  4738. /**
  4739. * Easing function with a bouncing shape (see link below).
  4740. * @see https://easings.net/#easeInBounce
  4741. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4742. */
  4743. var BounceEase = /** @class */ (function (_super) {
  4744. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BounceEase, _super);
  4745. /**
  4746. * Instantiates a bounce easing
  4747. * @see https://easings.net/#easeInBounce
  4748. * @param bounces Defines the number of bounces
  4749. * @param bounciness Defines the amplitude of the bounce
  4750. */
  4751. function BounceEase(
  4752. /** Defines the number of bounces */
  4753. bounces,
  4754. /** Defines the amplitude of the bounce */
  4755. bounciness) {
  4756. if (bounces === void 0) { bounces = 3; }
  4757. if (bounciness === void 0) { bounciness = 2; }
  4758. var _this = _super.call(this) || this;
  4759. _this.bounces = bounces;
  4760. _this.bounciness = bounciness;
  4761. return _this;
  4762. }
  4763. /** @hidden */
  4764. BounceEase.prototype.easeInCore = function (gradient) {
  4765. var y = Math.max(0.0, this.bounces);
  4766. var bounciness = this.bounciness;
  4767. if (bounciness <= 1.0) {
  4768. bounciness = 1.001;
  4769. }
  4770. var num9 = Math.pow(bounciness, y);
  4771. var num5 = 1.0 - bounciness;
  4772. var num4 = ((1.0 - num9) / num5) + (num9 * 0.5);
  4773. var num15 = gradient * num4;
  4774. var num65 = Math.log((-num15 * (1.0 - bounciness)) + 1.0) / Math.log(bounciness);
  4775. var num3 = Math.floor(num65);
  4776. var num13 = num3 + 1.0;
  4777. var num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);
  4778. var num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);
  4779. var num7 = (num8 + num12) * 0.5;
  4780. var num6 = gradient - num7;
  4781. var num2 = num7 - num8;
  4782. return (((-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2)) * (num6 + num2));
  4783. };
  4784. return BounceEase;
  4785. }(EasingFunction));
  4786. /**
  4787. * Easing function with a power of 3 shape (see link below).
  4788. * @see https://easings.net/#easeInCubic
  4789. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4790. */
  4791. var CubicEase = /** @class */ (function (_super) {
  4792. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubicEase, _super);
  4793. function CubicEase() {
  4794. return _super !== null && _super.apply(this, arguments) || this;
  4795. }
  4796. /** @hidden */
  4797. CubicEase.prototype.easeInCore = function (gradient) {
  4798. return (gradient * gradient * gradient);
  4799. };
  4800. return CubicEase;
  4801. }(EasingFunction));
  4802. /**
  4803. * Easing function with an elastic shape (see link below).
  4804. * @see https://easings.net/#easeInElastic
  4805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4806. */
  4807. var ElasticEase = /** @class */ (function (_super) {
  4808. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ElasticEase, _super);
  4809. /**
  4810. * Instantiates an elastic easing function
  4811. * @see https://easings.net/#easeInElastic
  4812. * @param oscillations Defines the number of oscillations
  4813. * @param springiness Defines the amplitude of the oscillations
  4814. */
  4815. function ElasticEase(
  4816. /** Defines the number of oscillations*/
  4817. oscillations,
  4818. /** Defines the amplitude of the oscillations*/
  4819. springiness) {
  4820. if (oscillations === void 0) { oscillations = 3; }
  4821. if (springiness === void 0) { springiness = 3; }
  4822. var _this = _super.call(this) || this;
  4823. _this.oscillations = oscillations;
  4824. _this.springiness = springiness;
  4825. return _this;
  4826. }
  4827. /** @hidden */
  4828. ElasticEase.prototype.easeInCore = function (gradient) {
  4829. var num2;
  4830. var num3 = Math.max(0.0, this.oscillations);
  4831. var num = Math.max(0.0, this.springiness);
  4832. if (num == 0) {
  4833. num2 = gradient;
  4834. }
  4835. else {
  4836. num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);
  4837. }
  4838. return (num2 * Math.sin(((6.2831853071795862 * num3) + 1.5707963267948966) * gradient));
  4839. };
  4840. return ElasticEase;
  4841. }(EasingFunction));
  4842. /**
  4843. * Easing function with an exponential shape (see link below).
  4844. * @see https://easings.net/#easeInExpo
  4845. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4846. */
  4847. var ExponentialEase = /** @class */ (function (_super) {
  4848. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExponentialEase, _super);
  4849. /**
  4850. * Instantiates an exponential easing function
  4851. * @see https://easings.net/#easeInExpo
  4852. * @param exponent Defines the exponent of the function
  4853. */
  4854. function ExponentialEase(
  4855. /** Defines the exponent of the function */
  4856. exponent) {
  4857. if (exponent === void 0) { exponent = 2; }
  4858. var _this = _super.call(this) || this;
  4859. _this.exponent = exponent;
  4860. return _this;
  4861. }
  4862. /** @hidden */
  4863. ExponentialEase.prototype.easeInCore = function (gradient) {
  4864. if (this.exponent <= 0) {
  4865. return gradient;
  4866. }
  4867. return ((Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0));
  4868. };
  4869. return ExponentialEase;
  4870. }(EasingFunction));
  4871. /**
  4872. * Easing function with a power shape (see link below).
  4873. * @see https://easings.net/#easeInQuad
  4874. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4875. */
  4876. var PowerEase = /** @class */ (function (_super) {
  4877. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PowerEase, _super);
  4878. /**
  4879. * Instantiates an power base easing function
  4880. * @see https://easings.net/#easeInQuad
  4881. * @param power Defines the power of the function
  4882. */
  4883. function PowerEase(
  4884. /** Defines the power of the function */
  4885. power) {
  4886. if (power === void 0) { power = 2; }
  4887. var _this = _super.call(this) || this;
  4888. _this.power = power;
  4889. return _this;
  4890. }
  4891. /** @hidden */
  4892. PowerEase.prototype.easeInCore = function (gradient) {
  4893. var y = Math.max(0.0, this.power);
  4894. return Math.pow(gradient, y);
  4895. };
  4896. return PowerEase;
  4897. }(EasingFunction));
  4898. /**
  4899. * Easing function with a power of 2 shape (see link below).
  4900. * @see https://easings.net/#easeInQuad
  4901. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4902. */
  4903. var QuadraticEase = /** @class */ (function (_super) {
  4904. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuadraticEase, _super);
  4905. function QuadraticEase() {
  4906. return _super !== null && _super.apply(this, arguments) || this;
  4907. }
  4908. /** @hidden */
  4909. QuadraticEase.prototype.easeInCore = function (gradient) {
  4910. return (gradient * gradient);
  4911. };
  4912. return QuadraticEase;
  4913. }(EasingFunction));
  4914. /**
  4915. * Easing function with a power of 4 shape (see link below).
  4916. * @see https://easings.net/#easeInQuart
  4917. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4918. */
  4919. var QuarticEase = /** @class */ (function (_super) {
  4920. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuarticEase, _super);
  4921. function QuarticEase() {
  4922. return _super !== null && _super.apply(this, arguments) || this;
  4923. }
  4924. /** @hidden */
  4925. QuarticEase.prototype.easeInCore = function (gradient) {
  4926. return (gradient * gradient * gradient * gradient);
  4927. };
  4928. return QuarticEase;
  4929. }(EasingFunction));
  4930. /**
  4931. * Easing function with a power of 5 shape (see link below).
  4932. * @see https://easings.net/#easeInQuint
  4933. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4934. */
  4935. var QuinticEase = /** @class */ (function (_super) {
  4936. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuinticEase, _super);
  4937. function QuinticEase() {
  4938. return _super !== null && _super.apply(this, arguments) || this;
  4939. }
  4940. /** @hidden */
  4941. QuinticEase.prototype.easeInCore = function (gradient) {
  4942. return (gradient * gradient * gradient * gradient * gradient);
  4943. };
  4944. return QuinticEase;
  4945. }(EasingFunction));
  4946. /**
  4947. * Easing function with a sin shape (see link below).
  4948. * @see https://easings.net/#easeInSine
  4949. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4950. */
  4951. var SineEase = /** @class */ (function (_super) {
  4952. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SineEase, _super);
  4953. function SineEase() {
  4954. return _super !== null && _super.apply(this, arguments) || this;
  4955. }
  4956. /** @hidden */
  4957. SineEase.prototype.easeInCore = function (gradient) {
  4958. return (1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient)));
  4959. };
  4960. return SineEase;
  4961. }(EasingFunction));
  4962. /**
  4963. * Easing function with a bezier shape (see link below).
  4964. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4965. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4966. */
  4967. var BezierCurveEase = /** @class */ (function (_super) {
  4968. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BezierCurveEase, _super);
  4969. /**
  4970. * Instantiates a bezier function
  4971. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4972. * @param x1 Defines the x component of the start tangent in the bezier curve
  4973. * @param y1 Defines the y component of the start tangent in the bezier curve
  4974. * @param x2 Defines the x component of the end tangent in the bezier curve
  4975. * @param y2 Defines the y component of the end tangent in the bezier curve
  4976. */
  4977. function BezierCurveEase(
  4978. /** Defines the x component of the start tangent in the bezier curve */
  4979. x1,
  4980. /** Defines the y component of the start tangent in the bezier curve */
  4981. y1,
  4982. /** Defines the x component of the end tangent in the bezier curve */
  4983. x2,
  4984. /** Defines the y component of the end tangent in the bezier curve */
  4985. y2) {
  4986. if (x1 === void 0) { x1 = 0; }
  4987. if (y1 === void 0) { y1 = 0; }
  4988. if (x2 === void 0) { x2 = 1; }
  4989. if (y2 === void 0) { y2 = 1; }
  4990. var _this = _super.call(this) || this;
  4991. _this.x1 = x1;
  4992. _this.y1 = y1;
  4993. _this.x2 = x2;
  4994. _this.y2 = y2;
  4995. return _this;
  4996. }
  4997. /** @hidden */
  4998. BezierCurveEase.prototype.easeInCore = function (gradient) {
  4999. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"].Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);
  5000. };
  5001. return BezierCurveEase;
  5002. }(EasingFunction));
  5003. /***/ }),
  5004. /***/ "./Animations/index.ts":
  5005. /*!*****************************!*\
  5006. !*** ./Animations/index.ts ***!
  5007. \*****************************/
  5008. /*! exports provided: Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange */
  5009. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5010. "use strict";
  5011. __webpack_require__.r(__webpack_exports__);
  5012. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  5013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _animatable__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  5014. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]; });
  5016. /* harmony import */ var _animationGroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./animationGroup */ "./Animations/animationGroup.ts");
  5017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  5018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  5019. /* harmony import */ var _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animationPropertiesOverride */ "./Animations/animationPropertiesOverride.ts");
  5020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__["AnimationPropertiesOverride"]; });
  5021. /* harmony import */ var _easing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./easing */ "./Animations/easing.ts");
  5022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["EasingFunction"]; });
  5023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CircleEase"]; });
  5024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BackEase"]; });
  5025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BounceEase"]; });
  5026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CubicEase"]; });
  5027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ElasticEase"]; });
  5028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ExponentialEase"]; });
  5029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["PowerEase"]; });
  5030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuadraticEase"]; });
  5031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuarticEase"]; });
  5032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuinticEase"]; });
  5033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["SineEase"]; });
  5034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BezierCurveEase"]; });
  5035. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  5036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__["RuntimeAnimation"]; });
  5037. /* harmony import */ var _animationEvent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./animationEvent */ "./Animations/animationEvent.ts");
  5038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _animationEvent__WEBPACK_IMPORTED_MODULE_6__["AnimationEvent"]; });
  5039. /* empty/unused harmony star reexport *//* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  5040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _animationKey__WEBPACK_IMPORTED_MODULE_7__["AnimationKeyInterpolation"]; });
  5041. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  5042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _animationRange__WEBPACK_IMPORTED_MODULE_8__["AnimationRange"]; });
  5043. /***/ }),
  5044. /***/ "./Animations/runtimeAnimation.ts":
  5045. /*!****************************************!*\
  5046. !*** ./Animations/runtimeAnimation.ts ***!
  5047. \****************************************/
  5048. /*! exports provided: RuntimeAnimation */
  5049. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5050. "use strict";
  5051. __webpack_require__.r(__webpack_exports__);
  5052. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return RuntimeAnimation; });
  5053. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  5054. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5055. // Static values to help the garbage collector
  5056. // Quaternion
  5057. var _staticOffsetValueQuaternion = Object.freeze(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 0));
  5058. // Vector3
  5059. var _staticOffsetValueVector3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero());
  5060. // Vector2
  5061. var _staticOffsetValueVector2 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero());
  5062. // Size
  5063. var _staticOffsetValueSize = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Zero());
  5064. // Color3
  5065. var _staticOffsetValueColor3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black());
  5066. /**
  5067. * Defines a runtime animation
  5068. */
  5069. var RuntimeAnimation = /** @class */ (function () {
  5070. /**
  5071. * Create a new RuntimeAnimation object
  5072. * @param target defines the target of the animation
  5073. * @param animation defines the source animation object
  5074. * @param scene defines the hosting scene
  5075. * @param host defines the initiating Animatable
  5076. */
  5077. function RuntimeAnimation(target, animation, scene, host) {
  5078. var _this = this;
  5079. this._events = new Array();
  5080. /**
  5081. * The current frame of the runtime animation
  5082. */
  5083. this._currentFrame = 0;
  5084. /**
  5085. * The original value of the runtime animation
  5086. */
  5087. this._originalValue = new Array();
  5088. /**
  5089. * The offsets cache of the runtime animation
  5090. */
  5091. this._offsetsCache = {};
  5092. /**
  5093. * The high limits cache of the runtime animation
  5094. */
  5095. this._highLimitsCache = {};
  5096. /**
  5097. * Specifies if the runtime animation has been stopped
  5098. */
  5099. this._stopped = false;
  5100. /**
  5101. * The blending factor of the runtime animation
  5102. */
  5103. this._blendingFactor = 0;
  5104. /**
  5105. * The target path of the runtime animation
  5106. */
  5107. this._targetPath = "";
  5108. /**
  5109. * The weight of the runtime animation
  5110. */
  5111. this._weight = 1.0;
  5112. /**
  5113. * The ratio offset of the runtime animation
  5114. */
  5115. this._ratioOffset = 0;
  5116. /**
  5117. * The previous delay of the runtime animation
  5118. */
  5119. this._previousDelay = 0;
  5120. /**
  5121. * The previous ratio of the runtime animation
  5122. */
  5123. this._previousRatio = 0;
  5124. this._animation = animation;
  5125. this._target = target;
  5126. this._scene = scene;
  5127. this._host = host;
  5128. animation._runtimeAnimations.push(this);
  5129. // Cloning events locally
  5130. var events = animation.getEvents();
  5131. if (events && events.length > 0) {
  5132. events.forEach(function (e) {
  5133. _this._events.push(e._clone());
  5134. });
  5135. }
  5136. }
  5137. Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
  5138. /**
  5139. * Gets the current frame of the runtime animation
  5140. */
  5141. get: function () {
  5142. return this._currentFrame;
  5143. },
  5144. enumerable: true,
  5145. configurable: true
  5146. });
  5147. Object.defineProperty(RuntimeAnimation.prototype, "weight", {
  5148. /**
  5149. * Gets the weight of the runtime animation
  5150. */
  5151. get: function () {
  5152. return this._weight;
  5153. },
  5154. enumerable: true,
  5155. configurable: true
  5156. });
  5157. Object.defineProperty(RuntimeAnimation.prototype, "currentValue", {
  5158. /**
  5159. * Gets the current value of the runtime animation
  5160. */
  5161. get: function () {
  5162. return this._currentValue;
  5163. },
  5164. enumerable: true,
  5165. configurable: true
  5166. });
  5167. Object.defineProperty(RuntimeAnimation.prototype, "targetPath", {
  5168. /**
  5169. * Gets the target path of the runtime animation
  5170. */
  5171. get: function () {
  5172. return this._targetPath;
  5173. },
  5174. enumerable: true,
  5175. configurable: true
  5176. });
  5177. Object.defineProperty(RuntimeAnimation.prototype, "target", {
  5178. /**
  5179. * Gets the actual target of the runtime animation
  5180. */
  5181. get: function () {
  5182. return this._activeTarget;
  5183. },
  5184. enumerable: true,
  5185. configurable: true
  5186. });
  5187. Object.defineProperty(RuntimeAnimation.prototype, "animation", {
  5188. /**
  5189. * Gets the animation from the runtime animation
  5190. */
  5191. get: function () {
  5192. return this._animation;
  5193. },
  5194. enumerable: true,
  5195. configurable: true
  5196. });
  5197. /**
  5198. * Resets the runtime animation to the beginning
  5199. * @param restoreOriginal defines whether to restore the target property to the original value
  5200. */
  5201. RuntimeAnimation.prototype.reset = function (restoreOriginal) {
  5202. if (restoreOriginal === void 0) { restoreOriginal = false; }
  5203. if (restoreOriginal) {
  5204. if (this._target instanceof Array) {
  5205. var index = 0;
  5206. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5207. var target = _a[_i];
  5208. if (this._originalValue[index] !== undefined) {
  5209. this._setValue(target, this._originalValue[index], -1);
  5210. }
  5211. index++;
  5212. }
  5213. }
  5214. else {
  5215. if (this._originalValue[0] !== undefined) {
  5216. this._setValue(this._target, this._originalValue[0], -1);
  5217. }
  5218. }
  5219. }
  5220. this._offsetsCache = {};
  5221. this._highLimitsCache = {};
  5222. this._currentFrame = 0;
  5223. this._blendingFactor = 0;
  5224. this._originalValue = new Array();
  5225. // Events
  5226. for (var index = 0; index < this._events.length; index++) {
  5227. this._events[index].isDone = false;
  5228. }
  5229. };
  5230. /**
  5231. * Specifies if the runtime animation is stopped
  5232. * @returns Boolean specifying if the runtime animation is stopped
  5233. */
  5234. RuntimeAnimation.prototype.isStopped = function () {
  5235. return this._stopped;
  5236. };
  5237. /**
  5238. * Disposes of the runtime animation
  5239. */
  5240. RuntimeAnimation.prototype.dispose = function () {
  5241. var index = this._animation.runtimeAnimations.indexOf(this);
  5242. if (index > -1) {
  5243. this._animation.runtimeAnimations.splice(index, 1);
  5244. }
  5245. };
  5246. /**
  5247. * Interpolates the animation from the current frame
  5248. * @param currentFrame The frame to interpolate the animation to
  5249. * @param repeatCount The number of times that the animation should loop
  5250. * @param loopMode The type of looping mode to use
  5251. * @param offsetValue Animation offset value
  5252. * @param highLimitValue The high limit value
  5253. * @returns The interpolated value
  5254. */
  5255. RuntimeAnimation.prototype._interpolate = function (currentFrame, repeatCount, loopMode, offsetValue, highLimitValue) {
  5256. this._currentFrame = currentFrame;
  5257. if (this._animation.dataType === _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_MATRIX && !this._workValue) {
  5258. this._workValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Zero();
  5259. }
  5260. return this._animation._interpolate(currentFrame, repeatCount, this._workValue, loopMode, offsetValue, highLimitValue);
  5261. };
  5262. /**
  5263. * Apply the interpolated value to the target
  5264. * @param currentValue defines the value computed by the animation
  5265. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5266. */
  5267. RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
  5268. if (weight === void 0) { weight = 1.0; }
  5269. if (this._target instanceof Array) {
  5270. var index = 0;
  5271. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5272. var target = _a[_i];
  5273. this._setValue(target, currentValue, weight, index);
  5274. index++;
  5275. }
  5276. }
  5277. else {
  5278. this._setValue(this._target, currentValue, weight);
  5279. }
  5280. };
  5281. RuntimeAnimation.prototype._setValue = function (target, currentValue, weight, targetIndex) {
  5282. if (targetIndex === void 0) { targetIndex = 0; }
  5283. // Set value
  5284. var path;
  5285. var destination;
  5286. var targetPropertyPath = this._animation.targetPropertyPath;
  5287. if (targetPropertyPath.length > 1) {
  5288. var property = target[targetPropertyPath[0]];
  5289. for (var index = 1; index < targetPropertyPath.length - 1; index++) {
  5290. property = property[targetPropertyPath[index]];
  5291. }
  5292. path = targetPropertyPath[targetPropertyPath.length - 1];
  5293. destination = property;
  5294. }
  5295. else {
  5296. path = targetPropertyPath[0];
  5297. destination = target;
  5298. }
  5299. this._targetPath = path;
  5300. this._activeTarget = destination;
  5301. this._weight = weight;
  5302. if (this._originalValue[targetIndex] === undefined) {
  5303. var originalValue = void 0;
  5304. if (destination.getRestPose && path === "_matrix") { // For bones
  5305. originalValue = destination.getRestPose();
  5306. }
  5307. else {
  5308. originalValue = destination[path];
  5309. }
  5310. if (originalValue && originalValue.clone) {
  5311. this._originalValue[targetIndex] = originalValue.clone();
  5312. }
  5313. else {
  5314. this._originalValue[targetIndex] = originalValue;
  5315. }
  5316. }
  5317. // Blending
  5318. var enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
  5319. if (enableBlending && this._blendingFactor <= 1.0) {
  5320. if (!this._originalBlendValue) {
  5321. var originalValue = destination[path];
  5322. if (originalValue.clone) {
  5323. this._originalBlendValue = originalValue.clone();
  5324. }
  5325. else {
  5326. this._originalBlendValue = originalValue;
  5327. }
  5328. }
  5329. if (this._originalBlendValue.m) { // Matrix
  5330. if (_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].AllowMatrixDecomposeForInterpolation) {
  5331. if (this._currentValue) {
  5332. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5333. }
  5334. else {
  5335. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5336. }
  5337. }
  5338. else {
  5339. if (this._currentValue) {
  5340. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5341. }
  5342. else {
  5343. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5344. }
  5345. }
  5346. }
  5347. else {
  5348. this._currentValue = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5349. }
  5350. var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  5351. this._blendingFactor += blendingSpeed;
  5352. }
  5353. else {
  5354. this._currentValue = currentValue;
  5355. }
  5356. if (weight !== -1.0) {
  5357. this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);
  5358. }
  5359. else {
  5360. destination[path] = this._currentValue;
  5361. }
  5362. if (target.markAsDirty) {
  5363. target.markAsDirty(this._animation.targetProperty);
  5364. }
  5365. };
  5366. /**
  5367. * Gets the loop pmode of the runtime animation
  5368. * @returns Loop Mode
  5369. */
  5370. RuntimeAnimation.prototype._getCorrectLoopMode = function () {
  5371. if (this._target && this._target.animationPropertiesOverride) {
  5372. return this._target.animationPropertiesOverride.loopMode;
  5373. }
  5374. return this._animation.loopMode;
  5375. };
  5376. /**
  5377. * Move the current animation to a given frame
  5378. * @param frame defines the frame to move to
  5379. */
  5380. RuntimeAnimation.prototype.goToFrame = function (frame) {
  5381. var keys = this._animation.getKeys();
  5382. if (frame < keys[0].frame) {
  5383. frame = keys[0].frame;
  5384. }
  5385. else if (frame > keys[keys.length - 1].frame) {
  5386. frame = keys[keys.length - 1].frame;
  5387. }
  5388. var currentValue = this._interpolate(frame, 0, this._getCorrectLoopMode());
  5389. this.setValue(currentValue, -1);
  5390. };
  5391. /**
  5392. * @hidden Internal use only
  5393. */
  5394. RuntimeAnimation.prototype._prepareForSpeedRatioChange = function (newSpeedRatio) {
  5395. var newRatio = this._previousDelay * (this._animation.framePerSecond * newSpeedRatio) / 1000.0;
  5396. this._ratioOffset = this._previousRatio - newRatio;
  5397. };
  5398. /**
  5399. * Execute the current animation
  5400. * @param delay defines the delay to add to the current frame
  5401. * @param from defines the lower bound of the animation range
  5402. * @param to defines the upper bound of the animation range
  5403. * @param loop defines if the current animation must loop
  5404. * @param speedRatio defines the current speed ratio
  5405. * @param weight defines the weight of the animation (default is -1 so no weight)
  5406. * @param onLoop optional callback called when animation loops
  5407. * @returns a boolean indicating if the animation is running
  5408. */
  5409. RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight, onLoop) {
  5410. if (weight === void 0) { weight = -1.0; }
  5411. var targetPropertyPath = this._animation.targetPropertyPath;
  5412. if (!targetPropertyPath || targetPropertyPath.length < 1) {
  5413. this._stopped = true;
  5414. return false;
  5415. }
  5416. var returnValue = true;
  5417. var keys = this._animation.getKeys();
  5418. var min = keys[0].frame;
  5419. var max = keys[keys.length - 1].frame;
  5420. // Add a start key at frame 0 if missing
  5421. if (min !== 0) {
  5422. var newKey = { frame: 0, value: keys[0].value };
  5423. keys.splice(0, 0, newKey);
  5424. }
  5425. // Check limits
  5426. if (from < min || from > max) {
  5427. from = min;
  5428. }
  5429. if (to < min || to > max) {
  5430. to = max;
  5431. }
  5432. var range = to - from;
  5433. var offsetValue;
  5434. // Compute ratio which represents the frame delta between from and to
  5435. var ratio = (delay * (this._animation.framePerSecond * speedRatio) / 1000.0) + this._ratioOffset;
  5436. var highLimitValue = 0;
  5437. this._previousDelay = delay;
  5438. this._previousRatio = ratio;
  5439. if (((to > from && ratio >= range) || (from > to && ratio <= range)) && !loop) { // If we are out of range and not looping get back to caller
  5440. returnValue = false;
  5441. highLimitValue = this._animation._getKeyValue(keys[keys.length - 1].value);
  5442. }
  5443. else {
  5444. // Get max value if required
  5445. if (this._getCorrectLoopMode() !== _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE) {
  5446. var keyOffset = to.toString() + from.toString();
  5447. if (!this._offsetsCache[keyOffset]) {
  5448. var fromValue = this._interpolate(from, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5449. var toValue = this._interpolate(to, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5450. switch (this._animation.dataType) {
  5451. // Float
  5452. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5453. this._offsetsCache[keyOffset] = toValue - fromValue;
  5454. break;
  5455. // Quaternion
  5456. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5457. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5458. break;
  5459. // Vector3
  5460. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5461. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5462. // Vector2
  5463. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5464. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5465. // Size
  5466. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5467. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5468. // Color3
  5469. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5470. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5471. default:
  5472. break;
  5473. }
  5474. this._highLimitsCache[keyOffset] = toValue;
  5475. }
  5476. highLimitValue = this._highLimitsCache[keyOffset];
  5477. offsetValue = this._offsetsCache[keyOffset];
  5478. }
  5479. }
  5480. if (offsetValue === undefined) {
  5481. switch (this._animation.dataType) {
  5482. // Float
  5483. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5484. offsetValue = 0;
  5485. break;
  5486. // Quaternion
  5487. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5488. offsetValue = _staticOffsetValueQuaternion;
  5489. break;
  5490. // Vector3
  5491. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5492. offsetValue = _staticOffsetValueVector3;
  5493. break;
  5494. // Vector2
  5495. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5496. offsetValue = _staticOffsetValueVector2;
  5497. break;
  5498. // Size
  5499. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5500. offsetValue = _staticOffsetValueSize;
  5501. break;
  5502. // Color3
  5503. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5504. offsetValue = _staticOffsetValueColor3;
  5505. }
  5506. }
  5507. // Compute value
  5508. var currentFrame = (returnValue && range !== 0) ? from + ratio % range : to;
  5509. // Need to normalize?
  5510. if (this._host && this._host.syncRoot) {
  5511. var syncRoot = this._host.syncRoot;
  5512. var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
  5513. currentFrame = from + (to - from) * hostNormalizedFrame;
  5514. }
  5515. // Reset events if looping
  5516. var events = this._events;
  5517. if (range > 0 && this.currentFrame > currentFrame ||
  5518. range < 0 && this.currentFrame < currentFrame) {
  5519. if (onLoop) {
  5520. onLoop();
  5521. }
  5522. // Need to reset animation events
  5523. for (var index = 0; index < events.length; index++) {
  5524. if (!events[index].onlyOnce) {
  5525. // reset event, the animation is looping
  5526. events[index].isDone = false;
  5527. }
  5528. }
  5529. }
  5530. var repeatCount = range === 0 ? 0 : (ratio / range) >> 0;
  5531. var currentValue = this._interpolate(currentFrame, repeatCount, this._getCorrectLoopMode(), offsetValue, highLimitValue);
  5532. // Set value
  5533. this.setValue(currentValue, weight);
  5534. // Check events
  5535. for (var index = 0; index < events.length; index++) {
  5536. // Make sure current frame has passed event frame and that event frame is within the current range
  5537. // Also, handle both forward and reverse animations
  5538. if ((range > 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||
  5539. (range < 0 && currentFrame <= events[index].frame && events[index].frame <= from)) {
  5540. var event = events[index];
  5541. if (!event.isDone) {
  5542. // If event should be done only once, remove it.
  5543. if (event.onlyOnce) {
  5544. events.splice(index, 1);
  5545. index--;
  5546. }
  5547. event.isDone = true;
  5548. event.action(currentFrame);
  5549. } // Don't do anything if the event has already be done.
  5550. }
  5551. }
  5552. if (!returnValue) {
  5553. this._stopped = true;
  5554. }
  5555. return returnValue;
  5556. };
  5557. return RuntimeAnimation;
  5558. }());
  5559. /***/ }),
  5560. /***/ "./Audio/analyser.ts":
  5561. /*!***************************!*\
  5562. !*** ./Audio/analyser.ts ***!
  5563. \***************************/
  5564. /*! exports provided: Analyser */
  5565. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5566. "use strict";
  5567. __webpack_require__.r(__webpack_exports__);
  5568. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return Analyser; });
  5569. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5570. /**
  5571. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5572. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5573. */
  5574. var Analyser = /** @class */ (function () {
  5575. /**
  5576. * Creates a new analyser
  5577. * @param scene defines hosting scene
  5578. */
  5579. function Analyser(scene) {
  5580. /**
  5581. * Gets or sets the smoothing
  5582. * @ignorenaming
  5583. */
  5584. this.SMOOTHING = 0.75;
  5585. /**
  5586. * Gets or sets the FFT table size
  5587. * @ignorenaming
  5588. */
  5589. this.FFT_SIZE = 512;
  5590. /**
  5591. * Gets or sets the bar graph amplitude
  5592. * @ignorenaming
  5593. */
  5594. this.BARGRAPHAMPLITUDE = 256;
  5595. /**
  5596. * Gets or sets the position of the debug canvas
  5597. * @ignorenaming
  5598. */
  5599. this.DEBUGCANVASPOS = { x: 20, y: 20 };
  5600. /**
  5601. * Gets or sets the debug canvas size
  5602. * @ignorenaming
  5603. */
  5604. this.DEBUGCANVASSIZE = { width: 320, height: 200 };
  5605. this._scene = scene;
  5606. this._audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine;
  5607. if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {
  5608. this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();
  5609. this._webAudioAnalyser.minDecibels = -140;
  5610. this._webAudioAnalyser.maxDecibels = 0;
  5611. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5612. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5613. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);
  5614. }
  5615. }
  5616. /**
  5617. * Get the number of data values you will have to play with for the visualization
  5618. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5619. * @returns a number
  5620. */
  5621. Analyser.prototype.getFrequencyBinCount = function () {
  5622. if (this._audioEngine.canUseWebAudio) {
  5623. return this._webAudioAnalyser.frequencyBinCount;
  5624. }
  5625. else {
  5626. return 0;
  5627. }
  5628. };
  5629. /**
  5630. * Gets the current frequency data as a byte array
  5631. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5632. * @returns a Uint8Array
  5633. */
  5634. Analyser.prototype.getByteFrequencyData = function () {
  5635. if (this._audioEngine.canUseWebAudio) {
  5636. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5637. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5638. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
  5639. }
  5640. return this._byteFreqs;
  5641. };
  5642. /**
  5643. * Gets the current waveform as a byte array
  5644. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5645. * @returns a Uint8Array
  5646. */
  5647. Analyser.prototype.getByteTimeDomainData = function () {
  5648. if (this._audioEngine.canUseWebAudio) {
  5649. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5650. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5651. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
  5652. }
  5653. return this._byteTime;
  5654. };
  5655. /**
  5656. * Gets the current frequency data as a float array
  5657. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5658. * @returns a Float32Array
  5659. */
  5660. Analyser.prototype.getFloatFrequencyData = function () {
  5661. if (this._audioEngine.canUseWebAudio) {
  5662. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5663. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5664. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
  5665. }
  5666. return this._floatFreqs;
  5667. };
  5668. /**
  5669. * Renders the debug canvas
  5670. */
  5671. Analyser.prototype.drawDebugCanvas = function () {
  5672. var _this = this;
  5673. if (this._audioEngine.canUseWebAudio) {
  5674. if (!this._debugCanvas) {
  5675. this._debugCanvas = document.createElement("canvas");
  5676. this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
  5677. this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
  5678. this._debugCanvas.style.position = "absolute";
  5679. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
  5680. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
  5681. this._debugCanvasContext = this._debugCanvas.getContext("2d");
  5682. document.body.appendChild(this._debugCanvas);
  5683. this._registerFunc = function () {
  5684. _this.drawDebugCanvas();
  5685. };
  5686. this._scene.registerBeforeRender(this._registerFunc);
  5687. }
  5688. if (this._registerFunc && this._debugCanvasContext) {
  5689. var workingArray = this.getByteFrequencyData();
  5690. this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
  5691. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  5692. // Draw the frequency domain chart.
  5693. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  5694. var value = workingArray[i];
  5695. var percent = value / this.BARGRAPHAMPLITUDE;
  5696. var height = this.DEBUGCANVASSIZE.height * percent;
  5697. var offset = this.DEBUGCANVASSIZE.height - height - 1;
  5698. var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
  5699. var hue = i / this.getFrequencyBinCount() * 360;
  5700. this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
  5701. this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);
  5702. }
  5703. }
  5704. }
  5705. };
  5706. /**
  5707. * Stops rendering the debug canvas and removes it
  5708. */
  5709. Analyser.prototype.stopDebugCanvas = function () {
  5710. if (this._debugCanvas) {
  5711. if (this._registerFunc) {
  5712. this._scene.unregisterBeforeRender(this._registerFunc);
  5713. this._registerFunc = null;
  5714. }
  5715. document.body.removeChild(this._debugCanvas);
  5716. this._debugCanvas = null;
  5717. this._debugCanvasContext = null;
  5718. }
  5719. };
  5720. /**
  5721. * Connects two audio nodes
  5722. * @param inputAudioNode defines first node to connect
  5723. * @param outputAudioNode defines second node to connect
  5724. */
  5725. Analyser.prototype.connectAudioNodes = function (inputAudioNode, outputAudioNode) {
  5726. if (this._audioEngine.canUseWebAudio) {
  5727. inputAudioNode.connect(this._webAudioAnalyser);
  5728. this._webAudioAnalyser.connect(outputAudioNode);
  5729. }
  5730. };
  5731. /**
  5732. * Releases all associated resources
  5733. */
  5734. Analyser.prototype.dispose = function () {
  5735. if (this._audioEngine.canUseWebAudio) {
  5736. this._webAudioAnalyser.disconnect();
  5737. }
  5738. };
  5739. return Analyser;
  5740. }());
  5741. /***/ }),
  5742. /***/ "./Audio/audioEngine.ts":
  5743. /*!******************************!*\
  5744. !*** ./Audio/audioEngine.ts ***!
  5745. \******************************/
  5746. /*! exports provided: AudioEngine */
  5747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5748. "use strict";
  5749. __webpack_require__.r(__webpack_exports__);
  5750. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return AudioEngine; });
  5751. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  5752. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  5753. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5754. // Sets the default audio engine to Babylon.js
  5755. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
  5756. /**
  5757. * This represents the default audio engine used in babylon.
  5758. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5760. */
  5761. var AudioEngine = /** @class */ (function () {
  5762. /**
  5763. * Instantiates a new audio engine.
  5764. *
  5765. * There should be only one per page as some browsers restrict the number
  5766. * of audio contexts you can create.
  5767. * @param hostElement defines the host element where to display the mute icon if necessary
  5768. */
  5769. function AudioEngine(hostElement) {
  5770. if (hostElement === void 0) { hostElement = null; }
  5771. var _this = this;
  5772. this._audioContext = null;
  5773. this._audioContextInitialized = false;
  5774. this._muteButton = null;
  5775. /**
  5776. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5777. */
  5778. this.canUseWebAudio = false;
  5779. /**
  5780. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5781. * @ignoreNaming
  5782. */
  5783. this.WarnedWebAudioUnsupported = false;
  5784. /**
  5785. * Gets whether or not mp3 are supported by your browser.
  5786. */
  5787. this.isMP3supported = false;
  5788. /**
  5789. * Gets whether or not ogg are supported by your browser.
  5790. */
  5791. this.isOGGsupported = false;
  5792. /**
  5793. * Gets whether audio has been unlocked on the device.
  5794. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5795. * a user interaction has happened.
  5796. */
  5797. this.unlocked = true;
  5798. /**
  5799. * Defines if the audio engine relies on a custom unlocked button.
  5800. * In this case, the embedded button will not be displayed.
  5801. */
  5802. this.useCustomUnlockedButton = false;
  5803. /**
  5804. * Event raised when audio has been unlocked on the browser.
  5805. */
  5806. this.onAudioUnlockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5807. /**
  5808. * Event raised when audio has been locked on the browser.
  5809. */
  5810. this.onAudioLockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5811. this._tryToRun = false;
  5812. this._onResize = function () {
  5813. _this._moveButtonToTopLeft();
  5814. };
  5815. if (typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined') {
  5816. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  5817. this.canUseWebAudio = true;
  5818. }
  5819. var audioElem = document.createElement('audio');
  5820. this._hostElement = hostElement;
  5821. try {
  5822. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
  5823. this.isMP3supported = true;
  5824. }
  5825. }
  5826. catch (e) {
  5827. // protect error during capability check.
  5828. }
  5829. try {
  5830. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
  5831. this.isOGGsupported = true;
  5832. }
  5833. }
  5834. catch (e) {
  5835. // protect error during capability check.
  5836. }
  5837. }
  5838. Object.defineProperty(AudioEngine.prototype, "audioContext", {
  5839. /**
  5840. * Gets the current AudioContext if available.
  5841. */
  5842. get: function () {
  5843. if (!this._audioContextInitialized) {
  5844. this._initializeAudioContext();
  5845. }
  5846. else {
  5847. if (!this.unlocked && !this._muteButton) {
  5848. this._displayMuteButton();
  5849. }
  5850. }
  5851. return this._audioContext;
  5852. },
  5853. enumerable: true,
  5854. configurable: true
  5855. });
  5856. /**
  5857. * Flags the audio engine in Locked state.
  5858. * This happens due to new browser policies preventing audio to autoplay.
  5859. */
  5860. AudioEngine.prototype.lock = function () {
  5861. this._triggerSuspendedState();
  5862. };
  5863. /**
  5864. * Unlocks the audio engine once a user action has been done on the dom.
  5865. * This is helpful to resume play once browser policies have been satisfied.
  5866. */
  5867. AudioEngine.prototype.unlock = function () {
  5868. this._triggerRunningState();
  5869. };
  5870. AudioEngine.prototype._resumeAudioContext = function () {
  5871. var result;
  5872. if (this._audioContext.resume) {
  5873. result = this._audioContext.resume();
  5874. }
  5875. return result || Promise.resolve();
  5876. };
  5877. AudioEngine.prototype._initializeAudioContext = function () {
  5878. try {
  5879. if (this.canUseWebAudio) {
  5880. this._audioContext = new AudioContext();
  5881. // create a global volume gain node
  5882. this.masterGain = this._audioContext.createGain();
  5883. this.masterGain.gain.value = 1;
  5884. this.masterGain.connect(this._audioContext.destination);
  5885. this._audioContextInitialized = true;
  5886. if (this._audioContext.state === "running") {
  5887. // Do not wait for the promise to unlock.
  5888. this._triggerRunningState();
  5889. }
  5890. }
  5891. }
  5892. catch (e) {
  5893. this.canUseWebAudio = false;
  5894. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Web Audio: " + e.message);
  5895. }
  5896. };
  5897. AudioEngine.prototype._triggerRunningState = function () {
  5898. var _this = this;
  5899. if (this._tryToRun) {
  5900. return;
  5901. }
  5902. this._tryToRun = true;
  5903. this._resumeAudioContext()
  5904. .then(function () {
  5905. _this._tryToRun = false;
  5906. if (_this._muteButton) {
  5907. _this._hideMuteButton();
  5908. }
  5909. }).catch(function () {
  5910. _this._tryToRun = false;
  5911. _this.unlocked = false;
  5912. });
  5913. // Notify users that the audio stack is unlocked/unmuted
  5914. this.unlocked = true;
  5915. this.onAudioUnlockedObservable.notifyObservers(this);
  5916. };
  5917. AudioEngine.prototype._triggerSuspendedState = function () {
  5918. this.unlocked = false;
  5919. this.onAudioLockedObservable.notifyObservers(this);
  5920. this._displayMuteButton();
  5921. };
  5922. AudioEngine.prototype._displayMuteButton = function () {
  5923. var _this = this;
  5924. if (this.useCustomUnlockedButton || this._muteButton) {
  5925. return;
  5926. }
  5927. this._muteButton = document.createElement("BUTTON");
  5928. this._muteButton.className = "babylonUnmuteIcon";
  5929. this._muteButton.id = "babylonUnmuteIconBtn";
  5930. this._muteButton.title = "Unmute";
  5931. 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) }";
  5932. var style = document.createElement('style');
  5933. style.appendChild(document.createTextNode(css));
  5934. document.getElementsByTagName('head')[0].appendChild(style);
  5935. document.body.appendChild(this._muteButton);
  5936. this._moveButtonToTopLeft();
  5937. this._muteButton.addEventListener('touchend', function () {
  5938. _this._triggerRunningState();
  5939. }, true);
  5940. this._muteButton.addEventListener('click', function () {
  5941. _this._triggerRunningState();
  5942. }, true);
  5943. window.addEventListener("resize", this._onResize);
  5944. };
  5945. AudioEngine.prototype._moveButtonToTopLeft = function () {
  5946. if (this._hostElement && this._muteButton) {
  5947. this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
  5948. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
  5949. }
  5950. };
  5951. AudioEngine.prototype._hideMuteButton = function () {
  5952. if (this._muteButton) {
  5953. document.body.removeChild(this._muteButton);
  5954. this._muteButton = null;
  5955. }
  5956. };
  5957. /**
  5958. * Destroy and release the resources associated with the audio ccontext.
  5959. */
  5960. AudioEngine.prototype.dispose = function () {
  5961. if (this.canUseWebAudio && this._audioContextInitialized) {
  5962. if (this._connectedAnalyser && this._audioContext) {
  5963. this._connectedAnalyser.stopDebugCanvas();
  5964. this._connectedAnalyser.dispose();
  5965. this.masterGain.disconnect();
  5966. this.masterGain.connect(this._audioContext.destination);
  5967. this._connectedAnalyser = null;
  5968. }
  5969. this.masterGain.gain.value = 1;
  5970. }
  5971. this.WarnedWebAudioUnsupported = false;
  5972. this._hideMuteButton();
  5973. window.removeEventListener("resize", this._onResize);
  5974. this.onAudioUnlockedObservable.clear();
  5975. this.onAudioLockedObservable.clear();
  5976. };
  5977. /**
  5978. * Gets the global volume sets on the master gain.
  5979. * @returns the global volume if set or -1 otherwise
  5980. */
  5981. AudioEngine.prototype.getGlobalVolume = function () {
  5982. if (this.canUseWebAudio && this._audioContextInitialized) {
  5983. return this.masterGain.gain.value;
  5984. }
  5985. else {
  5986. return -1;
  5987. }
  5988. };
  5989. /**
  5990. * Sets the global volume of your experience (sets on the master gain).
  5991. * @param newVolume Defines the new global volume of the application
  5992. */
  5993. AudioEngine.prototype.setGlobalVolume = function (newVolume) {
  5994. if (this.canUseWebAudio && this._audioContextInitialized) {
  5995. this.masterGain.gain.value = newVolume;
  5996. }
  5997. };
  5998. /**
  5999. * Connect the audio engine to an audio analyser allowing some amazing
  6000. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  6001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  6002. * @param analyser The analyser to connect to the engine
  6003. */
  6004. AudioEngine.prototype.connectToAnalyser = function (analyser) {
  6005. if (this._connectedAnalyser) {
  6006. this._connectedAnalyser.stopDebugCanvas();
  6007. }
  6008. if (this.canUseWebAudio && this._audioContextInitialized && this._audioContext) {
  6009. this._connectedAnalyser = analyser;
  6010. this.masterGain.disconnect();
  6011. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination);
  6012. }
  6013. };
  6014. return AudioEngine;
  6015. }());
  6016. /***/ }),
  6017. /***/ "./Audio/audioSceneComponent.ts":
  6018. /*!**************************************!*\
  6019. !*** ./Audio/audioSceneComponent.ts ***!
  6020. \**************************************/
  6021. /*! exports provided: AudioSceneComponent */
  6022. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6023. "use strict";
  6024. __webpack_require__.r(__webpack_exports__);
  6025. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return AudioSceneComponent; });
  6026. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6027. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6028. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6029. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6030. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  6031. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  6032. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  6033. // Adds the parser to the scene parsers.
  6034. _abstractScene__WEBPACK_IMPORTED_MODULE_6__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO, function (parsedData, scene, container, rootUrl) {
  6035. // TODO: add sound
  6036. var loadedSounds = [];
  6037. var loadedSound;
  6038. container.sounds = container.sounds || [];
  6039. if (parsedData.sounds !== undefined && parsedData.sounds !== null) {
  6040. for (var index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  6041. var parsedSound = parsedData.sounds[index];
  6042. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine.canUseWebAudio) {
  6043. if (!parsedSound.url) {
  6044. parsedSound.url = parsedSound.name;
  6045. }
  6046. if (!loadedSounds[parsedSound.url]) {
  6047. loadedSound = _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl);
  6048. loadedSounds[parsedSound.url] = loadedSound;
  6049. container.sounds.push(loadedSound);
  6050. }
  6051. else {
  6052. container.sounds.push(_sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));
  6053. }
  6054. }
  6055. else {
  6056. container.sounds.push(new _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"](parsedSound.name, null, scene));
  6057. }
  6058. }
  6059. }
  6060. loadedSounds = [];
  6061. });
  6062. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "mainSoundTrack", {
  6063. get: function () {
  6064. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6065. if (!compo) {
  6066. compo = new AudioSceneComponent(this);
  6067. this._addComponent(compo);
  6068. }
  6069. if (!this._mainSoundTrack) {
  6070. this._mainSoundTrack = new _soundTrack__WEBPACK_IMPORTED_MODULE_1__["SoundTrack"](this, { mainTrack: true });
  6071. }
  6072. return this._mainSoundTrack;
  6073. },
  6074. enumerable: true,
  6075. configurable: true
  6076. });
  6077. _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype.getSoundByName = function (name) {
  6078. var index;
  6079. for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
  6080. if (this.mainSoundTrack.soundCollection[index].name === name) {
  6081. return this.mainSoundTrack.soundCollection[index];
  6082. }
  6083. }
  6084. if (this.soundTracks) {
  6085. for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
  6086. for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
  6087. if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
  6088. return this.soundTracks[sdIndex].soundCollection[index];
  6089. }
  6090. }
  6091. }
  6092. }
  6093. return null;
  6094. };
  6095. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "audioEnabled", {
  6096. get: function () {
  6097. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6098. if (!compo) {
  6099. compo = new AudioSceneComponent(this);
  6100. this._addComponent(compo);
  6101. }
  6102. return compo.audioEnabled;
  6103. },
  6104. set: function (value) {
  6105. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6106. if (!compo) {
  6107. compo = new AudioSceneComponent(this);
  6108. this._addComponent(compo);
  6109. }
  6110. if (value) {
  6111. compo.enableAudio();
  6112. }
  6113. else {
  6114. compo.disableAudio();
  6115. }
  6116. },
  6117. enumerable: true,
  6118. configurable: true
  6119. });
  6120. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "headphone", {
  6121. get: function () {
  6122. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6123. if (!compo) {
  6124. compo = new AudioSceneComponent(this);
  6125. this._addComponent(compo);
  6126. }
  6127. return compo.headphone;
  6128. },
  6129. set: function (value) {
  6130. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6131. if (!compo) {
  6132. compo = new AudioSceneComponent(this);
  6133. this._addComponent(compo);
  6134. }
  6135. if (value) {
  6136. compo.switchAudioModeForHeadphones();
  6137. }
  6138. else {
  6139. compo.switchAudioModeForNormalSpeakers();
  6140. }
  6141. },
  6142. enumerable: true,
  6143. configurable: true
  6144. });
  6145. /**
  6146. * Defines the sound scene component responsible to manage any sounds
  6147. * in a given scene.
  6148. */
  6149. var AudioSceneComponent = /** @class */ (function () {
  6150. /**
  6151. * Creates a new instance of the component for the given scene
  6152. * @param scene Defines the scene to register the component in
  6153. */
  6154. function AudioSceneComponent(scene) {
  6155. /**
  6156. * The component name helpfull to identify the component in the list of scene components.
  6157. */
  6158. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO;
  6159. this._audioEnabled = true;
  6160. this._headphone = false;
  6161. this.scene = scene;
  6162. scene.soundTracks = new Array();
  6163. scene.sounds = new Array();
  6164. }
  6165. Object.defineProperty(AudioSceneComponent.prototype, "audioEnabled", {
  6166. /**
  6167. * Gets whether audio is enabled or not.
  6168. * Please use related enable/disable method to switch state.
  6169. */
  6170. get: function () {
  6171. return this._audioEnabled;
  6172. },
  6173. enumerable: true,
  6174. configurable: true
  6175. });
  6176. Object.defineProperty(AudioSceneComponent.prototype, "headphone", {
  6177. /**
  6178. * Gets whether audio is outputing to headphone or not.
  6179. * Please use the according Switch methods to change output.
  6180. */
  6181. get: function () {
  6182. return this._headphone;
  6183. },
  6184. enumerable: true,
  6185. configurable: true
  6186. });
  6187. /**
  6188. * Registers the component in a given scene
  6189. */
  6190. AudioSceneComponent.prototype.register = function () {
  6191. this.scene._afterRenderStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDER_AUDIO, this, this._afterRender);
  6192. };
  6193. /**
  6194. * Rebuilds the elements related to this component in case of
  6195. * context lost for instance.
  6196. */
  6197. AudioSceneComponent.prototype.rebuild = function () {
  6198. // Nothing to do here. (Not rendering related)
  6199. };
  6200. /**
  6201. * Serializes the component data to the specified json object
  6202. * @param serializationObject The object to serialize to
  6203. */
  6204. AudioSceneComponent.prototype.serialize = function (serializationObject) {
  6205. serializationObject.sounds = [];
  6206. if (this.scene.soundTracks) {
  6207. for (var index = 0; index < this.scene.soundTracks.length; index++) {
  6208. var soundtrack = this.scene.soundTracks[index];
  6209. for (var soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
  6210. serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
  6211. }
  6212. }
  6213. }
  6214. };
  6215. /**
  6216. * Adds all the element from the container to the scene
  6217. * @param container the container holding the elements
  6218. */
  6219. AudioSceneComponent.prototype.addFromContainer = function (container) {
  6220. var _this = this;
  6221. if (!container.sounds) {
  6222. return;
  6223. }
  6224. container.sounds.forEach(function (sound) {
  6225. sound.play();
  6226. sound.autoplay = true;
  6227. _this.scene.mainSoundTrack.AddSound(sound);
  6228. });
  6229. };
  6230. /**
  6231. * Removes all the elements in the container from the scene
  6232. * @param container contains the elements to remove
  6233. */
  6234. AudioSceneComponent.prototype.removeFromContainer = function (container) {
  6235. var _this = this;
  6236. if (!container.sounds) {
  6237. return;
  6238. }
  6239. container.sounds.forEach(function (sound) {
  6240. sound.stop();
  6241. sound.autoplay = false;
  6242. _this.scene.mainSoundTrack.RemoveSound(sound);
  6243. });
  6244. };
  6245. /**
  6246. * Disposes the component and the associated ressources.
  6247. */
  6248. AudioSceneComponent.prototype.dispose = function () {
  6249. var scene = this.scene;
  6250. if (scene._mainSoundTrack) {
  6251. scene.mainSoundTrack.dispose();
  6252. }
  6253. if (scene.soundTracks) {
  6254. for (var scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
  6255. scene.soundTracks[scIndex].dispose();
  6256. }
  6257. }
  6258. };
  6259. /**
  6260. * Disables audio in the associated scene.
  6261. */
  6262. AudioSceneComponent.prototype.disableAudio = function () {
  6263. var scene = this.scene;
  6264. this._audioEnabled = false;
  6265. var i;
  6266. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6267. scene.mainSoundTrack.soundCollection[i].pause();
  6268. }
  6269. if (scene.soundTracks) {
  6270. for (i = 0; i < scene.soundTracks.length; i++) {
  6271. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6272. scene.soundTracks[i].soundCollection[j].pause();
  6273. }
  6274. }
  6275. }
  6276. };
  6277. /**
  6278. * Enables audio in the associated scene.
  6279. */
  6280. AudioSceneComponent.prototype.enableAudio = function () {
  6281. var scene = this.scene;
  6282. this._audioEnabled = true;
  6283. var i;
  6284. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6285. if (scene.mainSoundTrack.soundCollection[i].isPaused) {
  6286. scene.mainSoundTrack.soundCollection[i].play();
  6287. }
  6288. }
  6289. if (scene.soundTracks) {
  6290. for (i = 0; i < scene.soundTracks.length; i++) {
  6291. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6292. if (scene.soundTracks[i].soundCollection[j].isPaused) {
  6293. scene.soundTracks[i].soundCollection[j].play();
  6294. }
  6295. }
  6296. }
  6297. }
  6298. };
  6299. /**
  6300. * Switch audio to headphone output.
  6301. */
  6302. AudioSceneComponent.prototype.switchAudioModeForHeadphones = function () {
  6303. var scene = this.scene;
  6304. this._headphone = true;
  6305. scene.mainSoundTrack.switchPanningModelToHRTF();
  6306. if (scene.soundTracks) {
  6307. for (var i = 0; i < scene.soundTracks.length; i++) {
  6308. scene.soundTracks[i].switchPanningModelToHRTF();
  6309. }
  6310. }
  6311. };
  6312. /**
  6313. * Switch audio to normal speakers.
  6314. */
  6315. AudioSceneComponent.prototype.switchAudioModeForNormalSpeakers = function () {
  6316. var scene = this.scene;
  6317. this._headphone = false;
  6318. scene.mainSoundTrack.switchPanningModelToEqualPower();
  6319. if (scene.soundTracks) {
  6320. for (var i = 0; i < scene.soundTracks.length; i++) {
  6321. scene.soundTracks[i].switchPanningModelToEqualPower();
  6322. }
  6323. }
  6324. };
  6325. AudioSceneComponent.prototype._afterRender = function () {
  6326. var scene = this.scene;
  6327. if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
  6328. return;
  6329. }
  6330. var listeningCamera;
  6331. var audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine;
  6332. if (scene.activeCameras.length > 0) {
  6333. listeningCamera = scene.activeCameras[0];
  6334. }
  6335. else {
  6336. listeningCamera = scene.activeCamera;
  6337. }
  6338. if (listeningCamera && audioEngine.audioContext) {
  6339. audioEngine.audioContext.listener.setPosition(listeningCamera.position.x, listeningCamera.position.y, listeningCamera.position.z);
  6340. // for VR cameras
  6341. if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
  6342. listeningCamera = listeningCamera.rigCameras[0];
  6343. }
  6344. var mat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(listeningCamera.getViewMatrix());
  6345. var cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1), mat);
  6346. cameraDirection.normalize();
  6347. // To avoid some errors on GearVR
  6348. if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
  6349. audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
  6350. }
  6351. var i;
  6352. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6353. var sound = scene.mainSoundTrack.soundCollection[i];
  6354. if (sound.useCustomAttenuation) {
  6355. sound.updateDistanceFromListener();
  6356. }
  6357. }
  6358. if (scene.soundTracks) {
  6359. for (i = 0; i < scene.soundTracks.length; i++) {
  6360. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6361. sound = scene.soundTracks[i].soundCollection[j];
  6362. if (sound.useCustomAttenuation) {
  6363. sound.updateDistanceFromListener();
  6364. }
  6365. }
  6366. }
  6367. }
  6368. }
  6369. };
  6370. return AudioSceneComponent;
  6371. }());
  6372. _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"]._SceneComponentInitialization = function (scene) {
  6373. var compo = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6374. if (!compo) {
  6375. compo = new AudioSceneComponent(scene);
  6376. scene._addComponent(compo);
  6377. }
  6378. };
  6379. /***/ }),
  6380. /***/ "./Audio/index.ts":
  6381. /*!************************!*\
  6382. !*** ./Audio/index.ts ***!
  6383. \************************/
  6384. /*! exports provided: Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound */
  6385. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6386. "use strict";
  6387. __webpack_require__.r(__webpack_exports__);
  6388. /* harmony import */ var _analyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./analyser */ "./Audio/analyser.ts");
  6389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _analyser__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  6390. /* harmony import */ var _audioEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audioEngine */ "./Audio/audioEngine.ts");
  6391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _audioEngine__WEBPACK_IMPORTED_MODULE_1__["AudioEngine"]; });
  6392. /* harmony import */ var _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./audioSceneComponent */ "./Audio/audioSceneComponent.ts");
  6393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__["AudioSceneComponent"]; });
  6394. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _sound__WEBPACK_IMPORTED_MODULE_3__["Sound"]; });
  6396. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _soundTrack__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  6398. /* harmony import */ var _weightedsound__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./weightedsound */ "./Audio/weightedsound.ts");
  6399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _weightedsound__WEBPACK_IMPORTED_MODULE_5__["WeightedSound"]; });
  6400. /***/ }),
  6401. /***/ "./Audio/sound.ts":
  6402. /*!************************!*\
  6403. !*** ./Audio/sound.ts ***!
  6404. \************************/
  6405. /*! exports provided: Sound */
  6406. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6407. "use strict";
  6408. __webpack_require__.r(__webpack_exports__);
  6409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return Sound; });
  6410. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  6411. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  6412. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6413. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6414. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  6415. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  6416. /**
  6417. * Defines a sound that can be played in the application.
  6418. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  6419. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6420. */
  6421. var Sound = /** @class */ (function () {
  6422. /**
  6423. * Create a sound and attach it to a scene
  6424. * @param name Name of your sound
  6425. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  6426. * @param scene defines the scene the sound belongs to
  6427. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  6428. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  6429. */
  6430. function Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options) {
  6431. if (readyToPlayCallback === void 0) { readyToPlayCallback = null; }
  6432. var _this = this;
  6433. /**
  6434. * Does the sound autoplay once loaded.
  6435. */
  6436. this.autoplay = false;
  6437. /**
  6438. * Does the sound loop after it finishes playing once.
  6439. */
  6440. this.loop = false;
  6441. /**
  6442. * Does the sound use a custom attenuation curve to simulate the falloff
  6443. * happening when the source gets further away from the camera.
  6444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6445. */
  6446. this.useCustomAttenuation = false;
  6447. /**
  6448. * Is this sound currently played.
  6449. */
  6450. this.isPlaying = false;
  6451. /**
  6452. * Is this sound currently paused.
  6453. */
  6454. this.isPaused = false;
  6455. /**
  6456. * Does this sound enables spatial sound.
  6457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6458. */
  6459. this.spatialSound = false;
  6460. /**
  6461. * Define the reference distance the sound should be heard perfectly.
  6462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6463. */
  6464. this.refDistance = 1;
  6465. /**
  6466. * Define the roll off factor of spatial sounds.
  6467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6468. */
  6469. this.rolloffFactor = 1;
  6470. /**
  6471. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  6472. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6473. */
  6474. this.maxDistance = 100;
  6475. /**
  6476. * Define the distance attenuation model the sound will follow.
  6477. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6478. */
  6479. this.distanceModel = "linear";
  6480. /**
  6481. * Observable event when the current playing sound finishes.
  6482. */
  6483. this.onEndedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6484. this._panningModel = "equalpower";
  6485. this._playbackRate = 1;
  6486. this._streaming = false;
  6487. this._startTime = 0;
  6488. this._startOffset = 0;
  6489. this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  6490. /** @hidden */
  6491. this._positionInEmitterSpace = false;
  6492. this._localDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0);
  6493. this._volume = 1;
  6494. this._isReadyToPlay = false;
  6495. this._isDirectional = false;
  6496. // Used if you'd like to create a directional sound.
  6497. // If not set, the sound will be omnidirectional
  6498. this._coneInnerAngle = 360;
  6499. this._coneOuterAngle = 360;
  6500. this._coneOuterGain = 0;
  6501. this._isOutputConnected = false;
  6502. this._urlType = "Unknown";
  6503. this.name = name;
  6504. this._scene = scene;
  6505. Sound._SceneComponentInitialization(scene);
  6506. this._readyToPlayCallback = readyToPlayCallback;
  6507. // Default custom attenuation function is a linear attenuation
  6508. this._customAttenuationFunction = function (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) {
  6509. if (currentDistance < maxDistance) {
  6510. return currentVolume * (1 - currentDistance / maxDistance);
  6511. }
  6512. else {
  6513. return 0;
  6514. }
  6515. };
  6516. if (options) {
  6517. this.autoplay = options.autoplay || false;
  6518. this.loop = options.loop || false;
  6519. // if volume === 0, we need another way to check this option
  6520. if (options.volume !== undefined) {
  6521. this._volume = options.volume;
  6522. }
  6523. this.spatialSound = options.spatialSound || false;
  6524. this.maxDistance = options.maxDistance || 100;
  6525. this.useCustomAttenuation = options.useCustomAttenuation || false;
  6526. this.rolloffFactor = options.rolloffFactor || 1;
  6527. this.refDistance = options.refDistance || 1;
  6528. this.distanceModel = options.distanceModel || "linear";
  6529. this._playbackRate = options.playbackRate || 1;
  6530. this._streaming = options.streaming || false;
  6531. }
  6532. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6533. this._soundGain = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createGain();
  6534. this._soundGain.gain.value = this._volume;
  6535. this._inputAudioNode = this._soundGain;
  6536. this._outputAudioNode = this._soundGain;
  6537. if (this.spatialSound) {
  6538. this._createSpatialParameters();
  6539. }
  6540. this._scene.mainSoundTrack.AddSound(this);
  6541. var validParameter = true;
  6542. // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
  6543. if (urlOrArrayBuffer) {
  6544. try {
  6545. if (typeof (urlOrArrayBuffer) === "string") {
  6546. this._urlType = "String";
  6547. }
  6548. else if (urlOrArrayBuffer instanceof ArrayBuffer) {
  6549. this._urlType = "ArrayBuffer";
  6550. }
  6551. else if (urlOrArrayBuffer instanceof MediaStream) {
  6552. this._urlType = "MediaStream";
  6553. }
  6554. else if (Array.isArray(urlOrArrayBuffer)) {
  6555. this._urlType = "Array";
  6556. }
  6557. var urls = [];
  6558. var codecSupportedFound = false;
  6559. switch (this._urlType) {
  6560. case "MediaStream":
  6561. this._streaming = true;
  6562. this._isReadyToPlay = true;
  6563. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);
  6564. if (this.autoplay) {
  6565. this.play();
  6566. }
  6567. if (this._readyToPlayCallback) {
  6568. this._readyToPlayCallback();
  6569. }
  6570. break;
  6571. case "ArrayBuffer":
  6572. if (urlOrArrayBuffer.byteLength > 0) {
  6573. codecSupportedFound = true;
  6574. this._soundLoaded(urlOrArrayBuffer);
  6575. }
  6576. break;
  6577. case "String":
  6578. urls.push(urlOrArrayBuffer);
  6579. case "Array":
  6580. if (urls.length === 0) {
  6581. urls = urlOrArrayBuffer;
  6582. }
  6583. // If we found a supported format, we load it immediately and stop the loop
  6584. for (var i = 0; i < urls.length; i++) {
  6585. var url = urls[i];
  6586. if (url.indexOf(".mp3", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isMP3supported) {
  6587. codecSupportedFound = true;
  6588. }
  6589. if (url.indexOf(".ogg", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isOGGsupported) {
  6590. codecSupportedFound = true;
  6591. }
  6592. if (url.indexOf(".wav", url.length - 4) !== -1) {
  6593. codecSupportedFound = true;
  6594. }
  6595. if (url.indexOf("blob:") !== -1) {
  6596. codecSupportedFound = true;
  6597. }
  6598. if (codecSupportedFound) {
  6599. // Loading sound using XHR2
  6600. if (!this._streaming) {
  6601. this._scene._loadFile(url, function (data) {
  6602. _this._soundLoaded(data);
  6603. }, undefined, true, true, function (exception) {
  6604. if (exception) {
  6605. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("XHR " + exception.status + " error on: " + url + ".");
  6606. }
  6607. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Sound creation aborted.");
  6608. _this._scene.mainSoundTrack.RemoveSound(_this);
  6609. });
  6610. }
  6611. // Streaming sound using HTML5 Audio tag
  6612. else {
  6613. this._htmlAudioElement = new Audio(url);
  6614. this._htmlAudioElement.controls = false;
  6615. this._htmlAudioElement.loop = this.loop;
  6616. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetCorsBehavior(url, this._htmlAudioElement);
  6617. this._htmlAudioElement.preload = "auto";
  6618. this._htmlAudioElement.addEventListener("canplaythrough", function () {
  6619. _this._isReadyToPlay = true;
  6620. if (_this.autoplay) {
  6621. _this.play();
  6622. }
  6623. if (_this._readyToPlayCallback) {
  6624. _this._readyToPlayCallback();
  6625. }
  6626. });
  6627. document.body.appendChild(this._htmlAudioElement);
  6628. this._htmlAudioElement.load();
  6629. }
  6630. break;
  6631. }
  6632. }
  6633. break;
  6634. default:
  6635. validParameter = false;
  6636. break;
  6637. }
  6638. if (!validParameter) {
  6639. _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.");
  6640. }
  6641. else {
  6642. if (!codecSupportedFound) {
  6643. this._isReadyToPlay = true;
  6644. // Simulating a ready to play event to avoid breaking code path
  6645. if (this._readyToPlayCallback) {
  6646. window.setTimeout(function () {
  6647. if (_this._readyToPlayCallback) {
  6648. _this._readyToPlayCallback();
  6649. }
  6650. }, 1000);
  6651. }
  6652. }
  6653. }
  6654. }
  6655. catch (ex) {
  6656. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Unexpected error. Sound creation aborted.");
  6657. this._scene.mainSoundTrack.RemoveSound(this);
  6658. }
  6659. }
  6660. }
  6661. else {
  6662. // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
  6663. this._scene.mainSoundTrack.AddSound(this);
  6664. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported) {
  6665. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Web Audio is not supported by your browser.");
  6666. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported = true;
  6667. }
  6668. // Simulating a ready to play event to avoid breaking code for non web audio browsers
  6669. if (this._readyToPlayCallback) {
  6670. window.setTimeout(function () {
  6671. if (_this._readyToPlayCallback) {
  6672. _this._readyToPlayCallback();
  6673. }
  6674. }, 1000);
  6675. }
  6676. }
  6677. }
  6678. /**
  6679. * Release the sound and its associated resources
  6680. */
  6681. Sound.prototype.dispose = function () {
  6682. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6683. if (this.isPlaying) {
  6684. this.stop();
  6685. }
  6686. this._isReadyToPlay = false;
  6687. if (this.soundTrackId === -1) {
  6688. this._scene.mainSoundTrack.RemoveSound(this);
  6689. }
  6690. else if (this._scene.soundTracks) {
  6691. this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
  6692. }
  6693. if (this._soundGain) {
  6694. this._soundGain.disconnect();
  6695. this._soundGain = null;
  6696. }
  6697. if (this._soundPanner) {
  6698. this._soundPanner.disconnect();
  6699. this._soundPanner = null;
  6700. }
  6701. if (this._soundSource) {
  6702. this._soundSource.disconnect();
  6703. this._soundSource = null;
  6704. }
  6705. this._audioBuffer = null;
  6706. if (this._htmlAudioElement) {
  6707. this._htmlAudioElement.pause();
  6708. this._htmlAudioElement.src = "";
  6709. document.body.removeChild(this._htmlAudioElement);
  6710. }
  6711. if (this._streamingSource) {
  6712. this._streamingSource.disconnect();
  6713. }
  6714. if (this._connectedTransformNode && this._registerFunc) {
  6715. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6716. this._connectedTransformNode = null;
  6717. }
  6718. }
  6719. };
  6720. /**
  6721. * Gets if the sounds is ready to be played or not.
  6722. * @returns true if ready, otherwise false
  6723. */
  6724. Sound.prototype.isReady = function () {
  6725. return this._isReadyToPlay;
  6726. };
  6727. Sound.prototype._soundLoaded = function (audioData) {
  6728. var _this = this;
  6729. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6730. return;
  6731. }
  6732. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.decodeAudioData(audioData, function (buffer) {
  6733. _this._audioBuffer = buffer;
  6734. _this._isReadyToPlay = true;
  6735. if (_this.autoplay) {
  6736. _this.play();
  6737. }
  6738. if (_this._readyToPlayCallback) {
  6739. _this._readyToPlayCallback();
  6740. }
  6741. }, function (err) { _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
  6742. };
  6743. /**
  6744. * Sets the data of the sound from an audiobuffer
  6745. * @param audioBuffer The audioBuffer containing the data
  6746. */
  6747. Sound.prototype.setAudioBuffer = function (audioBuffer) {
  6748. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6749. this._audioBuffer = audioBuffer;
  6750. this._isReadyToPlay = true;
  6751. }
  6752. };
  6753. /**
  6754. * Updates the current sounds options such as maxdistance, loop...
  6755. * @param options A JSON object containing values named as the object properties
  6756. */
  6757. Sound.prototype.updateOptions = function (options) {
  6758. if (options) {
  6759. this.loop = options.loop || this.loop;
  6760. this.maxDistance = options.maxDistance || this.maxDistance;
  6761. this.useCustomAttenuation = options.useCustomAttenuation || this.useCustomAttenuation;
  6762. this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
  6763. this.refDistance = options.refDistance || this.refDistance;
  6764. this.distanceModel = options.distanceModel || this.distanceModel;
  6765. this._playbackRate = options.playbackRate || this._playbackRate;
  6766. this._updateSpatialParameters();
  6767. if (this.isPlaying) {
  6768. if (this._streaming && this._htmlAudioElement) {
  6769. this._htmlAudioElement.playbackRate = this._playbackRate;
  6770. }
  6771. else {
  6772. if (this._soundSource) {
  6773. this._soundSource.playbackRate.value = this._playbackRate;
  6774. }
  6775. }
  6776. }
  6777. }
  6778. };
  6779. Sound.prototype._createSpatialParameters = function () {
  6780. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6781. if (this._scene.headphone) {
  6782. this._panningModel = "HRTF";
  6783. }
  6784. this._soundPanner = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createPanner();
  6785. this._updateSpatialParameters();
  6786. this._soundPanner.connect(this._outputAudioNode);
  6787. this._inputAudioNode = this._soundPanner;
  6788. }
  6789. };
  6790. Sound.prototype._updateSpatialParameters = function () {
  6791. if (this.spatialSound && this._soundPanner) {
  6792. if (this.useCustomAttenuation) {
  6793. // Tricks to disable in a way embedded Web Audio attenuation
  6794. this._soundPanner.distanceModel = "linear";
  6795. this._soundPanner.maxDistance = Number.MAX_VALUE;
  6796. this._soundPanner.refDistance = 1;
  6797. this._soundPanner.rolloffFactor = 1;
  6798. this._soundPanner.panningModel = this._panningModel;
  6799. }
  6800. else {
  6801. this._soundPanner.distanceModel = this.distanceModel;
  6802. this._soundPanner.maxDistance = this.maxDistance;
  6803. this._soundPanner.refDistance = this.refDistance;
  6804. this._soundPanner.rolloffFactor = this.rolloffFactor;
  6805. this._soundPanner.panningModel = this._panningModel;
  6806. }
  6807. }
  6808. };
  6809. /**
  6810. * Switch the panning model to HRTF:
  6811. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  6812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6813. */
  6814. Sound.prototype.switchPanningModelToHRTF = function () {
  6815. this._panningModel = "HRTF";
  6816. this._switchPanningModel();
  6817. };
  6818. /**
  6819. * Switch the panning model to Equal Power:
  6820. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  6821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6822. */
  6823. Sound.prototype.switchPanningModelToEqualPower = function () {
  6824. this._panningModel = "equalpower";
  6825. this._switchPanningModel();
  6826. };
  6827. Sound.prototype._switchPanningModel = function () {
  6828. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6829. this._soundPanner.panningModel = this._panningModel;
  6830. }
  6831. };
  6832. /**
  6833. * Connect this sound to a sound track audio node like gain...
  6834. * @param soundTrackAudioNode the sound track audio node to connect to
  6835. */
  6836. Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
  6837. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6838. if (this._isOutputConnected) {
  6839. this._outputAudioNode.disconnect();
  6840. }
  6841. this._outputAudioNode.connect(soundTrackAudioNode);
  6842. this._isOutputConnected = true;
  6843. }
  6844. };
  6845. /**
  6846. * Transform this sound into a directional source
  6847. * @param coneInnerAngle Size of the inner cone in degree
  6848. * @param coneOuterAngle Size of the outer cone in degree
  6849. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  6850. */
  6851. Sound.prototype.setDirectionalCone = function (coneInnerAngle, coneOuterAngle, coneOuterGain) {
  6852. if (coneOuterAngle < coneInnerAngle) {
  6853. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  6854. return;
  6855. }
  6856. this._coneInnerAngle = coneInnerAngle;
  6857. this._coneOuterAngle = coneOuterAngle;
  6858. this._coneOuterGain = coneOuterGain;
  6859. this._isDirectional = true;
  6860. if (this.isPlaying && this.loop) {
  6861. this.stop();
  6862. this.play();
  6863. }
  6864. };
  6865. Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
  6866. /**
  6867. * Gets or sets the inner angle for the directional cone.
  6868. */
  6869. get: function () {
  6870. return this._coneInnerAngle;
  6871. },
  6872. /**
  6873. * Gets or sets the inner angle for the directional cone.
  6874. */
  6875. set: function (value) {
  6876. if (value != this._coneInnerAngle) {
  6877. if (this._coneOuterAngle < value) {
  6878. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6879. return;
  6880. }
  6881. this._coneInnerAngle = value;
  6882. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6883. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6884. }
  6885. }
  6886. },
  6887. enumerable: true,
  6888. configurable: true
  6889. });
  6890. Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
  6891. /**
  6892. * Gets or sets the outer angle for the directional cone.
  6893. */
  6894. get: function () {
  6895. return this._coneOuterAngle;
  6896. },
  6897. /**
  6898. * Gets or sets the outer angle for the directional cone.
  6899. */
  6900. set: function (value) {
  6901. if (value != this._coneOuterAngle) {
  6902. if (value < this._coneInnerAngle) {
  6903. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6904. return;
  6905. }
  6906. this._coneOuterAngle = value;
  6907. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6908. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6909. }
  6910. }
  6911. },
  6912. enumerable: true,
  6913. configurable: true
  6914. });
  6915. /**
  6916. * Sets the position of the emitter if spatial sound is enabled
  6917. * @param newPosition Defines the new posisiton
  6918. */
  6919. Sound.prototype.setPosition = function (newPosition) {
  6920. this._position = newPosition;
  6921. 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)) {
  6922. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6923. }
  6924. };
  6925. /**
  6926. * Sets the local direction of the emitter if spatial sound is enabled
  6927. * @param newLocalDirection Defines the new local direction
  6928. */
  6929. Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
  6930. this._localDirection = newLocalDirection;
  6931. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
  6932. this._updateDirection();
  6933. }
  6934. };
  6935. Sound.prototype._updateDirection = function () {
  6936. if (!this._connectedTransformNode || !this._soundPanner) {
  6937. return;
  6938. }
  6939. var mat = this._connectedTransformNode.getWorldMatrix();
  6940. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(this._localDirection, mat);
  6941. direction.normalize();
  6942. this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
  6943. };
  6944. /** @hidden */
  6945. Sound.prototype.updateDistanceFromListener = function () {
  6946. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  6947. var distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  6948. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
  6949. }
  6950. };
  6951. /**
  6952. * Sets a new custom attenuation function for the sound.
  6953. * @param callback Defines the function used for the attenuation
  6954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6955. */
  6956. Sound.prototype.setAttenuationFunction = function (callback) {
  6957. this._customAttenuationFunction = callback;
  6958. };
  6959. /**
  6960. * Play the sound
  6961. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  6962. * @param offset (optional) Start the sound setting it at a specific time
  6963. */
  6964. Sound.prototype.play = function (time, offset) {
  6965. var _this = this;
  6966. if (this._isReadyToPlay && this._scene.audioEnabled && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6967. try {
  6968. if (this._startOffset < 0) {
  6969. time = -this._startOffset;
  6970. this._startOffset = 0;
  6971. }
  6972. var startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  6973. if (!this._soundSource || !this._streamingSource) {
  6974. if (this.spatialSound && this._soundPanner) {
  6975. if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6976. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6977. }
  6978. if (this._isDirectional) {
  6979. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6980. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6981. this._soundPanner.coneOuterGain = this._coneOuterGain;
  6982. if (this._connectedTransformNode) {
  6983. this._updateDirection();
  6984. }
  6985. else {
  6986. this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
  6987. }
  6988. }
  6989. }
  6990. }
  6991. if (this._streaming) {
  6992. if (!this._streamingSource) {
  6993. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
  6994. this._htmlAudioElement.onended = function () { _this._onended(); };
  6995. this._htmlAudioElement.playbackRate = this._playbackRate;
  6996. }
  6997. this._streamingSource.disconnect();
  6998. this._streamingSource.connect(this._inputAudioNode);
  6999. if (this._htmlAudioElement) {
  7000. // required to manage properly the new suspended default state of Chrome
  7001. // When the option 'streaming: true' is used, we need first to wait for
  7002. // the audio engine to be unlocked by a user gesture before trying to play
  7003. // an HTML Audio elememt
  7004. var tryToPlay = function () {
  7005. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.unlocked) {
  7006. var playPromise = _this._htmlAudioElement.play();
  7007. // In browsers that don’t yet support this functionality,
  7008. // playPromise won’t be defined.
  7009. if (playPromise !== undefined) {
  7010. playPromise.catch(function (error) {
  7011. // Automatic playback failed.
  7012. // Waiting for the audio engine to be unlocked by user click on unmute
  7013. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7014. if (_this.loop || _this.autoplay) {
  7015. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7016. }
  7017. });
  7018. }
  7019. }
  7020. else {
  7021. if (_this.loop || _this.autoplay) {
  7022. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7023. }
  7024. }
  7025. };
  7026. tryToPlay();
  7027. }
  7028. }
  7029. else {
  7030. var tryToPlay = function () {
  7031. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7032. _this._soundSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createBufferSource();
  7033. _this._soundSource.buffer = _this._audioBuffer;
  7034. _this._soundSource.connect(_this._inputAudioNode);
  7035. _this._soundSource.loop = _this.loop;
  7036. _this._soundSource.playbackRate.value = _this._playbackRate;
  7037. _this._soundSource.onended = function () { _this._onended(); };
  7038. startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7039. _this._soundSource.start(startTime, _this.isPaused ? _this._startOffset % _this._soundSource.buffer.duration : offset ? offset : 0);
  7040. }
  7041. };
  7042. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7043. // Wait a bit for FF as context seems late to be ready.
  7044. setTimeout(function () {
  7045. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7046. // Automatic playback failed.
  7047. // Waiting for the audio engine to be unlocked by user click on unmute
  7048. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7049. if (_this.loop || _this.autoplay) {
  7050. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7051. }
  7052. }
  7053. else {
  7054. tryToPlay();
  7055. }
  7056. }, 500);
  7057. }
  7058. else {
  7059. tryToPlay();
  7060. }
  7061. }
  7062. this._startTime = startTime;
  7063. this.isPlaying = true;
  7064. this.isPaused = false;
  7065. }
  7066. catch (ex) {
  7067. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while trying to play audio: " + this.name + ", " + ex.message);
  7068. }
  7069. }
  7070. };
  7071. Sound.prototype._onended = function () {
  7072. this.isPlaying = false;
  7073. if (this.onended) {
  7074. this.onended();
  7075. }
  7076. this.onEndedObservable.notifyObservers(this);
  7077. };
  7078. /**
  7079. * Stop the sound
  7080. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  7081. */
  7082. Sound.prototype.stop = function (time) {
  7083. if (this.isPlaying) {
  7084. if (this._streaming) {
  7085. if (this._htmlAudioElement) {
  7086. this._htmlAudioElement.pause();
  7087. // Test needed for Firefox or it will generate an Invalid State Error
  7088. if (this._htmlAudioElement.currentTime > 0) {
  7089. this._htmlAudioElement.currentTime = 0;
  7090. }
  7091. }
  7092. else {
  7093. this._streamingSource.disconnect();
  7094. }
  7095. }
  7096. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext && this._soundSource) {
  7097. var stopTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7098. this._soundSource.stop(stopTime);
  7099. this._soundSource.onended = function () { };
  7100. if (!this.isPaused) {
  7101. this._startOffset = 0;
  7102. }
  7103. }
  7104. this.isPlaying = false;
  7105. }
  7106. };
  7107. /**
  7108. * Put the sound in pause
  7109. */
  7110. Sound.prototype.pause = function () {
  7111. if (this.isPlaying) {
  7112. this.isPaused = true;
  7113. if (this._streaming) {
  7114. if (this._htmlAudioElement) {
  7115. this._htmlAudioElement.pause();
  7116. }
  7117. else {
  7118. this._streamingSource.disconnect();
  7119. }
  7120. }
  7121. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7122. this.stop(0);
  7123. this._startOffset += _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime - this._startTime;
  7124. }
  7125. }
  7126. };
  7127. /**
  7128. * Sets a dedicated volume for this sounds
  7129. * @param newVolume Define the new volume of the sound
  7130. * @param time Define in how long the sound should be at this value
  7131. */
  7132. Sound.prototype.setVolume = function (newVolume, time) {
  7133. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._soundGain) {
  7134. if (time && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7135. this._soundGain.gain.cancelScheduledValues(_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7136. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7137. this._soundGain.gain.linearRampToValueAtTime(newVolume, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time);
  7138. }
  7139. else {
  7140. this._soundGain.gain.value = newVolume;
  7141. }
  7142. }
  7143. this._volume = newVolume;
  7144. };
  7145. /**
  7146. * Set the sound play back rate
  7147. * @param newPlaybackRate Define the playback rate the sound should be played at
  7148. */
  7149. Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
  7150. this._playbackRate = newPlaybackRate;
  7151. if (this.isPlaying) {
  7152. if (this._streaming && this._htmlAudioElement) {
  7153. this._htmlAudioElement.playbackRate = this._playbackRate;
  7154. }
  7155. else if (this._soundSource) {
  7156. this._soundSource.playbackRate.value = this._playbackRate;
  7157. }
  7158. }
  7159. };
  7160. /**
  7161. * Gets the volume of the sound.
  7162. * @returns the volume of the sound
  7163. */
  7164. Sound.prototype.getVolume = function () {
  7165. return this._volume;
  7166. };
  7167. /**
  7168. * Attach the sound to a dedicated mesh
  7169. * @param transformNode The transform node to connect the sound with
  7170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7171. */
  7172. Sound.prototype.attachToMesh = function (transformNode) {
  7173. var _this = this;
  7174. if (this._connectedTransformNode && this._registerFunc) {
  7175. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7176. this._registerFunc = null;
  7177. }
  7178. this._connectedTransformNode = transformNode;
  7179. if (!this.spatialSound) {
  7180. this.spatialSound = true;
  7181. this._createSpatialParameters();
  7182. if (this.isPlaying && this.loop) {
  7183. this.stop();
  7184. this.play();
  7185. }
  7186. }
  7187. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);
  7188. this._registerFunc = function (transformNode) { return _this._onRegisterAfterWorldMatrixUpdate(transformNode); };
  7189. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
  7190. };
  7191. /**
  7192. * Detach the sound from the previously attached mesh
  7193. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7194. */
  7195. Sound.prototype.detachFromMesh = function () {
  7196. if (this._connectedTransformNode && this._registerFunc) {
  7197. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7198. this._registerFunc = null;
  7199. this._connectedTransformNode = null;
  7200. }
  7201. };
  7202. Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (node) {
  7203. if (!node.getBoundingInfo) {
  7204. return;
  7205. }
  7206. var mesh = node;
  7207. if (this._positionInEmitterSpace) {
  7208. mesh.worldMatrixFromCache.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0]);
  7209. this.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0].getTranslation());
  7210. }
  7211. else {
  7212. var boundingInfo = mesh.getBoundingInfo();
  7213. this.setPosition(boundingInfo.boundingSphere.centerWorld);
  7214. }
  7215. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {
  7216. this._updateDirection();
  7217. }
  7218. };
  7219. /**
  7220. * Clone the current sound in the scene.
  7221. * @returns the new sound clone
  7222. */
  7223. Sound.prototype.clone = function () {
  7224. var _this = this;
  7225. if (!this._streaming) {
  7226. var setBufferAndRun = function () {
  7227. if (_this._isReadyToPlay) {
  7228. clonedSound._audioBuffer = _this.getAudioBuffer();
  7229. clonedSound._isReadyToPlay = true;
  7230. if (clonedSound.autoplay) {
  7231. clonedSound.play();
  7232. }
  7233. }
  7234. else {
  7235. window.setTimeout(setBufferAndRun, 300);
  7236. }
  7237. };
  7238. var currentOptions = {
  7239. autoplay: this.autoplay, loop: this.loop,
  7240. volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance,
  7241. useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor,
  7242. refDistance: this.refDistance, distanceModel: this.distanceModel
  7243. };
  7244. var clonedSound = new Sound(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, currentOptions);
  7245. if (this.useCustomAttenuation) {
  7246. clonedSound.setAttenuationFunction(this._customAttenuationFunction);
  7247. }
  7248. clonedSound.setPosition(this._position);
  7249. clonedSound.setPlaybackRate(this._playbackRate);
  7250. setBufferAndRun();
  7251. return clonedSound;
  7252. }
  7253. // Can't clone a streaming sound
  7254. else {
  7255. return null;
  7256. }
  7257. };
  7258. /**
  7259. * Gets the current underlying audio buffer containing the data
  7260. * @returns the audio buffer
  7261. */
  7262. Sound.prototype.getAudioBuffer = function () {
  7263. return this._audioBuffer;
  7264. };
  7265. /**
  7266. * Serializes the Sound in a JSON representation
  7267. * @returns the JSON representation of the sound
  7268. */
  7269. Sound.prototype.serialize = function () {
  7270. var serializationObject = {
  7271. name: this.name,
  7272. url: this.name,
  7273. autoplay: this.autoplay,
  7274. loop: this.loop,
  7275. volume: this._volume,
  7276. spatialSound: this.spatialSound,
  7277. maxDistance: this.maxDistance,
  7278. rolloffFactor: this.rolloffFactor,
  7279. refDistance: this.refDistance,
  7280. distanceModel: this.distanceModel,
  7281. playbackRate: this._playbackRate,
  7282. panningModel: this._panningModel,
  7283. soundTrackId: this.soundTrackId
  7284. };
  7285. if (this.spatialSound) {
  7286. if (this._connectedTransformNode) {
  7287. serializationObject.connectedMeshId = this._connectedTransformNode.id;
  7288. }
  7289. serializationObject.position = this._position.asArray();
  7290. serializationObject.refDistance = this.refDistance;
  7291. serializationObject.distanceModel = this.distanceModel;
  7292. serializationObject.isDirectional = this._isDirectional;
  7293. serializationObject.localDirectionToMesh = this._localDirection.asArray();
  7294. serializationObject.coneInnerAngle = this._coneInnerAngle;
  7295. serializationObject.coneOuterAngle = this._coneOuterAngle;
  7296. serializationObject.coneOuterGain = this._coneOuterGain;
  7297. }
  7298. return serializationObject;
  7299. };
  7300. /**
  7301. * Parse a JSON representation of a sound to innstantiate in a given scene
  7302. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  7303. * @param scene Define the scene the new parsed sound should be created in
  7304. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  7305. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  7306. * @returns the newly parsed sound
  7307. */
  7308. Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
  7309. var soundName = parsedSound.name;
  7310. var soundUrl;
  7311. if (parsedSound.url) {
  7312. soundUrl = rootUrl + parsedSound.url;
  7313. }
  7314. else {
  7315. soundUrl = rootUrl + soundName;
  7316. }
  7317. var options = {
  7318. autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
  7319. spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
  7320. rolloffFactor: parsedSound.rolloffFactor,
  7321. refDistance: parsedSound.refDistance,
  7322. distanceModel: parsedSound.distanceModel,
  7323. playbackRate: parsedSound.playbackRate
  7324. };
  7325. var newSound;
  7326. if (!sourceSound) {
  7327. newSound = new Sound(soundName, soundUrl, scene, function () { scene._removePendingData(newSound); }, options);
  7328. scene._addPendingData(newSound);
  7329. }
  7330. else {
  7331. var setBufferAndRun = function () {
  7332. if (sourceSound._isReadyToPlay) {
  7333. newSound._audioBuffer = sourceSound.getAudioBuffer();
  7334. newSound._isReadyToPlay = true;
  7335. if (newSound.autoplay) {
  7336. newSound.play();
  7337. }
  7338. }
  7339. else {
  7340. window.setTimeout(setBufferAndRun, 300);
  7341. }
  7342. };
  7343. newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);
  7344. setBufferAndRun();
  7345. }
  7346. if (parsedSound.position) {
  7347. var soundPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.position);
  7348. newSound.setPosition(soundPosition);
  7349. }
  7350. if (parsedSound.isDirectional) {
  7351. newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
  7352. if (parsedSound.localDirectionToMesh) {
  7353. var localDirectionToMesh = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.localDirectionToMesh);
  7354. newSound.setLocalDirectionToMesh(localDirectionToMesh);
  7355. }
  7356. }
  7357. if (parsedSound.connectedMeshId) {
  7358. var connectedMesh = scene.getMeshByID(parsedSound.connectedMeshId);
  7359. if (connectedMesh) {
  7360. newSound.attachToMesh(connectedMesh);
  7361. }
  7362. }
  7363. return newSound;
  7364. };
  7365. /** @hidden */
  7366. Sound._SceneComponentInitialization = function (_) {
  7367. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AudioSceneComponent");
  7368. };
  7369. return Sound;
  7370. }());
  7371. /***/ }),
  7372. /***/ "./Audio/soundTrack.ts":
  7373. /*!*****************************!*\
  7374. !*** ./Audio/soundTrack.ts ***!
  7375. \*****************************/
  7376. /*! exports provided: SoundTrack */
  7377. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7378. "use strict";
  7379. __webpack_require__.r(__webpack_exports__);
  7380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return SoundTrack; });
  7381. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  7382. /**
  7383. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  7384. * It will be also used in a future release to apply effects on a specific track.
  7385. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7386. */
  7387. var SoundTrack = /** @class */ (function () {
  7388. /**
  7389. * Creates a new sound track.
  7390. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7391. * @param scene Define the scene the sound track belongs to
  7392. * @param options
  7393. */
  7394. function SoundTrack(scene, options) {
  7395. if (options === void 0) { options = {}; }
  7396. /**
  7397. * The unique identifier of the sound track in the scene.
  7398. */
  7399. this.id = -1;
  7400. this._isMainTrack = false;
  7401. this._isInitialized = false;
  7402. this._scene = scene;
  7403. this.soundCollection = new Array();
  7404. this._options = options;
  7405. if (!this._isMainTrack && this._scene.soundTracks) {
  7406. this._scene.soundTracks.push(this);
  7407. this.id = this._scene.soundTracks.length - 1;
  7408. }
  7409. }
  7410. SoundTrack.prototype._initializeSoundTrackAudioGraph = function () {
  7411. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext) {
  7412. this._outputAudioNode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext.createGain();
  7413. this._outputAudioNode.connect(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7414. if (this._options) {
  7415. if (this._options.volume) {
  7416. this._outputAudioNode.gain.value = this._options.volume;
  7417. }
  7418. if (this._options.mainTrack) {
  7419. this._isMainTrack = this._options.mainTrack;
  7420. }
  7421. }
  7422. this._isInitialized = true;
  7423. }
  7424. };
  7425. /**
  7426. * Release the sound track and its associated resources
  7427. */
  7428. SoundTrack.prototype.dispose = function () {
  7429. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7430. if (this._connectedAnalyser) {
  7431. this._connectedAnalyser.stopDebugCanvas();
  7432. }
  7433. while (this.soundCollection.length) {
  7434. this.soundCollection[0].dispose();
  7435. }
  7436. if (this._outputAudioNode) {
  7437. this._outputAudioNode.disconnect();
  7438. }
  7439. this._outputAudioNode = null;
  7440. }
  7441. };
  7442. /**
  7443. * Adds a sound to this sound track
  7444. * @param sound define the cound to add
  7445. * @ignoreNaming
  7446. */
  7447. SoundTrack.prototype.AddSound = function (sound) {
  7448. if (!this._isInitialized) {
  7449. this._initializeSoundTrackAudioGraph();
  7450. }
  7451. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7452. sound.connectToSoundTrackAudioNode(this._outputAudioNode);
  7453. }
  7454. if (sound.soundTrackId) {
  7455. if (sound.soundTrackId === -1) {
  7456. this._scene.mainSoundTrack.RemoveSound(sound);
  7457. }
  7458. else if (this._scene.soundTracks) {
  7459. this._scene.soundTracks[sound.soundTrackId].RemoveSound(sound);
  7460. }
  7461. }
  7462. this.soundCollection.push(sound);
  7463. sound.soundTrackId = this.id;
  7464. };
  7465. /**
  7466. * Removes a sound to this sound track
  7467. * @param sound define the cound to remove
  7468. * @ignoreNaming
  7469. */
  7470. SoundTrack.prototype.RemoveSound = function (sound) {
  7471. var index = this.soundCollection.indexOf(sound);
  7472. if (index !== -1) {
  7473. this.soundCollection.splice(index, 1);
  7474. }
  7475. };
  7476. /**
  7477. * Set a global volume for the full sound track.
  7478. * @param newVolume Define the new volume of the sound track
  7479. */
  7480. SoundTrack.prototype.setVolume = function (newVolume) {
  7481. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7482. this._outputAudioNode.gain.value = newVolume;
  7483. }
  7484. };
  7485. /**
  7486. * Switch the panning model to HRTF:
  7487. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  7488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7489. */
  7490. SoundTrack.prototype.switchPanningModelToHRTF = function () {
  7491. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7492. for (var i = 0; i < this.soundCollection.length; i++) {
  7493. this.soundCollection[i].switchPanningModelToHRTF();
  7494. }
  7495. }
  7496. };
  7497. /**
  7498. * Switch the panning model to Equal Power:
  7499. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  7500. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7501. */
  7502. SoundTrack.prototype.switchPanningModelToEqualPower = function () {
  7503. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7504. for (var i = 0; i < this.soundCollection.length; i++) {
  7505. this.soundCollection[i].switchPanningModelToEqualPower();
  7506. }
  7507. }
  7508. };
  7509. /**
  7510. * Connect the sound track to an audio analyser allowing some amazing
  7511. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  7512. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  7513. * @param analyser The analyser to connect to the engine
  7514. */
  7515. SoundTrack.prototype.connectToAnalyser = function (analyser) {
  7516. if (this._connectedAnalyser) {
  7517. this._connectedAnalyser.stopDebugCanvas();
  7518. }
  7519. this._connectedAnalyser = analyser;
  7520. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7521. this._outputAudioNode.disconnect();
  7522. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7523. }
  7524. };
  7525. return SoundTrack;
  7526. }());
  7527. /***/ }),
  7528. /***/ "./Audio/weightedsound.ts":
  7529. /*!********************************!*\
  7530. !*** ./Audio/weightedsound.ts ***!
  7531. \********************************/
  7532. /*! exports provided: WeightedSound */
  7533. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7534. "use strict";
  7535. __webpack_require__.r(__webpack_exports__);
  7536. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return WeightedSound; });
  7537. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  7538. /**
  7539. * Wraps one or more Sound objects and selects one with random weight for playback.
  7540. */
  7541. var WeightedSound = /** @class */ (function () {
  7542. /**
  7543. * Creates a new WeightedSound from the list of sounds given.
  7544. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  7545. * @param sounds Array of Sounds that will be selected from.
  7546. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  7547. */
  7548. function WeightedSound(loop, sounds, weights) {
  7549. var _this = this;
  7550. /** When true a Sound will be selected and played when the current playing Sound completes. */
  7551. this.loop = false;
  7552. this._coneInnerAngle = 360;
  7553. this._coneOuterAngle = 360;
  7554. this._volume = 1;
  7555. /** A Sound is currently playing. */
  7556. this.isPlaying = false;
  7557. /** A Sound is currently paused. */
  7558. this.isPaused = false;
  7559. this._sounds = [];
  7560. this._weights = [];
  7561. if (sounds.length !== weights.length) {
  7562. throw new Error('Sounds length does not equal weights length');
  7563. }
  7564. this.loop = loop;
  7565. this._weights = weights;
  7566. // Normalize the weights
  7567. var weightSum = 0;
  7568. for (var _i = 0, weights_1 = weights; _i < weights_1.length; _i++) {
  7569. var weight = weights_1[_i];
  7570. weightSum += weight;
  7571. }
  7572. var invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
  7573. for (var i = 0; i < this._weights.length; i++) {
  7574. this._weights[i] *= invWeightSum;
  7575. }
  7576. this._sounds = sounds;
  7577. for (var _a = 0, _b = this._sounds; _a < _b.length; _a++) {
  7578. var sound = _b[_a];
  7579. sound.onEndedObservable.add(function () { _this._onended(); });
  7580. }
  7581. }
  7582. Object.defineProperty(WeightedSound.prototype, "directionalConeInnerAngle", {
  7583. /**
  7584. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  7585. */
  7586. get: function () {
  7587. return this._coneInnerAngle;
  7588. },
  7589. /**
  7590. * The size of cone in degress for a directional sound in which there will be no attenuation.
  7591. */
  7592. set: function (value) {
  7593. if (value !== this._coneInnerAngle) {
  7594. if (this._coneOuterAngle < value) {
  7595. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7596. return;
  7597. }
  7598. this._coneInnerAngle = value;
  7599. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7600. var sound = _a[_i];
  7601. sound.directionalConeInnerAngle = value;
  7602. }
  7603. }
  7604. },
  7605. enumerable: true,
  7606. configurable: true
  7607. });
  7608. Object.defineProperty(WeightedSound.prototype, "directionalConeOuterAngle", {
  7609. /**
  7610. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7611. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7612. */
  7613. get: function () {
  7614. return this._coneOuterAngle;
  7615. },
  7616. /**
  7617. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7618. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7619. */
  7620. set: function (value) {
  7621. if (value !== this._coneOuterAngle) {
  7622. if (value < this._coneInnerAngle) {
  7623. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7624. return;
  7625. }
  7626. this._coneOuterAngle = value;
  7627. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7628. var sound = _a[_i];
  7629. sound.directionalConeOuterAngle = value;
  7630. }
  7631. }
  7632. },
  7633. enumerable: true,
  7634. configurable: true
  7635. });
  7636. Object.defineProperty(WeightedSound.prototype, "volume", {
  7637. /**
  7638. * Playback volume.
  7639. */
  7640. get: function () {
  7641. return this._volume;
  7642. },
  7643. /**
  7644. * Playback volume.
  7645. */
  7646. set: function (value) {
  7647. if (value !== this._volume) {
  7648. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7649. var sound = _a[_i];
  7650. sound.setVolume(value);
  7651. }
  7652. }
  7653. },
  7654. enumerable: true,
  7655. configurable: true
  7656. });
  7657. WeightedSound.prototype._onended = function () {
  7658. if (this._currentIndex !== undefined) {
  7659. this._sounds[this._currentIndex].autoplay = false;
  7660. }
  7661. if (this.loop && this.isPlaying) {
  7662. this.play();
  7663. }
  7664. else {
  7665. this.isPlaying = false;
  7666. }
  7667. };
  7668. /**
  7669. * Suspend playback
  7670. */
  7671. WeightedSound.prototype.pause = function () {
  7672. this.isPaused = true;
  7673. if (this._currentIndex !== undefined) {
  7674. this._sounds[this._currentIndex].pause();
  7675. }
  7676. };
  7677. /**
  7678. * Stop playback
  7679. */
  7680. WeightedSound.prototype.stop = function () {
  7681. this.isPlaying = false;
  7682. if (this._currentIndex !== undefined) {
  7683. this._sounds[this._currentIndex].stop();
  7684. }
  7685. };
  7686. /**
  7687. * Start playback.
  7688. * @param startOffset Position the clip head at a specific time in seconds.
  7689. */
  7690. WeightedSound.prototype.play = function (startOffset) {
  7691. if (!this.isPaused) {
  7692. this.stop();
  7693. var randomValue = Math.random();
  7694. var total = 0;
  7695. for (var i = 0; i < this._weights.length; i++) {
  7696. total += this._weights[i];
  7697. if (randomValue <= total) {
  7698. this._currentIndex = i;
  7699. break;
  7700. }
  7701. }
  7702. }
  7703. var sound = this._sounds[this._currentIndex];
  7704. if (sound.isReady()) {
  7705. sound.play(0, this.isPaused ? undefined : startOffset);
  7706. }
  7707. else {
  7708. sound.autoplay = true;
  7709. }
  7710. this.isPlaying = true;
  7711. this.isPaused = false;
  7712. };
  7713. return WeightedSound;
  7714. }());
  7715. /***/ }),
  7716. /***/ "./Behaviors/Cameras/autoRotationBehavior.ts":
  7717. /*!***************************************************!*\
  7718. !*** ./Behaviors/Cameras/autoRotationBehavior.ts ***!
  7719. \***************************************************/
  7720. /*! exports provided: AutoRotationBehavior */
  7721. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7722. "use strict";
  7723. __webpack_require__.r(__webpack_exports__);
  7724. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return AutoRotationBehavior; });
  7725. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7726. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7727. /**
  7728. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  7729. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7730. */
  7731. var AutoRotationBehavior = /** @class */ (function () {
  7732. function AutoRotationBehavior() {
  7733. this._zoomStopsAnimation = false;
  7734. this._idleRotationSpeed = 0.05;
  7735. this._idleRotationWaitTime = 2000;
  7736. this._idleRotationSpinupTime = 2000;
  7737. this._isPointerDown = false;
  7738. this._lastFrameTime = null;
  7739. this._lastInteractionTime = -Infinity;
  7740. this._cameraRotationSpeed = 0;
  7741. this._lastFrameRadius = 0;
  7742. }
  7743. Object.defineProperty(AutoRotationBehavior.prototype, "name", {
  7744. /**
  7745. * Gets the name of the behavior.
  7746. */
  7747. get: function () {
  7748. return "AutoRotation";
  7749. },
  7750. enumerable: true,
  7751. configurable: true
  7752. });
  7753. Object.defineProperty(AutoRotationBehavior.prototype, "zoomStopsAnimation", {
  7754. /**
  7755. * Gets the flag that indicates if user zooming should stop animation.
  7756. */
  7757. get: function () {
  7758. return this._zoomStopsAnimation;
  7759. },
  7760. /**
  7761. * Sets the flag that indicates if user zooming should stop animation.
  7762. */
  7763. set: function (flag) {
  7764. this._zoomStopsAnimation = flag;
  7765. },
  7766. enumerable: true,
  7767. configurable: true
  7768. });
  7769. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpeed", {
  7770. /**
  7771. * Gets the default speed at which the camera rotates around the model.
  7772. */
  7773. get: function () {
  7774. return this._idleRotationSpeed;
  7775. },
  7776. /**
  7777. * Sets the default speed at which the camera rotates around the model.
  7778. */
  7779. set: function (speed) {
  7780. this._idleRotationSpeed = speed;
  7781. },
  7782. enumerable: true,
  7783. configurable: true
  7784. });
  7785. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationWaitTime", {
  7786. /**
  7787. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  7788. */
  7789. get: function () {
  7790. return this._idleRotationWaitTime;
  7791. },
  7792. /**
  7793. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  7794. */
  7795. set: function (time) {
  7796. this._idleRotationWaitTime = time;
  7797. },
  7798. enumerable: true,
  7799. configurable: true
  7800. });
  7801. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpinupTime", {
  7802. /**
  7803. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7804. */
  7805. get: function () {
  7806. return this._idleRotationSpinupTime;
  7807. },
  7808. /**
  7809. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7810. */
  7811. set: function (time) {
  7812. this._idleRotationSpinupTime = time;
  7813. },
  7814. enumerable: true,
  7815. configurable: true
  7816. });
  7817. Object.defineProperty(AutoRotationBehavior.prototype, "rotationInProgress", {
  7818. /**
  7819. * Gets a value indicating if the camera is currently rotating because of this behavior
  7820. */
  7821. get: function () {
  7822. return Math.abs(this._cameraRotationSpeed) > 0;
  7823. },
  7824. enumerable: true,
  7825. configurable: true
  7826. });
  7827. /**
  7828. * Initializes the behavior.
  7829. */
  7830. AutoRotationBehavior.prototype.init = function () {
  7831. // Do notihng
  7832. };
  7833. /**
  7834. * Attaches the behavior to its arc rotate camera.
  7835. * @param camera Defines the camera to attach the behavior to
  7836. */
  7837. AutoRotationBehavior.prototype.attach = function (camera) {
  7838. var _this = this;
  7839. this._attachedCamera = camera;
  7840. var scene = this._attachedCamera.getScene();
  7841. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7842. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  7843. _this._isPointerDown = true;
  7844. return;
  7845. }
  7846. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  7847. _this._isPointerDown = false;
  7848. }
  7849. });
  7850. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7851. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7852. var dt = 0;
  7853. if (_this._lastFrameTime != null) {
  7854. dt = now - _this._lastFrameTime;
  7855. }
  7856. _this._lastFrameTime = now;
  7857. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7858. _this._applyUserInteraction();
  7859. var timeToRotation = now - _this._lastInteractionTime - _this._idleRotationWaitTime;
  7860. var scale = Math.max(Math.min(timeToRotation / (_this._idleRotationSpinupTime), 1), 0);
  7861. _this._cameraRotationSpeed = _this._idleRotationSpeed * scale;
  7862. // Step camera rotation by rotation speed
  7863. if (_this._attachedCamera) {
  7864. _this._attachedCamera.alpha -= _this._cameraRotationSpeed * (dt / 1000);
  7865. }
  7866. });
  7867. };
  7868. /**
  7869. * Detaches the behavior from its current arc rotate camera.
  7870. */
  7871. AutoRotationBehavior.prototype.detach = function () {
  7872. if (!this._attachedCamera) {
  7873. return;
  7874. }
  7875. var scene = this._attachedCamera.getScene();
  7876. if (this._onPrePointerObservableObserver) {
  7877. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  7878. }
  7879. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7880. this._attachedCamera = null;
  7881. };
  7882. /**
  7883. * Returns true if user is scrolling.
  7884. * @return true if user is scrolling.
  7885. */
  7886. AutoRotationBehavior.prototype._userIsZooming = function () {
  7887. if (!this._attachedCamera) {
  7888. return false;
  7889. }
  7890. return this._attachedCamera.inertialRadiusOffset !== 0;
  7891. };
  7892. AutoRotationBehavior.prototype._shouldAnimationStopForInteraction = function () {
  7893. if (!this._attachedCamera) {
  7894. return false;
  7895. }
  7896. var zoomHasHitLimit = false;
  7897. if (this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0) {
  7898. zoomHasHitLimit = true;
  7899. }
  7900. // Update the record of previous radius - works as an approx. indicator of hitting radius limits
  7901. this._lastFrameRadius = this._attachedCamera.radius;
  7902. return this._zoomStopsAnimation ? zoomHasHitLimit : this._userIsZooming();
  7903. };
  7904. /**
  7905. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  7906. */
  7907. AutoRotationBehavior.prototype._applyUserInteraction = function () {
  7908. if (this._userIsMoving() && !this._shouldAnimationStopForInteraction()) {
  7909. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7910. }
  7911. };
  7912. // Tools
  7913. AutoRotationBehavior.prototype._userIsMoving = function () {
  7914. if (!this._attachedCamera) {
  7915. return false;
  7916. }
  7917. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  7918. this._attachedCamera.inertialBetaOffset !== 0 ||
  7919. this._attachedCamera.inertialRadiusOffset !== 0 ||
  7920. this._attachedCamera.inertialPanningX !== 0 ||
  7921. this._attachedCamera.inertialPanningY !== 0 ||
  7922. this._isPointerDown;
  7923. };
  7924. return AutoRotationBehavior;
  7925. }());
  7926. /***/ }),
  7927. /***/ "./Behaviors/Cameras/bouncingBehavior.ts":
  7928. /*!***********************************************!*\
  7929. !*** ./Behaviors/Cameras/bouncingBehavior.ts ***!
  7930. \***********************************************/
  7931. /*! exports provided: BouncingBehavior */
  7932. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7933. "use strict";
  7934. __webpack_require__.r(__webpack_exports__);
  7935. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return BouncingBehavior; });
  7936. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  7937. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  7938. /**
  7939. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  7940. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7941. */
  7942. var BouncingBehavior = /** @class */ (function () {
  7943. function BouncingBehavior() {
  7944. /**
  7945. * The duration of the animation, in milliseconds
  7946. */
  7947. this.transitionDuration = 450;
  7948. /**
  7949. * Length of the distance animated by the transition when lower radius is reached
  7950. */
  7951. this.lowerRadiusTransitionRange = 2;
  7952. /**
  7953. * Length of the distance animated by the transition when upper radius is reached
  7954. */
  7955. this.upperRadiusTransitionRange = -2;
  7956. this._autoTransitionRange = false;
  7957. // Animations
  7958. this._radiusIsAnimating = false;
  7959. this._radiusBounceTransition = null;
  7960. this._animatables = new Array();
  7961. }
  7962. Object.defineProperty(BouncingBehavior.prototype, "name", {
  7963. /**
  7964. * Gets the name of the behavior.
  7965. */
  7966. get: function () {
  7967. return "Bouncing";
  7968. },
  7969. enumerable: true,
  7970. configurable: true
  7971. });
  7972. Object.defineProperty(BouncingBehavior.prototype, "autoTransitionRange", {
  7973. /**
  7974. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7975. */
  7976. get: function () {
  7977. return this._autoTransitionRange;
  7978. },
  7979. /**
  7980. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7981. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  7982. */
  7983. set: function (value) {
  7984. var _this = this;
  7985. if (this._autoTransitionRange === value) {
  7986. return;
  7987. }
  7988. this._autoTransitionRange = value;
  7989. var camera = this._attachedCamera;
  7990. if (!camera) {
  7991. return;
  7992. }
  7993. if (value) {
  7994. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  7995. if (!mesh) {
  7996. return;
  7997. }
  7998. mesh.computeWorldMatrix(true);
  7999. var diagonal = mesh.getBoundingInfo().diagonalLength;
  8000. _this.lowerRadiusTransitionRange = diagonal * 0.05;
  8001. _this.upperRadiusTransitionRange = diagonal * 0.05;
  8002. });
  8003. }
  8004. else if (this._onMeshTargetChangedObserver) {
  8005. camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8006. }
  8007. },
  8008. enumerable: true,
  8009. configurable: true
  8010. });
  8011. /**
  8012. * Initializes the behavior.
  8013. */
  8014. BouncingBehavior.prototype.init = function () {
  8015. // Do notihng
  8016. };
  8017. /**
  8018. * Attaches the behavior to its arc rotate camera.
  8019. * @param camera Defines the camera to attach the behavior to
  8020. */
  8021. BouncingBehavior.prototype.attach = function (camera) {
  8022. var _this = this;
  8023. this._attachedCamera = camera;
  8024. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8025. if (!_this._attachedCamera) {
  8026. return;
  8027. }
  8028. // Add the bounce animation to the lower radius limit
  8029. if (_this._isRadiusAtLimit(_this._attachedCamera.lowerRadiusLimit)) {
  8030. _this._applyBoundRadiusAnimation(_this.lowerRadiusTransitionRange);
  8031. }
  8032. // Add the bounce animation to the upper radius limit
  8033. if (_this._isRadiusAtLimit(_this._attachedCamera.upperRadiusLimit)) {
  8034. _this._applyBoundRadiusAnimation(_this.upperRadiusTransitionRange);
  8035. }
  8036. });
  8037. };
  8038. /**
  8039. * Detaches the behavior from its current arc rotate camera.
  8040. */
  8041. BouncingBehavior.prototype.detach = function () {
  8042. if (!this._attachedCamera) {
  8043. return;
  8044. }
  8045. if (this._onAfterCheckInputsObserver) {
  8046. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8047. }
  8048. if (this._onMeshTargetChangedObserver) {
  8049. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8050. }
  8051. this._attachedCamera = null;
  8052. };
  8053. /**
  8054. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  8055. * @param radiusLimit The limit to check against.
  8056. * @return Bool to indicate if at limit.
  8057. */
  8058. BouncingBehavior.prototype._isRadiusAtLimit = function (radiusLimit) {
  8059. if (!this._attachedCamera) {
  8060. return false;
  8061. }
  8062. if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
  8063. return true;
  8064. }
  8065. return false;
  8066. };
  8067. /**
  8068. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  8069. * @param radiusDelta The delta by which to animate to. Can be negative.
  8070. */
  8071. BouncingBehavior.prototype._applyBoundRadiusAnimation = function (radiusDelta) {
  8072. var _this = this;
  8073. if (!this._attachedCamera) {
  8074. return;
  8075. }
  8076. if (!this._radiusBounceTransition) {
  8077. BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
  8078. this._radiusBounceTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
  8079. }
  8080. // Prevent zoom until bounce has completed
  8081. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;
  8082. this._attachedCamera.wheelPrecision = Infinity;
  8083. this._attachedCamera.inertialRadiusOffset = 0;
  8084. // Animate to the radius limit
  8085. this.stopAllAnimations();
  8086. this._radiusIsAnimating = true;
  8087. 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(); });
  8088. if (animatable) {
  8089. this._animatables.push(animatable);
  8090. }
  8091. };
  8092. /**
  8093. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  8094. */
  8095. BouncingBehavior.prototype._clearAnimationLocks = function () {
  8096. this._radiusIsAnimating = false;
  8097. if (this._attachedCamera) {
  8098. this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
  8099. }
  8100. };
  8101. /**
  8102. * Stops and removes all animations that have been applied to the camera
  8103. */
  8104. BouncingBehavior.prototype.stopAllAnimations = function () {
  8105. if (this._attachedCamera) {
  8106. this._attachedCamera.animations = [];
  8107. }
  8108. while (this._animatables.length) {
  8109. this._animatables[0].onAnimationEnd = null;
  8110. this._animatables[0].stop();
  8111. this._animatables.shift();
  8112. }
  8113. };
  8114. /**
  8115. * The easing function used by animations
  8116. */
  8117. BouncingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["BackEase"](0.3);
  8118. /**
  8119. * The easing mode used by animations
  8120. */
  8121. BouncingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEOUT;
  8122. return BouncingBehavior;
  8123. }());
  8124. /***/ }),
  8125. /***/ "./Behaviors/Cameras/framingBehavior.ts":
  8126. /*!**********************************************!*\
  8127. !*** ./Behaviors/Cameras/framingBehavior.ts ***!
  8128. \**********************************************/
  8129. /*! exports provided: FramingBehavior */
  8130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8131. "use strict";
  8132. __webpack_require__.r(__webpack_exports__);
  8133. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return FramingBehavior; });
  8134. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  8135. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  8136. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  8137. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  8138. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8139. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  8140. /**
  8141. * 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.
  8142. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8143. */
  8144. var FramingBehavior = /** @class */ (function () {
  8145. function FramingBehavior() {
  8146. this._mode = FramingBehavior.FitFrustumSidesMode;
  8147. this._radiusScale = 1.0;
  8148. this._positionScale = 0.5;
  8149. this._defaultElevation = 0.3;
  8150. this._elevationReturnTime = 1500;
  8151. this._elevationReturnWaitTime = 1000;
  8152. this._zoomStopsAnimation = false;
  8153. this._framingTime = 1500;
  8154. /**
  8155. * Define if the behavior should automatically change the configured
  8156. * camera limits and sensibilities.
  8157. */
  8158. this.autoCorrectCameraLimitsAndSensibility = true;
  8159. this._isPointerDown = false;
  8160. this._lastInteractionTime = -Infinity;
  8161. // Framing control
  8162. this._animatables = new Array();
  8163. this._betaIsAnimating = false;
  8164. }
  8165. Object.defineProperty(FramingBehavior.prototype, "name", {
  8166. /**
  8167. * Gets the name of the behavior.
  8168. */
  8169. get: function () {
  8170. return "Framing";
  8171. },
  8172. enumerable: true,
  8173. configurable: true
  8174. });
  8175. Object.defineProperty(FramingBehavior.prototype, "mode", {
  8176. /**
  8177. * Gets current mode used by the behavior.
  8178. */
  8179. get: function () {
  8180. return this._mode;
  8181. },
  8182. /**
  8183. * Sets the current mode used by the behavior
  8184. */
  8185. set: function (mode) {
  8186. this._mode = mode;
  8187. },
  8188. enumerable: true,
  8189. configurable: true
  8190. });
  8191. Object.defineProperty(FramingBehavior.prototype, "radiusScale", {
  8192. /**
  8193. * Gets the scale applied to the radius
  8194. */
  8195. get: function () {
  8196. return this._radiusScale;
  8197. },
  8198. /**
  8199. * Sets the scale applied to the radius (1 by default)
  8200. */
  8201. set: function (radius) {
  8202. this._radiusScale = radius;
  8203. },
  8204. enumerable: true,
  8205. configurable: true
  8206. });
  8207. Object.defineProperty(FramingBehavior.prototype, "positionScale", {
  8208. /**
  8209. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8210. */
  8211. get: function () {
  8212. return this._positionScale;
  8213. },
  8214. /**
  8215. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8216. */
  8217. set: function (scale) {
  8218. this._positionScale = scale;
  8219. },
  8220. enumerable: true,
  8221. configurable: true
  8222. });
  8223. Object.defineProperty(FramingBehavior.prototype, "defaultElevation", {
  8224. /**
  8225. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8226. * behaviour is triggered, in radians.
  8227. */
  8228. get: function () {
  8229. return this._defaultElevation;
  8230. },
  8231. /**
  8232. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8233. * behaviour is triggered, in radians.
  8234. */
  8235. set: function (elevation) {
  8236. this._defaultElevation = elevation;
  8237. },
  8238. enumerable: true,
  8239. configurable: true
  8240. });
  8241. Object.defineProperty(FramingBehavior.prototype, "elevationReturnTime", {
  8242. /**
  8243. * Gets the time (in milliseconds) taken to return to the default beta position.
  8244. * Negative value indicates camera should not return to default.
  8245. */
  8246. get: function () {
  8247. return this._elevationReturnTime;
  8248. },
  8249. /**
  8250. * Sets the time (in milliseconds) taken to return to the default beta position.
  8251. * Negative value indicates camera should not return to default.
  8252. */
  8253. set: function (speed) {
  8254. this._elevationReturnTime = speed;
  8255. },
  8256. enumerable: true,
  8257. configurable: true
  8258. });
  8259. Object.defineProperty(FramingBehavior.prototype, "elevationReturnWaitTime", {
  8260. /**
  8261. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8262. */
  8263. get: function () {
  8264. return this._elevationReturnWaitTime;
  8265. },
  8266. /**
  8267. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8268. */
  8269. set: function (time) {
  8270. this._elevationReturnWaitTime = time;
  8271. },
  8272. enumerable: true,
  8273. configurable: true
  8274. });
  8275. Object.defineProperty(FramingBehavior.prototype, "zoomStopsAnimation", {
  8276. /**
  8277. * Gets the flag that indicates if user zooming should stop animation.
  8278. */
  8279. get: function () {
  8280. return this._zoomStopsAnimation;
  8281. },
  8282. /**
  8283. * Sets the flag that indicates if user zooming should stop animation.
  8284. */
  8285. set: function (flag) {
  8286. this._zoomStopsAnimation = flag;
  8287. },
  8288. enumerable: true,
  8289. configurable: true
  8290. });
  8291. Object.defineProperty(FramingBehavior.prototype, "framingTime", {
  8292. /**
  8293. * Gets the transition time when framing the mesh, in milliseconds
  8294. */
  8295. get: function () {
  8296. return this._framingTime;
  8297. },
  8298. /**
  8299. * Sets the transition time when framing the mesh, in milliseconds
  8300. */
  8301. set: function (time) {
  8302. this._framingTime = time;
  8303. },
  8304. enumerable: true,
  8305. configurable: true
  8306. });
  8307. /**
  8308. * Initializes the behavior.
  8309. */
  8310. FramingBehavior.prototype.init = function () {
  8311. // Do notihng
  8312. };
  8313. /**
  8314. * Attaches the behavior to its arc rotate camera.
  8315. * @param camera Defines the camera to attach the behavior to
  8316. */
  8317. FramingBehavior.prototype.attach = function (camera) {
  8318. var _this = this;
  8319. this._attachedCamera = camera;
  8320. var scene = this._attachedCamera.getScene();
  8321. FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
  8322. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  8323. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  8324. _this._isPointerDown = true;
  8325. return;
  8326. }
  8327. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  8328. _this._isPointerDown = false;
  8329. }
  8330. });
  8331. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8332. if (mesh) {
  8333. _this.zoomOnMesh(mesh);
  8334. }
  8335. });
  8336. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8337. // Stop the animation if there is user interaction and the animation should stop for this interaction
  8338. _this._applyUserInteraction();
  8339. // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it
  8340. // back to the default position after a given timeout
  8341. _this._maintainCameraAboveGround();
  8342. });
  8343. };
  8344. /**
  8345. * Detaches the behavior from its current arc rotate camera.
  8346. */
  8347. FramingBehavior.prototype.detach = function () {
  8348. if (!this._attachedCamera) {
  8349. return;
  8350. }
  8351. var scene = this._attachedCamera.getScene();
  8352. if (this._onPrePointerObservableObserver) {
  8353. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  8354. }
  8355. if (this._onAfterCheckInputsObserver) {
  8356. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8357. }
  8358. if (this._onMeshTargetChangedObserver) {
  8359. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8360. }
  8361. this._attachedCamera = null;
  8362. };
  8363. /**
  8364. * Targets the given mesh and updates zoom level accordingly.
  8365. * @param mesh The mesh to target.
  8366. * @param radius Optional. If a cached radius position already exists, overrides default.
  8367. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8368. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8369. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8370. */
  8371. FramingBehavior.prototype.zoomOnMesh = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8372. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8373. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8374. mesh.computeWorldMatrix(true);
  8375. var boundingBox = mesh.getBoundingInfo().boundingBox;
  8376. this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
  8377. };
  8378. /**
  8379. * Targets the given mesh with its children and updates zoom level accordingly.
  8380. * @param mesh The mesh to target.
  8381. * @param radius Optional. If a cached radius position already exists, overrides default.
  8382. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8383. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8384. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8385. */
  8386. FramingBehavior.prototype.zoomOnMeshHierarchy = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8387. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8388. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8389. mesh.computeWorldMatrix(true);
  8390. var boundingBox = mesh.getHierarchyBoundingVectors(true);
  8391. this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
  8392. };
  8393. /**
  8394. * Targets the given meshes with their children and updates zoom level accordingly.
  8395. * @param meshes The mesh to target.
  8396. * @param radius Optional. If a cached radius position already exists, overrides default.
  8397. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8398. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8399. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8400. */
  8401. FramingBehavior.prototype.zoomOnMeshesHierarchy = function (meshes, focusOnOriginXZ, onAnimationEnd) {
  8402. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8403. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8404. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  8405. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  8406. for (var i = 0; i < meshes.length; i++) {
  8407. var boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
  8408. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.min, min, max);
  8409. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.max, min, max);
  8410. }
  8411. this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
  8412. };
  8413. /**
  8414. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  8415. * @param minimumWorld Determines the smaller position of the bounding box extend
  8416. * @param maximumWorld Determines the bigger position of the bounding box extend
  8417. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8418. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8419. */
  8420. FramingBehavior.prototype.zoomOnBoundingInfo = function (minimumWorld, maximumWorld, focusOnOriginXZ, onAnimationEnd) {
  8421. var _this = this;
  8422. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8423. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8424. var zoomTarget;
  8425. if (!this._attachedCamera) {
  8426. return;
  8427. }
  8428. // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
  8429. var bottom = minimumWorld.y;
  8430. var top = maximumWorld.y;
  8431. var zoomTargetY = bottom + (top - bottom) * this._positionScale;
  8432. var radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
  8433. if (focusOnOriginXZ) {
  8434. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, zoomTargetY, 0);
  8435. }
  8436. else {
  8437. var centerWorld = minimumWorld.add(radiusWorld);
  8438. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](centerWorld.x, zoomTargetY, centerWorld.z);
  8439. }
  8440. if (!this._vectorTransition) {
  8441. this._vectorTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("target", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
  8442. }
  8443. this._betaIsAnimating = true;
  8444. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  8445. if (animatable) {
  8446. this._animatables.push(animatable);
  8447. }
  8448. // sets the radius and lower radius bounds
  8449. // Small delta ensures camera is not always at lower zoom limit.
  8450. var radius = 0;
  8451. if (this._mode === FramingBehavior.FitFrustumSidesMode) {
  8452. var position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8453. if (this.autoCorrectCameraLimitsAndSensibility) {
  8454. this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
  8455. }
  8456. radius = position;
  8457. }
  8458. else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8459. radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8460. if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {
  8461. this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
  8462. }
  8463. }
  8464. // Set sensibilities
  8465. if (this.autoCorrectCameraLimitsAndSensibility) {
  8466. var extend = maximumWorld.subtract(minimumWorld).length();
  8467. this._attachedCamera.panningSensibility = 5000 / extend;
  8468. this._attachedCamera.wheelPrecision = 100 / radius;
  8469. }
  8470. // transition to new radius
  8471. if (!this._radiusTransition) {
  8472. this._radiusTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8473. }
  8474. animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
  8475. _this.stopAllAnimations();
  8476. if (onAnimationEnd) {
  8477. onAnimationEnd();
  8478. }
  8479. if (_this._attachedCamera && _this._attachedCamera.useInputToRestoreState) {
  8480. _this._attachedCamera.storeState();
  8481. }
  8482. });
  8483. if (animatable) {
  8484. this._animatables.push(animatable);
  8485. }
  8486. };
  8487. /**
  8488. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  8489. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  8490. * frustum width.
  8491. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  8492. * to fully enclose the mesh in the viewing frustum.
  8493. */
  8494. FramingBehavior.prototype._calculateLowerRadiusFromModelBoundingSphere = function (minimumWorld, maximumWorld) {
  8495. var size = maximumWorld.subtract(minimumWorld);
  8496. var boxVectorGlobalDiagonal = size.length();
  8497. var frustumSlope = this._getFrustumSlope();
  8498. // Formula for setting distance
  8499. // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
  8500. var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
  8501. // Horizon distance
  8502. var radius = radiusWithoutFraming * this._radiusScale;
  8503. var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
  8504. var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
  8505. var distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
  8506. var camera = this._attachedCamera;
  8507. if (!camera) {
  8508. return 0;
  8509. }
  8510. if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8511. // Don't exceed the requested limit
  8512. distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
  8513. }
  8514. // Don't exceed the upper radius limit
  8515. if (camera.upperRadiusLimit) {
  8516. distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
  8517. }
  8518. return distance;
  8519. };
  8520. /**
  8521. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  8522. * is automatically returned to its default position (expected to be above ground plane).
  8523. */
  8524. FramingBehavior.prototype._maintainCameraAboveGround = function () {
  8525. var _this = this;
  8526. if (this._elevationReturnTime < 0) {
  8527. return;
  8528. }
  8529. var timeSinceInteraction = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now - this._lastInteractionTime;
  8530. var defaultBeta = Math.PI * 0.5 - this._defaultElevation;
  8531. var limitBeta = Math.PI * 0.5;
  8532. // Bring the camera back up if below the ground plane
  8533. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
  8534. this._betaIsAnimating = true;
  8535. //Transition to new position
  8536. this.stopAllAnimations();
  8537. if (!this._betaTransition) {
  8538. this._betaTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("beta", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8539. }
  8540. var animatabe = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function () {
  8541. _this._clearAnimationLocks();
  8542. _this.stopAllAnimations();
  8543. });
  8544. if (animatabe) {
  8545. this._animatables.push(animatabe);
  8546. }
  8547. }
  8548. };
  8549. /**
  8550. * Returns the frustum slope based on the canvas ratio and camera FOV
  8551. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  8552. */
  8553. FramingBehavior.prototype._getFrustumSlope = function () {
  8554. // Calculate the viewport ratio
  8555. // Aspect Ratio is Height/Width.
  8556. var camera = this._attachedCamera;
  8557. if (!camera) {
  8558. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"].Zero();
  8559. }
  8560. var engine = camera.getScene().getEngine();
  8561. var aspectRatio = engine.getAspectRatio(camera);
  8562. // Camera FOV is the vertical field of view (top-bottom) in radians.
  8563. // Slope of the frustum top/bottom planes in view space, relative to the forward vector.
  8564. var frustumSlopeY = Math.tan(camera.fov / 2);
  8565. // Slope of the frustum left/right planes in view space, relative to the forward vector.
  8566. // Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
  8567. // along the forward vector.
  8568. var frustumSlopeX = frustumSlopeY * aspectRatio;
  8569. return new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](frustumSlopeX, frustumSlopeY);
  8570. };
  8571. /**
  8572. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  8573. */
  8574. FramingBehavior.prototype._clearAnimationLocks = function () {
  8575. this._betaIsAnimating = false;
  8576. };
  8577. /**
  8578. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  8579. */
  8580. FramingBehavior.prototype._applyUserInteraction = function () {
  8581. if (this.isUserIsMoving) {
  8582. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now;
  8583. this.stopAllAnimations();
  8584. this._clearAnimationLocks();
  8585. }
  8586. };
  8587. /**
  8588. * Stops and removes all animations that have been applied to the camera
  8589. */
  8590. FramingBehavior.prototype.stopAllAnimations = function () {
  8591. if (this._attachedCamera) {
  8592. this._attachedCamera.animations = [];
  8593. }
  8594. while (this._animatables.length) {
  8595. if (this._animatables[0]) {
  8596. this._animatables[0].onAnimationEnd = null;
  8597. this._animatables[0].stop();
  8598. }
  8599. this._animatables.shift();
  8600. }
  8601. };
  8602. Object.defineProperty(FramingBehavior.prototype, "isUserIsMoving", {
  8603. /**
  8604. * Gets a value indicating if the user is moving the camera
  8605. */
  8606. get: function () {
  8607. if (!this._attachedCamera) {
  8608. return false;
  8609. }
  8610. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8611. this._attachedCamera.inertialBetaOffset !== 0 ||
  8612. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8613. this._attachedCamera.inertialPanningX !== 0 ||
  8614. this._attachedCamera.inertialPanningY !== 0 ||
  8615. this._isPointerDown;
  8616. },
  8617. enumerable: true,
  8618. configurable: true
  8619. });
  8620. /**
  8621. * The easing function used by animations
  8622. */
  8623. FramingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]();
  8624. /**
  8625. * The easing mode used by animations
  8626. */
  8627. FramingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEINOUT;
  8628. // Statics
  8629. /**
  8630. * The camera can move all the way towards the mesh.
  8631. */
  8632. FramingBehavior.IgnoreBoundsSizeMode = 0;
  8633. /**
  8634. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  8635. */
  8636. FramingBehavior.FitFrustumSidesMode = 1;
  8637. return FramingBehavior;
  8638. }());
  8639. /***/ }),
  8640. /***/ "./Behaviors/Cameras/index.ts":
  8641. /*!************************************!*\
  8642. !*** ./Behaviors/Cameras/index.ts ***!
  8643. \************************************/
  8644. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior */
  8645. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8646. "use strict";
  8647. __webpack_require__.r(__webpack_exports__);
  8648. /* harmony import */ var _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  8649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  8650. /* harmony import */ var _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  8651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__["BouncingBehavior"]; });
  8652. /* harmony import */ var _framingBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  8653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _framingBehavior__WEBPACK_IMPORTED_MODULE_2__["FramingBehavior"]; });
  8654. /***/ }),
  8655. /***/ "./Behaviors/Meshes/attachToBoxBehavior.ts":
  8656. /*!*************************************************!*\
  8657. !*** ./Behaviors/Meshes/attachToBoxBehavior.ts ***!
  8658. \*************************************************/
  8659. /*! exports provided: AttachToBoxBehavior */
  8660. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8661. "use strict";
  8662. __webpack_require__.r(__webpack_exports__);
  8663. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return AttachToBoxBehavior; });
  8664. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8665. /**
  8666. * @hidden
  8667. */
  8668. var FaceDirectionInfo = /** @class */ (function () {
  8669. function FaceDirectionInfo(direction, rotatedDirection, diff, ignore) {
  8670. if (rotatedDirection === void 0) { rotatedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](); }
  8671. if (diff === void 0) { diff = 0; }
  8672. if (ignore === void 0) { ignore = false; }
  8673. this.direction = direction;
  8674. this.rotatedDirection = rotatedDirection;
  8675. this.diff = diff;
  8676. this.ignore = ignore;
  8677. }
  8678. return FaceDirectionInfo;
  8679. }());
  8680. /**
  8681. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  8682. */
  8683. var AttachToBoxBehavior = /** @class */ (function () {
  8684. /**
  8685. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  8686. * @param ui The transform node that should be attched to the mesh
  8687. */
  8688. function AttachToBoxBehavior(ui) {
  8689. this.ui = ui;
  8690. /**
  8691. * The name of the behavior
  8692. */
  8693. this.name = "AttachToBoxBehavior";
  8694. /**
  8695. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  8696. */
  8697. this.distanceAwayFromFace = 0.15;
  8698. /**
  8699. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  8700. */
  8701. this.distanceAwayFromBottomOfFace = 0.15;
  8702. 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))];
  8703. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8704. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  8705. this._zeroVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  8706. this._lookAtTmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8707. /* Does nothing */
  8708. }
  8709. /**
  8710. * Initializes the behavior
  8711. */
  8712. AttachToBoxBehavior.prototype.init = function () {
  8713. /* Does nothing */
  8714. };
  8715. AttachToBoxBehavior.prototype._closestFace = function (targetDirection) {
  8716. var _this = this;
  8717. // Go over each face and calculate the angle between the face's normal and targetDirection
  8718. this._faceVectors.forEach(function (v) {
  8719. if (!_this._target.rotationQuaternion) {
  8720. _this._target.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this._target.rotation.y, _this._target.rotation.x, _this._target.rotation.z);
  8721. }
  8722. _this._target.rotationQuaternion.toRotationMatrix(_this._tmpMatrix);
  8723. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(v.direction, _this._tmpMatrix, v.rotatedDirection);
  8724. v.diff = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetAngleBetweenVectors(v.rotatedDirection, targetDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v.rotatedDirection, targetDirection));
  8725. });
  8726. // Return the face information of the one with the normal closeset to target direction
  8727. return this._faceVectors.reduce(function (min, p) {
  8728. if (min.ignore) {
  8729. return p;
  8730. }
  8731. else if (p.ignore) {
  8732. return min;
  8733. }
  8734. else {
  8735. return min.diff < p.diff ? min : p;
  8736. }
  8737. }, this._faceVectors[0]);
  8738. };
  8739. AttachToBoxBehavior.prototype._lookAtToRef = function (pos, up, ref) {
  8740. if (up === void 0) { up = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0); }
  8741. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);
  8742. this._lookAtTmpMatrix.invert();
  8743. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);
  8744. };
  8745. /**
  8746. * Attaches the AttachToBoxBehavior to the passed in mesh
  8747. * @param target The mesh that the specified node will be attached to
  8748. */
  8749. AttachToBoxBehavior.prototype.attach = function (target) {
  8750. var _this = this;
  8751. this._target = target;
  8752. this._scene = this._target.getScene();
  8753. // Every frame, update the app bars position
  8754. this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8755. if (!_this._scene.activeCamera) {
  8756. return;
  8757. }
  8758. // Find the face closest to the cameras position
  8759. var cameraPos = _this._scene.activeCamera.position;
  8760. if (_this._scene.activeCamera.devicePosition) {
  8761. cameraPos = _this._scene.activeCamera.devicePosition;
  8762. }
  8763. var facing = _this._closestFace(cameraPos.subtract(target.position));
  8764. if (_this._scene.activeCamera.leftCamera) {
  8765. _this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8766. }
  8767. else {
  8768. _this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8769. }
  8770. // Get camera up direction
  8771. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _this._tmpMatrix, _this._tmpVector);
  8772. // Ignore faces to not select a parrelel face for the up vector of the UI
  8773. _this._faceVectors.forEach(function (v) {
  8774. if (facing.direction.x && v.direction.x) {
  8775. v.ignore = true;
  8776. }
  8777. if (facing.direction.y && v.direction.y) {
  8778. v.ignore = true;
  8779. }
  8780. if (facing.direction.z && v.direction.z) {
  8781. v.ignore = true;
  8782. }
  8783. });
  8784. var facingUp = _this._closestFace(_this._tmpVector);
  8785. // Unignore faces
  8786. _this._faceVectors.forEach(function (v) {
  8787. v.ignore = false;
  8788. });
  8789. // Position the app bar on that face
  8790. _this.ui.position.copyFrom(target.position);
  8791. if (facing.direction.x) {
  8792. facing.rotatedDirection.scaleToRef((target.scaling.x / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8793. _this.ui.position.addInPlace(_this._tmpVector);
  8794. }
  8795. if (facing.direction.y) {
  8796. facing.rotatedDirection.scaleToRef((target.scaling.y / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8797. _this.ui.position.addInPlace(_this._tmpVector);
  8798. }
  8799. if (facing.direction.z) {
  8800. facing.rotatedDirection.scaleToRef((target.scaling.z / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8801. _this.ui.position.addInPlace(_this._tmpVector);
  8802. }
  8803. // Rotate to be oriented properly to the camera
  8804. if (!_this.ui.rotationQuaternion) {
  8805. _this.ui.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this.ui.rotation.y, _this.ui.rotation.x, _this.ui.rotation.z);
  8806. }
  8807. facing.rotatedDirection.scaleToRef(-1, _this._tmpVector);
  8808. _this._lookAtToRef(_this._tmpVector, facingUp.rotatedDirection, _this.ui.rotationQuaternion);
  8809. // Place ui the correct distance from the bottom of the mesh
  8810. if (facingUp.direction.x) {
  8811. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.x / 2, _this._tmpVector);
  8812. }
  8813. if (facingUp.direction.y) {
  8814. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.y / 2, _this._tmpVector);
  8815. }
  8816. if (facingUp.direction.z) {
  8817. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.z / 2, _this._tmpVector);
  8818. }
  8819. _this.ui.position.addInPlace(_this._tmpVector);
  8820. });
  8821. };
  8822. /**
  8823. * Detaches the behavior from the mesh
  8824. */
  8825. AttachToBoxBehavior.prototype.detach = function () {
  8826. this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
  8827. };
  8828. return AttachToBoxBehavior;
  8829. }());
  8830. /***/ }),
  8831. /***/ "./Behaviors/Meshes/fadeInOutBehavior.ts":
  8832. /*!***********************************************!*\
  8833. !*** ./Behaviors/Meshes/fadeInOutBehavior.ts ***!
  8834. \***********************************************/
  8835. /*! exports provided: FadeInOutBehavior */
  8836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8837. "use strict";
  8838. __webpack_require__.r(__webpack_exports__);
  8839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return FadeInOutBehavior; });
  8840. /**
  8841. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  8842. */
  8843. var FadeInOutBehavior = /** @class */ (function () {
  8844. /**
  8845. * Instatiates the FadeInOutBehavior
  8846. */
  8847. function FadeInOutBehavior() {
  8848. var _this = this;
  8849. /**
  8850. * Time in milliseconds to delay before fading in (Default: 0)
  8851. */
  8852. this.delay = 0;
  8853. /**
  8854. * Time in milliseconds for the mesh to fade in (Default: 300)
  8855. */
  8856. this.fadeInTime = 300;
  8857. this._millisecondsPerFrame = 1000 / 60;
  8858. this._hovered = false;
  8859. this._hoverValue = 0;
  8860. this._ownerNode = null;
  8861. this._update = function () {
  8862. if (_this._ownerNode) {
  8863. _this._hoverValue += _this._hovered ? _this._millisecondsPerFrame : -_this._millisecondsPerFrame;
  8864. _this._setAllVisibility(_this._ownerNode, (_this._hoverValue - _this.delay) / _this.fadeInTime);
  8865. if (_this._ownerNode.visibility > 1) {
  8866. _this._setAllVisibility(_this._ownerNode, 1);
  8867. _this._hoverValue = _this.fadeInTime + _this.delay;
  8868. return;
  8869. }
  8870. else if (_this._ownerNode.visibility < 0) {
  8871. _this._setAllVisibility(_this._ownerNode, 0);
  8872. if (_this._hoverValue < 0) {
  8873. _this._hoverValue = 0;
  8874. return;
  8875. }
  8876. }
  8877. setTimeout(_this._update, _this._millisecondsPerFrame);
  8878. }
  8879. };
  8880. }
  8881. Object.defineProperty(FadeInOutBehavior.prototype, "name", {
  8882. /**
  8883. * The name of the behavior
  8884. */
  8885. get: function () {
  8886. return "FadeInOut";
  8887. },
  8888. enumerable: true,
  8889. configurable: true
  8890. });
  8891. /**
  8892. * Initializes the behavior
  8893. */
  8894. FadeInOutBehavior.prototype.init = function () {
  8895. };
  8896. /**
  8897. * Attaches the fade behavior on the passed in mesh
  8898. * @param ownerNode The mesh that will be faded in/out once attached
  8899. */
  8900. FadeInOutBehavior.prototype.attach = function (ownerNode) {
  8901. this._ownerNode = ownerNode;
  8902. this._setAllVisibility(this._ownerNode, 0);
  8903. };
  8904. /**
  8905. * Detaches the behavior from the mesh
  8906. */
  8907. FadeInOutBehavior.prototype.detach = function () {
  8908. this._ownerNode = null;
  8909. };
  8910. /**
  8911. * Triggers the mesh to begin fading in or out
  8912. * @param value if the object should fade in or out (true to fade in)
  8913. */
  8914. FadeInOutBehavior.prototype.fadeIn = function (value) {
  8915. this._hovered = value;
  8916. this._update();
  8917. };
  8918. FadeInOutBehavior.prototype._setAllVisibility = function (mesh, value) {
  8919. var _this = this;
  8920. mesh.visibility = value;
  8921. mesh.getChildMeshes().forEach(function (c) {
  8922. _this._setAllVisibility(c, value);
  8923. });
  8924. };
  8925. return FadeInOutBehavior;
  8926. }());
  8927. /***/ }),
  8928. /***/ "./Behaviors/Meshes/index.ts":
  8929. /*!***********************************!*\
  8930. !*** ./Behaviors/Meshes/index.ts ***!
  8931. \***********************************/
  8932. /*! exports provided: AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  8933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8934. "use strict";
  8935. __webpack_require__.r(__webpack_exports__);
  8936. /* harmony import */ var _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./attachToBoxBehavior */ "./Behaviors/Meshes/attachToBoxBehavior.ts");
  8937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  8938. /* harmony import */ var _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fadeInOutBehavior */ "./Behaviors/Meshes/fadeInOutBehavior.ts");
  8939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  8940. /* harmony import */ var _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multiPointerScaleBehavior */ "./Behaviors/Meshes/multiPointerScaleBehavior.ts");
  8941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__["MultiPointerScaleBehavior"]; });
  8942. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__["PointerDragBehavior"]; });
  8944. /* harmony import */ var _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  8945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__["SixDofDragBehavior"]; });
  8946. /***/ }),
  8947. /***/ "./Behaviors/Meshes/multiPointerScaleBehavior.ts":
  8948. /*!*******************************************************!*\
  8949. !*** ./Behaviors/Meshes/multiPointerScaleBehavior.ts ***!
  8950. \*******************************************************/
  8951. /*! exports provided: MultiPointerScaleBehavior */
  8952. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8953. "use strict";
  8954. __webpack_require__.r(__webpack_exports__);
  8955. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return MultiPointerScaleBehavior; });
  8956. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8957. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8958. /**
  8959. * A behavior that when attached to a mesh will allow the mesh to be scaled
  8960. */
  8961. var MultiPointerScaleBehavior = /** @class */ (function () {
  8962. /**
  8963. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  8964. */
  8965. function MultiPointerScaleBehavior() {
  8966. this._startDistance = 0;
  8967. this._initialScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8968. this._targetScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8969. this._sceneRenderObserver = null;
  8970. this._dragBehaviorA = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8971. this._dragBehaviorA.moveAttached = false;
  8972. this._dragBehaviorB = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8973. this._dragBehaviorB.moveAttached = false;
  8974. }
  8975. Object.defineProperty(MultiPointerScaleBehavior.prototype, "name", {
  8976. /**
  8977. * The name of the behavior
  8978. */
  8979. get: function () {
  8980. return "MultiPointerScale";
  8981. },
  8982. enumerable: true,
  8983. configurable: true
  8984. });
  8985. /**
  8986. * Initializes the behavior
  8987. */
  8988. MultiPointerScaleBehavior.prototype.init = function () { };
  8989. MultiPointerScaleBehavior.prototype._getCurrentDistance = function () {
  8990. return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
  8991. };
  8992. /**
  8993. * Attaches the scale behavior the passed in mesh
  8994. * @param ownerNode The mesh that will be scaled around once attached
  8995. */
  8996. MultiPointerScaleBehavior.prototype.attach = function (ownerNode) {
  8997. var _this = this;
  8998. this._ownerNode = ownerNode;
  8999. // Create 2 drag behaviors such that each will only be triggered by a separate pointer
  9000. this._dragBehaviorA.onDragStartObservable.add(function (e) {
  9001. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9002. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9003. _this._dragBehaviorA.releaseDrag();
  9004. }
  9005. else {
  9006. _this._initialScale.copyFrom(ownerNode.scaling);
  9007. _this._startDistance = _this._getCurrentDistance();
  9008. }
  9009. }
  9010. });
  9011. this._dragBehaviorB.onDragStartObservable.add(function (e) {
  9012. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9013. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9014. _this._dragBehaviorB.releaseDrag();
  9015. }
  9016. else {
  9017. _this._initialScale.copyFrom(ownerNode.scaling);
  9018. _this._startDistance = _this._getCurrentDistance();
  9019. }
  9020. }
  9021. });
  9022. // Once both drag behaviors are active scale based on the distance between the two pointers
  9023. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9024. behavior.onDragObservable.add(function () {
  9025. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9026. var ratio = _this._getCurrentDistance() / _this._startDistance;
  9027. _this._initialScale.scaleToRef(ratio, _this._targetScale);
  9028. }
  9029. });
  9030. });
  9031. ownerNode.addBehavior(this._dragBehaviorA);
  9032. ownerNode.addBehavior(this._dragBehaviorB);
  9033. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9034. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9035. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9036. var change = _this._targetScale.subtract(ownerNode.scaling).scaleInPlace(0.1);
  9037. if (change.length() > 0.01) {
  9038. ownerNode.scaling.addInPlace(change);
  9039. }
  9040. }
  9041. });
  9042. };
  9043. /**
  9044. * Detaches the behavior from the mesh
  9045. */
  9046. MultiPointerScaleBehavior.prototype.detach = function () {
  9047. var _this = this;
  9048. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9049. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9050. behavior.onDragStartObservable.clear();
  9051. behavior.onDragObservable.clear();
  9052. _this._ownerNode.removeBehavior(behavior);
  9053. });
  9054. };
  9055. return MultiPointerScaleBehavior;
  9056. }());
  9057. /***/ }),
  9058. /***/ "./Behaviors/Meshes/pointerDragBehavior.ts":
  9059. /*!*************************************************!*\
  9060. !*** ./Behaviors/Meshes/pointerDragBehavior.ts ***!
  9061. \*************************************************/
  9062. /*! exports provided: PointerDragBehavior */
  9063. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9064. "use strict";
  9065. __webpack_require__.r(__webpack_exports__);
  9066. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return PointerDragBehavior; });
  9067. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  9068. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9069. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9070. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9071. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9072. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  9073. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9074. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  9075. /**
  9076. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  9077. */
  9078. var PointerDragBehavior = /** @class */ (function () {
  9079. /**
  9080. * Creates a pointer drag behavior that can be attached to a mesh
  9081. * @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)
  9082. */
  9083. function PointerDragBehavior(options) {
  9084. this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1;
  9085. /**
  9086. * 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)
  9087. */
  9088. this.maxDragAngle = 0;
  9089. /**
  9090. * @hidden
  9091. */
  9092. this._useAlternatePickedPointAboveMaxDragAngle = false;
  9093. /**
  9094. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9095. */
  9096. this.currentDraggingPointerID = -1;
  9097. /**
  9098. * If the behavior is currently in a dragging state
  9099. */
  9100. this.dragging = false;
  9101. /**
  9102. * 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)
  9103. */
  9104. this.dragDeltaRatio = 0.2;
  9105. /**
  9106. * If the drag plane orientation should be updated during the dragging (Default: true)
  9107. */
  9108. this.updateDragPlane = true;
  9109. // Debug mode will display drag planes to help visualize behavior
  9110. this._debugMode = false;
  9111. this._moving = false;
  9112. /**
  9113. * Fires each time the attached mesh is dragged with the pointer
  9114. * * delta between last drag position and current drag position in world space
  9115. * * dragDistance along the drag axis
  9116. * * dragPlaneNormal normal of the current drag plane used during the drag
  9117. * * dragPlanePoint in world space where the drag intersects the drag plane
  9118. */
  9119. this.onDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9120. /**
  9121. * Fires each time a drag begins (eg. mouse down on mesh)
  9122. */
  9123. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9124. /**
  9125. * Fires each time a drag ends (eg. mouse release after drag)
  9126. */
  9127. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9128. /**
  9129. * If the attached mesh should be moved when dragged
  9130. */
  9131. this.moveAttached = true;
  9132. /**
  9133. * If the drag behavior will react to drag events (Default: true)
  9134. */
  9135. this.enabled = true;
  9136. /**
  9137. * If camera controls should be detached during the drag
  9138. */
  9139. this.detachCameraControls = true;
  9140. /**
  9141. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  9142. */
  9143. this.useObjectOrienationForDragging = true;
  9144. /**
  9145. * Predicate to determine if it is valid to move the object to a new position when it is moved
  9146. */
  9147. this.validateDrag = function (targetPosition) { return true; };
  9148. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9149. this._alternatePickedPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9150. this._worldDragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9151. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9152. this._attachedElement = null;
  9153. 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"]());
  9154. this._lastPointerRay = {};
  9155. this._dragDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  9156. // Variables to avoid instantiation in the below method
  9157. this._pointA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9158. this._pointB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9159. this._pointC = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9160. this._lineA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9161. this._lineB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9162. this._localAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9163. this._lookAt = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9164. this._options = options ? options : {};
  9165. var optionCount = 0;
  9166. if (this._options.dragAxis) {
  9167. optionCount++;
  9168. }
  9169. if (this._options.dragPlaneNormal) {
  9170. optionCount++;
  9171. }
  9172. if (optionCount > 1) {
  9173. throw "Multiple drag modes specified in dragBehavior options. Only one expected";
  9174. }
  9175. }
  9176. Object.defineProperty(PointerDragBehavior.prototype, "name", {
  9177. /**
  9178. * The name of the behavior
  9179. */
  9180. get: function () {
  9181. return "PointerDrag";
  9182. },
  9183. enumerable: true,
  9184. configurable: true
  9185. });
  9186. /**
  9187. * Initializes the behavior
  9188. */
  9189. PointerDragBehavior.prototype.init = function () { };
  9190. /**
  9191. * Attaches the drag behavior the passed in mesh
  9192. * @param ownerNode The mesh that will be dragged around once attached
  9193. */
  9194. PointerDragBehavior.prototype.attach = function (ownerNode) {
  9195. var _this = this;
  9196. this._scene = ownerNode.getScene();
  9197. this._attachedNode = ownerNode;
  9198. // Initialize drag plane to not interfere with existing scene
  9199. if (!PointerDragBehavior._planeScene) {
  9200. if (this._debugMode) {
  9201. PointerDragBehavior._planeScene = this._scene;
  9202. }
  9203. else {
  9204. PointerDragBehavior._planeScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9205. PointerDragBehavior._planeScene.detachControl();
  9206. this._scene.getEngine().scenes.pop();
  9207. this._scene.onDisposeObservable.addOnce(function () {
  9208. PointerDragBehavior._planeScene.dispose();
  9209. PointerDragBehavior._planeScene = null;
  9210. });
  9211. }
  9212. }
  9213. 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);
  9214. // State of the drag
  9215. this.lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9216. var pickPredicate = function (m) {
  9217. return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
  9218. };
  9219. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9220. if (!_this.enabled) {
  9221. return;
  9222. }
  9223. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN) {
  9224. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedPoint && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9225. _this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);
  9226. }
  9227. }
  9228. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP) {
  9229. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9230. _this.releaseDrag();
  9231. }
  9232. }
  9233. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  9234. var pointerId = pointerInfo.event.pointerId;
  9235. // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
  9236. if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
  9237. if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
  9238. _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
  9239. delete _this._lastPointerRay[_this.currentDraggingPointerID];
  9240. }
  9241. _this.currentDraggingPointerID = pointerId;
  9242. }
  9243. // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
  9244. if (!_this._lastPointerRay[pointerId]) {
  9245. _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"]());
  9246. }
  9247. if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {
  9248. _this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);
  9249. _this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);
  9250. if (_this.currentDraggingPointerID == pointerId && _this.dragging) {
  9251. _this._moveDrag(pointerInfo.pickInfo.ray);
  9252. }
  9253. }
  9254. }
  9255. });
  9256. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  9257. if (_this._moving && _this.moveAttached) {
  9258. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(_this._attachedNode);
  9259. // Slowly move mesh to avoid jitter
  9260. _this._targetPosition.subtractToRef((_this._attachedNode).absolutePosition, _this._tmpVector);
  9261. _this._tmpVector.scaleInPlace(_this.dragDeltaRatio);
  9262. (_this._attachedNode).getAbsolutePosition().addToRef(_this._tmpVector, _this._tmpVector);
  9263. if (_this.validateDrag(_this._tmpVector)) {
  9264. (_this._attachedNode).setAbsolutePosition(_this._tmpVector);
  9265. }
  9266. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(_this._attachedNode);
  9267. }
  9268. });
  9269. };
  9270. /**
  9271. * Force relase the drag action by code.
  9272. */
  9273. PointerDragBehavior.prototype.releaseDrag = function () {
  9274. this.dragging = false;
  9275. this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID });
  9276. this.currentDraggingPointerID = -1;
  9277. this._moving = false;
  9278. // Reattach camera controls
  9279. if (this.detachCameraControls && this._attachedElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9280. this._scene.activeCamera.attachControl(this._attachedElement, true);
  9281. }
  9282. };
  9283. /**
  9284. * Simulates the start of a pointer drag event on the behavior
  9285. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  9286. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  9287. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  9288. */
  9289. PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
  9290. if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
  9291. this._startDrag(pointerId, fromRay, startPickedPoint);
  9292. var lastRay = this._lastPointerRay[pointerId];
  9293. if (pointerId === PointerDragBehavior._AnyMouseID) {
  9294. lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
  9295. }
  9296. if (lastRay) {
  9297. // if there was a last pointer ray drag the object there
  9298. this._moveDrag(lastRay);
  9299. }
  9300. };
  9301. PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
  9302. if (!this._scene.activeCamera || this.dragging || !this._attachedNode) {
  9303. return;
  9304. }
  9305. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(this._attachedNode);
  9306. // Create start ray from the camera to the object
  9307. if (fromRay) {
  9308. this._startDragRay.direction.copyFrom(fromRay.direction);
  9309. this._startDragRay.origin.copyFrom(fromRay.origin);
  9310. }
  9311. else {
  9312. this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);
  9313. this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);
  9314. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);
  9315. }
  9316. this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);
  9317. var pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);
  9318. if (pickedPoint) {
  9319. this.dragging = true;
  9320. this.currentDraggingPointerID = pointerId;
  9321. this.lastDragPosition.copyFrom(pickedPoint);
  9322. this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerID });
  9323. this._targetPosition.copyFrom((this._attachedNode).absolutePosition);
  9324. // Detatch camera controls
  9325. if (this.detachCameraControls && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9326. if (this._scene.activeCamera.inputs.attachedElement) {
  9327. this._attachedElement = this._scene.activeCamera.inputs.attachedElement;
  9328. this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
  9329. }
  9330. else {
  9331. this._attachedElement = null;
  9332. }
  9333. }
  9334. }
  9335. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(this._attachedNode);
  9336. };
  9337. PointerDragBehavior.prototype._moveDrag = function (ray) {
  9338. this._moving = true;
  9339. var pickedPoint = this._pickWithRayOnDragPlane(ray);
  9340. if (pickedPoint) {
  9341. if (this.updateDragPlane) {
  9342. this._updateDragPlanePosition(ray, pickedPoint);
  9343. }
  9344. var dragLength = 0;
  9345. // depending on the drag mode option drag accordingly
  9346. if (this._options.dragAxis) {
  9347. // Convert local drag axis to world
  9348. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis);
  9349. // Project delta drag from the drag plane onto the drag axis
  9350. pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);
  9351. dragLength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._tmpVector, this._worldDragAxis);
  9352. this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);
  9353. }
  9354. else {
  9355. dragLength = this._dragDelta.length();
  9356. pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);
  9357. }
  9358. this._targetPosition.addInPlace(this._dragDelta);
  9359. this.onDragObservable.notifyObservers({ dragDistance: dragLength, delta: this._dragDelta, dragPlanePoint: pickedPoint, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerID });
  9360. this.lastDragPosition.copyFrom(pickedPoint);
  9361. }
  9362. };
  9363. PointerDragBehavior.prototype._pickWithRayOnDragPlane = function (ray) {
  9364. var _this = this;
  9365. if (!ray) {
  9366. return null;
  9367. }
  9368. // Calculate angle between plane normal and ray
  9369. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, ray.direction));
  9370. // Correct if ray is casted from oposite side
  9371. if (angle > Math.PI / 2) {
  9372. angle = Math.PI - angle;
  9373. }
  9374. // If the angle is too perpendicular to the plane pick another point on the plane where it is looking
  9375. if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {
  9376. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  9377. // Invert ray direction along the towards object axis
  9378. this._tmpVector.copyFrom(ray.direction);
  9379. (this._attachedNode).absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);
  9380. this._alternatePickedPoint.normalize();
  9381. this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._alternatePickedPoint, this._tmpVector));
  9382. this._tmpVector.addInPlace(this._alternatePickedPoint);
  9383. // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point
  9384. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, this._tmpVector);
  9385. this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);
  9386. this._alternatePickedPoint.addInPlace(this._tmpVector);
  9387. this._alternatePickedPoint.addInPlace((this._attachedNode).absolutePosition);
  9388. return this._alternatePickedPoint;
  9389. }
  9390. else {
  9391. return null;
  9392. }
  9393. }
  9394. var pickResult = PointerDragBehavior._planeScene.pickWithRay(ray, function (m) { return m == _this._dragPlane; });
  9395. if (pickResult && pickResult.hit && pickResult.pickedMesh && pickResult.pickedPoint) {
  9396. return pickResult.pickedPoint;
  9397. }
  9398. else {
  9399. return null;
  9400. }
  9401. };
  9402. // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
  9403. PointerDragBehavior.prototype._updateDragPlanePosition = function (ray, dragPlanePosition) {
  9404. this._pointA.copyFrom(dragPlanePosition);
  9405. if (this._options.dragAxis) {
  9406. 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);
  9407. // Calculate plane normal in direction of camera but perpendicular to drag axis
  9408. this._pointA.addToRef(this._localAxis, this._pointB); // towards drag axis
  9409. ray.origin.subtractToRef(this._pointA, this._pointC);
  9410. this._pointA.addToRef(this._pointC.normalize(), this._pointC); // towards camera
  9411. // Get perpendicular line from direction to camera and drag axis
  9412. this._pointB.subtractToRef(this._pointA, this._lineA);
  9413. this._pointC.subtractToRef(this._pointA, this._lineB);
  9414. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lineB, this._lookAt);
  9415. // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
  9416. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lookAt, this._lookAt);
  9417. this._lookAt.normalize();
  9418. this._dragPlane.position.copyFrom(this._pointA);
  9419. this._pointA.addToRef(this._lookAt, this._lookAt);
  9420. this._dragPlane.lookAt(this._lookAt);
  9421. }
  9422. else if (this._options.dragPlaneNormal) {
  9423. 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);
  9424. this._dragPlane.position.copyFrom(this._pointA);
  9425. this._pointA.addToRef(this._localAxis, this._lookAt);
  9426. this._dragPlane.lookAt(this._lookAt);
  9427. }
  9428. else {
  9429. this._dragPlane.position.copyFrom(this._pointA);
  9430. this._dragPlane.lookAt(ray.origin);
  9431. }
  9432. // 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)
  9433. this._dragPlane.position.copyFrom(this._attachedNode.absolutePosition);
  9434. this._dragPlane.computeWorldMatrix(true);
  9435. };
  9436. /**
  9437. * Detaches the behavior from the mesh
  9438. */
  9439. PointerDragBehavior.prototype.detach = function () {
  9440. if (this._pointerObserver) {
  9441. this._scene.onPointerObservable.remove(this._pointerObserver);
  9442. }
  9443. if (this._beforeRenderObserver) {
  9444. this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  9445. }
  9446. };
  9447. PointerDragBehavior._AnyMouseID = -2;
  9448. return PointerDragBehavior;
  9449. }());
  9450. /***/ }),
  9451. /***/ "./Behaviors/Meshes/sixDofDragBehavior.ts":
  9452. /*!************************************************!*\
  9453. !*** ./Behaviors/Meshes/sixDofDragBehavior.ts ***!
  9454. \************************************************/
  9455. /*! exports provided: SixDofDragBehavior */
  9456. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9457. "use strict";
  9458. __webpack_require__.r(__webpack_exports__);
  9459. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return SixDofDragBehavior; });
  9460. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  9461. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9462. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9463. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9464. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9465. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  9466. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9467. /**
  9468. * 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
  9469. */
  9470. var SixDofDragBehavior = /** @class */ (function () {
  9471. /**
  9472. * 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
  9473. */
  9474. function SixDofDragBehavior() {
  9475. this._sceneRenderObserver = null;
  9476. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9477. this._moving = false;
  9478. this._startingOrientation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9479. /**
  9480. * 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)
  9481. */
  9482. this.zDragFactor = 3;
  9483. /**
  9484. * If the object should rotate to face the drag origin
  9485. */
  9486. this.rotateDraggedObject = true;
  9487. /**
  9488. * If the behavior is currently in a dragging state
  9489. */
  9490. this.dragging = false;
  9491. /**
  9492. * 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)
  9493. */
  9494. this.dragDeltaRatio = 0.2;
  9495. /**
  9496. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9497. */
  9498. this.currentDraggingPointerID = -1;
  9499. /**
  9500. * If camera controls should be detached during the drag
  9501. */
  9502. this.detachCameraControls = true;
  9503. /**
  9504. * Fires each time a drag starts
  9505. */
  9506. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9507. /**
  9508. * Fires each time a drag ends (eg. mouse release after drag)
  9509. */
  9510. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9511. }
  9512. Object.defineProperty(SixDofDragBehavior.prototype, "name", {
  9513. /**
  9514. * The name of the behavior
  9515. */
  9516. get: function () {
  9517. return "SixDofDrag";
  9518. },
  9519. enumerable: true,
  9520. configurable: true
  9521. });
  9522. /**
  9523. * Initializes the behavior
  9524. */
  9525. SixDofDragBehavior.prototype.init = function () { };
  9526. /**
  9527. * Attaches the scale behavior the passed in mesh
  9528. * @param ownerNode The mesh that will be scaled around once attached
  9529. */
  9530. SixDofDragBehavior.prototype.attach = function (ownerNode) {
  9531. var _this = this;
  9532. this._ownerNode = ownerNode;
  9533. this._scene = this._ownerNode.getScene();
  9534. if (!SixDofDragBehavior._virtualScene) {
  9535. SixDofDragBehavior._virtualScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9536. SixDofDragBehavior._virtualScene.detachControl();
  9537. this._scene.getEngine().scenes.pop();
  9538. }
  9539. var pickedMesh = null;
  9540. var lastSixDofOriginPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9541. // Setup virtual meshes to be used for dragging without dirtying the existing scene
  9542. this._virtualOriginMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9543. this._virtualOriginMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9544. this._virtualDragMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9545. this._virtualDragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9546. var pickPredicate = function (m) {
  9547. return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
  9548. };
  9549. var attachedElement = null;
  9550. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9551. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  9552. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9553. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9554. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9555. }
  9556. pickedMesh = _this._ownerNode;
  9557. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9558. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9559. // Set position and orientation of the controller
  9560. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9561. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9562. // Attach the virtual drag mesh to the virtual origin mesh so it can be dragged
  9563. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9564. pickedMesh.computeWorldMatrix();
  9565. _this._virtualDragMesh.position.copyFrom(pickedMesh.absolutePosition);
  9566. if (!pickedMesh.rotationQuaternion) {
  9567. pickedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(pickedMesh.rotation.y, pickedMesh.rotation.x, pickedMesh.rotation.z);
  9568. }
  9569. var oldParent = pickedMesh.parent;
  9570. pickedMesh.setParent(null);
  9571. _this._virtualDragMesh.rotationQuaternion.copyFrom(pickedMesh.rotationQuaternion);
  9572. pickedMesh.setParent(oldParent);
  9573. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9574. // Update state
  9575. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9576. _this.dragging = true;
  9577. _this.currentDraggingPointerID = pointerInfo.event.pointerId;
  9578. // Detatch camera controls
  9579. if (_this.detachCameraControls && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9580. if (_this._scene.activeCamera.inputs.attachedElement) {
  9581. attachedElement = _this._scene.activeCamera.inputs.attachedElement;
  9582. _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
  9583. }
  9584. else {
  9585. attachedElement = null;
  9586. }
  9587. }
  9588. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9589. _this.onDragStartObservable.notifyObservers({});
  9590. }
  9591. }
  9592. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP) {
  9593. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9594. _this.dragging = false;
  9595. _this._moving = false;
  9596. _this.currentDraggingPointerID = -1;
  9597. pickedMesh = null;
  9598. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9599. // Reattach camera controls
  9600. if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9601. _this._scene.activeCamera.attachControl(attachedElement, true);
  9602. }
  9603. _this.onDragEndObservable.notifyObservers({});
  9604. }
  9605. }
  9606. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE) {
  9607. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
  9608. var zDragFactor = _this.zDragFactor;
  9609. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9610. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9611. zDragFactor = 0;
  9612. }
  9613. // Calculate controller drag distance in controller space
  9614. var originDragDifference = pointerInfo.pickInfo.ray.origin.subtract(lastSixDofOriginPosition);
  9615. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9616. var localOriginDragDifference = -_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(originDragDifference, pointerInfo.pickInfo.ray.direction);
  9617. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9618. // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away
  9619. _this._virtualDragMesh.position.z -= _this._virtualDragMesh.position.z < 1 ? localOriginDragDifference * _this.zDragFactor : localOriginDragDifference * zDragFactor * _this._virtualDragMesh.position.z;
  9620. if (_this._virtualDragMesh.position.z < 0) {
  9621. _this._virtualDragMesh.position.z = 0;
  9622. }
  9623. // Update the controller position
  9624. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9625. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9626. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9627. // Move the virtualObjectsPosition into the picked mesh's space if needed
  9628. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9629. if (pickedMesh.parent) {
  9630. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._targetPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(pickedMesh.parent.getWorldMatrix()), _this._targetPosition);
  9631. }
  9632. if (!_this._moving) {
  9633. _this._startingOrientation.copyFrom(_this._virtualDragMesh.rotationQuaternion);
  9634. }
  9635. _this._moving = true;
  9636. }
  9637. }
  9638. });
  9639. var tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9640. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9641. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9642. if (_this.dragging && _this._moving && pickedMesh) {
  9643. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9644. // Slowly move mesh to avoid jitter
  9645. pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
  9646. if (_this.rotateDraggedObject) {
  9647. // Get change in rotation
  9648. tmpQuaternion.copyFrom(_this._startingOrientation);
  9649. tmpQuaternion.x = -tmpQuaternion.x;
  9650. tmpQuaternion.y = -tmpQuaternion.y;
  9651. tmpQuaternion.z = -tmpQuaternion.z;
  9652. _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
  9653. // Convert change in rotation to only y axis rotation
  9654. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
  9655. tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
  9656. // Slowly move mesh to avoid jitter
  9657. var oldParent = pickedMesh.parent;
  9658. // Only rotate the mesh if it's parent has uniform scaling
  9659. if (!oldParent || (oldParent.scaling && !oldParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  9660. pickedMesh.setParent(null);
  9661. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
  9662. pickedMesh.setParent(oldParent);
  9663. }
  9664. }
  9665. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9666. }
  9667. });
  9668. };
  9669. /**
  9670. * Detaches the behavior from the mesh
  9671. */
  9672. SixDofDragBehavior.prototype.detach = function () {
  9673. if (this._scene) {
  9674. this._scene.onPointerObservable.remove(this._pointerObserver);
  9675. }
  9676. if (this._ownerNode) {
  9677. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9678. }
  9679. if (this._virtualOriginMesh) {
  9680. this._virtualOriginMesh.dispose();
  9681. }
  9682. if (this._virtualDragMesh) {
  9683. this._virtualDragMesh.dispose();
  9684. }
  9685. this.onDragEndObservable.clear();
  9686. this.onDragStartObservable.clear();
  9687. };
  9688. return SixDofDragBehavior;
  9689. }());
  9690. /***/ }),
  9691. /***/ "./Behaviors/index.ts":
  9692. /*!****************************!*\
  9693. !*** ./Behaviors/index.ts ***!
  9694. \****************************/
  9695. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  9696. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9697. "use strict";
  9698. __webpack_require__.r(__webpack_exports__);
  9699. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cameras/index */ "./Behaviors/Cameras/index.ts");
  9700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  9701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  9702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  9703. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Meshes/index */ "./Behaviors/Meshes/index.ts");
  9704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["AttachToBoxBehavior"]; });
  9705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["MultiPointerScaleBehavior"]; });
  9707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["PointerDragBehavior"]; });
  9708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["SixDofDragBehavior"]; });
  9709. /***/ }),
  9710. /***/ "./Bones/bone.ts":
  9711. /*!***********************!*\
  9712. !*** ./Bones/bone.ts ***!
  9713. \***********************/
  9714. /*! exports provided: Bone */
  9715. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9716. "use strict";
  9717. __webpack_require__.r(__webpack_exports__);
  9718. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return Bone; });
  9719. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  9720. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  9721. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  9722. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  9723. /**
  9724. * Class used to store bone information
  9725. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9726. */
  9727. var Bone = /** @class */ (function (_super) {
  9728. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Bone, _super);
  9729. /**
  9730. * Create a new bone
  9731. * @param name defines the bone name
  9732. * @param skeleton defines the parent skeleton
  9733. * @param parentBone defines the parent (can be null if the bone is the root)
  9734. * @param localMatrix defines the local matrix
  9735. * @param restPose defines the rest pose matrix
  9736. * @param baseMatrix defines the base matrix
  9737. * @param index defines index of the bone in the hiearchy
  9738. */
  9739. function Bone(
  9740. /**
  9741. * defines the bone name
  9742. */
  9743. name, skeleton, parentBone, localMatrix, restPose, baseMatrix, index) {
  9744. if (parentBone === void 0) { parentBone = null; }
  9745. if (localMatrix === void 0) { localMatrix = null; }
  9746. if (restPose === void 0) { restPose = null; }
  9747. if (baseMatrix === void 0) { baseMatrix = null; }
  9748. if (index === void 0) { index = null; }
  9749. var _this = _super.call(this, name, skeleton.getScene(), false) || this;
  9750. _this.name = name;
  9751. /**
  9752. * Gets the list of child bones
  9753. */
  9754. _this.children = new Array();
  9755. /** Gets the animations associated with this bone */
  9756. _this.animations = new Array();
  9757. /**
  9758. * @hidden Internal only
  9759. * Set this value to map this bone to a different index in the transform matrices
  9760. * Set this value to -1 to exclude the bone from the transform matrices
  9761. */
  9762. _this._index = null;
  9763. _this._absoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9764. _this._invertedAbsoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9765. _this._scalingDeterminant = 1;
  9766. _this._worldTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9767. _this._needToDecompose = true;
  9768. _this._needToCompose = false;
  9769. /** @hidden */
  9770. _this._linkedTransformNode = null;
  9771. _this._skeleton = skeleton;
  9772. _this._localMatrix = localMatrix ? localMatrix.clone() : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  9773. _this._restPose = restPose ? restPose : _this._localMatrix.clone();
  9774. _this._baseMatrix = baseMatrix ? baseMatrix : _this._localMatrix.clone();
  9775. _this._index = index;
  9776. skeleton.bones.push(_this);
  9777. _this.setParent(parentBone, false);
  9778. if (baseMatrix || localMatrix) {
  9779. _this._updateDifferenceMatrix();
  9780. }
  9781. return _this;
  9782. }
  9783. Object.defineProperty(Bone.prototype, "_matrix", {
  9784. /** @hidden */
  9785. get: function () {
  9786. this._compose();
  9787. return this._localMatrix;
  9788. },
  9789. /** @hidden */
  9790. set: function (value) {
  9791. this._localMatrix.copyFrom(value);
  9792. this._needToDecompose = true;
  9793. },
  9794. enumerable: true,
  9795. configurable: true
  9796. });
  9797. // Members
  9798. /**
  9799. * Gets the parent skeleton
  9800. * @returns a skeleton
  9801. */
  9802. Bone.prototype.getSkeleton = function () {
  9803. return this._skeleton;
  9804. };
  9805. /**
  9806. * Gets parent bone
  9807. * @returns a bone or null if the bone is the root of the bone hierarchy
  9808. */
  9809. Bone.prototype.getParent = function () {
  9810. return this._parent;
  9811. };
  9812. /**
  9813. * Sets the parent bone
  9814. * @param parent defines the parent (can be null if the bone is the root)
  9815. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9816. */
  9817. Bone.prototype.setParent = function (parent, updateDifferenceMatrix) {
  9818. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9819. if (this._parent === parent) {
  9820. return;
  9821. }
  9822. if (this._parent) {
  9823. var index = this._parent.children.indexOf(this);
  9824. if (index !== -1) {
  9825. this._parent.children.splice(index, 1);
  9826. }
  9827. }
  9828. this._parent = parent;
  9829. if (this._parent) {
  9830. this._parent.children.push(this);
  9831. }
  9832. if (updateDifferenceMatrix) {
  9833. this._updateDifferenceMatrix();
  9834. }
  9835. this.markAsDirty();
  9836. };
  9837. /**
  9838. * Gets the local matrix
  9839. * @returns a matrix
  9840. */
  9841. Bone.prototype.getLocalMatrix = function () {
  9842. this._compose();
  9843. return this._localMatrix;
  9844. };
  9845. /**
  9846. * Gets the base matrix (initial matrix which remains unchanged)
  9847. * @returns a matrix
  9848. */
  9849. Bone.prototype.getBaseMatrix = function () {
  9850. return this._baseMatrix;
  9851. };
  9852. /**
  9853. * Gets the rest pose matrix
  9854. * @returns a matrix
  9855. */
  9856. Bone.prototype.getRestPose = function () {
  9857. return this._restPose;
  9858. };
  9859. /**
  9860. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9861. */
  9862. Bone.prototype.getWorldMatrix = function () {
  9863. return this._worldTransform;
  9864. };
  9865. /**
  9866. * Sets the local matrix to rest pose matrix
  9867. */
  9868. Bone.prototype.returnToRest = function () {
  9869. this.updateMatrix(this._restPose.clone());
  9870. };
  9871. /**
  9872. * Gets the inverse of the absolute transform matrix.
  9873. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9874. * @returns a matrix
  9875. */
  9876. Bone.prototype.getInvertedAbsoluteTransform = function () {
  9877. return this._invertedAbsoluteTransform;
  9878. };
  9879. /**
  9880. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9881. * @returns a matrix
  9882. */
  9883. Bone.prototype.getAbsoluteTransform = function () {
  9884. return this._absoluteTransform;
  9885. };
  9886. /**
  9887. * Links with the given transform node.
  9888. * The local matrix of this bone is copied from the transform node every frame.
  9889. * @param transformNode defines the transform node to link to
  9890. */
  9891. Bone.prototype.linkTransformNode = function (transformNode) {
  9892. if (this._linkedTransformNode) {
  9893. this._skeleton._numBonesWithLinkedTransformNode--;
  9894. }
  9895. this._linkedTransformNode = transformNode;
  9896. if (this._linkedTransformNode) {
  9897. this._skeleton._numBonesWithLinkedTransformNode++;
  9898. }
  9899. };
  9900. Object.defineProperty(Bone.prototype, "position", {
  9901. // Properties (matches AbstractMesh properties)
  9902. /** Gets or sets current position (in local space) */
  9903. get: function () {
  9904. this._decompose();
  9905. return this._localPosition;
  9906. },
  9907. set: function (newPosition) {
  9908. this._decompose();
  9909. this._localPosition.copyFrom(newPosition);
  9910. this._markAsDirtyAndCompose();
  9911. },
  9912. enumerable: true,
  9913. configurable: true
  9914. });
  9915. Object.defineProperty(Bone.prototype, "rotation", {
  9916. /** Gets or sets current rotation (in local space) */
  9917. get: function () {
  9918. return this.getRotation();
  9919. },
  9920. set: function (newRotation) {
  9921. this.setRotation(newRotation);
  9922. },
  9923. enumerable: true,
  9924. configurable: true
  9925. });
  9926. Object.defineProperty(Bone.prototype, "rotationQuaternion", {
  9927. /** Gets or sets current rotation quaternion (in local space) */
  9928. get: function () {
  9929. this._decompose();
  9930. return this._localRotation;
  9931. },
  9932. set: function (newRotation) {
  9933. this.setRotationQuaternion(newRotation);
  9934. },
  9935. enumerable: true,
  9936. configurable: true
  9937. });
  9938. Object.defineProperty(Bone.prototype, "scaling", {
  9939. /** Gets or sets current scaling (in local space) */
  9940. get: function () {
  9941. return this.getScale();
  9942. },
  9943. set: function (newScaling) {
  9944. this.setScale(newScaling);
  9945. },
  9946. enumerable: true,
  9947. configurable: true
  9948. });
  9949. Object.defineProperty(Bone.prototype, "animationPropertiesOverride", {
  9950. /**
  9951. * Gets the animation properties override
  9952. */
  9953. get: function () {
  9954. return this._skeleton.animationPropertiesOverride;
  9955. },
  9956. enumerable: true,
  9957. configurable: true
  9958. });
  9959. // Methods
  9960. Bone.prototype._decompose = function () {
  9961. if (!this._needToDecompose) {
  9962. return;
  9963. }
  9964. this._needToDecompose = false;
  9965. if (!this._localScaling) {
  9966. this._localScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9967. this._localRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Zero();
  9968. this._localPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9969. }
  9970. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition);
  9971. };
  9972. Bone.prototype._compose = function () {
  9973. if (!this._needToCompose) {
  9974. return;
  9975. }
  9976. this._needToCompose = false;
  9977. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix);
  9978. };
  9979. /**
  9980. * Update the base and local matrices
  9981. * @param matrix defines the new base or local matrix
  9982. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9983. * @param updateLocalMatrix defines if the local matrix should be updated
  9984. */
  9985. Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix, updateLocalMatrix) {
  9986. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9987. if (updateLocalMatrix === void 0) { updateLocalMatrix = true; }
  9988. this._baseMatrix.copyFrom(matrix);
  9989. if (updateDifferenceMatrix) {
  9990. this._updateDifferenceMatrix();
  9991. }
  9992. if (updateLocalMatrix) {
  9993. this._localMatrix.copyFrom(matrix);
  9994. this._markAsDirtyAndDecompose();
  9995. }
  9996. else {
  9997. this.markAsDirty();
  9998. }
  9999. };
  10000. /** @hidden */
  10001. Bone.prototype._updateDifferenceMatrix = function (rootMatrix, updateChildren) {
  10002. if (updateChildren === void 0) { updateChildren = true; }
  10003. if (!rootMatrix) {
  10004. rootMatrix = this._baseMatrix;
  10005. }
  10006. if (this._parent) {
  10007. rootMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10008. }
  10009. else {
  10010. this._absoluteTransform.copyFrom(rootMatrix);
  10011. }
  10012. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
  10013. if (updateChildren) {
  10014. for (var index = 0; index < this.children.length; index++) {
  10015. this.children[index]._updateDifferenceMatrix();
  10016. }
  10017. }
  10018. this._scalingDeterminant = (this._absoluteTransform.determinant() < 0 ? -1 : 1);
  10019. };
  10020. /**
  10021. * Flag the bone as dirty (Forcing it to update everything)
  10022. */
  10023. Bone.prototype.markAsDirty = function () {
  10024. this._currentRenderId++;
  10025. this._childRenderId++;
  10026. this._skeleton._markAsDirty();
  10027. };
  10028. Bone.prototype._markAsDirtyAndCompose = function () {
  10029. this.markAsDirty();
  10030. this._needToCompose = true;
  10031. };
  10032. Bone.prototype._markAsDirtyAndDecompose = function () {
  10033. this.markAsDirty();
  10034. this._needToDecompose = true;
  10035. };
  10036. /**
  10037. * Translate the bone in local or world space
  10038. * @param vec The amount to translate the bone
  10039. * @param space The space that the translation is in
  10040. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10041. */
  10042. Bone.prototype.translate = function (vec, space, mesh) {
  10043. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10044. var lm = this.getLocalMatrix();
  10045. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10046. lm.addAtIndex(12, vec.x);
  10047. lm.addAtIndex(13, vec.y);
  10048. lm.addAtIndex(14, vec.z);
  10049. }
  10050. else {
  10051. var wm = null;
  10052. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10053. if (mesh) {
  10054. wm = mesh.getWorldMatrix();
  10055. }
  10056. this._skeleton.computeAbsoluteTransforms();
  10057. var tmat = Bone._tmpMats[0];
  10058. var tvec = Bone._tmpVecs[0];
  10059. if (this._parent) {
  10060. if (mesh && wm) {
  10061. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10062. tmat.multiplyToRef(wm, tmat);
  10063. }
  10064. else {
  10065. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10066. }
  10067. }
  10068. tmat.setTranslationFromFloats(0, 0, 0);
  10069. tmat.invert();
  10070. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vec, tmat, tvec);
  10071. lm.addAtIndex(12, tvec.x);
  10072. lm.addAtIndex(13, tvec.y);
  10073. lm.addAtIndex(14, tvec.z);
  10074. }
  10075. this._markAsDirtyAndDecompose();
  10076. };
  10077. /**
  10078. * Set the postion of the bone in local or world space
  10079. * @param position The position to set the bone
  10080. * @param space The space that the position is in
  10081. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10082. */
  10083. Bone.prototype.setPosition = function (position, space, mesh) {
  10084. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10085. var lm = this.getLocalMatrix();
  10086. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10087. lm.setTranslationFromFloats(position.x, position.y, position.z);
  10088. }
  10089. else {
  10090. var wm = null;
  10091. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10092. if (mesh) {
  10093. wm = mesh.getWorldMatrix();
  10094. }
  10095. this._skeleton.computeAbsoluteTransforms();
  10096. var tmat = Bone._tmpMats[0];
  10097. var vec = Bone._tmpVecs[0];
  10098. if (this._parent) {
  10099. if (mesh && wm) {
  10100. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10101. tmat.multiplyToRef(wm, tmat);
  10102. }
  10103. else {
  10104. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10105. }
  10106. }
  10107. tmat.invert();
  10108. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, vec);
  10109. lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
  10110. }
  10111. this._markAsDirtyAndDecompose();
  10112. };
  10113. /**
  10114. * Set the absolute position of the bone (world space)
  10115. * @param position The position to set the bone
  10116. * @param mesh The mesh that this bone is attached to
  10117. */
  10118. Bone.prototype.setAbsolutePosition = function (position, mesh) {
  10119. this.setPosition(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh);
  10120. };
  10121. /**
  10122. * Scale the bone on the x, y and z axes (in local space)
  10123. * @param x The amount to scale the bone on the x axis
  10124. * @param y The amount to scale the bone on the y axis
  10125. * @param z The amount to scale the bone on the z axis
  10126. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  10127. */
  10128. Bone.prototype.scale = function (x, y, z, scaleChildren) {
  10129. if (scaleChildren === void 0) { scaleChildren = false; }
  10130. var locMat = this.getLocalMatrix();
  10131. // Apply new scaling on top of current local matrix
  10132. var scaleMat = Bone._tmpMats[0];
  10133. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(x, y, z, scaleMat);
  10134. scaleMat.multiplyToRef(locMat, locMat);
  10135. // Invert scaling matrix and apply the inverse to all children
  10136. scaleMat.invert();
  10137. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10138. var child = _a[_i];
  10139. var cm = child.getLocalMatrix();
  10140. cm.multiplyToRef(scaleMat, cm);
  10141. cm.multiplyAtIndex(12, x);
  10142. cm.multiplyAtIndex(13, y);
  10143. cm.multiplyAtIndex(14, z);
  10144. child._markAsDirtyAndDecompose();
  10145. }
  10146. this._markAsDirtyAndDecompose();
  10147. if (scaleChildren) {
  10148. for (var _b = 0, _c = this.children; _b < _c.length; _b++) {
  10149. var child = _c[_b];
  10150. child.scale(x, y, z, scaleChildren);
  10151. }
  10152. }
  10153. };
  10154. /**
  10155. * Set the bone scaling in local space
  10156. * @param scale defines the scaling vector
  10157. */
  10158. Bone.prototype.setScale = function (scale) {
  10159. this._decompose();
  10160. this._localScaling.copyFrom(scale);
  10161. this._markAsDirtyAndCompose();
  10162. };
  10163. /**
  10164. * Gets the current scaling in local space
  10165. * @returns the current scaling vector
  10166. */
  10167. Bone.prototype.getScale = function () {
  10168. this._decompose();
  10169. return this._localScaling;
  10170. };
  10171. /**
  10172. * Gets the current scaling in local space and stores it in a target vector
  10173. * @param result defines the target vector
  10174. */
  10175. Bone.prototype.getScaleToRef = function (result) {
  10176. this._decompose();
  10177. result.copyFrom(this._localScaling);
  10178. };
  10179. /**
  10180. * Set the yaw, pitch, and roll of the bone in local or world space
  10181. * @param yaw The rotation of the bone on the y axis
  10182. * @param pitch The rotation of the bone on the x axis
  10183. * @param roll The rotation of the bone on the z axis
  10184. * @param space The space that the axes of rotation are in
  10185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10186. */
  10187. Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
  10188. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10189. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10190. var quat = Bone._tmpQuat;
  10191. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(yaw, pitch, roll, quat);
  10192. this.setRotationQuaternion(quat, space, mesh);
  10193. return;
  10194. }
  10195. var rotMatInv = Bone._tmpMats[0];
  10196. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10197. return;
  10198. }
  10199. var rotMat = Bone._tmpMats[1];
  10200. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
  10201. rotMatInv.multiplyToRef(rotMat, rotMat);
  10202. this._rotateWithMatrix(rotMat, space, mesh);
  10203. };
  10204. /**
  10205. * Add a rotation to the bone on an axis in local or world space
  10206. * @param axis The axis to rotate the bone on
  10207. * @param amount The amount to rotate the bone
  10208. * @param space The space that the axis is in
  10209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10210. */
  10211. Bone.prototype.rotate = function (axis, amount, space, mesh) {
  10212. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10213. var rmat = Bone._tmpMats[0];
  10214. rmat.setTranslationFromFloats(0, 0, 0);
  10215. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, amount, rmat);
  10216. this._rotateWithMatrix(rmat, space, mesh);
  10217. };
  10218. /**
  10219. * Set the rotation of the bone to a particular axis angle in local or world space
  10220. * @param axis The axis to rotate the bone on
  10221. * @param angle The angle that the bone should be rotated to
  10222. * @param space The space that the axis is in
  10223. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10224. */
  10225. Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
  10226. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10227. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10228. var quat = Bone._tmpQuat;
  10229. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationAxisToRef(axis, angle, quat);
  10230. this.setRotationQuaternion(quat, space, mesh);
  10231. return;
  10232. }
  10233. var rotMatInv = Bone._tmpMats[0];
  10234. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10235. return;
  10236. }
  10237. var rotMat = Bone._tmpMats[1];
  10238. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, angle, rotMat);
  10239. rotMatInv.multiplyToRef(rotMat, rotMat);
  10240. this._rotateWithMatrix(rotMat, space, mesh);
  10241. };
  10242. /**
  10243. * Set the euler rotation of the bone in local of world space
  10244. * @param rotation The euler rotation that the bone should be set to
  10245. * @param space The space that the rotation is in
  10246. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10247. */
  10248. Bone.prototype.setRotation = function (rotation, space, mesh) {
  10249. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10250. this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
  10251. };
  10252. /**
  10253. * Set the quaternion rotation of the bone in local of world space
  10254. * @param quat The quaternion rotation that the bone should be set to
  10255. * @param space The space that the rotation is in
  10256. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10257. */
  10258. Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
  10259. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10260. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10261. this._decompose();
  10262. this._localRotation.copyFrom(quat);
  10263. this._markAsDirtyAndCompose();
  10264. return;
  10265. }
  10266. var rotMatInv = Bone._tmpMats[0];
  10267. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10268. return;
  10269. }
  10270. var rotMat = Bone._tmpMats[1];
  10271. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromQuaternionToRef(quat, rotMat);
  10272. rotMatInv.multiplyToRef(rotMat, rotMat);
  10273. this._rotateWithMatrix(rotMat, space, mesh);
  10274. };
  10275. /**
  10276. * Set the rotation matrix of the bone in local of world space
  10277. * @param rotMat The rotation matrix that the bone should be set to
  10278. * @param space The space that the rotation is in
  10279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10280. */
  10281. Bone.prototype.setRotationMatrix = function (rotMat, space, mesh) {
  10282. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10283. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10284. var quat = Bone._tmpQuat;
  10285. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(rotMat, quat);
  10286. this.setRotationQuaternion(quat, space, mesh);
  10287. return;
  10288. }
  10289. var rotMatInv = Bone._tmpMats[0];
  10290. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10291. return;
  10292. }
  10293. var rotMat2 = Bone._tmpMats[1];
  10294. rotMat2.copyFrom(rotMat);
  10295. rotMatInv.multiplyToRef(rotMat, rotMat2);
  10296. this._rotateWithMatrix(rotMat2, space, mesh);
  10297. };
  10298. Bone.prototype._rotateWithMatrix = function (rmat, space, mesh) {
  10299. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10300. var lmat = this.getLocalMatrix();
  10301. var lx = lmat.m[12];
  10302. var ly = lmat.m[13];
  10303. var lz = lmat.m[14];
  10304. var parent = this.getParent();
  10305. var parentScale = Bone._tmpMats[3];
  10306. var parentScaleInv = Bone._tmpMats[4];
  10307. if (parent && space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD) {
  10308. if (mesh) {
  10309. parentScale.copyFrom(mesh.getWorldMatrix());
  10310. parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
  10311. }
  10312. else {
  10313. parentScale.copyFrom(parent.getAbsoluteTransform());
  10314. }
  10315. parentScaleInv.copyFrom(parentScale);
  10316. parentScaleInv.invert();
  10317. lmat.multiplyToRef(parentScale, lmat);
  10318. lmat.multiplyToRef(rmat, lmat);
  10319. lmat.multiplyToRef(parentScaleInv, lmat);
  10320. }
  10321. else {
  10322. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD && mesh) {
  10323. parentScale.copyFrom(mesh.getWorldMatrix());
  10324. parentScaleInv.copyFrom(parentScale);
  10325. parentScaleInv.invert();
  10326. lmat.multiplyToRef(parentScale, lmat);
  10327. lmat.multiplyToRef(rmat, lmat);
  10328. lmat.multiplyToRef(parentScaleInv, lmat);
  10329. }
  10330. else {
  10331. lmat.multiplyToRef(rmat, lmat);
  10332. }
  10333. }
  10334. lmat.setTranslationFromFloats(lx, ly, lz);
  10335. this.computeAbsoluteTransforms();
  10336. this._markAsDirtyAndDecompose();
  10337. };
  10338. Bone.prototype._getNegativeRotationToRef = function (rotMatInv, mesh) {
  10339. var scaleMatrix = Bone._tmpMats[2];
  10340. rotMatInv.copyFrom(this.getAbsoluteTransform());
  10341. if (mesh) {
  10342. rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
  10343. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, scaleMatrix);
  10344. }
  10345. rotMatInv.invert();
  10346. if (isNaN(rotMatInv.m[0])) {
  10347. // Matrix failed to invert.
  10348. // This can happen if scale is zero for example.
  10349. return false;
  10350. }
  10351. scaleMatrix.multiplyAtIndex(0, this._scalingDeterminant);
  10352. rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
  10353. return true;
  10354. };
  10355. /**
  10356. * Get the position of the bone in local or world space
  10357. * @param space The space that the returned position is in
  10358. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10359. * @returns The position of the bone
  10360. */
  10361. Bone.prototype.getPosition = function (space, mesh) {
  10362. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10363. if (mesh === void 0) { mesh = null; }
  10364. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10365. this.getPositionToRef(space, mesh, pos);
  10366. return pos;
  10367. };
  10368. /**
  10369. * Copy the position of the bone to a vector3 in local or world space
  10370. * @param space The space that the returned position is in
  10371. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10372. * @param result The vector3 to copy the position to
  10373. */
  10374. Bone.prototype.getPositionToRef = function (space, mesh, result) {
  10375. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10376. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10377. var lm = this.getLocalMatrix();
  10378. result.x = lm.m[12];
  10379. result.y = lm.m[13];
  10380. result.z = lm.m[14];
  10381. }
  10382. else {
  10383. var wm = null;
  10384. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10385. if (mesh) {
  10386. wm = mesh.getWorldMatrix();
  10387. }
  10388. this._skeleton.computeAbsoluteTransforms();
  10389. var tmat = Bone._tmpMats[0];
  10390. if (mesh && wm) {
  10391. tmat.copyFrom(this.getAbsoluteTransform());
  10392. tmat.multiplyToRef(wm, tmat);
  10393. }
  10394. else {
  10395. tmat = this.getAbsoluteTransform();
  10396. }
  10397. result.x = tmat.m[12];
  10398. result.y = tmat.m[13];
  10399. result.z = tmat.m[14];
  10400. }
  10401. };
  10402. /**
  10403. * Get the absolute position of the bone (world space)
  10404. * @param mesh The mesh that this bone is attached to
  10405. * @returns The absolute position of the bone
  10406. */
  10407. Bone.prototype.getAbsolutePosition = function (mesh) {
  10408. if (mesh === void 0) { mesh = null; }
  10409. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10410. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, pos);
  10411. return pos;
  10412. };
  10413. /**
  10414. * Copy the absolute position of the bone (world space) to the result param
  10415. * @param mesh The mesh that this bone is attached to
  10416. * @param result The vector3 to copy the absolute position to
  10417. */
  10418. Bone.prototype.getAbsolutePositionToRef = function (mesh, result) {
  10419. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, result);
  10420. };
  10421. /**
  10422. * Compute the absolute transforms of this bone and its children
  10423. */
  10424. Bone.prototype.computeAbsoluteTransforms = function () {
  10425. this._compose();
  10426. if (this._parent) {
  10427. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10428. }
  10429. else {
  10430. this._absoluteTransform.copyFrom(this._localMatrix);
  10431. var poseMatrix = this._skeleton.getPoseMatrix();
  10432. if (poseMatrix) {
  10433. this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
  10434. }
  10435. }
  10436. var children = this.children;
  10437. var len = children.length;
  10438. for (var i = 0; i < len; i++) {
  10439. children[i].computeAbsoluteTransforms();
  10440. }
  10441. };
  10442. /**
  10443. * Get the world direction from an axis that is in the local space of the bone
  10444. * @param localAxis The local direction that is used to compute the world direction
  10445. * @param mesh The mesh that this bone is attached to
  10446. * @returns The world direction
  10447. */
  10448. Bone.prototype.getDirection = function (localAxis, mesh) {
  10449. if (mesh === void 0) { mesh = null; }
  10450. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10451. this.getDirectionToRef(localAxis, mesh, result);
  10452. return result;
  10453. };
  10454. /**
  10455. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  10456. * @param localAxis The local direction that is used to compute the world direction
  10457. * @param mesh The mesh that this bone is attached to
  10458. * @param result The vector3 that the world direction will be copied to
  10459. */
  10460. Bone.prototype.getDirectionToRef = function (localAxis, mesh, result) {
  10461. if (mesh === void 0) { mesh = null; }
  10462. var wm = null;
  10463. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10464. if (mesh) {
  10465. wm = mesh.getWorldMatrix();
  10466. }
  10467. this._skeleton.computeAbsoluteTransforms();
  10468. var mat = Bone._tmpMats[0];
  10469. mat.copyFrom(this.getAbsoluteTransform());
  10470. if (mesh && wm) {
  10471. mat.multiplyToRef(wm, mat);
  10472. }
  10473. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(localAxis, mat, result);
  10474. result.normalize();
  10475. };
  10476. /**
  10477. * Get the euler rotation of the bone in local or world space
  10478. * @param space The space that the rotation should be in
  10479. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10480. * @returns The euler rotation
  10481. */
  10482. Bone.prototype.getRotation = function (space, mesh) {
  10483. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10484. if (mesh === void 0) { mesh = null; }
  10485. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10486. this.getRotationToRef(space, mesh, result);
  10487. return result;
  10488. };
  10489. /**
  10490. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  10491. * @param space The space that the rotation should be in
  10492. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10493. * @param result The vector3 that the rotation should be copied to
  10494. */
  10495. Bone.prototype.getRotationToRef = function (space, mesh, result) {
  10496. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10497. if (mesh === void 0) { mesh = null; }
  10498. var quat = Bone._tmpQuat;
  10499. this.getRotationQuaternionToRef(space, mesh, quat);
  10500. quat.toEulerAnglesToRef(result);
  10501. };
  10502. /**
  10503. * Get the quaternion rotation of the bone in either local or world space
  10504. * @param space The space that the rotation should be in
  10505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10506. * @returns The quaternion rotation
  10507. */
  10508. Bone.prototype.getRotationQuaternion = function (space, mesh) {
  10509. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10510. if (mesh === void 0) { mesh = null; }
  10511. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10512. this.getRotationQuaternionToRef(space, mesh, result);
  10513. return result;
  10514. };
  10515. /**
  10516. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  10517. * @param space The space that the rotation should be in
  10518. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10519. * @param result The quaternion that the rotation should be copied to
  10520. */
  10521. Bone.prototype.getRotationQuaternionToRef = function (space, mesh, result) {
  10522. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10523. if (mesh === void 0) { mesh = null; }
  10524. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10525. this._decompose();
  10526. result.copyFrom(this._localRotation);
  10527. }
  10528. else {
  10529. var mat = Bone._tmpMats[0];
  10530. var amat = this.getAbsoluteTransform();
  10531. if (mesh) {
  10532. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10533. }
  10534. else {
  10535. mat.copyFrom(amat);
  10536. }
  10537. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10538. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10539. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10540. mat.decompose(undefined, result, undefined);
  10541. }
  10542. };
  10543. /**
  10544. * Get the rotation matrix of the bone in local or world space
  10545. * @param space The space that the rotation should be in
  10546. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10547. * @returns The rotation matrix
  10548. */
  10549. Bone.prototype.getRotationMatrix = function (space, mesh) {
  10550. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10551. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10552. this.getRotationMatrixToRef(space, mesh, result);
  10553. return result;
  10554. };
  10555. /**
  10556. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  10557. * @param space The space that the rotation should be in
  10558. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10559. * @param result The quaternion that the rotation should be copied to
  10560. */
  10561. Bone.prototype.getRotationMatrixToRef = function (space, mesh, result) {
  10562. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10563. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10564. this.getLocalMatrix().getRotationMatrixToRef(result);
  10565. }
  10566. else {
  10567. var mat = Bone._tmpMats[0];
  10568. var amat = this.getAbsoluteTransform();
  10569. if (mesh) {
  10570. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10571. }
  10572. else {
  10573. mat.copyFrom(amat);
  10574. }
  10575. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10576. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10577. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10578. mat.getRotationMatrixToRef(result);
  10579. }
  10580. };
  10581. /**
  10582. * Get the world position of a point that is in the local space of the bone
  10583. * @param position The local position
  10584. * @param mesh The mesh that this bone is attached to
  10585. * @returns The world position
  10586. */
  10587. Bone.prototype.getAbsolutePositionFromLocal = function (position, mesh) {
  10588. if (mesh === void 0) { mesh = null; }
  10589. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10590. this.getAbsolutePositionFromLocalToRef(position, mesh, result);
  10591. return result;
  10592. };
  10593. /**
  10594. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  10595. * @param position The local position
  10596. * @param mesh The mesh that this bone is attached to
  10597. * @param result The vector3 that the world position should be copied to
  10598. */
  10599. Bone.prototype.getAbsolutePositionFromLocalToRef = function (position, mesh, result) {
  10600. if (mesh === void 0) { mesh = null; }
  10601. var wm = null;
  10602. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10603. if (mesh) {
  10604. wm = mesh.getWorldMatrix();
  10605. }
  10606. this._skeleton.computeAbsoluteTransforms();
  10607. var tmat = Bone._tmpMats[0];
  10608. if (mesh && wm) {
  10609. tmat.copyFrom(this.getAbsoluteTransform());
  10610. tmat.multiplyToRef(wm, tmat);
  10611. }
  10612. else {
  10613. tmat = this.getAbsoluteTransform();
  10614. }
  10615. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10616. };
  10617. /**
  10618. * Get the local position of a point that is in world space
  10619. * @param position The world position
  10620. * @param mesh The mesh that this bone is attached to
  10621. * @returns The local position
  10622. */
  10623. Bone.prototype.getLocalPositionFromAbsolute = function (position, mesh) {
  10624. if (mesh === void 0) { mesh = null; }
  10625. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10626. this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
  10627. return result;
  10628. };
  10629. /**
  10630. * Get the local position of a point that is in world space and copy it to the result param
  10631. * @param position The world position
  10632. * @param mesh The mesh that this bone is attached to
  10633. * @param result The vector3 that the local position should be copied to
  10634. */
  10635. Bone.prototype.getLocalPositionFromAbsoluteToRef = function (position, mesh, result) {
  10636. if (mesh === void 0) { mesh = null; }
  10637. var wm = null;
  10638. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10639. if (mesh) {
  10640. wm = mesh.getWorldMatrix();
  10641. }
  10642. this._skeleton.computeAbsoluteTransforms();
  10643. var tmat = Bone._tmpMats[0];
  10644. tmat.copyFrom(this.getAbsoluteTransform());
  10645. if (mesh && wm) {
  10646. tmat.multiplyToRef(wm, tmat);
  10647. }
  10648. tmat.invert();
  10649. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10650. };
  10651. Bone._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  10652. Bone._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10653. Bone._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  10654. return Bone;
  10655. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  10656. /***/ }),
  10657. /***/ "./Bones/boneIKController.ts":
  10658. /*!***********************************!*\
  10659. !*** ./Bones/boneIKController.ts ***!
  10660. \***********************************/
  10661. /*! exports provided: BoneIKController */
  10662. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10663. "use strict";
  10664. __webpack_require__.r(__webpack_exports__);
  10665. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return BoneIKController; });
  10666. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10667. /**
  10668. * Class used to apply inverse kinematics to bones
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  10670. */
  10671. var BoneIKController = /** @class */ (function () {
  10672. /**
  10673. * Creates a new BoneIKController
  10674. * @param mesh defines the mesh to control
  10675. * @param bone defines the bone to control
  10676. * @param options defines options to set up the controller
  10677. */
  10678. function BoneIKController(mesh, bone, options) {
  10679. /**
  10680. * Gets or sets the target position
  10681. */
  10682. this.targetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10683. /**
  10684. * Gets or sets the pole target position
  10685. */
  10686. this.poleTargetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10687. /**
  10688. * Gets or sets the pole target local offset
  10689. */
  10690. this.poleTargetLocalOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10691. /**
  10692. * Gets or sets the pole angle
  10693. */
  10694. this.poleAngle = 0;
  10695. /**
  10696. * 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)
  10697. */
  10698. this.slerpAmount = 1;
  10699. this._bone1Quat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10700. this._bone1Mat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  10701. this._bone2Ang = Math.PI;
  10702. this._maxAngle = Math.PI;
  10703. this._rightHandedSystem = false;
  10704. this._bendAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right();
  10705. this._slerping = false;
  10706. this._adjustRoll = 0;
  10707. this._bone2 = bone;
  10708. this._bone1 = bone.getParent();
  10709. if (!this._bone1) {
  10710. return;
  10711. }
  10712. this.mesh = mesh;
  10713. var bonePos = bone.getPosition();
  10714. if (bone.getAbsoluteTransform().determinant() > 0) {
  10715. this._rightHandedSystem = true;
  10716. this._bendAxis.x = 0;
  10717. this._bendAxis.y = 0;
  10718. this._bendAxis.z = -1;
  10719. if (bonePos.x > bonePos.y && bonePos.x > bonePos.z) {
  10720. this._adjustRoll = Math.PI * .5;
  10721. this._bendAxis.z = 1;
  10722. }
  10723. }
  10724. if (this._bone1.length) {
  10725. var boneScale1 = this._bone1.getScale();
  10726. var boneScale2 = this._bone2.getScale();
  10727. this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
  10728. this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
  10729. }
  10730. else if (this._bone1.children[0]) {
  10731. mesh.computeWorldMatrix(true);
  10732. var pos1 = this._bone2.children[0].getAbsolutePosition(mesh);
  10733. var pos2 = this._bone2.getAbsolutePosition(mesh);
  10734. var pos3 = this._bone1.getAbsolutePosition(mesh);
  10735. this._bone1Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos1, pos2);
  10736. this._bone2Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos2, pos3);
  10737. }
  10738. this._bone1.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, mesh, this._bone1Mat);
  10739. this.maxAngle = Math.PI;
  10740. if (options) {
  10741. if (options.targetMesh) {
  10742. this.targetMesh = options.targetMesh;
  10743. this.targetMesh.computeWorldMatrix(true);
  10744. }
  10745. if (options.poleTargetMesh) {
  10746. this.poleTargetMesh = options.poleTargetMesh;
  10747. this.poleTargetMesh.computeWorldMatrix(true);
  10748. }
  10749. else if (options.poleTargetBone) {
  10750. this.poleTargetBone = options.poleTargetBone;
  10751. }
  10752. else if (this._bone1.getParent()) {
  10753. this.poleTargetBone = this._bone1.getParent();
  10754. }
  10755. if (options.poleTargetLocalOffset) {
  10756. this.poleTargetLocalOffset.copyFrom(options.poleTargetLocalOffset);
  10757. }
  10758. if (options.poleAngle) {
  10759. this.poleAngle = options.poleAngle;
  10760. }
  10761. if (options.bendAxis) {
  10762. this._bendAxis.copyFrom(options.bendAxis);
  10763. }
  10764. if (options.maxAngle) {
  10765. this.maxAngle = options.maxAngle;
  10766. }
  10767. if (options.slerpAmount) {
  10768. this.slerpAmount = options.slerpAmount;
  10769. }
  10770. }
  10771. }
  10772. Object.defineProperty(BoneIKController.prototype, "maxAngle", {
  10773. /**
  10774. * Gets or sets maximum allowed angle
  10775. */
  10776. get: function () {
  10777. return this._maxAngle;
  10778. },
  10779. set: function (value) {
  10780. this._setMaxAngle(value);
  10781. },
  10782. enumerable: true,
  10783. configurable: true
  10784. });
  10785. BoneIKController.prototype._setMaxAngle = function (ang) {
  10786. if (ang < 0) {
  10787. ang = 0;
  10788. }
  10789. if (ang > Math.PI || ang == undefined) {
  10790. ang = Math.PI;
  10791. }
  10792. this._maxAngle = ang;
  10793. var a = this._bone1Length;
  10794. var b = this._bone2Length;
  10795. this._maxReach = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang));
  10796. };
  10797. /**
  10798. * Force the controller to update the bones
  10799. */
  10800. BoneIKController.prototype.update = function () {
  10801. var bone1 = this._bone1;
  10802. if (!bone1) {
  10803. return;
  10804. }
  10805. var target = this.targetPosition;
  10806. var poleTarget = this.poleTargetPosition;
  10807. var mat1 = BoneIKController._tmpMats[0];
  10808. var mat2 = BoneIKController._tmpMats[1];
  10809. if (this.targetMesh) {
  10810. target.copyFrom(this.targetMesh.getAbsolutePosition());
  10811. }
  10812. if (this.poleTargetBone) {
  10813. this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, poleTarget);
  10814. }
  10815. else if (this.poleTargetMesh) {
  10816. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), poleTarget);
  10817. }
  10818. var bonePos = BoneIKController._tmpVecs[0];
  10819. var zaxis = BoneIKController._tmpVecs[1];
  10820. var xaxis = BoneIKController._tmpVecs[2];
  10821. var yaxis = BoneIKController._tmpVecs[3];
  10822. var upAxis = BoneIKController._tmpVecs[4];
  10823. var _tmpQuat = BoneIKController._tmpQuat;
  10824. bone1.getAbsolutePositionToRef(this.mesh, bonePos);
  10825. poleTarget.subtractToRef(bonePos, upAxis);
  10826. if (upAxis.x == 0 && upAxis.y == 0 && upAxis.z == 0) {
  10827. upAxis.y = 1;
  10828. }
  10829. else {
  10830. upAxis.normalize();
  10831. }
  10832. target.subtractToRef(bonePos, yaxis);
  10833. yaxis.normalize();
  10834. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, upAxis, zaxis);
  10835. zaxis.normalize();
  10836. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, zaxis, xaxis);
  10837. xaxis.normalize();
  10838. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, mat1);
  10839. var a = this._bone1Length;
  10840. var b = this._bone2Length;
  10841. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(bonePos, target);
  10842. if (this._maxReach > 0) {
  10843. c = Math.min(this._maxReach, c);
  10844. }
  10845. var acosa = (b * b + c * c - a * a) / (2 * b * c);
  10846. var acosb = (c * c + a * a - b * b) / (2 * c * a);
  10847. if (acosa > 1) {
  10848. acosa = 1;
  10849. }
  10850. if (acosb > 1) {
  10851. acosb = 1;
  10852. }
  10853. if (acosa < -1) {
  10854. acosa = -1;
  10855. }
  10856. if (acosb < -1) {
  10857. acosb = -1;
  10858. }
  10859. var angA = Math.acos(acosa);
  10860. var angB = Math.acos(acosb);
  10861. var angC = -angA - angB;
  10862. if (this._rightHandedSystem) {
  10863. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRollToRef(0, 0, this._adjustRoll, mat2);
  10864. mat2.multiplyToRef(mat1, mat1);
  10865. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(this._bendAxis, angB, mat2);
  10866. mat2.multiplyToRef(mat1, mat1);
  10867. }
  10868. else {
  10869. var _tmpVec = BoneIKController._tmpVecs[5];
  10870. _tmpVec.copyFrom(this._bendAxis);
  10871. _tmpVec.x *= -1;
  10872. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(_tmpVec, -angB, mat2);
  10873. mat2.multiplyToRef(mat1, mat1);
  10874. }
  10875. if (this.poleAngle) {
  10876. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(yaxis, this.poleAngle, mat2);
  10877. mat1.multiplyToRef(mat2, mat1);
  10878. }
  10879. if (this._bone1) {
  10880. if (this.slerpAmount < 1) {
  10881. if (!this._slerping) {
  10882. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat);
  10883. }
  10884. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(mat1, _tmpQuat);
  10885. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].SlerpToRef(this._bone1Quat, _tmpQuat, this.slerpAmount, this._bone1Quat);
  10886. angC = this._bone2Ang * (1.0 - this.slerpAmount) + angC * this.slerpAmount;
  10887. this._bone1.setRotationQuaternion(this._bone1Quat, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10888. this._slerping = true;
  10889. }
  10890. else {
  10891. this._bone1.setRotationMatrix(mat1, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10892. this._bone1Mat.copyFrom(mat1);
  10893. this._slerping = false;
  10894. }
  10895. }
  10896. this._bone2.setAxisAngle(this._bendAxis, angC, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].LOCAL);
  10897. this._bone2Ang = angC;
  10898. };
  10899. 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()];
  10900. BoneIKController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10901. BoneIKController._tmpMats = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity()];
  10902. return BoneIKController;
  10903. }());
  10904. /***/ }),
  10905. /***/ "./Bones/boneLookController.ts":
  10906. /*!*************************************!*\
  10907. !*** ./Bones/boneLookController.ts ***!
  10908. \*************************************/
  10909. /*! exports provided: BoneLookController */
  10910. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10911. "use strict";
  10912. __webpack_require__.r(__webpack_exports__);
  10913. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return BoneLookController; });
  10914. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  10915. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10916. /**
  10917. * Class used to make a bone look toward a point in space
  10918. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  10919. */
  10920. var BoneLookController = /** @class */ (function () {
  10921. /**
  10922. * Create a BoneLookController
  10923. * @param mesh the mesh that the bone belongs to
  10924. * @param bone the bone that will be looking to the target
  10925. * @param target the target Vector3 to look at
  10926. * @param options optional settings:
  10927. * * maxYaw: the maximum angle the bone will yaw to
  10928. * * minYaw: the minimum angle the bone will yaw to
  10929. * * maxPitch: the maximum angle the bone will pitch to
  10930. * * minPitch: the minimum angle the bone will yaw to
  10931. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  10932. * * upAxis: the up axis of the coordinate system
  10933. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  10934. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  10935. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  10936. * * adjustYaw: used to make an adjustment to the yaw of the bone
  10937. * * adjustPitch: used to make an adjustment to the pitch of the bone
  10938. * * adjustRoll: used to make an adjustment to the roll of the bone
  10939. **/
  10940. function BoneLookController(mesh, bone, target, options) {
  10941. /**
  10942. * The up axis of the coordinate system that is used when the bone is rotated
  10943. */
  10944. this.upAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
  10945. /**
  10946. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  10947. */
  10948. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  10949. /**
  10950. * Used to make an adjustment to the yaw of the bone
  10951. */
  10952. this.adjustYaw = 0;
  10953. /**
  10954. * Used to make an adjustment to the pitch of the bone
  10955. */
  10956. this.adjustPitch = 0;
  10957. /**
  10958. * Used to make an adjustment to the roll of the bone
  10959. */
  10960. this.adjustRoll = 0;
  10961. /**
  10962. * 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)
  10963. */
  10964. this.slerpAmount = 1;
  10965. this._boneQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10966. this._slerping = false;
  10967. this._firstFrameSkipped = false;
  10968. this._fowardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Forward();
  10969. this.mesh = mesh;
  10970. this.bone = bone;
  10971. this.target = target;
  10972. if (options) {
  10973. if (options.adjustYaw) {
  10974. this.adjustYaw = options.adjustYaw;
  10975. }
  10976. if (options.adjustPitch) {
  10977. this.adjustPitch = options.adjustPitch;
  10978. }
  10979. if (options.adjustRoll) {
  10980. this.adjustRoll = options.adjustRoll;
  10981. }
  10982. if (options.maxYaw != null) {
  10983. this.maxYaw = options.maxYaw;
  10984. }
  10985. else {
  10986. this.maxYaw = Math.PI;
  10987. }
  10988. if (options.minYaw != null) {
  10989. this.minYaw = options.minYaw;
  10990. }
  10991. else {
  10992. this.minYaw = -Math.PI;
  10993. }
  10994. if (options.maxPitch != null) {
  10995. this.maxPitch = options.maxPitch;
  10996. }
  10997. else {
  10998. this.maxPitch = Math.PI;
  10999. }
  11000. if (options.minPitch != null) {
  11001. this.minPitch = options.minPitch;
  11002. }
  11003. else {
  11004. this.minPitch = -Math.PI;
  11005. }
  11006. if (options.slerpAmount != null) {
  11007. this.slerpAmount = options.slerpAmount;
  11008. }
  11009. if (options.upAxis != null) {
  11010. this.upAxis = options.upAxis;
  11011. }
  11012. if (options.upAxisSpace != null) {
  11013. this.upAxisSpace = options.upAxisSpace;
  11014. }
  11015. if (options.yawAxis != null || options.pitchAxis != null) {
  11016. var newYawAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y;
  11017. var newPitchAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].X;
  11018. if (options.yawAxis != null) {
  11019. newYawAxis = options.yawAxis.clone();
  11020. newYawAxis.normalize();
  11021. }
  11022. if (options.pitchAxis != null) {
  11023. newPitchAxis = options.pitchAxis.clone();
  11024. newPitchAxis.normalize();
  11025. }
  11026. var newRollAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(newPitchAxis, newYawAxis);
  11027. this._transformYawPitch = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  11028. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(newPitchAxis, newYawAxis, newRollAxis, this._transformYawPitch);
  11029. this._transformYawPitchInv = this._transformYawPitch.clone();
  11030. this._transformYawPitch.invert();
  11031. }
  11032. }
  11033. if (!bone.getParent() && this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE) {
  11034. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  11035. }
  11036. }
  11037. Object.defineProperty(BoneLookController.prototype, "minYaw", {
  11038. /**
  11039. * Gets or sets the minimum yaw angle that the bone can look to
  11040. */
  11041. get: function () {
  11042. return this._minYaw;
  11043. },
  11044. set: function (value) {
  11045. this._minYaw = value;
  11046. this._minYawSin = Math.sin(value);
  11047. this._minYawCos = Math.cos(value);
  11048. if (this._maxYaw != null) {
  11049. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11050. this._yawRange = this._maxYaw - this._minYaw;
  11051. }
  11052. },
  11053. enumerable: true,
  11054. configurable: true
  11055. });
  11056. Object.defineProperty(BoneLookController.prototype, "maxYaw", {
  11057. /**
  11058. * Gets or sets the maximum yaw angle that the bone can look to
  11059. */
  11060. get: function () {
  11061. return this._maxYaw;
  11062. },
  11063. set: function (value) {
  11064. this._maxYaw = value;
  11065. this._maxYawSin = Math.sin(value);
  11066. this._maxYawCos = Math.cos(value);
  11067. if (this._minYaw != null) {
  11068. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11069. this._yawRange = this._maxYaw - this._minYaw;
  11070. }
  11071. },
  11072. enumerable: true,
  11073. configurable: true
  11074. });
  11075. Object.defineProperty(BoneLookController.prototype, "minPitch", {
  11076. /**
  11077. * Gets or sets the minimum pitch angle that the bone can look to
  11078. */
  11079. get: function () {
  11080. return this._minPitch;
  11081. },
  11082. set: function (value) {
  11083. this._minPitch = value;
  11084. this._minPitchTan = Math.tan(value);
  11085. },
  11086. enumerable: true,
  11087. configurable: true
  11088. });
  11089. Object.defineProperty(BoneLookController.prototype, "maxPitch", {
  11090. /**
  11091. * Gets or sets the maximum pitch angle that the bone can look to
  11092. */
  11093. get: function () {
  11094. return this._maxPitch;
  11095. },
  11096. set: function (value) {
  11097. this._maxPitch = value;
  11098. this._maxPitchTan = Math.tan(value);
  11099. },
  11100. enumerable: true,
  11101. configurable: true
  11102. });
  11103. /**
  11104. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  11105. */
  11106. BoneLookController.prototype.update = function () {
  11107. //skip the first frame when slerping so that the mesh rotation is correct
  11108. if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
  11109. this._firstFrameSkipped = true;
  11110. return;
  11111. }
  11112. var bone = this.bone;
  11113. var bonePos = BoneLookController._tmpVecs[0];
  11114. bone.getAbsolutePositionToRef(this.mesh, bonePos);
  11115. var target = this.target;
  11116. var _tmpMat1 = BoneLookController._tmpMats[0];
  11117. var _tmpMat2 = BoneLookController._tmpMats[1];
  11118. var mesh = this.mesh;
  11119. var parentBone = bone.getParent();
  11120. var upAxis = BoneLookController._tmpVecs[1];
  11121. upAxis.copyFrom(this.upAxis);
  11122. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && parentBone) {
  11123. if (this._transformYawPitch) {
  11124. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
  11125. }
  11126. parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
  11127. }
  11128. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  11129. mesh.getDirectionToRef(upAxis, upAxis);
  11130. if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
  11131. upAxis.normalize();
  11132. }
  11133. }
  11134. var checkYaw = false;
  11135. var checkPitch = false;
  11136. if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
  11137. checkYaw = true;
  11138. }
  11139. if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
  11140. checkPitch = true;
  11141. }
  11142. if (checkYaw || checkPitch) {
  11143. var spaceMat = BoneLookController._tmpMats[2];
  11144. var spaceMatInv = BoneLookController._tmpMats[3];
  11145. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && upAxis.y == 1 && parentBone) {
  11146. parentBone.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, spaceMat);
  11147. }
  11148. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL && upAxis.y == 1 && !parentBone) {
  11149. spaceMat.copyFrom(mesh.getWorldMatrix());
  11150. }
  11151. else {
  11152. var forwardAxis = BoneLookController._tmpVecs[2];
  11153. forwardAxis.copyFrom(this._fowardAxis);
  11154. if (this._transformYawPitch) {
  11155. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
  11156. }
  11157. if (parentBone) {
  11158. parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
  11159. }
  11160. else {
  11161. mesh.getDirectionToRef(forwardAxis, forwardAxis);
  11162. }
  11163. var rightAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(upAxis, forwardAxis);
  11164. rightAxis.normalize();
  11165. var forwardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(rightAxis, upAxis);
  11166. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
  11167. }
  11168. spaceMat.invertToRef(spaceMatInv);
  11169. var xzlen = null;
  11170. if (checkPitch) {
  11171. var localTarget = BoneLookController._tmpVecs[3];
  11172. target.subtractToRef(bonePos, localTarget);
  11173. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11174. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11175. var pitch = Math.atan2(localTarget.y, xzlen);
  11176. var newPitch = pitch;
  11177. if (pitch > this._maxPitch) {
  11178. localTarget.y = this._maxPitchTan * xzlen;
  11179. newPitch = this._maxPitch;
  11180. }
  11181. else if (pitch < this._minPitch) {
  11182. localTarget.y = this._minPitchTan * xzlen;
  11183. newPitch = this._minPitch;
  11184. }
  11185. if (pitch != newPitch) {
  11186. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11187. localTarget.addInPlace(bonePos);
  11188. target = localTarget;
  11189. }
  11190. }
  11191. if (checkYaw) {
  11192. var localTarget = BoneLookController._tmpVecs[4];
  11193. target.subtractToRef(bonePos, localTarget);
  11194. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11195. var yaw = Math.atan2(localTarget.x, localTarget.z);
  11196. var newYaw = yaw;
  11197. if (yaw > this._maxYaw || yaw < this._minYaw) {
  11198. if (xzlen == null) {
  11199. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11200. }
  11201. if (this._yawRange > Math.PI) {
  11202. if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
  11203. localTarget.z = this._maxYawCos * xzlen;
  11204. localTarget.x = this._maxYawSin * xzlen;
  11205. newYaw = this._maxYaw;
  11206. }
  11207. else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
  11208. localTarget.z = this._minYawCos * xzlen;
  11209. localTarget.x = this._minYawSin * xzlen;
  11210. newYaw = this._minYaw;
  11211. }
  11212. }
  11213. else {
  11214. if (yaw > this._maxYaw) {
  11215. localTarget.z = this._maxYawCos * xzlen;
  11216. localTarget.x = this._maxYawSin * xzlen;
  11217. newYaw = this._maxYaw;
  11218. }
  11219. else if (yaw < this._minYaw) {
  11220. localTarget.z = this._minYawCos * xzlen;
  11221. localTarget.x = this._minYawSin * xzlen;
  11222. newYaw = this._minYaw;
  11223. }
  11224. }
  11225. }
  11226. if (this._slerping && this._yawRange > Math.PI) {
  11227. //are we going to be crossing into the min/max region?
  11228. var boneFwd = BoneLookController._tmpVecs[8];
  11229. boneFwd.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Z);
  11230. if (this._transformYawPitch) {
  11231. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
  11232. }
  11233. var boneRotMat = BoneLookController._tmpMats[4];
  11234. this._boneQuat.toRotationMatrix(boneRotMat);
  11235. this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
  11236. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
  11237. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
  11238. var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
  11239. var angBtwTar = this._getAngleBetween(boneYaw, yaw);
  11240. var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
  11241. if (angBtwTar > angBtwMidYaw) {
  11242. if (xzlen == null) {
  11243. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11244. }
  11245. var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
  11246. var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
  11247. if (angBtwMin < angBtwMax) {
  11248. newYaw = boneYaw + Math.PI * .75;
  11249. localTarget.z = Math.cos(newYaw) * xzlen;
  11250. localTarget.x = Math.sin(newYaw) * xzlen;
  11251. }
  11252. else {
  11253. newYaw = boneYaw - Math.PI * .75;
  11254. localTarget.z = Math.cos(newYaw) * xzlen;
  11255. localTarget.x = Math.sin(newYaw) * xzlen;
  11256. }
  11257. }
  11258. }
  11259. if (yaw != newYaw) {
  11260. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11261. localTarget.addInPlace(bonePos);
  11262. target = localTarget;
  11263. }
  11264. }
  11265. }
  11266. var zaxis = BoneLookController._tmpVecs[5];
  11267. var xaxis = BoneLookController._tmpVecs[6];
  11268. var yaxis = BoneLookController._tmpVecs[7];
  11269. var _tmpQuat = BoneLookController._tmpQuat;
  11270. target.subtractToRef(bonePos, zaxis);
  11271. zaxis.normalize();
  11272. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(upAxis, zaxis, xaxis);
  11273. xaxis.normalize();
  11274. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(zaxis, xaxis, yaxis);
  11275. yaxis.normalize();
  11276. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
  11277. if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
  11278. return;
  11279. }
  11280. if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
  11281. return;
  11282. }
  11283. if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
  11284. return;
  11285. }
  11286. if (this.adjustYaw || this.adjustPitch || this.adjustRoll) {
  11287. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, _tmpMat2);
  11288. _tmpMat2.multiplyToRef(_tmpMat1, _tmpMat1);
  11289. }
  11290. if (this.slerpAmount < 1) {
  11291. if (!this._slerping) {
  11292. this.bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, this._boneQuat);
  11293. }
  11294. if (this._transformYawPitch) {
  11295. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11296. }
  11297. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
  11298. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
  11299. this.bone.setRotationQuaternion(this._boneQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11300. this._slerping = true;
  11301. }
  11302. else {
  11303. if (this._transformYawPitch) {
  11304. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11305. }
  11306. this.bone.setRotationMatrix(_tmpMat1, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11307. this._slerping = false;
  11308. }
  11309. };
  11310. BoneLookController.prototype._getAngleDiff = function (ang1, ang2) {
  11311. var angDiff = ang2 - ang1;
  11312. angDiff %= Math.PI * 2;
  11313. if (angDiff > Math.PI) {
  11314. angDiff -= Math.PI * 2;
  11315. }
  11316. else if (angDiff < -Math.PI) {
  11317. angDiff += Math.PI * 2;
  11318. }
  11319. return angDiff;
  11320. };
  11321. BoneLookController.prototype._getAngleBetween = function (ang1, ang2) {
  11322. ang1 %= (2 * Math.PI);
  11323. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11324. ang2 %= (2 * Math.PI);
  11325. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11326. var ab = 0;
  11327. if (ang1 < ang2) {
  11328. ab = ang2 - ang1;
  11329. }
  11330. else {
  11331. ab = ang1 - ang2;
  11332. }
  11333. if (ab > Math.PI) {
  11334. ab = Math.PI * 2 - ab;
  11335. }
  11336. return ab;
  11337. };
  11338. BoneLookController.prototype._isAngleBetween = function (ang, ang1, ang2) {
  11339. ang %= (2 * Math.PI);
  11340. ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
  11341. ang1 %= (2 * Math.PI);
  11342. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11343. ang2 %= (2 * Math.PI);
  11344. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11345. if (ang1 < ang2) {
  11346. if (ang > ang1 && ang < ang2) {
  11347. return true;
  11348. }
  11349. }
  11350. else {
  11351. if (ang > ang2 && ang < ang1) {
  11352. return true;
  11353. }
  11354. }
  11355. return false;
  11356. };
  11357. BoneLookController._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(10, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  11358. BoneLookController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11359. BoneLookController._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  11360. return BoneLookController;
  11361. }());
  11362. /***/ }),
  11363. /***/ "./Bones/index.ts":
  11364. /*!************************!*\
  11365. !*** ./Bones/index.ts ***!
  11366. \************************/
  11367. /*! exports provided: Bone, BoneIKController, BoneLookController, Skeleton */
  11368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11369. "use strict";
  11370. __webpack_require__.r(__webpack_exports__);
  11371. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  11373. /* harmony import */ var _boneIKController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneIKController */ "./Bones/boneIKController.ts");
  11374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _boneIKController__WEBPACK_IMPORTED_MODULE_1__["BoneIKController"]; });
  11375. /* harmony import */ var _boneLookController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boneLookController */ "./Bones/boneLookController.ts");
  11376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _boneLookController__WEBPACK_IMPORTED_MODULE_2__["BoneLookController"]; });
  11377. /* harmony import */ var _skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./skeleton */ "./Bones/skeleton.ts");
  11378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _skeleton__WEBPACK_IMPORTED_MODULE_3__["Skeleton"]; });
  11379. /***/ }),
  11380. /***/ "./Bones/skeleton.ts":
  11381. /*!***************************!*\
  11382. !*** ./Bones/skeleton.ts ***!
  11383. \***************************/
  11384. /*! exports provided: Skeleton */
  11385. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11386. "use strict";
  11387. __webpack_require__.r(__webpack_exports__);
  11388. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return Skeleton; });
  11389. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11390. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  11391. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  11392. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  11393. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  11394. /* harmony import */ var _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animationRange */ "./Animations/animationRange.ts");
  11395. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  11396. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  11397. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  11398. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  11399. /**
  11400. * Class used to handle skinning animations
  11401. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  11402. */
  11403. var Skeleton = /** @class */ (function () {
  11404. /**
  11405. * Creates a new skeleton
  11406. * @param name defines the skeleton name
  11407. * @param id defines the skeleton Id
  11408. * @param scene defines the hosting scene
  11409. */
  11410. function Skeleton(
  11411. /** defines the skeleton name */
  11412. name,
  11413. /** defines the skeleton Id */
  11414. id, scene) {
  11415. this.name = name;
  11416. this.id = id;
  11417. /**
  11418. * Defines the list of child bones
  11419. */
  11420. this.bones = new Array();
  11421. /**
  11422. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  11423. */
  11424. this.needInitialSkinMatrix = false;
  11425. /**
  11426. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  11427. */
  11428. this.overrideMesh = null;
  11429. this._isDirty = true;
  11430. this._meshesWithPoseMatrix = new Array();
  11431. this._identity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  11432. this._ranges = {};
  11433. this._lastAbsoluteTransformsUpdateId = -1;
  11434. this._canUseTextureForBones = false;
  11435. /** @hidden */
  11436. this._numBonesWithLinkedTransformNode = 0;
  11437. /**
  11438. * Specifies if the skeleton should be serialized
  11439. */
  11440. this.doNotSerialize = false;
  11441. /**
  11442. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  11443. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  11444. */
  11445. this.useTextureToStoreBoneMatrices = true;
  11446. this._animationPropertiesOverride = null;
  11447. // Events
  11448. /**
  11449. * An observable triggered before computing the skeleton's matrices
  11450. */
  11451. this.onBeforeComputeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11452. this.bones = [];
  11453. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  11454. this._scene.skeletons.push(this);
  11455. //make sure it will recalculate the matrix next time prepare is called.
  11456. this._isDirty = true;
  11457. var engineCaps = this._scene.getEngine().getCaps();
  11458. this._canUseTextureForBones = engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0;
  11459. }
  11460. Object.defineProperty(Skeleton.prototype, "animationPropertiesOverride", {
  11461. /**
  11462. * Gets or sets the animation properties override
  11463. */
  11464. get: function () {
  11465. if (!this._animationPropertiesOverride) {
  11466. return this._scene.animationPropertiesOverride;
  11467. }
  11468. return this._animationPropertiesOverride;
  11469. },
  11470. set: function (value) {
  11471. this._animationPropertiesOverride = value;
  11472. },
  11473. enumerable: true,
  11474. configurable: true
  11475. });
  11476. Object.defineProperty(Skeleton.prototype, "isUsingTextureForMatrices", {
  11477. /**
  11478. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  11479. */
  11480. get: function () {
  11481. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones && !this.needInitialSkinMatrix;
  11482. },
  11483. enumerable: true,
  11484. configurable: true
  11485. });
  11486. // Members
  11487. /**
  11488. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  11489. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11490. * @returns a Float32Array containing matrices data
  11491. */
  11492. Skeleton.prototype.getTransformMatrices = function (mesh) {
  11493. if (this.needInitialSkinMatrix && mesh._bonesTransformMatrices) {
  11494. return mesh._bonesTransformMatrices;
  11495. }
  11496. if (!this._transformMatrices) {
  11497. this.prepare();
  11498. }
  11499. return this._transformMatrices;
  11500. };
  11501. /**
  11502. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  11503. * @returns a raw texture containing the data
  11504. */
  11505. Skeleton.prototype.getTransformMatrixTexture = function () {
  11506. return this._transformMatrixTexture;
  11507. };
  11508. /**
  11509. * Gets the current hosting scene
  11510. * @returns a scene object
  11511. */
  11512. Skeleton.prototype.getScene = function () {
  11513. return this._scene;
  11514. };
  11515. // Methods
  11516. /**
  11517. * Gets a string representing the current skeleton data
  11518. * @param fullDetails defines a boolean indicating if we want a verbose version
  11519. * @returns a string representing the current skeleton data
  11520. */
  11521. Skeleton.prototype.toString = function (fullDetails) {
  11522. var ret = "Name: " + this.name + ", nBones: " + this.bones.length;
  11523. ret += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  11524. if (fullDetails) {
  11525. ret += ", Ranges: {";
  11526. var first = true;
  11527. for (var name_1 in this._ranges) {
  11528. if (first) {
  11529. ret += ", ";
  11530. first = false;
  11531. }
  11532. ret += name_1;
  11533. }
  11534. ret += "}";
  11535. }
  11536. return ret;
  11537. };
  11538. /**
  11539. * Get bone's index searching by name
  11540. * @param name defines bone's name to search for
  11541. * @return the indice of the bone. Returns -1 if not found
  11542. */
  11543. Skeleton.prototype.getBoneIndexByName = function (name) {
  11544. for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
  11545. if (this.bones[boneIndex].name === name) {
  11546. return boneIndex;
  11547. }
  11548. }
  11549. return -1;
  11550. };
  11551. /**
  11552. * Creater a new animation range
  11553. * @param name defines the name of the range
  11554. * @param from defines the start key
  11555. * @param to defines the end key
  11556. */
  11557. Skeleton.prototype.createAnimationRange = function (name, from, to) {
  11558. // check name not already in use
  11559. if (!this._ranges[name]) {
  11560. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  11561. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11562. if (this.bones[i].animations[0]) {
  11563. this.bones[i].animations[0].createRange(name, from, to);
  11564. }
  11565. }
  11566. }
  11567. };
  11568. /**
  11569. * Delete a specific animation range
  11570. * @param name defines the name of the range
  11571. * @param deleteFrames defines if frames must be removed as well
  11572. */
  11573. Skeleton.prototype.deleteAnimationRange = function (name, deleteFrames) {
  11574. if (deleteFrames === void 0) { deleteFrames = true; }
  11575. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11576. if (this.bones[i].animations[0]) {
  11577. this.bones[i].animations[0].deleteRange(name, deleteFrames);
  11578. }
  11579. }
  11580. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  11581. };
  11582. /**
  11583. * Gets a specific animation range
  11584. * @param name defines the name of the range to look for
  11585. * @returns the requested animation range or null if not found
  11586. */
  11587. Skeleton.prototype.getAnimationRange = function (name) {
  11588. return this._ranges[name];
  11589. };
  11590. /**
  11591. * Gets the list of all animation ranges defined on this skeleton
  11592. * @returns an array
  11593. */
  11594. Skeleton.prototype.getAnimationRanges = function () {
  11595. var animationRanges = [];
  11596. var name;
  11597. var i = 0;
  11598. for (name in this._ranges) {
  11599. animationRanges[i] = this._ranges[name];
  11600. i++;
  11601. }
  11602. return animationRanges;
  11603. };
  11604. /**
  11605. * Copy animation range from a source skeleton.
  11606. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  11607. * @param source defines the source skeleton
  11608. * @param name defines the name of the range to copy
  11609. * @param rescaleAsRequired defines if rescaling must be applied if required
  11610. * @returns true if operation was successful
  11611. */
  11612. Skeleton.prototype.copyAnimationRange = function (source, name, rescaleAsRequired) {
  11613. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  11614. if (this._ranges[name] || !source.getAnimationRange(name)) {
  11615. return false;
  11616. }
  11617. var ret = true;
  11618. var frameOffset = this._getHighestAnimationFrame() + 1;
  11619. // make a dictionary of source skeleton's bones, so exact same order or doublely nested loop is not required
  11620. var boneDict = {};
  11621. var sourceBones = source.bones;
  11622. var nBones;
  11623. var i;
  11624. for (i = 0, nBones = sourceBones.length; i < nBones; i++) {
  11625. boneDict[sourceBones[i].name] = sourceBones[i];
  11626. }
  11627. if (this.bones.length !== sourceBones.length) {
  11628. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + sourceBones.length);
  11629. ret = false;
  11630. }
  11631. var skelDimensionsRatio = (rescaleAsRequired && this.dimensionsAtRest && source.dimensionsAtRest) ? this.dimensionsAtRest.divide(source.dimensionsAtRest) : null;
  11632. for (i = 0, nBones = this.bones.length; i < nBones; i++) {
  11633. var boneName = this.bones[i].name;
  11634. var sourceBone = boneDict[boneName];
  11635. if (sourceBone) {
  11636. ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
  11637. }
  11638. else {
  11639. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
  11640. ret = false;
  11641. }
  11642. }
  11643. // do not call createAnimationRange(), since it also is done to bones, which was already done
  11644. var range = source.getAnimationRange(name);
  11645. if (range) {
  11646. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, range.from + frameOffset, range.to + frameOffset);
  11647. }
  11648. return ret;
  11649. };
  11650. /**
  11651. * Forces the skeleton to go to rest pose
  11652. */
  11653. Skeleton.prototype.returnToRest = function () {
  11654. for (var index = 0; index < this.bones.length; index++) {
  11655. this.bones[index].returnToRest();
  11656. }
  11657. };
  11658. Skeleton.prototype._getHighestAnimationFrame = function () {
  11659. var ret = 0;
  11660. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11661. if (this.bones[i].animations[0]) {
  11662. var highest = this.bones[i].animations[0].getHighestFrame();
  11663. if (ret < highest) {
  11664. ret = highest;
  11665. }
  11666. }
  11667. }
  11668. return ret;
  11669. };
  11670. /**
  11671. * Begin a specific animation range
  11672. * @param name defines the name of the range to start
  11673. * @param loop defines if looping must be turned on (false by default)
  11674. * @param speedRatio defines the speed ratio to apply (1 by default)
  11675. * @param onAnimationEnd defines a callback which will be called when animation will end
  11676. * @returns a new animatable
  11677. */
  11678. Skeleton.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  11679. var range = this.getAnimationRange(name);
  11680. if (!range) {
  11681. return null;
  11682. }
  11683. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  11684. };
  11685. /** @hidden */
  11686. Skeleton.prototype._markAsDirty = function () {
  11687. this._isDirty = true;
  11688. };
  11689. /** @hidden */
  11690. Skeleton.prototype._registerMeshWithPoseMatrix = function (mesh) {
  11691. this._meshesWithPoseMatrix.push(mesh);
  11692. };
  11693. /** @hidden */
  11694. Skeleton.prototype._unregisterMeshWithPoseMatrix = function (mesh) {
  11695. var index = this._meshesWithPoseMatrix.indexOf(mesh);
  11696. if (index > -1) {
  11697. this._meshesWithPoseMatrix.splice(index, 1);
  11698. }
  11699. };
  11700. Skeleton.prototype._computeTransformMatrices = function (targetMatrix, initialSkinMatrix) {
  11701. this.onBeforeComputeObservable.notifyObservers(this);
  11702. for (var index = 0; index < this.bones.length; index++) {
  11703. var bone = this.bones[index];
  11704. var parentBone = bone.getParent();
  11705. if (parentBone) {
  11706. bone.getLocalMatrix().multiplyToRef(parentBone.getWorldMatrix(), bone.getWorldMatrix());
  11707. }
  11708. else {
  11709. if (initialSkinMatrix) {
  11710. bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getWorldMatrix());
  11711. }
  11712. else {
  11713. bone.getWorldMatrix().copyFrom(bone.getLocalMatrix());
  11714. }
  11715. }
  11716. if (bone._index !== -1) {
  11717. var mappedIndex = bone._index === null ? index : bone._index;
  11718. bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), targetMatrix, mappedIndex * 16);
  11719. }
  11720. }
  11721. this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  11722. };
  11723. /**
  11724. * Build all resources required to render a skeleton
  11725. */
  11726. Skeleton.prototype.prepare = function () {
  11727. // Update the local matrix of bones with linked transform nodes.
  11728. if (this._numBonesWithLinkedTransformNode > 0) {
  11729. for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
  11730. var bone_1 = _a[_i];
  11731. if (bone_1._linkedTransformNode) {
  11732. // Computing the world matrix also computes the local matrix.
  11733. bone_1._linkedTransformNode.computeWorldMatrix();
  11734. bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
  11735. bone_1.markAsDirty();
  11736. }
  11737. }
  11738. }
  11739. if (!this._isDirty) {
  11740. return;
  11741. }
  11742. if (this.needInitialSkinMatrix) {
  11743. for (var index = 0; index < this._meshesWithPoseMatrix.length; index++) {
  11744. var mesh = this._meshesWithPoseMatrix[index];
  11745. var poseMatrix = mesh.getPoseMatrix();
  11746. if (!mesh._bonesTransformMatrices || mesh._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) {
  11747. mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11748. }
  11749. if (this._synchronizedWithMesh !== mesh) {
  11750. this._synchronizedWithMesh = mesh;
  11751. // Prepare bones
  11752. for (var boneIndex = 0; boneIndex < this.bones.length; boneIndex++) {
  11753. var bone = this.bones[boneIndex];
  11754. if (!bone.getParent()) {
  11755. var matrix = bone.getBaseMatrix();
  11756. matrix.multiplyToRef(poseMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11757. bone._updateDifferenceMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11758. }
  11759. }
  11760. }
  11761. this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
  11762. }
  11763. }
  11764. else {
  11765. if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
  11766. this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11767. if (this.isUsingTextureForMatrices) {
  11768. if (this._transformMatrixTexture) {
  11769. this._transformMatrixTexture.dispose();
  11770. }
  11771. 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);
  11772. }
  11773. }
  11774. this._computeTransformMatrices(this._transformMatrices, null);
  11775. if (this.isUsingTextureForMatrices && this._transformMatrixTexture) {
  11776. this._transformMatrixTexture.update(this._transformMatrices);
  11777. }
  11778. }
  11779. this._isDirty = false;
  11780. this._scene._activeBones.addCount(this.bones.length, false);
  11781. };
  11782. /**
  11783. * Gets the list of animatables currently running for this skeleton
  11784. * @returns an array of animatables
  11785. */
  11786. Skeleton.prototype.getAnimatables = function () {
  11787. if (!this._animatables || this._animatables.length !== this.bones.length) {
  11788. this._animatables = [];
  11789. for (var index = 0; index < this.bones.length; index++) {
  11790. this._animatables.push(this.bones[index]);
  11791. }
  11792. }
  11793. return this._animatables;
  11794. };
  11795. /**
  11796. * Clone the current skeleton
  11797. * @param name defines the name of the new skeleton
  11798. * @param id defines the id of the enw skeleton
  11799. * @returns the new skeleton
  11800. */
  11801. Skeleton.prototype.clone = function (name, id) {
  11802. var result = new Skeleton(name, id || name, this._scene);
  11803. result.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11804. for (var index = 0; index < this.bones.length; index++) {
  11805. var source = this.bones[index];
  11806. var parentBone = null;
  11807. var parent_1 = source.getParent();
  11808. if (parent_1) {
  11809. var parentIndex = this.bones.indexOf(parent_1);
  11810. parentBone = result.bones[parentIndex];
  11811. }
  11812. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](source.name, result, parentBone, source.getBaseMatrix().clone(), source.getRestPose().clone());
  11813. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source.animations, bone.animations);
  11814. }
  11815. if (this._ranges) {
  11816. result._ranges = {};
  11817. for (var rangeName in this._ranges) {
  11818. var range = this._ranges[rangeName];
  11819. if (range) {
  11820. result._ranges[rangeName] = range.clone();
  11821. }
  11822. }
  11823. }
  11824. this._isDirty = true;
  11825. return result;
  11826. };
  11827. /**
  11828. * Enable animation blending for this skeleton
  11829. * @param blendingSpeed defines the blending speed to apply
  11830. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  11831. */
  11832. Skeleton.prototype.enableBlending = function (blendingSpeed) {
  11833. if (blendingSpeed === void 0) { blendingSpeed = 0.01; }
  11834. this.bones.forEach(function (bone) {
  11835. bone.animations.forEach(function (animation) {
  11836. animation.enableBlending = true;
  11837. animation.blendingSpeed = blendingSpeed;
  11838. });
  11839. });
  11840. };
  11841. /**
  11842. * Releases all resources associated with the current skeleton
  11843. */
  11844. Skeleton.prototype.dispose = function () {
  11845. this._meshesWithPoseMatrix = [];
  11846. // Animations
  11847. this.getScene().stopAnimation(this);
  11848. // Remove from scene
  11849. this.getScene().removeSkeleton(this);
  11850. if (this._transformMatrixTexture) {
  11851. this._transformMatrixTexture.dispose();
  11852. this._transformMatrixTexture = null;
  11853. }
  11854. };
  11855. /**
  11856. * Serialize the skeleton in a JSON object
  11857. * @returns a JSON object
  11858. */
  11859. Skeleton.prototype.serialize = function () {
  11860. var serializationObject = {};
  11861. serializationObject.name = this.name;
  11862. serializationObject.id = this.id;
  11863. if (this.dimensionsAtRest) {
  11864. serializationObject.dimensionsAtRest = this.dimensionsAtRest.asArray();
  11865. }
  11866. serializationObject.bones = [];
  11867. serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11868. for (var index = 0; index < this.bones.length; index++) {
  11869. var bone = this.bones[index];
  11870. var parent_2 = bone.getParent();
  11871. var serializedBone = {
  11872. parentBoneIndex: parent_2 ? this.bones.indexOf(parent_2) : -1,
  11873. name: bone.name,
  11874. matrix: bone.getBaseMatrix().toArray(),
  11875. rest: bone.getRestPose().toArray()
  11876. };
  11877. serializationObject.bones.push(serializedBone);
  11878. if (bone.length) {
  11879. serializedBone.length = bone.length;
  11880. }
  11881. if (bone.metadata) {
  11882. serializedBone.metadata = bone.metadata;
  11883. }
  11884. if (bone.animations && bone.animations.length > 0) {
  11885. serializedBone.animation = bone.animations[0].serialize();
  11886. }
  11887. serializationObject.ranges = [];
  11888. for (var name in this._ranges) {
  11889. var source = this._ranges[name];
  11890. if (!source) {
  11891. continue;
  11892. }
  11893. var range = {};
  11894. range.name = name;
  11895. range.from = source.from;
  11896. range.to = source.to;
  11897. serializationObject.ranges.push(range);
  11898. }
  11899. }
  11900. return serializationObject;
  11901. };
  11902. /**
  11903. * Creates a new skeleton from serialized data
  11904. * @param parsedSkeleton defines the serialized data
  11905. * @param scene defines the hosting scene
  11906. * @returns a new skeleton
  11907. */
  11908. Skeleton.Parse = function (parsedSkeleton, scene) {
  11909. var skeleton = new Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
  11910. if (parsedSkeleton.dimensionsAtRest) {
  11911. skeleton.dimensionsAtRest = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSkeleton.dimensionsAtRest);
  11912. }
  11913. skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;
  11914. var index;
  11915. for (index = 0; index < parsedSkeleton.bones.length; index++) {
  11916. var parsedBone = parsedSkeleton.bones[index];
  11917. var parentBone = null;
  11918. if (parsedBone.parentBoneIndex > -1) {
  11919. parentBone = skeleton.bones[parsedBone.parentBoneIndex];
  11920. }
  11921. var rest = parsedBone.rest ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.rest) : null;
  11922. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](parsedBone.name, skeleton, parentBone, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.matrix), rest);
  11923. if (parsedBone.id !== undefined && parsedBone.id !== null) {
  11924. bone.id = parsedBone.id;
  11925. }
  11926. if (parsedBone.length) {
  11927. bone.length = parsedBone.length;
  11928. }
  11929. if (parsedBone.metadata) {
  11930. bone.metadata = parsedBone.metadata;
  11931. }
  11932. if (parsedBone.animation) {
  11933. bone.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedBone.animation));
  11934. }
  11935. }
  11936. // placed after bones, so createAnimationRange can cascade down
  11937. if (parsedSkeleton.ranges) {
  11938. for (index = 0; index < parsedSkeleton.ranges.length; index++) {
  11939. var data = parsedSkeleton.ranges[index];
  11940. skeleton.createAnimationRange(data.name, data.from, data.to);
  11941. }
  11942. }
  11943. return skeleton;
  11944. };
  11945. /**
  11946. * Compute all node absolute transforms
  11947. * @param forceUpdate defines if computation must be done even if cache is up to date
  11948. */
  11949. Skeleton.prototype.computeAbsoluteTransforms = function (forceUpdate) {
  11950. if (forceUpdate === void 0) { forceUpdate = false; }
  11951. var renderId = this._scene.getRenderId();
  11952. if (this._lastAbsoluteTransformsUpdateId != renderId || forceUpdate) {
  11953. this.bones[0].computeAbsoluteTransforms();
  11954. this._lastAbsoluteTransformsUpdateId = renderId;
  11955. }
  11956. };
  11957. /**
  11958. * Gets the root pose matrix
  11959. * @returns a matrix
  11960. */
  11961. Skeleton.prototype.getPoseMatrix = function () {
  11962. var poseMatrix = null;
  11963. if (this._meshesWithPoseMatrix.length > 0) {
  11964. poseMatrix = this._meshesWithPoseMatrix[0].getPoseMatrix();
  11965. }
  11966. return poseMatrix;
  11967. };
  11968. /**
  11969. * Sorts bones per internal index
  11970. */
  11971. Skeleton.prototype.sortBones = function () {
  11972. var bones = new Array();
  11973. var visited = new Array(this.bones.length);
  11974. for (var index = 0; index < this.bones.length; index++) {
  11975. this._sortBones(index, bones, visited);
  11976. }
  11977. this.bones = bones;
  11978. };
  11979. Skeleton.prototype._sortBones = function (index, bones, visited) {
  11980. if (visited[index]) {
  11981. return;
  11982. }
  11983. visited[index] = true;
  11984. var bone = this.bones[index];
  11985. if (bone._index === undefined) {
  11986. bone._index = index;
  11987. }
  11988. var parentBone = bone.getParent();
  11989. if (parentBone) {
  11990. this._sortBones(this.bones.indexOf(parentBone), bones, visited);
  11991. }
  11992. bones.push(bone);
  11993. };
  11994. return Skeleton;
  11995. }());
  11996. /***/ }),
  11997. /***/ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts":
  11998. /*!*******************************************************!*\
  11999. !*** ./Cameras/Inputs/arcRotateCameraGamepadInput.ts ***!
  12000. \*******************************************************/
  12001. /*! exports provided: ArcRotateCameraGamepadInput */
  12002. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12003. "use strict";
  12004. __webpack_require__.r(__webpack_exports__);
  12005. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return ArcRotateCameraGamepadInput; });
  12006. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12007. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12008. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12009. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  12010. /**
  12011. * Manage the gamepad inputs to control an arc rotate camera.
  12012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12013. */
  12014. var ArcRotateCameraGamepadInput = /** @class */ (function () {
  12015. function ArcRotateCameraGamepadInput() {
  12016. /**
  12017. * Defines the gamepad rotation sensiblity.
  12018. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  12019. */
  12020. this.gamepadRotationSensibility = 80;
  12021. /**
  12022. * Defines the gamepad move sensiblity.
  12023. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  12024. */
  12025. this.gamepadMoveSensibility = 40;
  12026. }
  12027. /**
  12028. * Attach the input controls to a specific dom element to get the input from.
  12029. * @param element Defines the element the controls should be listened from
  12030. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12031. */
  12032. ArcRotateCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  12033. var _this = this;
  12034. var manager = this.camera.getScene().gamepadManager;
  12035. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  12036. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].POSE_ENABLED) {
  12037. // prioritize XBOX gamepads.
  12038. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX) {
  12039. _this.gamepad = gamepad;
  12040. }
  12041. }
  12042. });
  12043. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  12044. if (_this.gamepad === gamepad) {
  12045. _this.gamepad = null;
  12046. }
  12047. });
  12048. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX);
  12049. };
  12050. /**
  12051. * Detach the current controls from the specified dom element.
  12052. * @param element Defines the element to stop listening the inputs from
  12053. */
  12054. ArcRotateCameraGamepadInput.prototype.detachControl = function (element) {
  12055. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  12056. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  12057. this.gamepad = null;
  12058. };
  12059. /**
  12060. * Update the current camera state depending on the inputs that have been used this frame.
  12061. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12062. */
  12063. ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
  12064. if (this.gamepad) {
  12065. var camera = this.camera;
  12066. var RSValues = this.gamepad.rightStick;
  12067. if (RSValues) {
  12068. if (RSValues.x != 0) {
  12069. var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
  12070. if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
  12071. camera.inertialAlphaOffset += normalizedRX;
  12072. }
  12073. }
  12074. if (RSValues.y != 0) {
  12075. var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
  12076. if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
  12077. camera.inertialBetaOffset += normalizedRY;
  12078. }
  12079. }
  12080. }
  12081. var LSValues = this.gamepad.leftStick;
  12082. if (LSValues && LSValues.y != 0) {
  12083. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  12084. if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
  12085. this.camera.inertialRadiusOffset -= normalizedLY;
  12086. }
  12087. }
  12088. }
  12089. };
  12090. /**
  12091. * Gets the class name of the current intput.
  12092. * @returns the class name
  12093. */
  12094. ArcRotateCameraGamepadInput.prototype.getClassName = function () {
  12095. return "ArcRotateCameraGamepadInput";
  12096. };
  12097. /**
  12098. * Get the friendly name associated with the input class.
  12099. * @returns the input friendly name
  12100. */
  12101. ArcRotateCameraGamepadInput.prototype.getSimpleName = function () {
  12102. return "gamepad";
  12103. };
  12104. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12105. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12106. ], ArcRotateCameraGamepadInput.prototype, "gamepadRotationSensibility", void 0);
  12107. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12109. ], ArcRotateCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  12110. return ArcRotateCameraGamepadInput;
  12111. }());
  12112. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
  12113. /***/ }),
  12114. /***/ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts":
  12115. /*!************************************************************!*\
  12116. !*** ./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts ***!
  12117. \************************************************************/
  12118. /*! exports provided: ArcRotateCameraKeyboardMoveInput */
  12119. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12120. "use strict";
  12121. __webpack_require__.r(__webpack_exports__);
  12122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return ArcRotateCameraKeyboardMoveInput; });
  12123. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12124. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12125. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12126. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12127. /**
  12128. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  12129. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12130. */
  12131. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  12132. function ArcRotateCameraKeyboardMoveInput() {
  12133. /**
  12134. * Defines the list of key codes associated with the up action (increase alpha)
  12135. */
  12136. this.keysUp = [38];
  12137. /**
  12138. * Defines the list of key codes associated with the down action (decrease alpha)
  12139. */
  12140. this.keysDown = [40];
  12141. /**
  12142. * Defines the list of key codes associated with the left action (increase beta)
  12143. */
  12144. this.keysLeft = [37];
  12145. /**
  12146. * Defines the list of key codes associated with the right action (decrease beta)
  12147. */
  12148. this.keysRight = [39];
  12149. /**
  12150. * Defines the list of key codes associated with the reset action.
  12151. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  12152. */
  12153. this.keysReset = [220];
  12154. /**
  12155. * Defines the panning sensibility of the inputs.
  12156. * (How fast is the camera paning)
  12157. */
  12158. this.panningSensibility = 50.0;
  12159. /**
  12160. * Defines the zooming sensibility of the inputs.
  12161. * (How fast is the camera zooming)
  12162. */
  12163. this.zoomingSensibility = 25.0;
  12164. /**
  12165. * Defines wether maintaining the alt key down switch the movement mode from
  12166. * orientation to zoom.
  12167. */
  12168. this.useAltToZoom = true;
  12169. /**
  12170. * Rotation speed of the camera
  12171. */
  12172. this.angularSpeed = 0.01;
  12173. this._keys = new Array();
  12174. }
  12175. /**
  12176. * Attach the input controls to a specific dom element to get the input from.
  12177. * @param element Defines the element the controls should be listened from
  12178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12179. */
  12180. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  12181. var _this = this;
  12182. if (this._onCanvasBlurObserver) {
  12183. return;
  12184. }
  12185. this._scene = this.camera.getScene();
  12186. this._engine = this._scene.getEngine();
  12187. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12188. _this._keys = [];
  12189. });
  12190. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12191. var evt = info.event;
  12192. if (!evt.metaKey) {
  12193. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12194. _this._ctrlPressed = evt.ctrlKey;
  12195. _this._altPressed = evt.altKey;
  12196. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12197. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12198. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12199. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12200. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12201. var index = _this._keys.indexOf(evt.keyCode);
  12202. if (index === -1) {
  12203. _this._keys.push(evt.keyCode);
  12204. }
  12205. if (evt.preventDefault) {
  12206. if (!noPreventDefault) {
  12207. evt.preventDefault();
  12208. }
  12209. }
  12210. }
  12211. }
  12212. else {
  12213. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12214. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12215. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12216. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12217. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12218. var index = _this._keys.indexOf(evt.keyCode);
  12219. if (index >= 0) {
  12220. _this._keys.splice(index, 1);
  12221. }
  12222. if (evt.preventDefault) {
  12223. if (!noPreventDefault) {
  12224. evt.preventDefault();
  12225. }
  12226. }
  12227. }
  12228. }
  12229. }
  12230. });
  12231. };
  12232. /**
  12233. * Detach the current controls from the specified dom element.
  12234. * @param element Defines the element to stop listening the inputs from
  12235. */
  12236. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  12237. if (this._scene) {
  12238. if (this._onKeyboardObserver) {
  12239. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  12240. }
  12241. if (this._onCanvasBlurObserver) {
  12242. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  12243. }
  12244. this._onKeyboardObserver = null;
  12245. this._onCanvasBlurObserver = null;
  12246. }
  12247. this._keys = [];
  12248. };
  12249. /**
  12250. * Update the current camera state depending on the inputs that have been used this frame.
  12251. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12252. */
  12253. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  12254. if (this._onKeyboardObserver) {
  12255. var camera = this.camera;
  12256. for (var index = 0; index < this._keys.length; index++) {
  12257. var keyCode = this._keys[index];
  12258. if (this.keysLeft.indexOf(keyCode) !== -1) {
  12259. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12260. camera.inertialPanningX -= 1 / this.panningSensibility;
  12261. }
  12262. else {
  12263. camera.inertialAlphaOffset -= this.angularSpeed;
  12264. }
  12265. }
  12266. else if (this.keysUp.indexOf(keyCode) !== -1) {
  12267. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12268. camera.inertialPanningY += 1 / this.panningSensibility;
  12269. }
  12270. else if (this._altPressed && this.useAltToZoom) {
  12271. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  12272. }
  12273. else {
  12274. camera.inertialBetaOffset -= this.angularSpeed;
  12275. }
  12276. }
  12277. else if (this.keysRight.indexOf(keyCode) !== -1) {
  12278. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12279. camera.inertialPanningX += 1 / this.panningSensibility;
  12280. }
  12281. else {
  12282. camera.inertialAlphaOffset += this.angularSpeed;
  12283. }
  12284. }
  12285. else if (this.keysDown.indexOf(keyCode) !== -1) {
  12286. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12287. camera.inertialPanningY -= 1 / this.panningSensibility;
  12288. }
  12289. else if (this._altPressed && this.useAltToZoom) {
  12290. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  12291. }
  12292. else {
  12293. camera.inertialBetaOffset += this.angularSpeed;
  12294. }
  12295. }
  12296. else if (this.keysReset.indexOf(keyCode) !== -1) {
  12297. if (camera.useInputToRestoreState) {
  12298. camera.restoreState();
  12299. }
  12300. }
  12301. }
  12302. }
  12303. };
  12304. /**
  12305. * Gets the class name of the current intput.
  12306. * @returns the class name
  12307. */
  12308. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  12309. return "ArcRotateCameraKeyboardMoveInput";
  12310. };
  12311. /**
  12312. * Get the friendly name associated with the input class.
  12313. * @returns the input friendly name
  12314. */
  12315. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  12316. return "keyboard";
  12317. };
  12318. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12319. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12320. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  12321. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12322. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12323. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  12324. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12325. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12326. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  12327. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12328. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12329. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  12330. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12331. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12332. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  12333. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12334. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12335. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  12336. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12337. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12338. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  12339. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12340. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12341. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  12342. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12343. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12344. ], ArcRotateCameraKeyboardMoveInput.prototype, "angularSpeed", void 0);
  12345. return ArcRotateCameraKeyboardMoveInput;
  12346. }());
  12347. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  12348. /***/ }),
  12349. /***/ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts":
  12350. /*!**********************************************************!*\
  12351. !*** ./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts ***!
  12352. \**********************************************************/
  12353. /*! exports provided: ArcRotateCameraMouseWheelInput */
  12354. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12355. "use strict";
  12356. __webpack_require__.r(__webpack_exports__);
  12357. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return ArcRotateCameraMouseWheelInput; });
  12358. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12359. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12360. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12361. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12362. /**
  12363. * Manage the mouse wheel inputs to control an arc rotate camera.
  12364. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12365. */
  12366. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  12367. function ArcRotateCameraMouseWheelInput() {
  12368. /**
  12369. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  12370. */
  12371. this.wheelPrecision = 3.0;
  12372. /**
  12373. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  12374. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  12375. */
  12376. this.wheelDeltaPercentage = 0;
  12377. }
  12378. /**
  12379. * Attach the input controls to a specific dom element to get the input from.
  12380. * @param element Defines the element the controls should be listened from
  12381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12382. */
  12383. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  12384. var _this = this;
  12385. this._wheel = function (p, s) {
  12386. //sanity check - this should be a PointerWheel event.
  12387. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  12388. return;
  12389. }
  12390. var event = p.event;
  12391. var delta = 0;
  12392. var mouseWheelLegacyEvent = event;
  12393. if (mouseWheelLegacyEvent.wheelDelta) {
  12394. if (_this.wheelDeltaPercentage) {
  12395. var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * _this.wheelDeltaPercentage) * _this.camera.radius;
  12396. if (mouseWheelLegacyEvent.wheelDelta > 0) {
  12397. delta = wheelDelta / (1.0 + _this.wheelDeltaPercentage);
  12398. }
  12399. else {
  12400. delta = wheelDelta * (1.0 + _this.wheelDeltaPercentage);
  12401. }
  12402. }
  12403. else {
  12404. delta = mouseWheelLegacyEvent.wheelDelta / (_this.wheelPrecision * 40);
  12405. }
  12406. }
  12407. else {
  12408. var deltaValue = event.deltaY || event.detail;
  12409. delta = -deltaValue / _this.wheelPrecision;
  12410. }
  12411. if (delta) {
  12412. _this.camera.inertialRadiusOffset += delta;
  12413. }
  12414. if (event.preventDefault) {
  12415. if (!noPreventDefault) {
  12416. event.preventDefault();
  12417. }
  12418. }
  12419. };
  12420. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  12421. };
  12422. /**
  12423. * Detach the current controls from the specified dom element.
  12424. * @param element Defines the element to stop listening the inputs from
  12425. */
  12426. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  12427. if (this._observer && element) {
  12428. this.camera.getScene().onPointerObservable.remove(this._observer);
  12429. this._observer = null;
  12430. this._wheel = null;
  12431. }
  12432. };
  12433. /**
  12434. * Gets the class name of the current intput.
  12435. * @returns the class name
  12436. */
  12437. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  12438. return "ArcRotateCameraMouseWheelInput";
  12439. };
  12440. /**
  12441. * Get the friendly name associated with the input class.
  12442. * @returns the input friendly name
  12443. */
  12444. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  12445. return "mousewheel";
  12446. };
  12447. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12448. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12449. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  12450. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12451. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12452. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  12453. return ArcRotateCameraMouseWheelInput;
  12454. }());
  12455. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  12456. /***/ }),
  12457. /***/ "./Cameras/Inputs/arcRotateCameraPointersInput.ts":
  12458. /*!********************************************************!*\
  12459. !*** ./Cameras/Inputs/arcRotateCameraPointersInput.ts ***!
  12460. \********************************************************/
  12461. /*! exports provided: ArcRotateCameraPointersInput */
  12462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12463. "use strict";
  12464. __webpack_require__.r(__webpack_exports__);
  12465. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return ArcRotateCameraPointersInput; });
  12466. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12467. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12468. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  12469. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12470. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12471. /**
  12472. * Manage the pointers inputs to control an arc rotate camera.
  12473. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12474. */
  12475. var ArcRotateCameraPointersInput = /** @class */ (function () {
  12476. function ArcRotateCameraPointersInput() {
  12477. /**
  12478. * Defines the buttons associated with the input to handle camera move.
  12479. */
  12480. this.buttons = [0, 1, 2];
  12481. /**
  12482. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  12483. */
  12484. this.angularSensibilityX = 1000.0;
  12485. /**
  12486. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  12487. */
  12488. this.angularSensibilityY = 1000.0;
  12489. /**
  12490. * Defines the pointer pinch precision or how fast is the camera zooming.
  12491. */
  12492. this.pinchPrecision = 12.0;
  12493. /**
  12494. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  12495. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  12496. */
  12497. this.pinchDeltaPercentage = 0;
  12498. /**
  12499. * Defines the pointer panning sensibility or how fast is the camera moving.
  12500. */
  12501. this.panningSensibility = 1000.0;
  12502. /**
  12503. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  12504. */
  12505. this.multiTouchPanning = true;
  12506. /**
  12507. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  12508. */
  12509. this.multiTouchPanAndZoom = true;
  12510. /**
  12511. * Revers pinch action direction.
  12512. */
  12513. this.pinchInwards = true;
  12514. this._isPanClick = false;
  12515. }
  12516. /**
  12517. * Attach the input controls to a specific dom element to get the input from.
  12518. * @param element Defines the element the controls should be listened from
  12519. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12520. */
  12521. ArcRotateCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  12522. var _this = this;
  12523. var engine = this.camera.getEngine();
  12524. var cacheSoloPointer; // cache pointer object for better perf on camera rotation
  12525. var pointA = null;
  12526. var pointB = null;
  12527. var previousPinchSquaredDistance = 0;
  12528. var initialDistance = 0;
  12529. var twoFingerActivityCount = 0;
  12530. var previousMultiTouchPanPosition = { x: 0, y: 0, isPaning: false, isPinching: false };
  12531. this._pointerInput = function (p, s) {
  12532. var evt = p.event;
  12533. var isTouch = p.event.pointerType === "touch";
  12534. if (engine.isInVRExclusivePointerMode) {
  12535. return;
  12536. }
  12537. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  12538. return;
  12539. }
  12540. var srcElement = (evt.srcElement || evt.target);
  12541. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12542. try {
  12543. srcElement.setPointerCapture(evt.pointerId);
  12544. }
  12545. catch (e) {
  12546. //Nothing to do with the error. Execution will continue.
  12547. }
  12548. // Manage panning with pan button click
  12549. _this._isPanClick = evt.button === _this.camera._panningMouseButton;
  12550. // manage pointers
  12551. cacheSoloPointer = { x: evt.clientX, y: evt.clientY, pointerId: evt.pointerId, type: evt.pointerType };
  12552. if (pointA === null) {
  12553. pointA = cacheSoloPointer;
  12554. }
  12555. else if (pointB === null) {
  12556. pointB = cacheSoloPointer;
  12557. }
  12558. if (!noPreventDefault) {
  12559. evt.preventDefault();
  12560. element.focus();
  12561. }
  12562. }
  12563. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOUBLETAP) {
  12564. if (_this.camera.useInputToRestoreState) {
  12565. _this.camera.restoreState();
  12566. }
  12567. }
  12568. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP && srcElement) {
  12569. try {
  12570. srcElement.releasePointerCapture(evt.pointerId);
  12571. }
  12572. catch (e) {
  12573. //Nothing to do with the error.
  12574. }
  12575. cacheSoloPointer = null;
  12576. previousPinchSquaredDistance = 0;
  12577. previousMultiTouchPanPosition.isPaning = false;
  12578. previousMultiTouchPanPosition.isPinching = false;
  12579. twoFingerActivityCount = 0;
  12580. initialDistance = 0;
  12581. if (!isTouch) {
  12582. pointB = null; // Mouse and pen are mono pointer
  12583. }
  12584. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  12585. //but emptying completly pointers collection is required to fix a bug on iPhone :
  12586. //when changing orientation while pinching camera, one pointer stay pressed forever if we don't release all pointers
  12587. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  12588. if (engine._badOS) {
  12589. pointA = pointB = null;
  12590. }
  12591. else {
  12592. //only remove the impacted pointer in case of multitouch allowing on most
  12593. //platforms switching from rotate to zoom and pan seamlessly.
  12594. if (pointB && pointA && pointA.pointerId == evt.pointerId) {
  12595. pointA = pointB;
  12596. pointB = null;
  12597. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  12598. }
  12599. else if (pointA && pointB && pointB.pointerId == evt.pointerId) {
  12600. pointB = null;
  12601. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  12602. }
  12603. else {
  12604. pointA = pointB = null;
  12605. }
  12606. }
  12607. if (!noPreventDefault) {
  12608. evt.preventDefault();
  12609. }
  12610. }
  12611. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  12612. if (!noPreventDefault) {
  12613. evt.preventDefault();
  12614. }
  12615. // One button down
  12616. if (pointA && pointB === null && cacheSoloPointer) {
  12617. if (_this.panningSensibility !== 0 &&
  12618. ((evt.ctrlKey && _this.camera._useCtrlForPanning) || _this._isPanClick)) {
  12619. _this.camera.inertialPanningX += -(evt.clientX - cacheSoloPointer.x) / _this.panningSensibility;
  12620. _this.camera.inertialPanningY += (evt.clientY - cacheSoloPointer.y) / _this.panningSensibility;
  12621. }
  12622. else {
  12623. var offsetX = evt.clientX - cacheSoloPointer.x;
  12624. var offsetY = evt.clientY - cacheSoloPointer.y;
  12625. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  12626. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  12627. }
  12628. cacheSoloPointer.x = evt.clientX;
  12629. cacheSoloPointer.y = evt.clientY;
  12630. }
  12631. // Two buttons down: pinch/pan
  12632. else if (pointA && pointB) {
  12633. //if (noPreventDefault) { evt.preventDefault(); } //if pinch gesture, could be useful to force preventDefault to avoid html page scroll/zoom in some mobile browsers
  12634. var ed = (pointA.pointerId === evt.pointerId) ? pointA : pointB;
  12635. ed.x = evt.clientX;
  12636. ed.y = evt.clientY;
  12637. var direction = _this.pinchInwards ? 1 : -1;
  12638. var distX = pointA.x - pointB.x;
  12639. var distY = pointA.y - pointB.y;
  12640. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  12641. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  12642. if (previousPinchSquaredDistance === 0) {
  12643. initialDistance = pinchDistance;
  12644. previousPinchSquaredDistance = pinchSquaredDistance;
  12645. previousMultiTouchPanPosition.x = (pointA.x + pointB.x) / 2;
  12646. previousMultiTouchPanPosition.y = (pointA.y + pointB.y) / 2;
  12647. return;
  12648. }
  12649. if (_this.multiTouchPanAndZoom) {
  12650. if (_this.pinchDeltaPercentage) {
  12651. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  12652. }
  12653. else {
  12654. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  12655. (_this.pinchPrecision *
  12656. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  12657. direction);
  12658. }
  12659. if (_this.panningSensibility !== 0) {
  12660. var pointersCenterX = (pointA.x + pointB.x) / 2;
  12661. var pointersCenterY = (pointA.y + pointB.y) / 2;
  12662. var pointersCenterDistX = pointersCenterX - previousMultiTouchPanPosition.x;
  12663. var pointersCenterDistY = pointersCenterY - previousMultiTouchPanPosition.y;
  12664. previousMultiTouchPanPosition.x = pointersCenterX;
  12665. previousMultiTouchPanPosition.y = pointersCenterY;
  12666. _this.camera.inertialPanningX += -(pointersCenterDistX) / (_this.panningSensibility);
  12667. _this.camera.inertialPanningY += (pointersCenterDistY) / (_this.panningSensibility);
  12668. }
  12669. }
  12670. else {
  12671. twoFingerActivityCount++;
  12672. if (previousMultiTouchPanPosition.isPinching || (twoFingerActivityCount < 20 && Math.abs(pinchDistance - initialDistance) > _this.camera.pinchToPanMaxDistance)) {
  12673. if (_this.pinchDeltaPercentage) {
  12674. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  12675. }
  12676. else {
  12677. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  12678. (_this.pinchPrecision *
  12679. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  12680. direction);
  12681. }
  12682. previousMultiTouchPanPosition.isPaning = false;
  12683. previousMultiTouchPanPosition.isPinching = true;
  12684. }
  12685. else {
  12686. if (cacheSoloPointer && cacheSoloPointer.pointerId === ed.pointerId && _this.panningSensibility !== 0 && _this.multiTouchPanning) {
  12687. if (!previousMultiTouchPanPosition.isPaning) {
  12688. previousMultiTouchPanPosition.isPaning = true;
  12689. previousMultiTouchPanPosition.isPinching = false;
  12690. previousMultiTouchPanPosition.x = ed.x;
  12691. previousMultiTouchPanPosition.y = ed.y;
  12692. return;
  12693. }
  12694. _this.camera.inertialPanningX += -(ed.x - previousMultiTouchPanPosition.x) / (_this.panningSensibility);
  12695. _this.camera.inertialPanningY += (ed.y - previousMultiTouchPanPosition.y) / (_this.panningSensibility);
  12696. }
  12697. }
  12698. if (cacheSoloPointer && cacheSoloPointer.pointerId === evt.pointerId) {
  12699. previousMultiTouchPanPosition.x = ed.x;
  12700. previousMultiTouchPanPosition.y = ed.y;
  12701. }
  12702. }
  12703. previousPinchSquaredDistance = pinchSquaredDistance;
  12704. }
  12705. }
  12706. };
  12707. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOUBLETAP);
  12708. this._onContextMenu = function (evt) {
  12709. evt.preventDefault();
  12710. };
  12711. if (!this.camera._useCtrlForPanning) {
  12712. element.addEventListener("contextmenu", this._onContextMenu, false);
  12713. }
  12714. this._onLostFocus = function () {
  12715. //this._keys = [];
  12716. pointA = pointB = null;
  12717. previousPinchSquaredDistance = 0;
  12718. previousMultiTouchPanPosition.isPaning = false;
  12719. previousMultiTouchPanPosition.isPinching = false;
  12720. twoFingerActivityCount = 0;
  12721. cacheSoloPointer = null;
  12722. initialDistance = 0;
  12723. };
  12724. this._onMouseMove = function (evt) {
  12725. if (!engine.isPointerLock) {
  12726. return;
  12727. }
  12728. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  12729. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  12730. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  12731. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  12732. if (!noPreventDefault) {
  12733. evt.preventDefault();
  12734. }
  12735. };
  12736. this._onGestureStart = function (e) {
  12737. if (window.MSGesture === undefined) {
  12738. return;
  12739. }
  12740. if (!_this._MSGestureHandler) {
  12741. _this._MSGestureHandler = new MSGesture();
  12742. _this._MSGestureHandler.target = element;
  12743. }
  12744. _this._MSGestureHandler.addPointer(e.pointerId);
  12745. };
  12746. this._onGesture = function (e) {
  12747. _this.camera.radius *= e.scale;
  12748. if (e.preventDefault) {
  12749. if (!noPreventDefault) {
  12750. e.stopPropagation();
  12751. e.preventDefault();
  12752. }
  12753. }
  12754. };
  12755. element.addEventListener("mousemove", this._onMouseMove, false);
  12756. element.addEventListener("MSPointerDown", this._onGestureStart, false);
  12757. element.addEventListener("MSGestureChange", this._onGesture, false);
  12758. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RegisterTopRootEvents([
  12759. { name: "blur", handler: this._onLostFocus }
  12760. ]);
  12761. };
  12762. /**
  12763. * Detach the current controls from the specified dom element.
  12764. * @param element Defines the element to stop listening the inputs from
  12765. */
  12766. ArcRotateCameraPointersInput.prototype.detachControl = function (element) {
  12767. if (this._onLostFocus) {
  12768. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].UnregisterTopRootEvents([
  12769. { name: "blur", handler: this._onLostFocus }
  12770. ]);
  12771. }
  12772. if (element && this._observer) {
  12773. this.camera.getScene().onPointerObservable.remove(this._observer);
  12774. this._observer = null;
  12775. if (this._onContextMenu) {
  12776. element.removeEventListener("contextmenu", this._onContextMenu);
  12777. }
  12778. if (this._onMouseMove) {
  12779. element.removeEventListener("mousemove", this._onMouseMove);
  12780. }
  12781. if (this._onGestureStart) {
  12782. element.removeEventListener("MSPointerDown", this._onGestureStart);
  12783. }
  12784. if (this._onGesture) {
  12785. element.removeEventListener("MSGestureChange", this._onGesture);
  12786. }
  12787. this._isPanClick = false;
  12788. this.pinchInwards = true;
  12789. this._onMouseMove = null;
  12790. this._onGestureStart = null;
  12791. this._onGesture = null;
  12792. this._MSGestureHandler = null;
  12793. this._onLostFocus = null;
  12794. this._onContextMenu = null;
  12795. }
  12796. };
  12797. /**
  12798. * Gets the class name of the current intput.
  12799. * @returns the class name
  12800. */
  12801. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  12802. return "ArcRotateCameraPointersInput";
  12803. };
  12804. /**
  12805. * Get the friendly name associated with the input class.
  12806. * @returns the input friendly name
  12807. */
  12808. ArcRotateCameraPointersInput.prototype.getSimpleName = function () {
  12809. return "pointers";
  12810. };
  12811. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12812. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12813. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  12814. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12815. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12816. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  12817. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12818. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12819. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  12820. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12822. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  12823. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12824. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12825. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  12826. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12827. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12828. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  12829. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12830. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12831. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  12832. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12834. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  12835. return ArcRotateCameraPointersInput;
  12836. }());
  12837. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["CameraInputTypes"]["ArcRotateCameraPointersInput"] = ArcRotateCameraPointersInput;
  12838. /***/ }),
  12839. /***/ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts":
  12840. /*!*******************************************************************!*\
  12841. !*** ./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts ***!
  12842. \*******************************************************************/
  12843. /*! exports provided: ArcRotateCameraVRDeviceOrientationInput */
  12844. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12845. "use strict";
  12846. __webpack_require__.r(__webpack_exports__);
  12847. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return ArcRotateCameraVRDeviceOrientationInput; });
  12848. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12849. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  12850. /**
  12851. * Add orientation input support to the input manager.
  12852. * @returns the current input manager
  12853. */
  12854. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraInputsManager"].prototype.addVRDeviceOrientation = function () {
  12855. this.add(new ArcRotateCameraVRDeviceOrientationInput());
  12856. return this;
  12857. };
  12858. /**
  12859. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  12860. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12861. */
  12862. var ArcRotateCameraVRDeviceOrientationInput = /** @class */ (function () {
  12863. /**
  12864. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  12865. */
  12866. function ArcRotateCameraVRDeviceOrientationInput() {
  12867. /**
  12868. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  12869. */
  12870. this.alphaCorrection = 1;
  12871. /**
  12872. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  12873. */
  12874. this.gammaCorrection = 1;
  12875. this._alpha = 0;
  12876. this._gamma = 0;
  12877. this._dirty = false;
  12878. this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
  12879. }
  12880. /**
  12881. * Attach the input controls to a specific dom element to get the input from.
  12882. * @param element Defines the element the controls should be listened from
  12883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12884. */
  12885. ArcRotateCameraVRDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  12886. this.camera.attachControl(element, noPreventDefault);
  12887. window.addEventListener("deviceorientation", this._deviceOrientationHandler);
  12888. };
  12889. /** @hidden */
  12890. ArcRotateCameraVRDeviceOrientationInput.prototype._onOrientationEvent = function (evt) {
  12891. if (evt.alpha !== null) {
  12892. this._alpha = (+evt.alpha | 0) * this.alphaCorrection;
  12893. }
  12894. if (evt.gamma !== null) {
  12895. this._gamma = (+evt.gamma | 0) * this.gammaCorrection;
  12896. }
  12897. this._dirty = true;
  12898. };
  12899. /**
  12900. * Update the current camera state depending on the inputs that have been used this frame.
  12901. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12902. */
  12903. ArcRotateCameraVRDeviceOrientationInput.prototype.checkInputs = function () {
  12904. if (this._dirty) {
  12905. this._dirty = false;
  12906. if (this._gamma < 0) {
  12907. this._gamma = 180 + this._gamma;
  12908. }
  12909. this.camera.alpha = (-this._alpha / 180.0 * Math.PI) % Math.PI * 2;
  12910. this.camera.beta = (this._gamma / 180.0 * Math.PI);
  12911. }
  12912. };
  12913. /**
  12914. * Detach the current controls from the specified dom element.
  12915. * @param element Defines the element to stop listening the inputs from
  12916. */
  12917. ArcRotateCameraVRDeviceOrientationInput.prototype.detachControl = function (element) {
  12918. window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
  12919. };
  12920. /**
  12921. * Gets the class name of the current intput.
  12922. * @returns the class name
  12923. */
  12924. ArcRotateCameraVRDeviceOrientationInput.prototype.getClassName = function () {
  12925. return "ArcRotateCameraVRDeviceOrientationInput";
  12926. };
  12927. /**
  12928. * Get the friendly name associated with the input class.
  12929. * @returns the input friendly name
  12930. */
  12931. ArcRotateCameraVRDeviceOrientationInput.prototype.getSimpleName = function () {
  12932. return "VRDeviceOrientation";
  12933. };
  12934. return ArcRotateCameraVRDeviceOrientationInput;
  12935. }());
  12936. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["ArcRotateCameraVRDeviceOrientationInput"] = ArcRotateCameraVRDeviceOrientationInput;
  12937. /***/ }),
  12938. /***/ "./Cameras/Inputs/flyCameraKeyboardInput.ts":
  12939. /*!**************************************************!*\
  12940. !*** ./Cameras/Inputs/flyCameraKeyboardInput.ts ***!
  12941. \**************************************************/
  12942. /*! exports provided: FlyCameraKeyboardInput */
  12943. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12944. "use strict";
  12945. __webpack_require__.r(__webpack_exports__);
  12946. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return FlyCameraKeyboardInput; });
  12947. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12948. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12949. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12950. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12951. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  12952. /**
  12953. * Listen to keyboard events to control the camera.
  12954. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12955. */
  12956. var FlyCameraKeyboardInput = /** @class */ (function () {
  12957. function FlyCameraKeyboardInput() {
  12958. /**
  12959. * The list of keyboard keys used to control the forward move of the camera.
  12960. */
  12961. this.keysForward = [87];
  12962. /**
  12963. * The list of keyboard keys used to control the backward move of the camera.
  12964. */
  12965. this.keysBackward = [83];
  12966. /**
  12967. * The list of keyboard keys used to control the forward move of the camera.
  12968. */
  12969. this.keysUp = [69];
  12970. /**
  12971. * The list of keyboard keys used to control the backward move of the camera.
  12972. */
  12973. this.keysDown = [81];
  12974. /**
  12975. * The list of keyboard keys used to control the right strafe move of the camera.
  12976. */
  12977. this.keysRight = [68];
  12978. /**
  12979. * The list of keyboard keys used to control the left strafe move of the camera.
  12980. */
  12981. this.keysLeft = [65];
  12982. this._keys = new Array();
  12983. }
  12984. /**
  12985. * Attach the input controls to a specific dom element to get the input from.
  12986. * @param element Defines the element the controls should be listened from
  12987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12988. */
  12989. FlyCameraKeyboardInput.prototype.attachControl = function (element, noPreventDefault) {
  12990. var _this = this;
  12991. if (this._onCanvasBlurObserver) {
  12992. return;
  12993. }
  12994. this._scene = this.camera.getScene();
  12995. this._engine = this._scene.getEngine();
  12996. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12997. _this._keys = [];
  12998. });
  12999. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13000. var evt = info.event;
  13001. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13002. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13003. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13004. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13005. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13006. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13007. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13008. var index = _this._keys.indexOf(evt.keyCode);
  13009. if (index === -1) {
  13010. _this._keys.push(evt.keyCode);
  13011. }
  13012. if (!noPreventDefault) {
  13013. evt.preventDefault();
  13014. }
  13015. }
  13016. }
  13017. else {
  13018. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13019. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13020. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13021. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13022. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13023. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13024. var index = _this._keys.indexOf(evt.keyCode);
  13025. if (index >= 0) {
  13026. _this._keys.splice(index, 1);
  13027. }
  13028. if (!noPreventDefault) {
  13029. evt.preventDefault();
  13030. }
  13031. }
  13032. }
  13033. });
  13034. };
  13035. /**
  13036. * Detach the current controls from the specified dom element.
  13037. * @param element Defines the element to stop listening the inputs from
  13038. */
  13039. FlyCameraKeyboardInput.prototype.detachControl = function (element) {
  13040. if (this._scene) {
  13041. if (this._onKeyboardObserver) {
  13042. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13043. }
  13044. if (this._onCanvasBlurObserver) {
  13045. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13046. }
  13047. this._onKeyboardObserver = null;
  13048. this._onCanvasBlurObserver = null;
  13049. }
  13050. this._keys = [];
  13051. };
  13052. /**
  13053. * Gets the class name of the current intput.
  13054. * @returns the class name
  13055. */
  13056. FlyCameraKeyboardInput.prototype.getClassName = function () {
  13057. return "FlyCameraKeyboardInput";
  13058. };
  13059. /** @hidden */
  13060. FlyCameraKeyboardInput.prototype._onLostFocus = function (e) {
  13061. this._keys = [];
  13062. };
  13063. /**
  13064. * Get the friendly name associated with the input class.
  13065. * @returns the input friendly name
  13066. */
  13067. FlyCameraKeyboardInput.prototype.getSimpleName = function () {
  13068. return "keyboard";
  13069. };
  13070. /**
  13071. * Update the current camera state depending on the inputs that have been used this frame.
  13072. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13073. */
  13074. FlyCameraKeyboardInput.prototype.checkInputs = function () {
  13075. if (this._onKeyboardObserver) {
  13076. var camera = this.camera;
  13077. // Keyboard
  13078. for (var index = 0; index < this._keys.length; index++) {
  13079. var keyCode = this._keys[index];
  13080. var speed = camera._computeLocalCameraSpeed();
  13081. if (this.keysForward.indexOf(keyCode) !== -1) {
  13082. camera._localDirection.copyFromFloats(0, 0, speed);
  13083. }
  13084. else if (this.keysBackward.indexOf(keyCode) !== -1) {
  13085. camera._localDirection.copyFromFloats(0, 0, -speed);
  13086. }
  13087. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13088. camera._localDirection.copyFromFloats(0, speed, 0);
  13089. }
  13090. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13091. camera._localDirection.copyFromFloats(0, -speed, 0);
  13092. }
  13093. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13094. camera._localDirection.copyFromFloats(speed, 0, 0);
  13095. }
  13096. else if (this.keysLeft.indexOf(keyCode) !== -1) {
  13097. camera._localDirection.copyFromFloats(-speed, 0, 0);
  13098. }
  13099. if (camera.getScene().useRightHandedSystem) {
  13100. camera._localDirection.z *= -1;
  13101. }
  13102. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  13103. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  13104. camera.cameraDirection.addInPlace(camera._transformedDirection);
  13105. }
  13106. }
  13107. };
  13108. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13109. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13110. ], FlyCameraKeyboardInput.prototype, "keysForward", void 0);
  13111. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13112. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13113. ], FlyCameraKeyboardInput.prototype, "keysBackward", void 0);
  13114. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13115. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13116. ], FlyCameraKeyboardInput.prototype, "keysUp", void 0);
  13117. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13118. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13119. ], FlyCameraKeyboardInput.prototype, "keysDown", void 0);
  13120. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13121. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13122. ], FlyCameraKeyboardInput.prototype, "keysRight", void 0);
  13123. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13124. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13125. ], FlyCameraKeyboardInput.prototype, "keysLeft", void 0);
  13126. return FlyCameraKeyboardInput;
  13127. }());
  13128. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraKeyboardInput"] = FlyCameraKeyboardInput;
  13129. /***/ }),
  13130. /***/ "./Cameras/Inputs/flyCameraMouseInput.ts":
  13131. /*!***********************************************!*\
  13132. !*** ./Cameras/Inputs/flyCameraMouseInput.ts ***!
  13133. \***********************************************/
  13134. /*! exports provided: FlyCameraMouseInput */
  13135. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13136. "use strict";
  13137. __webpack_require__.r(__webpack_exports__);
  13138. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return FlyCameraMouseInput; });
  13139. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13140. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13141. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13142. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13143. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13144. /**
  13145. * Listen to mouse events to control the camera.
  13146. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13147. */
  13148. var FlyCameraMouseInput = /** @class */ (function () {
  13149. /**
  13150. * Listen to mouse events to control the camera.
  13151. * @param touchEnabled Define if touch is enabled. (Default is true.)
  13152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13153. */
  13154. function FlyCameraMouseInput(touchEnabled) {
  13155. if (touchEnabled === void 0) { touchEnabled = true; }
  13156. /**
  13157. * Defines the buttons associated with the input to handle camera rotation.
  13158. */
  13159. this.buttons = [0, 1, 2];
  13160. /**
  13161. * Assign buttons for Yaw control.
  13162. */
  13163. this.buttonsYaw = [-1, 0, 1];
  13164. /**
  13165. * Assign buttons for Pitch control.
  13166. */
  13167. this.buttonsPitch = [-1, 0, 1];
  13168. /**
  13169. * Assign buttons for Roll control.
  13170. */
  13171. this.buttonsRoll = [2];
  13172. /**
  13173. * Detect if any button is being pressed while mouse is moved.
  13174. * -1 = Mouse locked.
  13175. * 0 = Left button.
  13176. * 1 = Middle Button.
  13177. * 2 = Right Button.
  13178. */
  13179. this.activeButton = -1;
  13180. /**
  13181. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  13182. * Higher values reduce its sensitivity.
  13183. */
  13184. this.angularSensibility = 1000.0;
  13185. this.previousPosition = null;
  13186. }
  13187. /**
  13188. * Attach the mouse control to the HTML DOM element.
  13189. * @param element Defines the element that listens to the input events.
  13190. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  13191. */
  13192. FlyCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  13193. var _this = this;
  13194. this.element = element;
  13195. this.noPreventDefault = noPreventDefault;
  13196. this._observer = this.camera.getScene().onPointerObservable.add(function (p, s) {
  13197. _this._pointerInput(p, s);
  13198. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  13199. // Correct Roll by rate, if enabled.
  13200. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function () {
  13201. if (_this.camera.rollCorrect) {
  13202. _this.camera.restoreRoll(_this.camera.rollCorrect);
  13203. }
  13204. });
  13205. // Helper function to keep 'this'.
  13206. this._mousemoveCallback = function (e) {
  13207. _this._onMouseMove(e);
  13208. };
  13209. element.addEventListener("mousemove", this._mousemoveCallback, false);
  13210. };
  13211. /**
  13212. * Detach the current controls from the specified dom element.
  13213. * @param element Defines the element to stop listening the inputs from
  13214. */
  13215. FlyCameraMouseInput.prototype.detachControl = function (element) {
  13216. if (this._observer && element) {
  13217. this.camera.getScene().onPointerObservable.remove(this._observer);
  13218. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver);
  13219. if (this._mousemoveCallback) {
  13220. element.removeEventListener("mousemove", this._mousemoveCallback);
  13221. }
  13222. this._observer = null;
  13223. this._rollObserver = null;
  13224. this.previousPosition = null;
  13225. this.noPreventDefault = undefined;
  13226. }
  13227. };
  13228. /**
  13229. * Gets the class name of the current input.
  13230. * @returns the class name.
  13231. */
  13232. FlyCameraMouseInput.prototype.getClassName = function () {
  13233. return "FlyCameraMouseInput";
  13234. };
  13235. /**
  13236. * Get the friendly name associated with the input class.
  13237. * @returns the input's friendly name.
  13238. */
  13239. FlyCameraMouseInput.prototype.getSimpleName = function () {
  13240. return "mouse";
  13241. };
  13242. // Track mouse movement, when the pointer is not locked.
  13243. FlyCameraMouseInput.prototype._pointerInput = function (p, s) {
  13244. var e = p.event;
  13245. var camera = this.camera;
  13246. var engine = camera.getEngine();
  13247. if (engine.isInVRExclusivePointerMode) {
  13248. return;
  13249. }
  13250. if (!this.touchEnabled && e.pointerType === "touch") {
  13251. return;
  13252. }
  13253. // Mouse is moved but an unknown mouse button is pressed.
  13254. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && this.buttons.indexOf(e.button) === -1) {
  13255. return;
  13256. }
  13257. var srcElement = (e.srcElement || e.target);
  13258. // Mouse down.
  13259. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  13260. try {
  13261. srcElement.setPointerCapture(e.pointerId);
  13262. }
  13263. catch (e) {
  13264. // Nothing to do with the error. Execution continues.
  13265. }
  13266. this.previousPosition = {
  13267. x: e.clientX,
  13268. y: e.clientY
  13269. };
  13270. this.activeButton = e.button;
  13271. if (!this.noPreventDefault) {
  13272. e.preventDefault();
  13273. this.element.focus();
  13274. }
  13275. }
  13276. else
  13277. // Mouse up.
  13278. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  13279. try {
  13280. srcElement.releasePointerCapture(e.pointerId);
  13281. }
  13282. catch (e) {
  13283. // Nothing to do with the error. Execution continues.
  13284. }
  13285. this.activeButton = -1;
  13286. this.previousPosition = null;
  13287. if (!this.noPreventDefault) {
  13288. e.preventDefault();
  13289. }
  13290. }
  13291. else
  13292. // Mouse move.
  13293. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13294. if (!this.previousPosition || engine.isPointerLock) {
  13295. return;
  13296. }
  13297. var offsetX = e.clientX - this.previousPosition.x;
  13298. var offsetY = e.clientY - this.previousPosition.y;
  13299. this.rotateCamera(offsetX, offsetY);
  13300. this.previousPosition = {
  13301. x: e.clientX,
  13302. y: e.clientY
  13303. };
  13304. if (!this.noPreventDefault) {
  13305. e.preventDefault();
  13306. }
  13307. }
  13308. };
  13309. // Track mouse movement, when pointer is locked.
  13310. FlyCameraMouseInput.prototype._onMouseMove = function (e) {
  13311. var camera = this.camera;
  13312. var engine = camera.getEngine();
  13313. if (!engine.isPointerLock || engine.isInVRExclusivePointerMode) {
  13314. return;
  13315. }
  13316. var offsetX = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0;
  13317. var offsetY = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  13318. this.rotateCamera(offsetX, offsetY);
  13319. this.previousPosition = null;
  13320. if (!this.noPreventDefault) {
  13321. e.preventDefault();
  13322. }
  13323. };
  13324. /**
  13325. * Rotate camera by mouse offset.
  13326. */
  13327. FlyCameraMouseInput.prototype.rotateCamera = function (offsetX, offsetY) {
  13328. var _this = this;
  13329. var camera = this.camera;
  13330. var scene = this.camera.getScene();
  13331. if (scene.useRightHandedSystem) {
  13332. offsetX *= -1;
  13333. }
  13334. if (camera.parent && camera.parent._getWorldMatrixDeterminant() < 0) {
  13335. offsetX *= -1;
  13336. }
  13337. var x = offsetX / this.angularSensibility;
  13338. var y = offsetY / this.angularSensibility;
  13339. // Initialize to current rotation.
  13340. var currentRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, camera.rotation.z);
  13341. var rotationChange;
  13342. // Pitch.
  13343. if (this.buttonsPitch.some(function (v) { return v === _this.activeButton; })) {
  13344. // Apply change in Radians to vector Angle.
  13345. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].X, y);
  13346. // Apply Pitch to quaternion.
  13347. currentRotation.multiplyInPlace(rotationChange);
  13348. }
  13349. // Yaw.
  13350. if (this.buttonsYaw.some(function (v) { return v === _this.activeButton; })) {
  13351. // Apply change in Radians to vector Angle.
  13352. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Y, x);
  13353. // Apply Yaw to quaternion.
  13354. currentRotation.multiplyInPlace(rotationChange);
  13355. // Add Roll, if banked turning is enabled, within Roll limit.
  13356. var limit = (camera.bankedTurnLimit) + camera._trackRoll; // Defaults to 90° plus manual roll.
  13357. if (camera.bankedTurn && -limit < camera.rotation.z && camera.rotation.z < limit) {
  13358. var bankingDelta = camera.bankedTurnMultiplier * -x;
  13359. // Apply change in Radians to vector Angle.
  13360. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, bankingDelta);
  13361. // Apply Yaw to quaternion.
  13362. currentRotation.multiplyInPlace(rotationChange);
  13363. }
  13364. }
  13365. // Roll.
  13366. if (this.buttonsRoll.some(function (v) { return v === _this.activeButton; })) {
  13367. // Apply change in Radians to vector Angle.
  13368. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, -x);
  13369. // Track Rolling.
  13370. camera._trackRoll -= x;
  13371. // Apply Pitch to quaternion.
  13372. currentRotation.multiplyInPlace(rotationChange);
  13373. }
  13374. // Apply rotationQuaternion to Euler camera.rotation.
  13375. currentRotation.toEulerAnglesToRef(camera.rotation);
  13376. };
  13377. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13378. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13379. ], FlyCameraMouseInput.prototype, "buttons", void 0);
  13380. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13381. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13382. ], FlyCameraMouseInput.prototype, "angularSensibility", void 0);
  13383. return FlyCameraMouseInput;
  13384. }());
  13385. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraMouseInput"] = FlyCameraMouseInput;
  13386. /***/ }),
  13387. /***/ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts":
  13388. /*!*********************************************************!*\
  13389. !*** ./Cameras/Inputs/followCameraKeyboardMoveInput.ts ***!
  13390. \*********************************************************/
  13391. /*! exports provided: FollowCameraKeyboardMoveInput */
  13392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13393. "use strict";
  13394. __webpack_require__.r(__webpack_exports__);
  13395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return FollowCameraKeyboardMoveInput; });
  13396. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13397. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13398. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13399. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13400. /**
  13401. * Manage the keyboard inputs to control the movement of a follow camera.
  13402. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13403. */
  13404. var FollowCameraKeyboardMoveInput = /** @class */ (function () {
  13405. function FollowCameraKeyboardMoveInput() {
  13406. /**
  13407. * Defines the list of key codes associated with the up action (increase heightOffset)
  13408. */
  13409. this.keysHeightOffsetIncr = [38];
  13410. /**
  13411. * Defines the list of key codes associated with the down action (decrease heightOffset)
  13412. */
  13413. this.keysHeightOffsetDecr = [40];
  13414. /**
  13415. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  13416. */
  13417. this.keysHeightOffsetModifierAlt = false;
  13418. /**
  13419. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  13420. */
  13421. this.keysHeightOffsetModifierCtrl = false;
  13422. /**
  13423. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  13424. */
  13425. this.keysHeightOffsetModifierShift = false;
  13426. /**
  13427. * Defines the list of key codes associated with the left action (increase rotationOffset)
  13428. */
  13429. this.keysRotationOffsetIncr = [37];
  13430. /**
  13431. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  13432. */
  13433. this.keysRotationOffsetDecr = [39];
  13434. /**
  13435. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  13436. */
  13437. this.keysRotationOffsetModifierAlt = false;
  13438. /**
  13439. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  13440. */
  13441. this.keysRotationOffsetModifierCtrl = false;
  13442. /**
  13443. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  13444. */
  13445. this.keysRotationOffsetModifierShift = false;
  13446. /**
  13447. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  13448. */
  13449. this.keysRadiusIncr = [40];
  13450. /**
  13451. * Defines the list of key codes associated with the zoom-out action (increase radius)
  13452. */
  13453. this.keysRadiusDecr = [38];
  13454. /**
  13455. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  13456. */
  13457. this.keysRadiusModifierAlt = true;
  13458. /**
  13459. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  13460. */
  13461. this.keysRadiusModifierCtrl = false;
  13462. /**
  13463. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  13464. */
  13465. this.keysRadiusModifierShift = false;
  13466. /**
  13467. * Defines the rate of change of heightOffset.
  13468. */
  13469. this.heightSensibility = 1;
  13470. /**
  13471. * Defines the rate of change of rotationOffset.
  13472. */
  13473. this.rotationSensibility = 1;
  13474. /**
  13475. * Defines the rate of change of radius.
  13476. */
  13477. this.radiusSensibility = 1;
  13478. this._keys = new Array();
  13479. }
  13480. /**
  13481. * Attach the input controls to a specific dom element to get the input from.
  13482. * @param element Defines the element the controls should be listened from
  13483. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13484. */
  13485. FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13486. var _this = this;
  13487. if (this._onCanvasBlurObserver) {
  13488. return;
  13489. }
  13490. this._scene = this.camera.getScene();
  13491. this._engine = this._scene.getEngine();
  13492. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13493. _this._keys = [];
  13494. });
  13495. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13496. var evt = info.event;
  13497. if (!evt.metaKey) {
  13498. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13499. _this._ctrlPressed = evt.ctrlKey;
  13500. _this._altPressed = evt.altKey;
  13501. _this._shiftPressed = evt.shiftKey;
  13502. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13503. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13504. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13505. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13506. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13507. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13508. var index = _this._keys.indexOf(evt.keyCode);
  13509. if (index === -1) {
  13510. _this._keys.push(evt.keyCode);
  13511. }
  13512. if (evt.preventDefault) {
  13513. if (!noPreventDefault) {
  13514. evt.preventDefault();
  13515. }
  13516. }
  13517. }
  13518. }
  13519. else {
  13520. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13521. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13522. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13523. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13524. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13525. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13526. var index = _this._keys.indexOf(evt.keyCode);
  13527. if (index >= 0) {
  13528. _this._keys.splice(index, 1);
  13529. }
  13530. if (evt.preventDefault) {
  13531. if (!noPreventDefault) {
  13532. evt.preventDefault();
  13533. }
  13534. }
  13535. }
  13536. }
  13537. }
  13538. });
  13539. };
  13540. /**
  13541. * Detach the current controls from the specified dom element.
  13542. * @param element Defines the element to stop listening the inputs from
  13543. */
  13544. FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13545. if (this._scene) {
  13546. if (this._onKeyboardObserver) {
  13547. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13548. }
  13549. if (this._onCanvasBlurObserver) {
  13550. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13551. }
  13552. this._onKeyboardObserver = null;
  13553. this._onCanvasBlurObserver = null;
  13554. }
  13555. this._keys = [];
  13556. };
  13557. /**
  13558. * Update the current camera state depending on the inputs that have been used this frame.
  13559. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13560. */
  13561. FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13562. var _this = this;
  13563. if (this._onKeyboardObserver) {
  13564. this._keys.forEach(function (keyCode) {
  13565. if (_this.keysHeightOffsetIncr.indexOf(keyCode) !== -1 &&
  13566. _this._modifierHeightOffset()) {
  13567. _this.camera.heightOffset += _this.heightSensibility;
  13568. }
  13569. else if (_this.keysHeightOffsetDecr.indexOf(keyCode) !== -1 &&
  13570. _this._modifierHeightOffset()) {
  13571. _this.camera.heightOffset -= _this.heightSensibility;
  13572. }
  13573. else if (_this.keysRotationOffsetIncr.indexOf(keyCode) !== -1 &&
  13574. _this._modifierRotationOffset()) {
  13575. _this.camera.rotationOffset += _this.rotationSensibility;
  13576. _this.camera.rotationOffset %= 360;
  13577. }
  13578. else if (_this.keysRotationOffsetDecr.indexOf(keyCode) !== -1 &&
  13579. _this._modifierRotationOffset()) {
  13580. _this.camera.rotationOffset -= _this.rotationSensibility;
  13581. _this.camera.rotationOffset %= 360;
  13582. }
  13583. else if (_this.keysRadiusIncr.indexOf(keyCode) !== -1 &&
  13584. _this._modifierRadius()) {
  13585. _this.camera.radius += _this.radiusSensibility;
  13586. }
  13587. else if (_this.keysRadiusDecr.indexOf(keyCode) !== -1 &&
  13588. _this._modifierRadius()) {
  13589. _this.camera.radius -= _this.radiusSensibility;
  13590. }
  13591. });
  13592. }
  13593. };
  13594. /**
  13595. * Gets the class name of the current input.
  13596. * @returns the class name
  13597. */
  13598. FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
  13599. return "FollowCameraKeyboardMoveInput";
  13600. };
  13601. /**
  13602. * Get the friendly name associated with the input class.
  13603. * @returns the input friendly name
  13604. */
  13605. FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13606. return "keyboard";
  13607. };
  13608. /**
  13609. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13610. * allow modification of the heightOffset value.
  13611. */
  13612. FollowCameraKeyboardMoveInput.prototype._modifierHeightOffset = function () {
  13613. return (this.keysHeightOffsetModifierAlt === this._altPressed &&
  13614. this.keysHeightOffsetModifierCtrl === this._ctrlPressed &&
  13615. this.keysHeightOffsetModifierShift === this._shiftPressed);
  13616. };
  13617. /**
  13618. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13619. * allow modification of the rotationOffset value.
  13620. */
  13621. FollowCameraKeyboardMoveInput.prototype._modifierRotationOffset = function () {
  13622. return (this.keysRotationOffsetModifierAlt === this._altPressed &&
  13623. this.keysRotationOffsetModifierCtrl === this._ctrlPressed &&
  13624. this.keysRotationOffsetModifierShift === this._shiftPressed);
  13625. };
  13626. /**
  13627. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13628. * allow modification of the radius value.
  13629. */
  13630. FollowCameraKeyboardMoveInput.prototype._modifierRadius = function () {
  13631. return (this.keysRadiusModifierAlt === this._altPressed &&
  13632. this.keysRadiusModifierCtrl === this._ctrlPressed &&
  13633. this.keysRadiusModifierShift === this._shiftPressed);
  13634. };
  13635. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13636. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13637. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetIncr", void 0);
  13638. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13639. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13640. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetDecr", void 0);
  13641. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13642. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13643. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierAlt", void 0);
  13644. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13645. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13646. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierCtrl", void 0);
  13647. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13648. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13649. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierShift", void 0);
  13650. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13651. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13652. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetIncr", void 0);
  13653. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13654. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13655. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetDecr", void 0);
  13656. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13657. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13658. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierAlt", void 0);
  13659. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13660. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13661. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierCtrl", void 0);
  13662. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13663. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13664. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierShift", void 0);
  13665. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13666. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13667. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusIncr", void 0);
  13668. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13669. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13670. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusDecr", void 0);
  13671. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13673. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierAlt", void 0);
  13674. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13675. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13676. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierCtrl", void 0);
  13677. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13678. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13679. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierShift", void 0);
  13680. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13681. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13682. ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
  13683. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13684. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13685. ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
  13686. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13687. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13688. ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
  13689. return FollowCameraKeyboardMoveInput;
  13690. }());
  13691. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
  13692. /***/ }),
  13693. /***/ "./Cameras/Inputs/followCameraMouseWheelInput.ts":
  13694. /*!*******************************************************!*\
  13695. !*** ./Cameras/Inputs/followCameraMouseWheelInput.ts ***!
  13696. \*******************************************************/
  13697. /*! exports provided: FollowCameraMouseWheelInput */
  13698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13699. "use strict";
  13700. __webpack_require__.r(__webpack_exports__);
  13701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return FollowCameraMouseWheelInput; });
  13702. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13703. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13704. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13705. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13706. /**
  13707. * Manage the mouse wheel inputs to control a follow camera.
  13708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13709. */
  13710. var FollowCameraMouseWheelInput = /** @class */ (function () {
  13711. function FollowCameraMouseWheelInput() {
  13712. /**
  13713. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  13714. */
  13715. this.axisControlRadius = true;
  13716. /**
  13717. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  13718. */
  13719. this.axisControlHeight = false;
  13720. /**
  13721. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  13722. */
  13723. this.axisControlRotation = false;
  13724. /**
  13725. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  13726. * relation to mouseWheel events.
  13727. */
  13728. this.wheelPrecision = 3.0;
  13729. /**
  13730. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  13731. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  13732. */
  13733. this.wheelDeltaPercentage = 0;
  13734. }
  13735. /**
  13736. * Attach the input controls to a specific dom element to get the input from.
  13737. * @param element Defines the element the controls should be listened from
  13738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13739. */
  13740. FollowCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  13741. var _this = this;
  13742. this._wheel = function (p, s) {
  13743. // sanity check - this should be a PointerWheel event.
  13744. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  13745. return;
  13746. }
  13747. var event = p.event;
  13748. var delta = 0;
  13749. // Chrome, Safari: event.deltaY
  13750. // IE: event.wheelDelta
  13751. // Firefox: event.detail (inverted)
  13752. var wheelDelta = Math.max(-1, Math.min(1, (event.deltaY || event.wheelDelta || -event.detail)));
  13753. if (_this.wheelDeltaPercentage) {
  13754. console.assert((_this.axisControlRadius +
  13755. _this.axisControlHeight +
  13756. _this.axisControlRotation) <= 1, "wheelDeltaPercentage only usable when mouse wheel " +
  13757. "controlls ONE axis. " +
  13758. "Currently enabled: " +
  13759. "axisControlRadius: " + _this.axisControlRadius +
  13760. ", axisControlHeightOffset: " + _this.axisControlHeight +
  13761. ", axisControlRotationOffset: " + _this.axisControlRotation);
  13762. if (_this.axisControlRadius) {
  13763. delta =
  13764. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13765. _this.camera.radius;
  13766. }
  13767. else if (_this.axisControlHeight) {
  13768. delta =
  13769. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13770. _this.camera.heightOffset;
  13771. }
  13772. else if (_this.axisControlRotation) {
  13773. delta =
  13774. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13775. _this.camera.rotationOffset;
  13776. }
  13777. }
  13778. else {
  13779. delta = wheelDelta * _this.wheelPrecision;
  13780. }
  13781. if (delta) {
  13782. if (_this.axisControlRadius) {
  13783. _this.camera.radius += delta;
  13784. }
  13785. else if (_this.axisControlHeight) {
  13786. _this.camera.heightOffset -= delta;
  13787. }
  13788. else if (_this.axisControlRotation) {
  13789. _this.camera.rotationOffset -= delta;
  13790. }
  13791. }
  13792. if (event.preventDefault) {
  13793. if (!noPreventDefault) {
  13794. event.preventDefault();
  13795. }
  13796. }
  13797. };
  13798. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  13799. };
  13800. /**
  13801. * Detach the current controls from the specified dom element.
  13802. * @param element Defines the element to stop listening the inputs from
  13803. */
  13804. FollowCameraMouseWheelInput.prototype.detachControl = function (element) {
  13805. if (this._observer && element) {
  13806. this.camera.getScene().onPointerObservable.remove(this._observer);
  13807. this._observer = null;
  13808. this._wheel = null;
  13809. }
  13810. };
  13811. /**
  13812. * Gets the class name of the current intput.
  13813. * @returns the class name
  13814. */
  13815. FollowCameraMouseWheelInput.prototype.getClassName = function () {
  13816. return "ArcRotateCameraMouseWheelInput";
  13817. };
  13818. /**
  13819. * Get the friendly name associated with the input class.
  13820. * @returns the input friendly name
  13821. */
  13822. FollowCameraMouseWheelInput.prototype.getSimpleName = function () {
  13823. return "mousewheel";
  13824. };
  13825. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13826. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13827. ], FollowCameraMouseWheelInput.prototype, "axisControlRadius", void 0);
  13828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13830. ], FollowCameraMouseWheelInput.prototype, "axisControlHeight", void 0);
  13831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13833. ], FollowCameraMouseWheelInput.prototype, "axisControlRotation", void 0);
  13834. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13835. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13836. ], FollowCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  13837. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13838. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13839. ], FollowCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  13840. return FollowCameraMouseWheelInput;
  13841. }());
  13842. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraMouseWheelInput"] = FollowCameraMouseWheelInput;
  13843. /***/ }),
  13844. /***/ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts":
  13845. /*!************************************************************!*\
  13846. !*** ./Cameras/Inputs/freeCameraDeviceOrientationInput.ts ***!
  13847. \************************************************************/
  13848. /*! exports provided: FreeCameraDeviceOrientationInput */
  13849. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13850. "use strict";
  13851. __webpack_require__.r(__webpack_exports__);
  13852. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return FreeCameraDeviceOrientationInput; });
  13853. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13854. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13855. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  13856. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  13857. /**
  13858. * Add orientation input support to the input manager.
  13859. * @returns the current input manager
  13860. */
  13861. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addDeviceOrientation = function () {
  13862. this.add(new FreeCameraDeviceOrientationInput());
  13863. return this;
  13864. };
  13865. /**
  13866. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  13867. * Screen rotation is taken into account.
  13868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13869. */
  13870. var FreeCameraDeviceOrientationInput = /** @class */ (function () {
  13871. /**
  13872. * Instantiates a new input
  13873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13874. */
  13875. function FreeCameraDeviceOrientationInput() {
  13876. var _this = this;
  13877. this._screenOrientationAngle = 0;
  13878. this._screenQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  13879. this._alpha = 0;
  13880. this._beta = 0;
  13881. this._gamma = 0;
  13882. this._orientationChanged = function () {
  13883. _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
  13884. _this._screenOrientationAngle = -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(_this._screenOrientationAngle / 2);
  13885. _this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
  13886. };
  13887. this._deviceOrientation = function (evt) {
  13888. _this._alpha = evt.alpha !== null ? evt.alpha : 0;
  13889. _this._beta = evt.beta !== null ? evt.beta : 0;
  13890. _this._gamma = evt.gamma !== null ? evt.gamma : 0;
  13891. };
  13892. this._constantTranform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
  13893. this._orientationChanged();
  13894. }
  13895. Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
  13896. /**
  13897. * Define the camera controlled by the input.
  13898. */
  13899. get: function () {
  13900. return this._camera;
  13901. },
  13902. set: function (camera) {
  13903. this._camera = camera;
  13904. if (this._camera != null && !this._camera.rotationQuaternion) {
  13905. this._camera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  13906. }
  13907. },
  13908. enumerable: true,
  13909. configurable: true
  13910. });
  13911. /**
  13912. * Attach the input controls to a specific dom element to get the input from.
  13913. * @param element Defines the element the controls should be listened from
  13914. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13915. */
  13916. FreeCameraDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  13917. window.addEventListener("orientationchange", this._orientationChanged);
  13918. window.addEventListener("deviceorientation", this._deviceOrientation);
  13919. //In certain cases, the attach control is called AFTER orientation was changed,
  13920. //So this is needed.
  13921. this._orientationChanged();
  13922. };
  13923. /**
  13924. * Detach the current controls from the specified dom element.
  13925. * @param element Defines the element to stop listening the inputs from
  13926. */
  13927. FreeCameraDeviceOrientationInput.prototype.detachControl = function (element) {
  13928. window.removeEventListener("orientationchange", this._orientationChanged);
  13929. window.removeEventListener("deviceorientation", this._deviceOrientation);
  13930. };
  13931. /**
  13932. * Update the current camera state depending on the inputs that have been used this frame.
  13933. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13934. */
  13935. FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
  13936. //if no device orientation provided, don't update the rotation.
  13937. //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
  13938. if (!this._alpha) {
  13939. return;
  13940. }
  13941. _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);
  13942. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
  13943. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
  13944. //Mirror on XY Plane
  13945. this._camera.rotationQuaternion.z *= -1;
  13946. this._camera.rotationQuaternion.w *= -1;
  13947. };
  13948. /**
  13949. * Gets the class name of the current intput.
  13950. * @returns the class name
  13951. */
  13952. FreeCameraDeviceOrientationInput.prototype.getClassName = function () {
  13953. return "FreeCameraDeviceOrientationInput";
  13954. };
  13955. /**
  13956. * Get the friendly name associated with the input class.
  13957. * @returns the input friendly name
  13958. */
  13959. FreeCameraDeviceOrientationInput.prototype.getSimpleName = function () {
  13960. return "deviceOrientation";
  13961. };
  13962. return FreeCameraDeviceOrientationInput;
  13963. }());
  13964. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["FreeCameraDeviceOrientationInput"] = FreeCameraDeviceOrientationInput;
  13965. /***/ }),
  13966. /***/ "./Cameras/Inputs/freeCameraGamepadInput.ts":
  13967. /*!**************************************************!*\
  13968. !*** ./Cameras/Inputs/freeCameraGamepadInput.ts ***!
  13969. \**************************************************/
  13970. /*! exports provided: FreeCameraGamepadInput */
  13971. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13972. "use strict";
  13973. __webpack_require__.r(__webpack_exports__);
  13974. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return FreeCameraGamepadInput; });
  13975. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13976. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13977. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13978. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13979. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  13980. /**
  13981. * Manage the gamepad inputs to control a free camera.
  13982. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13983. */
  13984. var FreeCameraGamepadInput = /** @class */ (function () {
  13985. function FreeCameraGamepadInput() {
  13986. /**
  13987. * Defines the gamepad rotation sensiblity.
  13988. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  13989. */
  13990. this.gamepadAngularSensibility = 200;
  13991. /**
  13992. * Defines the gamepad move sensiblity.
  13993. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  13994. */
  13995. this.gamepadMoveSensibility = 40;
  13996. this._cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  13997. this._deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  13998. this._vector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  13999. this._vector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  14000. }
  14001. /**
  14002. * Attach the input controls to a specific dom element to get the input from.
  14003. * @param element Defines the element the controls should be listened from
  14004. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14005. */
  14006. FreeCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  14007. var _this = this;
  14008. var manager = this.camera.getScene().gamepadManager;
  14009. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  14010. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].POSE_ENABLED) {
  14011. // prioritize XBOX gamepads.
  14012. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX) {
  14013. _this.gamepad = gamepad;
  14014. }
  14015. }
  14016. });
  14017. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  14018. if (_this.gamepad === gamepad) {
  14019. _this.gamepad = null;
  14020. }
  14021. });
  14022. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX);
  14023. };
  14024. /**
  14025. * Detach the current controls from the specified dom element.
  14026. * @param element Defines the element to stop listening the inputs from
  14027. */
  14028. FreeCameraGamepadInput.prototype.detachControl = function (element) {
  14029. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  14030. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  14031. this.gamepad = null;
  14032. };
  14033. /**
  14034. * Update the current camera state depending on the inputs that have been used this frame.
  14035. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14036. */
  14037. FreeCameraGamepadInput.prototype.checkInputs = function () {
  14038. if (this.gamepad && this.gamepad.leftStick) {
  14039. var camera = this.camera;
  14040. var LSValues = this.gamepad.leftStick;
  14041. var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
  14042. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  14043. LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
  14044. LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
  14045. var RSValues = this.gamepad.rightStick;
  14046. if (RSValues) {
  14047. var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
  14048. var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
  14049. RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
  14050. RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
  14051. }
  14052. else {
  14053. RSValues = { x: 0, y: 0 };
  14054. }
  14055. if (!camera.rotationQuaternion) {
  14056. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
  14057. }
  14058. else {
  14059. camera.rotationQuaternion.toRotationMatrix(this._cameraTransform);
  14060. }
  14061. var speed = camera._computeLocalCameraSpeed() * 50.0;
  14062. this._vector3.copyFromFloats(LSValues.x * speed, 0, -LSValues.y * speed);
  14063. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform);
  14064. camera.cameraDirection.addInPlace(this._deltaTransform);
  14065. this._vector2.copyFromFloats(RSValues.y, RSValues.x);
  14066. camera.cameraRotation.addInPlace(this._vector2);
  14067. }
  14068. };
  14069. /**
  14070. * Gets the class name of the current intput.
  14071. * @returns the class name
  14072. */
  14073. FreeCameraGamepadInput.prototype.getClassName = function () {
  14074. return "FreeCameraGamepadInput";
  14075. };
  14076. /**
  14077. * Get the friendly name associated with the input class.
  14078. * @returns the input friendly name
  14079. */
  14080. FreeCameraGamepadInput.prototype.getSimpleName = function () {
  14081. return "gamepad";
  14082. };
  14083. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14084. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14085. ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
  14086. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14087. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14088. ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  14089. return FreeCameraGamepadInput;
  14090. }());
  14091. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraGamepadInput"] = FreeCameraGamepadInput;
  14092. /***/ }),
  14093. /***/ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts":
  14094. /*!*******************************************************!*\
  14095. !*** ./Cameras/Inputs/freeCameraKeyboardMoveInput.ts ***!
  14096. \*******************************************************/
  14097. /*! exports provided: FreeCameraKeyboardMoveInput */
  14098. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14099. "use strict";
  14100. __webpack_require__.r(__webpack_exports__);
  14101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return FreeCameraKeyboardMoveInput; });
  14102. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14103. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14104. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14105. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  14106. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14107. /**
  14108. * Manage the keyboard inputs to control the movement of a free camera.
  14109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14110. */
  14111. var FreeCameraKeyboardMoveInput = /** @class */ (function () {
  14112. function FreeCameraKeyboardMoveInput() {
  14113. /**
  14114. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  14115. */
  14116. this.keysUp = [38];
  14117. /**
  14118. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  14119. */
  14120. this.keysDown = [40];
  14121. /**
  14122. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  14123. */
  14124. this.keysLeft = [37];
  14125. /**
  14126. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  14127. */
  14128. this.keysRight = [39];
  14129. this._keys = new Array();
  14130. }
  14131. /**
  14132. * Attach the input controls to a specific dom element to get the input from.
  14133. * @param element Defines the element the controls should be listened from
  14134. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14135. */
  14136. FreeCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  14137. var _this = this;
  14138. if (this._onCanvasBlurObserver) {
  14139. return;
  14140. }
  14141. this._scene = this.camera.getScene();
  14142. this._engine = this._scene.getEngine();
  14143. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  14144. _this._keys = [];
  14145. });
  14146. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  14147. var evt = info.event;
  14148. if (!evt.metaKey) {
  14149. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  14150. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14151. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14152. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14153. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14154. var index = _this._keys.indexOf(evt.keyCode);
  14155. if (index === -1) {
  14156. _this._keys.push(evt.keyCode);
  14157. }
  14158. if (!noPreventDefault) {
  14159. evt.preventDefault();
  14160. }
  14161. }
  14162. }
  14163. else {
  14164. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14165. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14166. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14167. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14168. var index = _this._keys.indexOf(evt.keyCode);
  14169. if (index >= 0) {
  14170. _this._keys.splice(index, 1);
  14171. }
  14172. if (!noPreventDefault) {
  14173. evt.preventDefault();
  14174. }
  14175. }
  14176. }
  14177. }
  14178. });
  14179. };
  14180. /**
  14181. * Detach the current controls from the specified dom element.
  14182. * @param element Defines the element to stop listening the inputs from
  14183. */
  14184. FreeCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  14185. if (this._scene) {
  14186. if (this._onKeyboardObserver) {
  14187. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  14188. }
  14189. if (this._onCanvasBlurObserver) {
  14190. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  14191. }
  14192. this._onKeyboardObserver = null;
  14193. this._onCanvasBlurObserver = null;
  14194. }
  14195. this._keys = [];
  14196. };
  14197. /**
  14198. * Update the current camera state depending on the inputs that have been used this frame.
  14199. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14200. */
  14201. FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
  14202. if (this._onKeyboardObserver) {
  14203. var camera = this.camera;
  14204. // Keyboard
  14205. for (var index = 0; index < this._keys.length; index++) {
  14206. var keyCode = this._keys[index];
  14207. var speed = camera._computeLocalCameraSpeed();
  14208. if (this.keysLeft.indexOf(keyCode) !== -1) {
  14209. camera._localDirection.copyFromFloats(-speed, 0, 0);
  14210. }
  14211. else if (this.keysUp.indexOf(keyCode) !== -1) {
  14212. camera._localDirection.copyFromFloats(0, 0, speed);
  14213. }
  14214. else if (this.keysRight.indexOf(keyCode) !== -1) {
  14215. camera._localDirection.copyFromFloats(speed, 0, 0);
  14216. }
  14217. else if (this.keysDown.indexOf(keyCode) !== -1) {
  14218. camera._localDirection.copyFromFloats(0, 0, -speed);
  14219. }
  14220. if (camera.getScene().useRightHandedSystem) {
  14221. camera._localDirection.z *= -1;
  14222. }
  14223. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  14224. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  14225. camera.cameraDirection.addInPlace(camera._transformedDirection);
  14226. }
  14227. }
  14228. };
  14229. /**
  14230. * Gets the class name of the current intput.
  14231. * @returns the class name
  14232. */
  14233. FreeCameraKeyboardMoveInput.prototype.getClassName = function () {
  14234. return "FreeCameraKeyboardMoveInput";
  14235. };
  14236. /** @hidden */
  14237. FreeCameraKeyboardMoveInput.prototype._onLostFocus = function () {
  14238. this._keys = [];
  14239. };
  14240. /**
  14241. * Get the friendly name associated with the input class.
  14242. * @returns the input friendly name
  14243. */
  14244. FreeCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  14245. return "keyboard";
  14246. };
  14247. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14248. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14249. ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  14250. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14252. ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  14253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14255. ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  14256. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14258. ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  14259. return FreeCameraKeyboardMoveInput;
  14260. }());
  14261. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraKeyboardMoveInput"] = FreeCameraKeyboardMoveInput;
  14262. /***/ }),
  14263. /***/ "./Cameras/Inputs/freeCameraMouseInput.ts":
  14264. /*!************************************************!*\
  14265. !*** ./Cameras/Inputs/freeCameraMouseInput.ts ***!
  14266. \************************************************/
  14267. /*! exports provided: FreeCameraMouseInput */
  14268. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14269. "use strict";
  14270. __webpack_require__.r(__webpack_exports__);
  14271. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return FreeCameraMouseInput; });
  14272. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14273. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14274. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14275. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14276. /**
  14277. * Manage the mouse inputs to control the movement of a free camera.
  14278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14279. */
  14280. var FreeCameraMouseInput = /** @class */ (function () {
  14281. /**
  14282. * Manage the mouse inputs to control the movement of a free camera.
  14283. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14284. * @param touchEnabled Defines if touch is enabled or not
  14285. */
  14286. function FreeCameraMouseInput(
  14287. /**
  14288. * Define if touch is enabled in the mouse input
  14289. */
  14290. touchEnabled) {
  14291. if (touchEnabled === void 0) { touchEnabled = true; }
  14292. this.touchEnabled = touchEnabled;
  14293. /**
  14294. * Defines the buttons associated with the input to handle camera move.
  14295. */
  14296. this.buttons = [0, 1, 2];
  14297. /**
  14298. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  14299. */
  14300. this.angularSensibility = 2000.0;
  14301. this.previousPosition = null;
  14302. }
  14303. /**
  14304. * Attach the input controls to a specific dom element to get the input from.
  14305. * @param element Defines the element the controls should be listened from
  14306. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14307. */
  14308. FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  14309. var _this = this;
  14310. var engine = this.camera.getEngine();
  14311. if (!this._pointerInput) {
  14312. this._pointerInput = function (p) {
  14313. var evt = p.event;
  14314. if (engine.isInVRExclusivePointerMode) {
  14315. return;
  14316. }
  14317. if (!_this.touchEnabled && evt.pointerType === "touch") {
  14318. return;
  14319. }
  14320. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  14321. return;
  14322. }
  14323. var srcElement = (evt.srcElement || evt.target);
  14324. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  14325. try {
  14326. srcElement.setPointerCapture(evt.pointerId);
  14327. }
  14328. catch (e) {
  14329. //Nothing to do with the error. Execution will continue.
  14330. }
  14331. _this.previousPosition = {
  14332. x: evt.clientX,
  14333. y: evt.clientY
  14334. };
  14335. if (!noPreventDefault) {
  14336. evt.preventDefault();
  14337. element.focus();
  14338. }
  14339. }
  14340. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  14341. try {
  14342. srcElement.releasePointerCapture(evt.pointerId);
  14343. }
  14344. catch (e) {
  14345. //Nothing to do with the error.
  14346. }
  14347. _this.previousPosition = null;
  14348. if (!noPreventDefault) {
  14349. evt.preventDefault();
  14350. }
  14351. }
  14352. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14353. if (!_this.previousPosition || engine.isPointerLock) {
  14354. return;
  14355. }
  14356. var offsetX = evt.clientX - _this.previousPosition.x;
  14357. if (_this.camera.getScene().useRightHandedSystem) {
  14358. offsetX *= -1;
  14359. }
  14360. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14361. offsetX *= -1;
  14362. }
  14363. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14364. var offsetY = evt.clientY - _this.previousPosition.y;
  14365. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14366. _this.previousPosition = {
  14367. x: evt.clientX,
  14368. y: evt.clientY
  14369. };
  14370. if (!noPreventDefault) {
  14371. evt.preventDefault();
  14372. }
  14373. }
  14374. };
  14375. }
  14376. this._onMouseMove = function (evt) {
  14377. if (!engine.isPointerLock) {
  14378. return;
  14379. }
  14380. if (engine.isInVRExclusivePointerMode) {
  14381. return;
  14382. }
  14383. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  14384. if (_this.camera.getScene().useRightHandedSystem) {
  14385. offsetX *= -1;
  14386. }
  14387. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14388. offsetX *= -1;
  14389. }
  14390. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14391. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  14392. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14393. _this.previousPosition = null;
  14394. if (!noPreventDefault) {
  14395. evt.preventDefault();
  14396. }
  14397. };
  14398. 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);
  14399. element.addEventListener("mousemove", this._onMouseMove, false);
  14400. };
  14401. /**
  14402. * Detach the current controls from the specified dom element.
  14403. * @param element Defines the element to stop listening the inputs from
  14404. */
  14405. FreeCameraMouseInput.prototype.detachControl = function (element) {
  14406. if (this._observer && element) {
  14407. this.camera.getScene().onPointerObservable.remove(this._observer);
  14408. if (this._onMouseMove) {
  14409. element.removeEventListener("mousemove", this._onMouseMove);
  14410. }
  14411. this._observer = null;
  14412. this._onMouseMove = null;
  14413. this.previousPosition = null;
  14414. }
  14415. };
  14416. /**
  14417. * Gets the class name of the current intput.
  14418. * @returns the class name
  14419. */
  14420. FreeCameraMouseInput.prototype.getClassName = function () {
  14421. return "FreeCameraMouseInput";
  14422. };
  14423. /**
  14424. * Get the friendly name associated with the input class.
  14425. * @returns the input friendly name
  14426. */
  14427. FreeCameraMouseInput.prototype.getSimpleName = function () {
  14428. return "mouse";
  14429. };
  14430. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14431. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14432. ], FreeCameraMouseInput.prototype, "buttons", void 0);
  14433. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14434. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14435. ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
  14436. return FreeCameraMouseInput;
  14437. }());
  14438. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraMouseInput"] = FreeCameraMouseInput;
  14439. /***/ }),
  14440. /***/ "./Cameras/Inputs/freeCameraTouchInput.ts":
  14441. /*!************************************************!*\
  14442. !*** ./Cameras/Inputs/freeCameraTouchInput.ts ***!
  14443. \************************************************/
  14444. /*! exports provided: FreeCameraTouchInput */
  14445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14446. "use strict";
  14447. __webpack_require__.r(__webpack_exports__);
  14448. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return FreeCameraTouchInput; });
  14449. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14450. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14451. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14452. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14453. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14454. /**
  14455. * Manage the touch inputs to control the movement of a free camera.
  14456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14457. */
  14458. var FreeCameraTouchInput = /** @class */ (function () {
  14459. function FreeCameraTouchInput() {
  14460. /**
  14461. * Defines the touch sensibility for rotation.
  14462. * The higher the faster.
  14463. */
  14464. this.touchAngularSensibility = 200000.0;
  14465. /**
  14466. * Defines the touch sensibility for move.
  14467. * The higher the faster.
  14468. */
  14469. this.touchMoveSensibility = 250.0;
  14470. this._offsetX = null;
  14471. this._offsetY = null;
  14472. this._pointerPressed = new Array();
  14473. }
  14474. /**
  14475. * Attach the input controls to a specific dom element to get the input from.
  14476. * @param element Defines the element the controls should be listened from
  14477. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14478. */
  14479. FreeCameraTouchInput.prototype.attachControl = function (element, noPreventDefault) {
  14480. var _this = this;
  14481. var previousPosition = null;
  14482. if (this._pointerInput === undefined) {
  14483. this._onLostFocus = function () {
  14484. _this._offsetX = null;
  14485. _this._offsetY = null;
  14486. };
  14487. this._pointerInput = function (p) {
  14488. var evt = p.event;
  14489. if (evt.pointerType === "mouse") {
  14490. return;
  14491. }
  14492. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN) {
  14493. if (!noPreventDefault) {
  14494. evt.preventDefault();
  14495. }
  14496. _this._pointerPressed.push(evt.pointerId);
  14497. if (_this._pointerPressed.length !== 1) {
  14498. return;
  14499. }
  14500. previousPosition = {
  14501. x: evt.clientX,
  14502. y: evt.clientY
  14503. };
  14504. }
  14505. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP) {
  14506. if (!noPreventDefault) {
  14507. evt.preventDefault();
  14508. }
  14509. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14510. if (index === -1) {
  14511. return;
  14512. }
  14513. _this._pointerPressed.splice(index, 1);
  14514. if (index != 0) {
  14515. return;
  14516. }
  14517. previousPosition = null;
  14518. _this._offsetX = null;
  14519. _this._offsetY = null;
  14520. }
  14521. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14522. if (!noPreventDefault) {
  14523. evt.preventDefault();
  14524. }
  14525. if (!previousPosition) {
  14526. return;
  14527. }
  14528. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14529. if (index != 0) {
  14530. return;
  14531. }
  14532. _this._offsetX = evt.clientX - previousPosition.x;
  14533. _this._offsetY = -(evt.clientY - previousPosition.y);
  14534. }
  14535. };
  14536. }
  14537. 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);
  14538. if (this._onLostFocus) {
  14539. element.addEventListener("blur", this._onLostFocus);
  14540. }
  14541. };
  14542. /**
  14543. * Detach the current controls from the specified dom element.
  14544. * @param element Defines the element to stop listening the inputs from
  14545. */
  14546. FreeCameraTouchInput.prototype.detachControl = function (element) {
  14547. if (this._pointerInput && element) {
  14548. if (this._observer) {
  14549. this.camera.getScene().onPointerObservable.remove(this._observer);
  14550. this._observer = null;
  14551. }
  14552. if (this._onLostFocus) {
  14553. element.removeEventListener("blur", this._onLostFocus);
  14554. this._onLostFocus = null;
  14555. }
  14556. this._pointerPressed = [];
  14557. this._offsetX = null;
  14558. this._offsetY = null;
  14559. }
  14560. };
  14561. /**
  14562. * Update the current camera state depending on the inputs that have been used this frame.
  14563. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14564. */
  14565. FreeCameraTouchInput.prototype.checkInputs = function () {
  14566. if (this._offsetX && this._offsetY) {
  14567. var camera = this.camera;
  14568. camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
  14569. if (this._pointerPressed.length > 1) {
  14570. camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
  14571. }
  14572. else {
  14573. var speed = camera._computeLocalCameraSpeed();
  14574. var direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, speed * this._offsetY / this.touchMoveSensibility);
  14575. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
  14576. camera.cameraDirection.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(direction, camera._cameraRotationMatrix));
  14577. }
  14578. }
  14579. };
  14580. /**
  14581. * Gets the class name of the current intput.
  14582. * @returns the class name
  14583. */
  14584. FreeCameraTouchInput.prototype.getClassName = function () {
  14585. return "FreeCameraTouchInput";
  14586. };
  14587. /**
  14588. * Get the friendly name associated with the input class.
  14589. * @returns the input friendly name
  14590. */
  14591. FreeCameraTouchInput.prototype.getSimpleName = function () {
  14592. return "touch";
  14593. };
  14594. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14595. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14596. ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
  14597. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14598. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14599. ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
  14600. return FreeCameraTouchInput;
  14601. }());
  14602. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraTouchInput"] = FreeCameraTouchInput;
  14603. /***/ }),
  14604. /***/ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts":
  14605. /*!**********************************************************!*\
  14606. !*** ./Cameras/Inputs/freeCameraVirtualJoystickInput.ts ***!
  14607. \**********************************************************/
  14608. /*! exports provided: FreeCameraVirtualJoystickInput */
  14609. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14610. "use strict";
  14611. __webpack_require__.r(__webpack_exports__);
  14612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return FreeCameraVirtualJoystickInput; });
  14613. /* harmony import */ var _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/virtualJoystick */ "./Misc/virtualJoystick.ts");
  14614. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14615. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14616. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14617. /**
  14618. * Add virtual joystick input support to the input manager.
  14619. * @returns the current input manager
  14620. */
  14621. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addVirtualJoystick = function () {
  14622. this.add(new FreeCameraVirtualJoystickInput());
  14623. return this;
  14624. };
  14625. /**
  14626. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  14627. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14628. */
  14629. var FreeCameraVirtualJoystickInput = /** @class */ (function () {
  14630. function FreeCameraVirtualJoystickInput() {
  14631. }
  14632. /**
  14633. * Gets the left stick of the virtual joystick.
  14634. * @returns The virtual Joystick
  14635. */
  14636. FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
  14637. return this._leftjoystick;
  14638. };
  14639. /**
  14640. * Gets the right stick of the virtual joystick.
  14641. * @returns The virtual Joystick
  14642. */
  14643. FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
  14644. return this._rightjoystick;
  14645. };
  14646. /**
  14647. * Update the current camera state depending on the inputs that have been used this frame.
  14648. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14649. */
  14650. FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
  14651. if (this._leftjoystick) {
  14652. var camera = this.camera;
  14653. var speed = camera._computeLocalCameraSpeed() * 50;
  14654. var cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
  14655. 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);
  14656. camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
  14657. camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
  14658. if (!this._leftjoystick.pressed) {
  14659. this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
  14660. }
  14661. if (!this._rightjoystick.pressed) {
  14662. this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
  14663. }
  14664. }
  14665. };
  14666. /**
  14667. * Attach the input controls to a specific dom element to get the input from.
  14668. * @param element Defines the element the controls should be listened from
  14669. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14670. */
  14671. FreeCameraVirtualJoystickInput.prototype.attachControl = function (element, noPreventDefault) {
  14672. this._leftjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](true);
  14673. this._leftjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Z);
  14674. this._leftjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  14675. this._leftjoystick.setJoystickSensibility(0.15);
  14676. this._rightjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](false);
  14677. this._rightjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  14678. this._rightjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Y);
  14679. this._rightjoystick.reverseUpDown = true;
  14680. this._rightjoystick.setJoystickSensibility(0.05);
  14681. this._rightjoystick.setJoystickColor("yellow");
  14682. };
  14683. /**
  14684. * Detach the current controls from the specified dom element.
  14685. * @param element Defines the element to stop listening the inputs from
  14686. */
  14687. FreeCameraVirtualJoystickInput.prototype.detachControl = function (element) {
  14688. this._leftjoystick.releaseCanvas();
  14689. this._rightjoystick.releaseCanvas();
  14690. };
  14691. /**
  14692. * Gets the class name of the current intput.
  14693. * @returns the class name
  14694. */
  14695. FreeCameraVirtualJoystickInput.prototype.getClassName = function () {
  14696. return "FreeCameraVirtualJoystickInput";
  14697. };
  14698. /**
  14699. * Get the friendly name associated with the input class.
  14700. * @returns the input friendly name
  14701. */
  14702. FreeCameraVirtualJoystickInput.prototype.getSimpleName = function () {
  14703. return "virtualJoystick";
  14704. };
  14705. return FreeCameraVirtualJoystickInput;
  14706. }());
  14707. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FreeCameraVirtualJoystickInput"] = FreeCameraVirtualJoystickInput;
  14708. /***/ }),
  14709. /***/ "./Cameras/Inputs/index.ts":
  14710. /*!*********************************!*\
  14711. !*** ./Cameras/Inputs/index.ts ***!
  14712. \*********************************/
  14713. /*! exports provided: ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput */
  14714. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14715. "use strict";
  14716. __webpack_require__.r(__webpack_exports__);
  14717. /* harmony import */ var _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  14718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  14719. /* harmony import */ var _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  14720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraKeyboardMoveInput"]; });
  14721. /* harmony import */ var _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  14722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraMouseWheelInput"]; });
  14723. /* harmony import */ var _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  14724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraPointersInput"]; });
  14725. /* harmony import */ var _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  14726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraVRDeviceOrientationInput"]; });
  14727. /* harmony import */ var _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  14728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__["FlyCameraKeyboardInput"]; });
  14729. /* harmony import */ var _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  14730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__["FlyCameraMouseInput"]; });
  14731. /* harmony import */ var _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  14732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  14733. /* harmony import */ var _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  14734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_8__["FreeCameraGamepadInput"]; });
  14735. /* harmony import */ var _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  14736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_9__["FreeCameraKeyboardMoveInput"]; });
  14737. /* harmony import */ var _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  14738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_10__["FreeCameraMouseInput"]; });
  14739. /* harmony import */ var _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  14740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_11__["FreeCameraTouchInput"]; });
  14741. /* harmony import */ var _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  14742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_12__["FreeCameraVirtualJoystickInput"]; });
  14743. /***/ }),
  14744. /***/ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts":
  14745. /*!*********************************************************!*\
  14746. !*** ./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts ***!
  14747. \*********************************************************/
  14748. /*! no exports provided */
  14749. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14750. "use strict";
  14751. __webpack_require__.r(__webpack_exports__);
  14752. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14753. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  14754. /* harmony import */ var _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  14755. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicAnaglyphRigMode = function (camera) {
  14756. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  14757. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__["AnaglyphPostProcess"](camera.name + "_anaglyph", 1.0, camera._rigCameras);
  14758. };
  14759. /***/ }),
  14760. /***/ "./Cameras/RigModes/stereoscopicRigMode.ts":
  14761. /*!*************************************************!*\
  14762. !*** ./Cameras/RigModes/stereoscopicRigMode.ts ***!
  14763. \*************************************************/
  14764. /*! no exports provided */
  14765. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14766. "use strict";
  14767. __webpack_require__.r(__webpack_exports__);
  14768. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14769. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  14770. /* harmony import */ var _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  14771. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicRigMode = function (camera) {
  14772. 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;
  14773. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  14774. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__["StereoscopicInterlacePostProcess"](camera.name + "_stereoInterlace", camera._rigCameras, isStereoscopicHoriz);
  14775. };
  14776. /***/ }),
  14777. /***/ "./Cameras/RigModes/vrRigMode.ts":
  14778. /*!***************************************!*\
  14779. !*** ./Cameras/RigModes/vrRigMode.ts ***!
  14780. \***************************************/
  14781. /*! no exports provided */
  14782. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14783. "use strict";
  14784. __webpack_require__.r(__webpack_exports__);
  14785. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14786. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14787. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  14788. /* harmony import */ var _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  14789. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setVRRigMode = function (camera, rigParams) {
  14790. var metrics = rigParams.vrCameraMetrics || _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault();
  14791. camera._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
  14792. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  14793. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14794. camera._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
  14795. camera._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
  14796. camera._rigCameras[0].getProjectionMatrix = camera._rigCameras[0]._getVRProjectionMatrix;
  14797. camera._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
  14798. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  14799. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14800. camera._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
  14801. camera._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
  14802. camera._rigCameras[1].getProjectionMatrix = camera._rigCameras[1]._getVRProjectionMatrix;
  14803. if (metrics.compensateDistortion) {
  14804. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Left", camera._rigCameras[0], false, metrics);
  14805. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Right", camera._rigCameras[1], true, metrics);
  14806. }
  14807. };
  14808. /***/ }),
  14809. /***/ "./Cameras/RigModes/webVRRigMode.ts":
  14810. /*!******************************************!*\
  14811. !*** ./Cameras/RigModes/webVRRigMode.ts ***!
  14812. \******************************************/
  14813. /*! no exports provided */
  14814. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14815. "use strict";
  14816. __webpack_require__.r(__webpack_exports__);
  14817. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14818. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14819. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setWebVRRigMode = function (camera, rigParams) {
  14820. if (rigParams.vrDisplay) {
  14821. var leftEye = rigParams.vrDisplay.getEyeParameters('left');
  14822. var rightEye = rigParams.vrDisplay.getEyeParameters('right');
  14823. //Left eye
  14824. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  14825. camera._rigCameras[0].setCameraRigParameter("left", true);
  14826. //leaving this for future reference
  14827. camera._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
  14828. camera._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
  14829. camera._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
  14830. camera._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  14831. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14832. camera._rigCameras[0].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  14833. camera._rigCameras[0].parent = camera;
  14834. camera._rigCameras[0]._getViewMatrix = camera._getWebVRViewMatrix;
  14835. //Right eye
  14836. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  14837. camera._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
  14838. camera._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
  14839. camera._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
  14840. camera._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  14841. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14842. camera._rigCameras[1].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  14843. camera._rigCameras[1].parent = camera;
  14844. camera._rigCameras[1]._getViewMatrix = camera._getWebVRViewMatrix;
  14845. if (_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].UseAlternateWebVRRendering) {
  14846. camera._rigCameras[1]._skipRendering = true;
  14847. camera._rigCameras[0]._alternateCamera = camera._rigCameras[1];
  14848. }
  14849. }
  14850. };
  14851. /***/ }),
  14852. /***/ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts":
  14853. /*!*********************************************************!*\
  14854. !*** ./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts ***!
  14855. \*********************************************************/
  14856. /*! exports provided: AnaglyphArcRotateCamera */
  14857. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14858. "use strict";
  14859. __webpack_require__.r(__webpack_exports__);
  14860. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return AnaglyphArcRotateCamera; });
  14861. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14862. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14863. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  14864. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14865. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14866. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14867. // Side effect import to define the stereoscopic mode.
  14868. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphArcRotateCamera", function (name, scene, options) {
  14869. return function () { return new AnaglyphArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14870. });
  14871. /**
  14872. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  14873. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14874. */
  14875. var AnaglyphArcRotateCamera = /** @class */ (function (_super) {
  14876. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphArcRotateCamera, _super);
  14877. /**
  14878. * Creates a new AnaglyphArcRotateCamera
  14879. * @param name defines camera name
  14880. * @param alpha defines alpha angle (in radians)
  14881. * @param beta defines beta angle (in radians)
  14882. * @param radius defines radius
  14883. * @param target defines camera target
  14884. * @param interaxialDistance defines distance between each color axis
  14885. * @param scene defines the hosting scene
  14886. */
  14887. function AnaglyphArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, scene) {
  14888. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  14889. _this.interaxialDistance = interaxialDistance;
  14890. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14891. return _this;
  14892. }
  14893. /**
  14894. * Gets camera class name
  14895. * @returns AnaglyphArcRotateCamera
  14896. */
  14897. AnaglyphArcRotateCamera.prototype.getClassName = function () {
  14898. return "AnaglyphArcRotateCamera";
  14899. };
  14900. return AnaglyphArcRotateCamera;
  14901. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  14902. /***/ }),
  14903. /***/ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts":
  14904. /*!****************************************************!*\
  14905. !*** ./Cameras/Stereoscopic/anaglyphFreeCamera.ts ***!
  14906. \****************************************************/
  14907. /*! exports provided: AnaglyphFreeCamera */
  14908. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14909. "use strict";
  14910. __webpack_require__.r(__webpack_exports__);
  14911. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return AnaglyphFreeCamera; });
  14912. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14913. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14914. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  14915. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14916. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14917. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14918. // Side effect import to define the stereoscopic mode.
  14919. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphFreeCamera", function (name, scene, options) {
  14920. return function () { return new AnaglyphFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14921. });
  14922. /**
  14923. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  14924. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14925. */
  14926. var AnaglyphFreeCamera = /** @class */ (function (_super) {
  14927. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphFreeCamera, _super);
  14928. /**
  14929. * Creates a new AnaglyphFreeCamera
  14930. * @param name defines camera name
  14931. * @param position defines initial position
  14932. * @param interaxialDistance defines distance between each color axis
  14933. * @param scene defines the hosting scene
  14934. */
  14935. function AnaglyphFreeCamera(name, position, interaxialDistance, scene) {
  14936. var _this = _super.call(this, name, position, scene) || this;
  14937. _this.interaxialDistance = interaxialDistance;
  14938. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14939. return _this;
  14940. }
  14941. /**
  14942. * Gets camera class name
  14943. * @returns AnaglyphFreeCamera
  14944. */
  14945. AnaglyphFreeCamera.prototype.getClassName = function () {
  14946. return "AnaglyphFreeCamera";
  14947. };
  14948. return AnaglyphFreeCamera;
  14949. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  14950. /***/ }),
  14951. /***/ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts":
  14952. /*!*******************************************************!*\
  14953. !*** ./Cameras/Stereoscopic/anaglyphGamepadCamera.ts ***!
  14954. \*******************************************************/
  14955. /*! exports provided: AnaglyphGamepadCamera */
  14956. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14957. "use strict";
  14958. __webpack_require__.r(__webpack_exports__);
  14959. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return AnaglyphGamepadCamera; });
  14960. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14961. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14962. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  14963. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14964. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14965. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14966. // Side effect import to define the stereoscopic mode.
  14967. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphGamepadCamera", function (name, scene, options) {
  14968. return function () { return new AnaglyphGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14969. });
  14970. /**
  14971. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  14972. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14973. */
  14974. var AnaglyphGamepadCamera = /** @class */ (function (_super) {
  14975. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphGamepadCamera, _super);
  14976. /**
  14977. * Creates a new AnaglyphGamepadCamera
  14978. * @param name defines camera name
  14979. * @param position defines initial position
  14980. * @param interaxialDistance defines distance between each color axis
  14981. * @param scene defines the hosting scene
  14982. */
  14983. function AnaglyphGamepadCamera(name, position, interaxialDistance, scene) {
  14984. var _this = _super.call(this, name, position, scene) || this;
  14985. _this.interaxialDistance = interaxialDistance;
  14986. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14987. return _this;
  14988. }
  14989. /**
  14990. * Gets camera class name
  14991. * @returns AnaglyphGamepadCamera
  14992. */
  14993. AnaglyphGamepadCamera.prototype.getClassName = function () {
  14994. return "AnaglyphGamepadCamera";
  14995. };
  14996. return AnaglyphGamepadCamera;
  14997. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  14998. /***/ }),
  14999. /***/ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts":
  15000. /*!*********************************************************!*\
  15001. !*** ./Cameras/Stereoscopic/anaglyphUniversalCamera.ts ***!
  15002. \*********************************************************/
  15003. /*! exports provided: AnaglyphUniversalCamera */
  15004. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15005. "use strict";
  15006. __webpack_require__.r(__webpack_exports__);
  15007. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return AnaglyphUniversalCamera; });
  15008. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15009. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15010. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15011. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15012. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15013. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15014. // Side effect import to define the stereoscopic mode.
  15015. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphUniversalCamera", function (name, scene, options) {
  15016. return function () { return new AnaglyphUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15017. });
  15018. /**
  15019. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  15020. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15021. */
  15022. var AnaglyphUniversalCamera = /** @class */ (function (_super) {
  15023. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphUniversalCamera, _super);
  15024. /**
  15025. * Creates a new AnaglyphUniversalCamera
  15026. * @param name defines camera name
  15027. * @param position defines initial position
  15028. * @param interaxialDistance defines distance between each color axis
  15029. * @param scene defines the hosting scene
  15030. */
  15031. function AnaglyphUniversalCamera(name, position, interaxialDistance, scene) {
  15032. var _this = _super.call(this, name, position, scene) || this;
  15033. _this.interaxialDistance = interaxialDistance;
  15034. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15035. return _this;
  15036. }
  15037. /**
  15038. * Gets camera class name
  15039. * @returns AnaglyphUniversalCamera
  15040. */
  15041. AnaglyphUniversalCamera.prototype.getClassName = function () {
  15042. return "AnaglyphUniversalCamera";
  15043. };
  15044. return AnaglyphUniversalCamera;
  15045. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15046. /***/ }),
  15047. /***/ "./Cameras/Stereoscopic/index.ts":
  15048. /*!***************************************!*\
  15049. !*** ./Cameras/Stereoscopic/index.ts ***!
  15050. \***************************************/
  15051. /*! exports provided: AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera */
  15052. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15053. "use strict";
  15054. __webpack_require__.r(__webpack_exports__);
  15055. /* harmony import */ var _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphArcRotateCamera */ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts");
  15056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  15057. /* harmony import */ var _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./anaglyphFreeCamera */ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts");
  15058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__["AnaglyphFreeCamera"]; });
  15059. /* harmony import */ var _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./anaglyphGamepadCamera */ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts");
  15060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__["AnaglyphGamepadCamera"]; });
  15061. /* harmony import */ var _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./anaglyphUniversalCamera */ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts");
  15062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__["AnaglyphUniversalCamera"]; });
  15063. /* harmony import */ var _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stereoscopicArcRotateCamera */ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts");
  15064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__["StereoscopicArcRotateCamera"]; });
  15065. /* harmony import */ var _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stereoscopicFreeCamera */ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts");
  15066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__["StereoscopicFreeCamera"]; });
  15067. /* harmony import */ var _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stereoscopicGamepadCamera */ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts");
  15068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__["StereoscopicGamepadCamera"]; });
  15069. /* harmony import */ var _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stereoscopicUniversalCamera */ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts");
  15070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  15071. /***/ }),
  15072. /***/ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts":
  15073. /*!*************************************************************!*\
  15074. !*** ./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts ***!
  15075. \*************************************************************/
  15076. /*! exports provided: StereoscopicArcRotateCamera */
  15077. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15078. "use strict";
  15079. __webpack_require__.r(__webpack_exports__);
  15080. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return StereoscopicArcRotateCamera; });
  15081. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15082. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15083. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15084. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15085. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15086. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15087. // Side effect import to define the stereoscopic mode.
  15088. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicArcRotateCamera", function (name, scene, options) {
  15089. return function () { return new StereoscopicArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15090. });
  15091. /**
  15092. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  15093. * @see http://doc.babylonjs.com/features/cameras
  15094. */
  15095. var StereoscopicArcRotateCamera = /** @class */ (function (_super) {
  15096. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicArcRotateCamera, _super);
  15097. /**
  15098. * Creates a new StereoscopicArcRotateCamera
  15099. * @param name defines camera name
  15100. * @param alpha defines alpha angle (in radians)
  15101. * @param beta defines beta angle (in radians)
  15102. * @param radius defines radius
  15103. * @param target defines camera target
  15104. * @param interaxialDistance defines distance between each color axis
  15105. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15106. * @param scene defines the hosting scene
  15107. */
  15108. function StereoscopicArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, isStereoscopicSideBySide, scene) {
  15109. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15110. _this.interaxialDistance = interaxialDistance;
  15111. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15112. _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 });
  15113. return _this;
  15114. }
  15115. /**
  15116. * Gets camera class name
  15117. * @returns StereoscopicArcRotateCamera
  15118. */
  15119. StereoscopicArcRotateCamera.prototype.getClassName = function () {
  15120. return "StereoscopicArcRotateCamera";
  15121. };
  15122. return StereoscopicArcRotateCamera;
  15123. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15124. /***/ }),
  15125. /***/ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts":
  15126. /*!********************************************************!*\
  15127. !*** ./Cameras/Stereoscopic/stereoscopicFreeCamera.ts ***!
  15128. \********************************************************/
  15129. /*! exports provided: StereoscopicFreeCamera */
  15130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15131. "use strict";
  15132. __webpack_require__.r(__webpack_exports__);
  15133. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return StereoscopicFreeCamera; });
  15134. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15135. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15136. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15137. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15138. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15139. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15140. // Side effect import to define the stereoscopic mode.
  15141. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15142. return function () { return new StereoscopicFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15143. });
  15144. /**
  15145. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  15146. * @see http://doc.babylonjs.com/features/cameras
  15147. */
  15148. var StereoscopicFreeCamera = /** @class */ (function (_super) {
  15149. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicFreeCamera, _super);
  15150. /**
  15151. * Creates a new StereoscopicFreeCamera
  15152. * @param name defines camera name
  15153. * @param position defines initial position
  15154. * @param interaxialDistance defines distance between each color axis
  15155. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15156. * @param scene defines the hosting scene
  15157. */
  15158. function StereoscopicFreeCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15159. var _this = _super.call(this, name, position, scene) || this;
  15160. _this.interaxialDistance = interaxialDistance;
  15161. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15162. _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 });
  15163. return _this;
  15164. }
  15165. /**
  15166. * Gets camera class name
  15167. * @returns StereoscopicFreeCamera
  15168. */
  15169. StereoscopicFreeCamera.prototype.getClassName = function () {
  15170. return "StereoscopicFreeCamera";
  15171. };
  15172. return StereoscopicFreeCamera;
  15173. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15174. /***/ }),
  15175. /***/ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts":
  15176. /*!***********************************************************!*\
  15177. !*** ./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts ***!
  15178. \***********************************************************/
  15179. /*! exports provided: StereoscopicGamepadCamera */
  15180. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15181. "use strict";
  15182. __webpack_require__.r(__webpack_exports__);
  15183. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return StereoscopicGamepadCamera; });
  15184. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15185. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15186. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15187. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15188. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15189. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15190. // Side effect import to define the stereoscopic mode.
  15191. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicGamepadCamera", function (name, scene, options) {
  15192. return function () { return new StereoscopicGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15193. });
  15194. /**
  15195. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  15196. * @see http://doc.babylonjs.com/features/cameras
  15197. */
  15198. var StereoscopicGamepadCamera = /** @class */ (function (_super) {
  15199. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicGamepadCamera, _super);
  15200. /**
  15201. * Creates a new StereoscopicGamepadCamera
  15202. * @param name defines camera name
  15203. * @param position defines initial position
  15204. * @param interaxialDistance defines distance between each color axis
  15205. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15206. * @param scene defines the hosting scene
  15207. */
  15208. function StereoscopicGamepadCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15209. var _this = _super.call(this, name, position, scene) || this;
  15210. _this.interaxialDistance = interaxialDistance;
  15211. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15212. _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 });
  15213. return _this;
  15214. }
  15215. /**
  15216. * Gets camera class name
  15217. * @returns StereoscopicGamepadCamera
  15218. */
  15219. StereoscopicGamepadCamera.prototype.getClassName = function () {
  15220. return "StereoscopicGamepadCamera";
  15221. };
  15222. return StereoscopicGamepadCamera;
  15223. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15224. /***/ }),
  15225. /***/ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts":
  15226. /*!*************************************************************!*\
  15227. !*** ./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts ***!
  15228. \*************************************************************/
  15229. /*! exports provided: StereoscopicUniversalCamera */
  15230. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15231. "use strict";
  15232. __webpack_require__.r(__webpack_exports__);
  15233. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return StereoscopicUniversalCamera; });
  15234. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15235. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15236. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15237. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15238. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15239. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15240. // Side effect import to define the stereoscopic mode.
  15241. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15242. return function () { return new StereoscopicUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15243. });
  15244. /**
  15245. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  15246. * @see http://doc.babylonjs.com/features/cameras
  15247. */
  15248. var StereoscopicUniversalCamera = /** @class */ (function (_super) {
  15249. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicUniversalCamera, _super);
  15250. /**
  15251. * Creates a new StereoscopicUniversalCamera
  15252. * @param name defines camera name
  15253. * @param position defines initial position
  15254. * @param interaxialDistance defines distance between each color axis
  15255. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15256. * @param scene defines the hosting scene
  15257. */
  15258. function StereoscopicUniversalCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15259. var _this = _super.call(this, name, position, scene) || this;
  15260. _this.interaxialDistance = interaxialDistance;
  15261. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15262. _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 });
  15263. return _this;
  15264. }
  15265. /**
  15266. * Gets camera class name
  15267. * @returns StereoscopicUniversalCamera
  15268. */
  15269. StereoscopicUniversalCamera.prototype.getClassName = function () {
  15270. return "StereoscopicUniversalCamera";
  15271. };
  15272. return StereoscopicUniversalCamera;
  15273. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15274. /***/ }),
  15275. /***/ "./Cameras/VR/index.ts":
  15276. /*!*****************************!*\
  15277. !*** ./Cameras/VR/index.ts ***!
  15278. \*****************************/
  15279. /*! exports provided: VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera */
  15280. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15281. "use strict";
  15282. __webpack_require__.r(__webpack_exports__);
  15283. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  15285. /* harmony import */ var _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationArcRotateCamera */ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts");
  15286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationArcRotateCamera"]; });
  15287. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__["VRDeviceOrientationFreeCamera"]; });
  15289. /* harmony import */ var _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrDeviceOrientationGamepadCamera */ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts");
  15290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__["VRDeviceOrientationGamepadCamera"]; });
  15291. /* harmony import */ var _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  15292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["VRExperienceHelper"]; });
  15293. /* harmony import */ var _webVRCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _webVRCamera__WEBPACK_IMPORTED_MODULE_5__["WebVRFreeCamera"]; });
  15295. /***/ }),
  15296. /***/ "./Cameras/VR/vrCameraMetrics.ts":
  15297. /*!***************************************!*\
  15298. !*** ./Cameras/VR/vrCameraMetrics.ts ***!
  15299. \***************************************/
  15300. /*! exports provided: VRCameraMetrics */
  15301. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15302. "use strict";
  15303. __webpack_require__.r(__webpack_exports__);
  15304. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return VRCameraMetrics; });
  15305. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15306. /**
  15307. * This represents all the required metrics to create a VR camera.
  15308. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  15309. */
  15310. var VRCameraMetrics = /** @class */ (function () {
  15311. function VRCameraMetrics() {
  15312. /**
  15313. * Define if the current vr camera should compensate the distortion of the lense or not.
  15314. */
  15315. this.compensateDistortion = true;
  15316. }
  15317. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  15318. /**
  15319. * Gets the rendering aspect ratio based on the provided resolutions.
  15320. */
  15321. get: function () {
  15322. return this.hResolution / (2 * this.vResolution);
  15323. },
  15324. enumerable: true,
  15325. configurable: true
  15326. });
  15327. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  15328. /**
  15329. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  15330. */
  15331. get: function () {
  15332. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  15333. },
  15334. enumerable: true,
  15335. configurable: true
  15336. });
  15337. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  15338. /**
  15339. * @hidden
  15340. */
  15341. get: function () {
  15342. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15343. var h = (4 * meters) / this.hScreenSize;
  15344. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(h, 0, 0);
  15345. },
  15346. enumerable: true,
  15347. configurable: true
  15348. });
  15349. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  15350. /**
  15351. * @hidden
  15352. */
  15353. get: function () {
  15354. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15355. var h = (4 * meters) / this.hScreenSize;
  15356. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-h, 0, 0);
  15357. },
  15358. enumerable: true,
  15359. configurable: true
  15360. });
  15361. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  15362. /**
  15363. * @hidden
  15364. */
  15365. get: function () {
  15366. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(0.5 * this.interpupillaryDistance, 0, 0);
  15367. },
  15368. enumerable: true,
  15369. configurable: true
  15370. });
  15371. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  15372. /**
  15373. * @hidden
  15374. */
  15375. get: function () {
  15376. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  15377. },
  15378. enumerable: true,
  15379. configurable: true
  15380. });
  15381. /**
  15382. * Get the default VRMetrics based on the most generic setup.
  15383. * @returns the default vr metrics
  15384. */
  15385. VRCameraMetrics.GetDefault = function () {
  15386. var result = new VRCameraMetrics();
  15387. result.hResolution = 1280;
  15388. result.vResolution = 800;
  15389. result.hScreenSize = 0.149759993;
  15390. result.vScreenSize = 0.0935999975;
  15391. result.vScreenCenter = 0.0467999987;
  15392. result.eyeToScreenDistance = 0.0410000011;
  15393. result.lensSeparationDistance = 0.0635000020;
  15394. result.interpupillaryDistance = 0.0640000030;
  15395. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  15396. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  15397. result.postProcessScaleFactor = 1.714605507808412;
  15398. result.lensCenterOffset = 0.151976421;
  15399. return result;
  15400. };
  15401. return VRCameraMetrics;
  15402. }());
  15403. /***/ }),
  15404. /***/ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts":
  15405. /*!**********************************************************!*\
  15406. !*** ./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts ***!
  15407. \**********************************************************/
  15408. /*! exports provided: VRDeviceOrientationArcRotateCamera */
  15409. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15410. "use strict";
  15411. __webpack_require__.r(__webpack_exports__);
  15412. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return VRDeviceOrientationArcRotateCamera; });
  15413. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15414. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15415. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15416. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15417. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15418. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15419. /* harmony import */ var _Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Inputs/arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15420. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15421. // Side effect import to define the stereoscopic mode.
  15422. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15423. return function () { return new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15424. });
  15425. /**
  15426. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  15427. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15428. */
  15429. var VRDeviceOrientationArcRotateCamera = /** @class */ (function (_super) {
  15430. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationArcRotateCamera, _super);
  15431. /**
  15432. * Creates a new VRDeviceOrientationArcRotateCamera
  15433. * @param name defines camera name
  15434. * @param alpha defines the camera rotation along the logitudinal axis
  15435. * @param beta defines the camera rotation along the latitudinal axis
  15436. * @param radius defines the camera distance from its target
  15437. * @param target defines the camera target
  15438. * @param scene defines the scene the camera belongs to
  15439. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15440. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15441. */
  15442. function VRDeviceOrientationArcRotateCamera(name, alpha, beta, radius, target, scene, compensateDistortion, vrCameraMetrics) {
  15443. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15444. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15445. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15446. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15447. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15448. _this.inputs.addVRDeviceOrientation();
  15449. return _this;
  15450. }
  15451. /**
  15452. * Gets camera class name
  15453. * @returns VRDeviceOrientationArcRotateCamera
  15454. */
  15455. VRDeviceOrientationArcRotateCamera.prototype.getClassName = function () {
  15456. return "VRDeviceOrientationArcRotateCamera";
  15457. };
  15458. return VRDeviceOrientationArcRotateCamera;
  15459. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15460. /***/ }),
  15461. /***/ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts":
  15462. /*!*****************************************************!*\
  15463. !*** ./Cameras/VR/vrDeviceOrientationFreeCamera.ts ***!
  15464. \*****************************************************/
  15465. /*! exports provided: VRDeviceOrientationFreeCamera */
  15466. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15467. "use strict";
  15468. __webpack_require__.r(__webpack_exports__);
  15469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return VRDeviceOrientationFreeCamera; });
  15470. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15471. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15472. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15473. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15474. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15475. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15476. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15477. // Side effect import to define the stereoscopic mode.
  15478. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15479. return function () { return new VRDeviceOrientationFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15480. });
  15481. /**
  15482. * Camera used to simulate VR rendering (based on FreeCamera)
  15483. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15484. */
  15485. var VRDeviceOrientationFreeCamera = /** @class */ (function (_super) {
  15486. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationFreeCamera, _super);
  15487. /**
  15488. * Creates a new VRDeviceOrientationFreeCamera
  15489. * @param name defines camera name
  15490. * @param position defines the start position of the camera
  15491. * @param scene defines the scene the camera belongs to
  15492. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15493. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15494. */
  15495. function VRDeviceOrientationFreeCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15496. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15497. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15498. var _this = _super.call(this, name, position, scene) || this;
  15499. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15500. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15501. return _this;
  15502. }
  15503. /**
  15504. * Gets camera class name
  15505. * @returns VRDeviceOrientationFreeCamera
  15506. */
  15507. VRDeviceOrientationFreeCamera.prototype.getClassName = function () {
  15508. return "VRDeviceOrientationFreeCamera";
  15509. };
  15510. return VRDeviceOrientationFreeCamera;
  15511. }(_Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__["DeviceOrientationCamera"]));
  15512. /***/ }),
  15513. /***/ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts":
  15514. /*!********************************************************!*\
  15515. !*** ./Cameras/VR/vrDeviceOrientationGamepadCamera.ts ***!
  15516. \********************************************************/
  15517. /*! exports provided: VRDeviceOrientationGamepadCamera */
  15518. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15519. "use strict";
  15520. __webpack_require__.r(__webpack_exports__);
  15521. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return VRDeviceOrientationGamepadCamera; });
  15522. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15523. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15524. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15525. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15526. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15527. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("VRDeviceOrientationGamepadCamera", function (name, scene) {
  15528. return function () { return new VRDeviceOrientationGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  15529. });
  15530. /**
  15531. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  15532. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15533. */
  15534. var VRDeviceOrientationGamepadCamera = /** @class */ (function (_super) {
  15535. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationGamepadCamera, _super);
  15536. /**
  15537. * Creates a new VRDeviceOrientationGamepadCamera
  15538. * @param name defines camera name
  15539. * @param position defines the start position of the camera
  15540. * @param scene defines the scene the camera belongs to
  15541. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15542. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15543. */
  15544. function VRDeviceOrientationGamepadCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15545. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15546. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__["VRCameraMetrics"].GetDefault(); }
  15547. var _this = _super.call(this, name, position, scene, compensateDistortion, vrCameraMetrics) || this;
  15548. _this.inputs.addGamepad();
  15549. return _this;
  15550. }
  15551. /**
  15552. * Gets camera class name
  15553. * @returns VRDeviceOrientationGamepadCamera
  15554. */
  15555. VRDeviceOrientationGamepadCamera.prototype.getClassName = function () {
  15556. return "VRDeviceOrientationGamepadCamera";
  15557. };
  15558. return VRDeviceOrientationGamepadCamera;
  15559. }(_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationFreeCamera"]));
  15560. /***/ }),
  15561. /***/ "./Cameras/VR/vrExperienceHelper.ts":
  15562. /*!******************************************!*\
  15563. !*** ./Cameras/VR/vrExperienceHelper.ts ***!
  15564. \******************************************/
  15565. /*! exports provided: VRExperienceHelper */
  15566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15567. "use strict";
  15568. __webpack_require__.r(__webpack_exports__);
  15569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return VRExperienceHelper; });
  15570. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15571. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  15572. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  15573. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15574. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  15575. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15576. /* harmony import */ var _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Cameras/VR/vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15577. /* harmony import */ var _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Cameras/VR/webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15578. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  15579. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15580. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  15581. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  15582. /* harmony import */ var _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Gamepads/Controllers/webVRController */ "./Gamepads/Controllers/webVRController.ts");
  15583. /* harmony import */ var _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Gamepads/xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  15584. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  15585. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  15586. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  15587. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  15588. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  15589. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  15590. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  15591. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  15592. /* harmony import */ var _Meshes_Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Meshes/Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  15593. /* harmony import */ var _Meshes_Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Meshes/Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  15594. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  15595. /* harmony import */ var _Gamepads_gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../../Gamepads/gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  15596. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../../Animations/animatable */ "./Animations/animatable.ts");
  15597. var VRExperienceHelperGazer = /** @class */ (function () {
  15598. function VRExperienceHelperGazer(scene, gazeTrackerToClone) {
  15599. if (gazeTrackerToClone === void 0) { gazeTrackerToClone = null; }
  15600. this.scene = scene;
  15601. /** @hidden */
  15602. this._pointerDownOnMeshAsked = false;
  15603. /** @hidden */
  15604. this._isActionableMesh = false;
  15605. /** @hidden */
  15606. this._teleportationRequestInitiated = false;
  15607. /** @hidden */
  15608. this._teleportationBackRequestInitiated = false;
  15609. /** @hidden */
  15610. this._rotationRightAsked = false;
  15611. /** @hidden */
  15612. this._rotationLeftAsked = false;
  15613. /** @hidden */
  15614. this._dpadPressed = true;
  15615. /** @hidden */
  15616. this._activePointer = false;
  15617. this._id = VRExperienceHelperGazer._idCounter++;
  15618. // Gaze tracker
  15619. if (!gazeTrackerToClone) {
  15620. this._gazeTracker = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("gazeTracker", 0.0035, 0.0025, 20, scene, false);
  15621. this._gazeTracker.bakeCurrentTransformIntoVertices();
  15622. this._gazeTracker.isPickable = false;
  15623. this._gazeTracker.isVisible = false;
  15624. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("targetMat", scene);
  15625. targetMat.specularColor = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"].Black();
  15626. targetMat.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  15627. targetMat.backFaceCulling = false;
  15628. this._gazeTracker.material = targetMat;
  15629. }
  15630. else {
  15631. this._gazeTracker = gazeTrackerToClone.clone("gazeTracker");
  15632. }
  15633. }
  15634. /** @hidden */
  15635. VRExperienceHelperGazer.prototype._getForwardRay = function (length) {
  15636. 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));
  15637. };
  15638. /** @hidden */
  15639. VRExperienceHelperGazer.prototype._selectionPointerDown = function () {
  15640. this._pointerDownOnMeshAsked = true;
  15641. if (this._currentHit) {
  15642. this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
  15643. }
  15644. };
  15645. /** @hidden */
  15646. VRExperienceHelperGazer.prototype._selectionPointerUp = function () {
  15647. if (this._currentHit) {
  15648. this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id });
  15649. }
  15650. this._pointerDownOnMeshAsked = false;
  15651. };
  15652. /** @hidden */
  15653. VRExperienceHelperGazer.prototype._activatePointer = function () {
  15654. this._activePointer = true;
  15655. };
  15656. /** @hidden */
  15657. VRExperienceHelperGazer.prototype._deactivatePointer = function () {
  15658. this._activePointer = false;
  15659. };
  15660. /** @hidden */
  15661. VRExperienceHelperGazer.prototype._updatePointerDistance = function (distance) {
  15662. if (distance === void 0) { distance = 100; }
  15663. };
  15664. VRExperienceHelperGazer.prototype.dispose = function () {
  15665. this._interactionsEnabled = false;
  15666. this._teleportationEnabled = false;
  15667. if (this._gazeTracker) {
  15668. this._gazeTracker.dispose();
  15669. }
  15670. };
  15671. VRExperienceHelperGazer._idCounter = 0;
  15672. return VRExperienceHelperGazer;
  15673. }());
  15674. var VRExperienceHelperControllerGazer = /** @class */ (function (_super) {
  15675. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperControllerGazer, _super);
  15676. function VRExperienceHelperControllerGazer(webVRController, scene, gazeTrackerToClone) {
  15677. var _this = _super.call(this, scene, gazeTrackerToClone) || this;
  15678. _this.webVRController = webVRController;
  15679. // Laser pointer
  15680. _this._laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, scene, false);
  15681. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("laserPointerMat", scene);
  15682. laserPointerMaterial.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  15683. laserPointerMaterial.alpha = 0.6;
  15684. _this._laserPointer.material = laserPointerMaterial;
  15685. _this._laserPointer.rotation.x = Math.PI / 2;
  15686. _this._laserPointer.position.z = -0.5;
  15687. _this._laserPointer.isVisible = false;
  15688. _this._laserPointer.isPickable = false;
  15689. if (!webVRController.mesh) {
  15690. // Create an empty mesh that is used prior to loading the high quality model
  15691. var preloadMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"]("preloadControllerMesh", scene);
  15692. var preloadPointerPose = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"](_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE, scene);
  15693. preloadPointerPose.rotation.x = -0.7;
  15694. preloadMesh.addChild(preloadPointerPose);
  15695. webVRController.attachToMesh(preloadMesh);
  15696. }
  15697. _this._setLaserPointerParent(webVRController.mesh);
  15698. _this._meshAttachedObserver = webVRController._meshAttachedObservable.add(function (mesh) {
  15699. _this._setLaserPointerParent(mesh);
  15700. });
  15701. return _this;
  15702. }
  15703. VRExperienceHelperControllerGazer.prototype._getForwardRay = function (length) {
  15704. return this.webVRController.getForwardRay(length);
  15705. };
  15706. /** @hidden */
  15707. VRExperienceHelperControllerGazer.prototype._activatePointer = function () {
  15708. _super.prototype._activatePointer.call(this);
  15709. this._laserPointer.isVisible = true;
  15710. };
  15711. /** @hidden */
  15712. VRExperienceHelperControllerGazer.prototype._deactivatePointer = function () {
  15713. _super.prototype._deactivatePointer.call(this);
  15714. this._laserPointer.isVisible = false;
  15715. };
  15716. /** @hidden */
  15717. VRExperienceHelperControllerGazer.prototype._setLaserPointerColor = function (color) {
  15718. this._laserPointer.material.emissiveColor = color;
  15719. };
  15720. /** @hidden */
  15721. VRExperienceHelperControllerGazer.prototype._setLaserPointerParent = function (mesh) {
  15722. var makeNotPick = function (root) {
  15723. root.isPickable = false;
  15724. root.getChildMeshes().forEach(function (c) {
  15725. makeNotPick(c);
  15726. });
  15727. };
  15728. makeNotPick(mesh);
  15729. var meshChildren = mesh.getChildren(undefined, false);
  15730. var laserParent = mesh;
  15731. this.webVRController._pointingPoseNode = null;
  15732. for (var i = 0; i < meshChildren.length; i++) {
  15733. if (meshChildren[i].name && meshChildren[i].name.indexOf(_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE) >= 0) {
  15734. laserParent = meshChildren[i];
  15735. this.webVRController._pointingPoseNode = laserParent;
  15736. break;
  15737. }
  15738. }
  15739. this._laserPointer.parent = laserParent;
  15740. };
  15741. VRExperienceHelperControllerGazer.prototype._updatePointerDistance = function (distance) {
  15742. if (distance === void 0) { distance = 100; }
  15743. this._laserPointer.scaling.y = distance;
  15744. this._laserPointer.position.z = -distance / 2;
  15745. };
  15746. VRExperienceHelperControllerGazer.prototype.dispose = function () {
  15747. _super.prototype.dispose.call(this);
  15748. this._laserPointer.dispose();
  15749. if (this._meshAttachedObserver) {
  15750. this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
  15751. }
  15752. };
  15753. return VRExperienceHelperControllerGazer;
  15754. }(VRExperienceHelperGazer));
  15755. var VRExperienceHelperCameraGazer = /** @class */ (function (_super) {
  15756. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperCameraGazer, _super);
  15757. function VRExperienceHelperCameraGazer(getCamera, scene) {
  15758. var _this = _super.call(this, scene) || this;
  15759. _this.getCamera = getCamera;
  15760. return _this;
  15761. }
  15762. VRExperienceHelperCameraGazer.prototype._getForwardRay = function (length) {
  15763. var camera = this.getCamera();
  15764. if (camera) {
  15765. return camera.getForwardRay(length);
  15766. }
  15767. else {
  15768. 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());
  15769. }
  15770. };
  15771. return VRExperienceHelperCameraGazer;
  15772. }(VRExperienceHelperGazer));
  15773. /**
  15774. * Helps to quickly add VR support to an existing scene.
  15775. * See http://doc.babylonjs.com/how_to/webvr_helper
  15776. */
  15777. var VRExperienceHelper = /** @class */ (function () {
  15778. /**
  15779. * Instantiates a VRExperienceHelper.
  15780. * Helps to quickly add VR support to an existing scene.
  15781. * @param scene The scene the VRExperienceHelper belongs to.
  15782. * @param webVROptions Options to modify the vr experience helper's behavior.
  15783. */
  15784. function VRExperienceHelper(scene,
  15785. /** Options to modify the vr experience helper's behavior. */
  15786. webVROptions) {
  15787. if (webVROptions === void 0) { webVROptions = {}; }
  15788. var _this = this;
  15789. this.webVROptions = webVROptions;
  15790. // Can the system support WebVR, even if a headset isn't plugged in?
  15791. this._webVRsupported = false;
  15792. // If WebVR is supported, is a headset plugged in and are we ready to present?
  15793. this._webVRready = false;
  15794. // Are we waiting for the requestPresent callback to complete?
  15795. this._webVRrequesting = false;
  15796. // Are we presenting to the headset right now? (this is the vrDevice state)
  15797. this._webVRpresenting = false;
  15798. // Are we presenting in the fullscreen fallback?
  15799. this._fullscreenVRpresenting = false;
  15800. /**
  15801. * Observable raised when entering VR.
  15802. */
  15803. this.onEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15804. /**
  15805. * Observable raised when exiting VR.
  15806. */
  15807. this.onExitingVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15808. /**
  15809. * Observable raised when controller mesh is loaded.
  15810. */
  15811. this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15812. this._useCustomVRButton = false;
  15813. this._teleportationRequested = false;
  15814. this._teleportActive = false;
  15815. this._floorMeshesCollection = [];
  15816. this._rotationAllowed = true;
  15817. this._teleportBackwardsVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, -1, -1);
  15818. this._isDefaultTeleportationTarget = true;
  15819. this._teleportationFillColor = "#444444";
  15820. this._teleportationBorderColor = "#FFFFFF";
  15821. this._rotationAngle = 0;
  15822. this._haloCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, 0);
  15823. this._padSensibilityUp = 0.65;
  15824. this._padSensibilityDown = 0.35;
  15825. this._leftController = null;
  15826. this._rightController = null;
  15827. /**
  15828. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  15829. */
  15830. this.onNewMeshSelected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15831. /**
  15832. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  15833. */
  15834. this.onNewMeshPicked = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15835. /**
  15836. * Observable raised before camera teleportation
  15837. */
  15838. this.onBeforeCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15839. /**
  15840. * Observable raised after camera teleportation
  15841. */
  15842. this.onAfterCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15843. /**
  15844. * Observable raised when current selected mesh gets unselected
  15845. */
  15846. this.onSelectedMeshUnselected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15847. /**
  15848. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  15849. */
  15850. this.teleportationEnabled = true;
  15851. this._teleportationInitialized = false;
  15852. this._interactionsEnabled = false;
  15853. this._interactionsRequested = false;
  15854. this._displayGaze = true;
  15855. this._displayLaserPointer = true;
  15856. /**
  15857. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  15858. */
  15859. this.updateGazeTrackerScale = true;
  15860. /**
  15861. * If the gaze trackers color should be updated when selecting meshes
  15862. */
  15863. this.updateGazeTrackerColor = true;
  15864. /**
  15865. * Defines wether or not Pointer lock should be requested when switching to
  15866. * full screen.
  15867. */
  15868. this.requestPointerLockOnFullScreen = true;
  15869. this._onResize = function () {
  15870. _this.moveButtonToBottomRight();
  15871. if (_this._fullscreenVRpresenting && _this._webVRready) {
  15872. _this.exitVR();
  15873. }
  15874. };
  15875. this._onFullscreenChange = function () {
  15876. if (document.fullscreen !== undefined) {
  15877. _this._fullscreenVRpresenting = document.fullscreen;
  15878. }
  15879. else if (document.mozFullScreen !== undefined) {
  15880. _this._fullscreenVRpresenting = document.mozFullScreen;
  15881. }
  15882. else if (document.webkitIsFullScreen !== undefined) {
  15883. _this._fullscreenVRpresenting = document.webkitIsFullScreen;
  15884. }
  15885. else if (document.msIsFullScreen !== undefined) {
  15886. _this._fullscreenVRpresenting = document.msIsFullScreen;
  15887. }
  15888. else if (document.msFullscreenElement !== undefined) {
  15889. _this._fullscreenVRpresenting = document.msFullscreenElement;
  15890. }
  15891. if (!_this._fullscreenVRpresenting && _this._canvas) {
  15892. _this.exitVR();
  15893. if (!_this._useCustomVRButton) {
  15894. _this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
  15895. _this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
  15896. }
  15897. }
  15898. };
  15899. this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null };
  15900. this.beforeRender = function () {
  15901. if (_this._leftController && _this._leftController._activePointer) {
  15902. _this._castRayAndSelectObject(_this._leftController);
  15903. }
  15904. if (_this._rightController && _this._rightController._activePointer) {
  15905. _this._castRayAndSelectObject(_this._rightController);
  15906. }
  15907. if (_this._noControllerIsActive) {
  15908. _this._castRayAndSelectObject(_this._cameraGazer);
  15909. }
  15910. else {
  15911. _this._cameraGazer._gazeTracker.isVisible = false;
  15912. }
  15913. };
  15914. this._onNewGamepadConnected = function (gamepad) {
  15915. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].POSE_ENABLED) {
  15916. if (gamepad.leftStick) {
  15917. gamepad.onleftstickchanged(function (stickValues) {
  15918. if (_this._teleportationInitialized && _this.teleportationEnabled) {
  15919. // Listening to classic/xbox gamepad only if no VR controller is active
  15920. if ((!_this._leftController && !_this._rightController) ||
  15921. ((_this._leftController && !_this._leftController._activePointer) &&
  15922. (_this._rightController && !_this._rightController._activePointer))) {
  15923. _this._checkTeleportWithRay(stickValues, _this._cameraGazer);
  15924. _this._checkTeleportBackwards(stickValues, _this._cameraGazer);
  15925. }
  15926. }
  15927. });
  15928. }
  15929. if (gamepad.rightStick) {
  15930. gamepad.onrightstickchanged(function (stickValues) {
  15931. if (_this._teleportationInitialized) {
  15932. _this._checkRotate(stickValues, _this._cameraGazer);
  15933. }
  15934. });
  15935. }
  15936. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].XBOX) {
  15937. gamepad.onbuttondown(function (buttonPressed) {
  15938. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  15939. _this._cameraGazer._selectionPointerDown();
  15940. }
  15941. });
  15942. gamepad.onbuttonup(function (buttonPressed) {
  15943. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  15944. _this._cameraGazer._selectionPointerUp();
  15945. }
  15946. });
  15947. }
  15948. }
  15949. else {
  15950. var webVRController = gamepad;
  15951. var controller = new VRExperienceHelperControllerGazer(webVRController, _this._scene, _this._cameraGazer._gazeTracker);
  15952. if (webVRController.hand === "right" || (_this._leftController && _this._leftController.webVRController != webVRController)) {
  15953. _this._rightController = controller;
  15954. }
  15955. else {
  15956. _this._leftController = controller;
  15957. }
  15958. _this._tryEnableInteractionOnController(controller);
  15959. }
  15960. };
  15961. // 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
  15962. this._tryEnableInteractionOnController = function (controller) {
  15963. if (_this._interactionsRequested && !controller._interactionsEnabled) {
  15964. _this._enableInteractionOnController(controller);
  15965. }
  15966. if (_this._teleportationRequested && !controller._teleportationEnabled) {
  15967. _this._enableTeleportationOnController(controller);
  15968. }
  15969. };
  15970. this._onNewGamepadDisconnected = function (gamepad) {
  15971. if (gamepad instanceof _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__["WebVRController"]) {
  15972. if (gamepad.hand === "left" && _this._leftController != null) {
  15973. _this._leftController.dispose();
  15974. _this._leftController = null;
  15975. }
  15976. if (gamepad.hand === "right" && _this._rightController != null) {
  15977. _this._rightController.dispose();
  15978. _this._rightController = null;
  15979. }
  15980. }
  15981. };
  15982. this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero();
  15983. this._workingQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].Identity();
  15984. this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].Identity();
  15985. this._scene = scene;
  15986. this._canvas = scene.getEngine().getRenderingCanvas();
  15987. // Parse options
  15988. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera === undefined) {
  15989. webVROptions.createFallbackVRDeviceOrientationFreeCamera = true;
  15990. }
  15991. if (webVROptions.createDeviceOrientationCamera === undefined) {
  15992. webVROptions.createDeviceOrientationCamera = true;
  15993. }
  15994. if (webVROptions.laserToggle === undefined) {
  15995. webVROptions.laserToggle = true;
  15996. }
  15997. if (webVROptions.defaultHeight === undefined) {
  15998. webVROptions.defaultHeight = 1.7;
  15999. }
  16000. if (webVROptions.useCustomVRButton) {
  16001. this._useCustomVRButton = true;
  16002. if (webVROptions.customVRButton) {
  16003. this._btnVR = webVROptions.customVRButton;
  16004. }
  16005. }
  16006. if (webVROptions.rayLength) {
  16007. this._rayLength = webVROptions.rayLength;
  16008. }
  16009. this._defaultHeight = webVROptions.defaultHeight;
  16010. if (webVROptions.positionScale) {
  16011. this._rayLength *= webVROptions.positionScale;
  16012. this._defaultHeight *= webVROptions.positionScale;
  16013. }
  16014. this._hasEnteredVR = false;
  16015. // Set position
  16016. if (this._scene.activeCamera) {
  16017. this._position = this._scene.activeCamera.position.clone();
  16018. }
  16019. else {
  16020. this._position = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, this._defaultHeight, 0);
  16021. }
  16022. // Set non-vr camera
  16023. if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
  16024. this._deviceOrientationCamera = new _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__["DeviceOrientationCamera"]("deviceOrientationVRHelper", this._position.clone(), scene);
  16025. // Copy data from existing camera
  16026. if (this._scene.activeCamera) {
  16027. this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16028. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
  16029. // Set rotation from previous camera
  16030. if (this._scene.activeCamera instanceof _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"] && this._scene.activeCamera.rotation) {
  16031. var targetCamera = this._scene.activeCamera;
  16032. if (targetCamera.rotationQuaternion) {
  16033. this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
  16034. }
  16035. else {
  16036. this._deviceOrientationCamera.rotationQuaternion.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
  16037. }
  16038. this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
  16039. }
  16040. }
  16041. this._scene.activeCamera = this._deviceOrientationCamera;
  16042. if (this._canvas) {
  16043. this._scene.activeCamera.attachControl(this._canvas);
  16044. }
  16045. }
  16046. else {
  16047. this._existingCamera = this._scene.activeCamera;
  16048. }
  16049. // Create VR cameras
  16050. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16051. this._vrDeviceOrientationCamera = new _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__["VRDeviceOrientationFreeCamera"]("VRDeviceOrientationVRHelper", this._position, this._scene, true, webVROptions.vrDeviceOrientationCameraMetrics);
  16052. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16053. }
  16054. this._webVRCamera = new _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]("WebVRHelper", this._position, this._scene, webVROptions);
  16055. this._webVRCamera.useStandingMatrix();
  16056. this._cameraGazer = new VRExperienceHelperCameraGazer(function () { return _this.currentVRCamera; }, scene);
  16057. // Create default button
  16058. if (!this._useCustomVRButton) {
  16059. this._btnVR = document.createElement("BUTTON");
  16060. this._btnVR.className = "babylonVRicon";
  16061. this._btnVR.id = "babylonVRiconbtn";
  16062. this._btnVR.title = "Click to switch to VR";
  16063. 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) }";
  16064. css += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  16065. // TODO: Add user feedback so that they know what state the VRDisplay is in (disconnected, connected, entering-VR)
  16066. // css += ".babylonVRicon.vrdisplaysupported { }";
  16067. // css += ".babylonVRicon.vrdisplayready { }";
  16068. // css += ".babylonVRicon.vrdisplayrequesting { }";
  16069. var style = document.createElement('style');
  16070. style.appendChild(document.createTextNode(css));
  16071. document.getElementsByTagName('head')[0].appendChild(style);
  16072. this.moveButtonToBottomRight();
  16073. }
  16074. // VR button click event
  16075. if (this._btnVR) {
  16076. this._btnVR.addEventListener("click", function () {
  16077. if (!_this.isInVRMode) {
  16078. _this.enterVR();
  16079. }
  16080. else {
  16081. _this.exitVR();
  16082. }
  16083. });
  16084. }
  16085. // Window events
  16086. window.addEventListener("resize", this._onResize);
  16087. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  16088. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  16089. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  16090. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  16091. document.onmsfullscreenchange = this._onFullscreenChange;
  16092. // Display vr button when headset is connected
  16093. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16094. this.displayVRButton();
  16095. }
  16096. else {
  16097. this._scene.getEngine().onVRDisplayChangedObservable.add(function (e) {
  16098. if (e.vrDisplay) {
  16099. _this.displayVRButton();
  16100. }
  16101. });
  16102. }
  16103. // Exiting VR mode using 'ESC' key on desktop
  16104. this._onKeyDown = function (event) {
  16105. if (event.keyCode === 27 && _this.isInVRMode) {
  16106. _this.exitVR();
  16107. }
  16108. };
  16109. document.addEventListener("keydown", this._onKeyDown);
  16110. // Exiting VR mode double tapping the touch screen
  16111. this._scene.onPrePointerObservable.add(function () {
  16112. if (_this.isInVRMode) {
  16113. _this.exitVR();
  16114. if (_this._fullscreenVRpresenting) {
  16115. _this._scene.getEngine().exitFullscreen();
  16116. }
  16117. }
  16118. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOUBLETAP, false);
  16119. // Listen for WebVR display changes
  16120. this._onVRDisplayChanged = function (eventArgs) { return _this.onVRDisplayChanged(eventArgs); };
  16121. this._onVrDisplayPresentChange = function () { return _this.onVrDisplayPresentChange(); };
  16122. this._onVRRequestPresentStart = function () {
  16123. _this._webVRrequesting = true;
  16124. _this.updateButtonVisibility();
  16125. };
  16126. this._onVRRequestPresentComplete = function () {
  16127. _this._webVRrequesting = false;
  16128. _this.updateButtonVisibility();
  16129. };
  16130. scene.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged);
  16131. scene.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart);
  16132. scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
  16133. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16134. scene.onDisposeObservable.add(function () {
  16135. _this.dispose();
  16136. });
  16137. // Gamepad connection events
  16138. this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
  16139. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected);
  16140. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected);
  16141. this.updateButtonVisibility();
  16142. //create easing functions
  16143. this._circleEase = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["CircleEase"]();
  16144. this._circleEase.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16145. if (this.webVROptions.floorMeshes) {
  16146. this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
  16147. }
  16148. }
  16149. Object.defineProperty(VRExperienceHelper.prototype, "onEnteringVR", {
  16150. /** Return this.onEnteringVRObservable
  16151. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  16152. */
  16153. get: function () {
  16154. return this.onEnteringVRObservable;
  16155. },
  16156. enumerable: true,
  16157. configurable: true
  16158. });
  16159. Object.defineProperty(VRExperienceHelper.prototype, "onExitingVR", {
  16160. /** Return this.onExitingVRObservable
  16161. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  16162. */
  16163. get: function () {
  16164. return this.onExitingVRObservable;
  16165. },
  16166. enumerable: true,
  16167. configurable: true
  16168. });
  16169. Object.defineProperty(VRExperienceHelper.prototype, "onControllerMeshLoaded", {
  16170. /** Return this.onControllerMeshLoadedObservable
  16171. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  16172. */
  16173. get: function () {
  16174. return this.onControllerMeshLoadedObservable;
  16175. },
  16176. enumerable: true,
  16177. configurable: true
  16178. });
  16179. Object.defineProperty(VRExperienceHelper.prototype, "teleportationTarget", {
  16180. /**
  16181. * The mesh used to display where the user is going to teleport.
  16182. */
  16183. get: function () {
  16184. return this._teleportationTarget;
  16185. },
  16186. /**
  16187. * Sets the mesh to be used to display where the user is going to teleport.
  16188. */
  16189. set: function (value) {
  16190. if (value) {
  16191. value.name = "teleportationTarget";
  16192. this._isDefaultTeleportationTarget = false;
  16193. this._teleportationTarget = value;
  16194. }
  16195. },
  16196. enumerable: true,
  16197. configurable: true
  16198. });
  16199. Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
  16200. /**
  16201. * 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
  16202. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  16203. * See http://doc.babylonjs.com/resources/baking_transformations
  16204. */
  16205. get: function () {
  16206. return this._cameraGazer._gazeTracker;
  16207. },
  16208. set: function (value) {
  16209. if (value) {
  16210. // Dispose of existing meshes
  16211. if (this._cameraGazer._gazeTracker) {
  16212. this._cameraGazer._gazeTracker.dispose();
  16213. }
  16214. if (this._leftController && this._leftController._gazeTracker) {
  16215. this._leftController._gazeTracker.dispose();
  16216. }
  16217. if (this._rightController && this._rightController._gazeTracker) {
  16218. this._rightController._gazeTracker.dispose();
  16219. }
  16220. // Set and create gaze trackers on head and controllers
  16221. this._cameraGazer._gazeTracker = value;
  16222. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
  16223. this._cameraGazer._gazeTracker.isPickable = false;
  16224. this._cameraGazer._gazeTracker.isVisible = false;
  16225. this._cameraGazer._gazeTracker.name = "gazeTracker";
  16226. if (this._leftController) {
  16227. this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16228. }
  16229. if (this._rightController) {
  16230. this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16231. }
  16232. }
  16233. },
  16234. enumerable: true,
  16235. configurable: true
  16236. });
  16237. Object.defineProperty(VRExperienceHelper.prototype, "leftControllerGazeTrackerMesh", {
  16238. /**
  16239. * The gaze tracking mesh corresponding to the left controller
  16240. */
  16241. get: function () {
  16242. if (this._leftController) {
  16243. return this._leftController._gazeTracker;
  16244. }
  16245. return null;
  16246. },
  16247. enumerable: true,
  16248. configurable: true
  16249. });
  16250. Object.defineProperty(VRExperienceHelper.prototype, "rightControllerGazeTrackerMesh", {
  16251. /**
  16252. * The gaze tracking mesh corresponding to the right controller
  16253. */
  16254. get: function () {
  16255. if (this._rightController) {
  16256. return this._rightController._gazeTracker;
  16257. }
  16258. return null;
  16259. },
  16260. enumerable: true,
  16261. configurable: true
  16262. });
  16263. Object.defineProperty(VRExperienceHelper.prototype, "displayGaze", {
  16264. /**
  16265. * If the ray of the gaze should be displayed.
  16266. */
  16267. get: function () {
  16268. return this._displayGaze;
  16269. },
  16270. /**
  16271. * Sets if the ray of the gaze should be displayed.
  16272. */
  16273. set: function (value) {
  16274. this._displayGaze = value;
  16275. if (!value) {
  16276. this._cameraGazer._gazeTracker.isVisible = false;
  16277. if (this._leftController) {
  16278. this._leftController._gazeTracker.isVisible = false;
  16279. }
  16280. if (this._rightController) {
  16281. this._rightController._gazeTracker.isVisible = false;
  16282. }
  16283. }
  16284. },
  16285. enumerable: true,
  16286. configurable: true
  16287. });
  16288. Object.defineProperty(VRExperienceHelper.prototype, "displayLaserPointer", {
  16289. /**
  16290. * If the ray of the LaserPointer should be displayed.
  16291. */
  16292. get: function () {
  16293. return this._displayLaserPointer;
  16294. },
  16295. /**
  16296. * Sets if the ray of the LaserPointer should be displayed.
  16297. */
  16298. set: function (value) {
  16299. this._displayLaserPointer = value;
  16300. if (!value) {
  16301. if (this._rightController) {
  16302. this._rightController._deactivatePointer();
  16303. this._rightController._gazeTracker.isVisible = false;
  16304. }
  16305. if (this._leftController) {
  16306. this._leftController._deactivatePointer();
  16307. this._leftController._gazeTracker.isVisible = false;
  16308. }
  16309. }
  16310. else {
  16311. if (this._rightController) {
  16312. this._rightController._activatePointer();
  16313. }
  16314. if (this._leftController) {
  16315. this._leftController._activatePointer();
  16316. }
  16317. }
  16318. },
  16319. enumerable: true,
  16320. configurable: true
  16321. });
  16322. Object.defineProperty(VRExperienceHelper.prototype, "deviceOrientationCamera", {
  16323. /**
  16324. * The deviceOrientationCamera used as the camera when not in VR.
  16325. */
  16326. get: function () {
  16327. return this._deviceOrientationCamera;
  16328. },
  16329. enumerable: true,
  16330. configurable: true
  16331. });
  16332. Object.defineProperty(VRExperienceHelper.prototype, "currentVRCamera", {
  16333. /**
  16334. * Based on the current WebVR support, returns the current VR camera used.
  16335. */
  16336. get: function () {
  16337. if (this._webVRready) {
  16338. return this._webVRCamera;
  16339. }
  16340. else {
  16341. return this._scene.activeCamera;
  16342. }
  16343. },
  16344. enumerable: true,
  16345. configurable: true
  16346. });
  16347. Object.defineProperty(VRExperienceHelper.prototype, "webVRCamera", {
  16348. /**
  16349. * The webVRCamera which is used when in VR.
  16350. */
  16351. get: function () {
  16352. return this._webVRCamera;
  16353. },
  16354. enumerable: true,
  16355. configurable: true
  16356. });
  16357. Object.defineProperty(VRExperienceHelper.prototype, "vrDeviceOrientationCamera", {
  16358. /**
  16359. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  16360. */
  16361. get: function () {
  16362. return this._vrDeviceOrientationCamera;
  16363. },
  16364. enumerable: true,
  16365. configurable: true
  16366. });
  16367. Object.defineProperty(VRExperienceHelper.prototype, "_teleportationRequestInitiated", {
  16368. get: function () {
  16369. var result = this._cameraGazer._teleportationRequestInitiated
  16370. || (this._leftController !== null && this._leftController._teleportationRequestInitiated)
  16371. || (this._rightController !== null && this._rightController._teleportationRequestInitiated);
  16372. return result;
  16373. },
  16374. enumerable: true,
  16375. configurable: true
  16376. });
  16377. // Raised when one of the controller has loaded successfully its associated default mesh
  16378. VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
  16379. if (this._leftController && this._leftController.webVRController == webVRController) {
  16380. if (webVRController.mesh) {
  16381. this._leftController._setLaserPointerParent(webVRController.mesh);
  16382. }
  16383. }
  16384. if (this._rightController && this._rightController.webVRController == webVRController) {
  16385. if (webVRController.mesh) {
  16386. this._rightController._setLaserPointerParent(webVRController.mesh);
  16387. }
  16388. }
  16389. try {
  16390. this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
  16391. }
  16392. catch (err) {
  16393. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onControllerMeshLoaded: " + err);
  16394. }
  16395. };
  16396. Object.defineProperty(VRExperienceHelper.prototype, "isInVRMode", {
  16397. /**
  16398. * Gets a value indicating if we are currently in VR mode.
  16399. */
  16400. get: function () {
  16401. return this._webVRpresenting || this._fullscreenVRpresenting;
  16402. },
  16403. enumerable: true,
  16404. configurable: true
  16405. });
  16406. VRExperienceHelper.prototype.onVrDisplayPresentChange = function () {
  16407. var vrDisplay = this._scene.getEngine().getVRDevice();
  16408. if (vrDisplay) {
  16409. var wasPresenting = this._webVRpresenting;
  16410. this._webVRpresenting = vrDisplay.isPresenting;
  16411. if (wasPresenting && !this._webVRpresenting) {
  16412. this.exitVR();
  16413. }
  16414. }
  16415. else {
  16416. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
  16417. }
  16418. this.updateButtonVisibility();
  16419. };
  16420. VRExperienceHelper.prototype.onVRDisplayChanged = function (eventArgs) {
  16421. this._webVRsupported = eventArgs.vrSupported;
  16422. this._webVRready = !!eventArgs.vrDisplay;
  16423. this._webVRpresenting = eventArgs.vrDisplay && eventArgs.vrDisplay.isPresenting;
  16424. this.updateButtonVisibility();
  16425. };
  16426. VRExperienceHelper.prototype.moveButtonToBottomRight = function () {
  16427. if (this._canvas && !this._useCustomVRButton) {
  16428. this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
  16429. this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
  16430. }
  16431. };
  16432. VRExperienceHelper.prototype.displayVRButton = function () {
  16433. if (!this._useCustomVRButton && !this._btnVRDisplayed) {
  16434. document.body.appendChild(this._btnVR);
  16435. this._btnVRDisplayed = true;
  16436. }
  16437. };
  16438. VRExperienceHelper.prototype.updateButtonVisibility = function () {
  16439. if (!this._btnVR || this._useCustomVRButton) {
  16440. return;
  16441. }
  16442. this._btnVR.className = "babylonVRicon";
  16443. if (this.isInVRMode) {
  16444. this._btnVR.className += " vrdisplaypresenting";
  16445. }
  16446. else {
  16447. if (this._webVRready) {
  16448. this._btnVR.className += " vrdisplayready";
  16449. }
  16450. if (this._webVRsupported) {
  16451. this._btnVR.className += " vrdisplaysupported";
  16452. }
  16453. if (this._webVRrequesting) {
  16454. this._btnVR.className += " vrdisplayrequesting";
  16455. }
  16456. }
  16457. };
  16458. /**
  16459. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  16460. * Otherwise, will use the fullscreen API.
  16461. */
  16462. VRExperienceHelper.prototype.enterVR = function () {
  16463. if (this.onEnteringVRObservable) {
  16464. try {
  16465. this.onEnteringVRObservable.notifyObservers(this);
  16466. }
  16467. catch (err) {
  16468. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onEnteringVR: " + err);
  16469. }
  16470. }
  16471. if (this._scene.activeCamera) {
  16472. this._position = this._scene.activeCamera.position.clone();
  16473. if (this.vrDeviceOrientationCamera) {
  16474. this.vrDeviceOrientationCamera.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles();
  16475. this.vrDeviceOrientationCamera.angularSensibility = 2000;
  16476. }
  16477. if (this.webVRCamera) {
  16478. var currentYRotation = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y;
  16479. var desiredYRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y;
  16480. var delta = desiredYRotation - currentYRotation;
  16481. var currentGlobalRotation = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  16482. this.webVRCamera.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromEulerAngles(0, currentGlobalRotation + delta, 0);
  16483. }
  16484. // make sure that we return to the last active camera
  16485. this._existingCamera = this._scene.activeCamera;
  16486. // Remove and cache angular sensability to avoid camera rotation when in VR
  16487. if (this._existingCamera.angularSensibilityX) {
  16488. this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX;
  16489. this._existingCamera.angularSensibilityX = Number.MAX_VALUE;
  16490. }
  16491. if (this._existingCamera.angularSensibilityY) {
  16492. this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY;
  16493. this._existingCamera.angularSensibilityY = Number.MAX_VALUE;
  16494. }
  16495. if (this._existingCamera.angularSensibility) {
  16496. this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility;
  16497. this._existingCamera.angularSensibility = Number.MAX_VALUE;
  16498. }
  16499. }
  16500. if (this._webVRrequesting) {
  16501. return;
  16502. }
  16503. // If WebVR is supported and a headset is connected
  16504. if (this._webVRready) {
  16505. if (!this._webVRpresenting) {
  16506. this._webVRCamera.position = this._position;
  16507. this._scene.activeCamera = this._webVRCamera;
  16508. }
  16509. }
  16510. else if (this._vrDeviceOrientationCamera) {
  16511. this._vrDeviceOrientationCamera.position = this._position;
  16512. if (this._scene.activeCamera) {
  16513. this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16514. }
  16515. this._scene.activeCamera = this._vrDeviceOrientationCamera;
  16516. this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen);
  16517. this.updateButtonVisibility();
  16518. }
  16519. if (this._scene.activeCamera && this._canvas) {
  16520. this._scene.activeCamera.attachControl(this._canvas);
  16521. }
  16522. if (this._interactionsEnabled) {
  16523. this._scene.registerBeforeRender(this.beforeRender);
  16524. }
  16525. if (this._displayLaserPointer) {
  16526. [this._leftController, this._rightController].forEach(function (controller) {
  16527. if (controller) {
  16528. controller._activatePointer();
  16529. }
  16530. });
  16531. }
  16532. this._hasEnteredVR = true;
  16533. };
  16534. /**
  16535. * Attempt to exit VR, or fullscreen.
  16536. */
  16537. VRExperienceHelper.prototype.exitVR = function () {
  16538. if (this._hasEnteredVR) {
  16539. if (this.onExitingVRObservable) {
  16540. try {
  16541. this.onExitingVRObservable.notifyObservers(this);
  16542. }
  16543. catch (err) {
  16544. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onExitingVR: " + err);
  16545. }
  16546. }
  16547. if (this._webVRpresenting) {
  16548. this._scene.getEngine().disableVR();
  16549. }
  16550. if (this._scene.activeCamera) {
  16551. this._position = this._scene.activeCamera.position.clone();
  16552. }
  16553. if (this.vrDeviceOrientationCamera) {
  16554. this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16555. }
  16556. if (this._deviceOrientationCamera) {
  16557. this._deviceOrientationCamera.position = this._position;
  16558. this._scene.activeCamera = this._deviceOrientationCamera;
  16559. if (this._canvas) {
  16560. this._scene.activeCamera.attachControl(this._canvas);
  16561. }
  16562. // Restore angular sensibility
  16563. if (this._cachedAngularSensibility.angularSensibilityX) {
  16564. this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16565. this._cachedAngularSensibility.angularSensibilityX = null;
  16566. }
  16567. if (this._cachedAngularSensibility.angularSensibilityY) {
  16568. this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16569. this._cachedAngularSensibility.angularSensibilityY = null;
  16570. }
  16571. if (this._cachedAngularSensibility.angularSensibility) {
  16572. this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  16573. this._cachedAngularSensibility.angularSensibility = null;
  16574. }
  16575. }
  16576. else if (this._existingCamera) {
  16577. this._existingCamera.position = this._position;
  16578. this._scene.activeCamera = this._existingCamera;
  16579. // Restore angular sensibility
  16580. if (this._cachedAngularSensibility.angularSensibilityX) {
  16581. this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16582. this._cachedAngularSensibility.angularSensibilityX = null;
  16583. }
  16584. if (this._cachedAngularSensibility.angularSensibilityY) {
  16585. this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16586. this._cachedAngularSensibility.angularSensibilityY = null;
  16587. }
  16588. if (this._cachedAngularSensibility.angularSensibility) {
  16589. this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  16590. this._cachedAngularSensibility.angularSensibility = null;
  16591. }
  16592. }
  16593. this.updateButtonVisibility();
  16594. if (this._interactionsEnabled) {
  16595. this._scene.unregisterBeforeRender(this.beforeRender);
  16596. this._cameraGazer._gazeTracker.isVisible = false;
  16597. if (this._leftController) {
  16598. this._leftController._gazeTracker.isVisible = false;
  16599. }
  16600. if (this._rightController) {
  16601. this._rightController._gazeTracker.isVisible = false;
  16602. }
  16603. }
  16604. // resize to update width and height when exiting vr exits fullscreen
  16605. this._scene.getEngine().resize();
  16606. [this._leftController, this._rightController].forEach(function (controller) {
  16607. if (controller) {
  16608. controller._deactivatePointer();
  16609. }
  16610. });
  16611. this._hasEnteredVR = false;
  16612. }
  16613. };
  16614. Object.defineProperty(VRExperienceHelper.prototype, "position", {
  16615. /**
  16616. * The position of the vr experience helper.
  16617. */
  16618. get: function () {
  16619. return this._position;
  16620. },
  16621. /**
  16622. * Sets the position of the vr experience helper.
  16623. */
  16624. set: function (value) {
  16625. this._position = value;
  16626. if (this._scene.activeCamera) {
  16627. this._scene.activeCamera.position = value;
  16628. }
  16629. },
  16630. enumerable: true,
  16631. configurable: true
  16632. });
  16633. /**
  16634. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  16635. */
  16636. VRExperienceHelper.prototype.enableInteractions = function () {
  16637. var _this = this;
  16638. if (!this._interactionsEnabled) {
  16639. this._interactionsRequested = true;
  16640. if (this._leftController) {
  16641. this._enableInteractionOnController(this._leftController);
  16642. }
  16643. if (this._rightController) {
  16644. this._enableInteractionOnController(this._rightController);
  16645. }
  16646. this.raySelectionPredicate = function (mesh) {
  16647. return mesh.isVisible && (mesh.isPickable || mesh.name === _this._floorMeshName);
  16648. };
  16649. this.meshSelectionPredicate = function () {
  16650. return true;
  16651. };
  16652. this._raySelectionPredicate = function (mesh) {
  16653. if (_this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
  16654. && mesh.name.indexOf("teleportationTarget") === -1
  16655. && mesh.name.indexOf("torusTeleportation") === -1)) {
  16656. return _this.raySelectionPredicate(mesh);
  16657. }
  16658. return false;
  16659. };
  16660. this._interactionsEnabled = true;
  16661. }
  16662. };
  16663. Object.defineProperty(VRExperienceHelper.prototype, "_noControllerIsActive", {
  16664. get: function () {
  16665. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer);
  16666. },
  16667. enumerable: true,
  16668. configurable: true
  16669. });
  16670. VRExperienceHelper.prototype._isTeleportationFloor = function (mesh) {
  16671. for (var i = 0; i < this._floorMeshesCollection.length; i++) {
  16672. if (this._floorMeshesCollection[i].id === mesh.id) {
  16673. return true;
  16674. }
  16675. }
  16676. if (this._floorMeshName && mesh.name === this._floorMeshName) {
  16677. return true;
  16678. }
  16679. return false;
  16680. };
  16681. /**
  16682. * Adds a floor mesh to be used for teleportation.
  16683. * @param floorMesh the mesh to be used for teleportation.
  16684. */
  16685. VRExperienceHelper.prototype.addFloorMesh = function (floorMesh) {
  16686. if (!this._floorMeshesCollection) {
  16687. return;
  16688. }
  16689. if (this._floorMeshesCollection.indexOf(floorMesh) > -1) {
  16690. return;
  16691. }
  16692. this._floorMeshesCollection.push(floorMesh);
  16693. };
  16694. /**
  16695. * Removes a floor mesh from being used for teleportation.
  16696. * @param floorMesh the mesh to be removed.
  16697. */
  16698. VRExperienceHelper.prototype.removeFloorMesh = function (floorMesh) {
  16699. if (!this._floorMeshesCollection) {
  16700. return;
  16701. }
  16702. var meshIndex = this._floorMeshesCollection.indexOf(floorMesh);
  16703. if (meshIndex !== -1) {
  16704. this._floorMeshesCollection.splice(meshIndex, 1);
  16705. }
  16706. };
  16707. /**
  16708. * Enables interactions and teleportation using the VR controllers and gaze.
  16709. * @param vrTeleportationOptions options to modify teleportation behavior.
  16710. */
  16711. VRExperienceHelper.prototype.enableTeleportation = function (vrTeleportationOptions) {
  16712. if (vrTeleportationOptions === void 0) { vrTeleportationOptions = {}; }
  16713. if (!this._teleportationInitialized) {
  16714. this._teleportationRequested = true;
  16715. this.enableInteractions();
  16716. if (vrTeleportationOptions.floorMeshName) {
  16717. this._floorMeshName = vrTeleportationOptions.floorMeshName;
  16718. }
  16719. if (vrTeleportationOptions.floorMeshes) {
  16720. this._floorMeshesCollection = vrTeleportationOptions.floorMeshes;
  16721. }
  16722. if (this._leftController != null) {
  16723. this._enableTeleportationOnController(this._leftController);
  16724. }
  16725. if (this._rightController != null) {
  16726. this._enableTeleportationOnController(this._rightController);
  16727. }
  16728. // Creates an image processing post process for the vignette not relying
  16729. // on the main scene configuration for image processing to reduce setup and spaces
  16730. // (gamma/linear) conflicts.
  16731. var imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__["ImageProcessingConfiguration"]();
  16732. imageProcessingConfiguration.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color4"](0, 0, 0, 0);
  16733. imageProcessingConfiguration.vignetteEnabled = true;
  16734. this._postProcessMove = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__["ImageProcessingPostProcess"]("postProcessMove", 1.0, this._webVRCamera, undefined, undefined, undefined, undefined, imageProcessingConfiguration);
  16735. this._webVRCamera.detachPostProcess(this._postProcessMove);
  16736. this._teleportationInitialized = true;
  16737. if (this._isDefaultTeleportationTarget) {
  16738. this._createTeleportationCircles();
  16739. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor);
  16740. }
  16741. }
  16742. };
  16743. VRExperienceHelper.prototype._enableInteractionOnController = function (controller) {
  16744. var _this = this;
  16745. var controllerMesh = controller.webVRController.mesh;
  16746. if (controllerMesh) {
  16747. controller._interactionsEnabled = true;
  16748. if (this.isInVRMode && this._displayLaserPointer) {
  16749. controller._activatePointer();
  16750. }
  16751. if (this.webVROptions.laserToggle) {
  16752. controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
  16753. // Enabling / disabling laserPointer
  16754. if (_this._displayLaserPointer && stateObject.value === 1) {
  16755. if (controller._activePointer) {
  16756. controller._deactivatePointer();
  16757. }
  16758. else {
  16759. controller._activatePointer();
  16760. }
  16761. if (_this.displayGaze) {
  16762. controller._gazeTracker.isVisible = controller._activePointer;
  16763. }
  16764. }
  16765. });
  16766. }
  16767. controller.webVRController.onTriggerStateChangedObservable.add(function (stateObject) {
  16768. var gazer = controller;
  16769. if (_this._noControllerIsActive) {
  16770. gazer = _this._cameraGazer;
  16771. }
  16772. if (!gazer._pointerDownOnMeshAsked) {
  16773. if (stateObject.value > _this._padSensibilityUp) {
  16774. gazer._selectionPointerDown();
  16775. }
  16776. }
  16777. else if (stateObject.value < _this._padSensibilityDown) {
  16778. gazer._selectionPointerUp();
  16779. }
  16780. });
  16781. }
  16782. };
  16783. VRExperienceHelper.prototype._checkTeleportWithRay = function (stateObject, gazer) {
  16784. // Dont teleport if another gaze already requested teleportation
  16785. if (this._teleportationRequestInitiated && !gazer._teleportationRequestInitiated) {
  16786. return;
  16787. }
  16788. if (!gazer._teleportationRequestInitiated) {
  16789. if (stateObject.y < -this._padSensibilityUp && gazer._dpadPressed) {
  16790. gazer._activatePointer();
  16791. gazer._teleportationRequestInitiated = true;
  16792. }
  16793. }
  16794. else {
  16795. // Listening to the proper controller values changes to confirm teleportation
  16796. if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
  16797. if (this._teleportActive) {
  16798. this.teleportCamera(this._haloCenter);
  16799. }
  16800. gazer._teleportationRequestInitiated = false;
  16801. }
  16802. }
  16803. };
  16804. VRExperienceHelper.prototype._checkRotate = function (stateObject, gazer) {
  16805. // Only rotate when user is not currently selecting a teleportation location
  16806. if (gazer._teleportationRequestInitiated) {
  16807. return;
  16808. }
  16809. if (!gazer._rotationLeftAsked) {
  16810. if (stateObject.x < -this._padSensibilityUp && gazer._dpadPressed) {
  16811. gazer._rotationLeftAsked = true;
  16812. if (this._rotationAllowed) {
  16813. this._rotateCamera(false);
  16814. }
  16815. }
  16816. }
  16817. else {
  16818. if (stateObject.x > -this._padSensibilityDown) {
  16819. gazer._rotationLeftAsked = false;
  16820. }
  16821. }
  16822. if (!gazer._rotationRightAsked) {
  16823. if (stateObject.x > this._padSensibilityUp && gazer._dpadPressed) {
  16824. gazer._rotationRightAsked = true;
  16825. if (this._rotationAllowed) {
  16826. this._rotateCamera(true);
  16827. }
  16828. }
  16829. }
  16830. else {
  16831. if (stateObject.x < this._padSensibilityDown) {
  16832. gazer._rotationRightAsked = false;
  16833. }
  16834. }
  16835. };
  16836. VRExperienceHelper.prototype._checkTeleportBackwards = function (stateObject, gazer) {
  16837. // Only teleport backwards when user is not currently selecting a teleportation location
  16838. if (gazer._teleportationRequestInitiated) {
  16839. return;
  16840. }
  16841. // Teleport backwards
  16842. if (stateObject.y > this._padSensibilityUp && gazer._dpadPressed) {
  16843. if (!gazer._teleportationBackRequestInitiated) {
  16844. if (!this.currentVRCamera) {
  16845. return;
  16846. }
  16847. // Get rotation and position of the current camera
  16848. var rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix());
  16849. var position = this.currentVRCamera.position;
  16850. // If the camera has device position, use that instead
  16851. if (this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion) {
  16852. rotation = this.currentVRCamera.deviceRotationQuaternion;
  16853. position = this.currentVRCamera.devicePosition;
  16854. }
  16855. // Get matrix with only the y rotation of the device rotation
  16856. rotation.toEulerAnglesToRef(this._workingVector);
  16857. this._workingVector.z = 0;
  16858. this._workingVector.x = 0;
  16859. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion);
  16860. this._workingQuaternion.toRotationMatrix(this._workingMatrix);
  16861. // Rotate backwards ray by device rotation to cast at the ground behind the user
  16862. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  16863. // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
  16864. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](position, this._workingVector);
  16865. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  16866. if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
  16867. this.teleportCamera(hit.pickedPoint);
  16868. }
  16869. gazer._teleportationBackRequestInitiated = true;
  16870. }
  16871. }
  16872. else {
  16873. gazer._teleportationBackRequestInitiated = false;
  16874. }
  16875. };
  16876. VRExperienceHelper.prototype._enableTeleportationOnController = function (controller) {
  16877. var _this = this;
  16878. var controllerMesh = controller.webVRController.mesh;
  16879. if (controllerMesh) {
  16880. if (!controller._interactionsEnabled) {
  16881. this._enableInteractionOnController(controller);
  16882. }
  16883. controller._interactionsEnabled = true;
  16884. controller._teleportationEnabled = true;
  16885. if (controller.webVRController.controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledControllerType"].VIVE) {
  16886. controller._dpadPressed = false;
  16887. controller.webVRController.onPadStateChangedObservable.add(function (stateObject) {
  16888. controller._dpadPressed = stateObject.pressed;
  16889. if (!controller._dpadPressed) {
  16890. controller._rotationLeftAsked = false;
  16891. controller._rotationRightAsked = false;
  16892. controller._teleportationBackRequestInitiated = false;
  16893. }
  16894. });
  16895. }
  16896. controller.webVRController.onPadValuesChangedObservable.add(function (stateObject) {
  16897. if (_this.teleportationEnabled) {
  16898. _this._checkTeleportBackwards(stateObject, controller);
  16899. _this._checkTeleportWithRay(stateObject, controller);
  16900. }
  16901. _this._checkRotate(stateObject, controller);
  16902. });
  16903. }
  16904. };
  16905. VRExperienceHelper.prototype._createTeleportationCircles = function () {
  16906. this._teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, this._scene);
  16907. this._teleportationTarget.isPickable = false;
  16908. var length = 512;
  16909. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__["DynamicTexture"]("DynamicTexture", length, this._scene, true);
  16910. dynamicTexture.hasAlpha = true;
  16911. var context = dynamicTexture.getContext();
  16912. var centerX = length / 2;
  16913. var centerY = length / 2;
  16914. var radius = 200;
  16915. context.beginPath();
  16916. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  16917. context.fillStyle = this._teleportationFillColor;
  16918. context.fill();
  16919. context.lineWidth = 10;
  16920. context.strokeStyle = this._teleportationBorderColor;
  16921. context.stroke();
  16922. context.closePath();
  16923. dynamicTexture.update();
  16924. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("TextPlaneMaterial", this._scene);
  16925. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  16926. this._teleportationTarget.material = teleportationCircleMaterial;
  16927. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
  16928. torus.isPickable = false;
  16929. torus.parent = this._teleportationTarget;
  16930. 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);
  16931. var keys = [];
  16932. keys.push({
  16933. frame: 0,
  16934. value: 0
  16935. });
  16936. keys.push({
  16937. frame: 30,
  16938. value: 0.4
  16939. });
  16940. keys.push({
  16941. frame: 60,
  16942. value: 0
  16943. });
  16944. animationInnerCircle.setKeys(keys);
  16945. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["SineEase"]();
  16946. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16947. animationInnerCircle.setEasingFunction(easingFunction);
  16948. torus.animations = [];
  16949. torus.animations.push(animationInnerCircle);
  16950. this._scene.beginAnimation(torus, 0, 60, true);
  16951. this._hideTeleportationTarget();
  16952. };
  16953. VRExperienceHelper.prototype._displayTeleportationTarget = function () {
  16954. this._teleportActive = true;
  16955. if (this._teleportationInitialized) {
  16956. this._teleportationTarget.isVisible = true;
  16957. if (this._isDefaultTeleportationTarget) {
  16958. this._teleportationTarget.getChildren()[0].isVisible = true;
  16959. }
  16960. }
  16961. };
  16962. VRExperienceHelper.prototype._hideTeleportationTarget = function () {
  16963. this._teleportActive = false;
  16964. if (this._teleportationInitialized) {
  16965. this._teleportationTarget.isVisible = false;
  16966. if (this._isDefaultTeleportationTarget) {
  16967. this._teleportationTarget.getChildren()[0].isVisible = false;
  16968. }
  16969. }
  16970. };
  16971. VRExperienceHelper.prototype._rotateCamera = function (right) {
  16972. var _this = this;
  16973. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  16974. return;
  16975. }
  16976. if (right) {
  16977. this._rotationAngle++;
  16978. }
  16979. else {
  16980. this._rotationAngle--;
  16981. }
  16982. this.currentVRCamera.animations = [];
  16983. var target = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].RotationY(Math.PI / 4 * this._rotationAngle));
  16984. 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);
  16985. var animationRotationKeys = [];
  16986. animationRotationKeys.push({
  16987. frame: 0,
  16988. value: this.currentVRCamera.rotationQuaternion
  16989. });
  16990. animationRotationKeys.push({
  16991. frame: 6,
  16992. value: target
  16993. });
  16994. animationRotation.setKeys(animationRotationKeys);
  16995. animationRotation.setEasingFunction(this._circleEase);
  16996. this.currentVRCamera.animations.push(animationRotation);
  16997. this._postProcessMove.animations = [];
  16998. 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);
  16999. var vignetteWeightKeys = [];
  17000. vignetteWeightKeys.push({
  17001. frame: 0,
  17002. value: 0
  17003. });
  17004. vignetteWeightKeys.push({
  17005. frame: 3,
  17006. value: 4
  17007. });
  17008. vignetteWeightKeys.push({
  17009. frame: 6,
  17010. value: 0
  17011. });
  17012. animationPP.setKeys(vignetteWeightKeys);
  17013. animationPP.setEasingFunction(this._circleEase);
  17014. this._postProcessMove.animations.push(animationPP);
  17015. 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);
  17016. var vignetteStretchKeys = [];
  17017. vignetteStretchKeys.push({
  17018. frame: 0,
  17019. value: 0
  17020. });
  17021. vignetteStretchKeys.push({
  17022. frame: 3,
  17023. value: 10
  17024. });
  17025. vignetteStretchKeys.push({
  17026. frame: 6,
  17027. value: 0
  17028. });
  17029. animationPP2.setKeys(vignetteStretchKeys);
  17030. animationPP2.setEasingFunction(this._circleEase);
  17031. this._postProcessMove.animations.push(animationPP2);
  17032. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17033. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17034. this._postProcessMove.samples = 4;
  17035. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17036. this._scene.beginAnimation(this._postProcessMove, 0, 6, false, 1, function () {
  17037. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17038. });
  17039. this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
  17040. };
  17041. VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
  17042. if (hit.pickedPoint) {
  17043. if (gazer._teleportationRequestInitiated) {
  17044. this._displayTeleportationTarget();
  17045. this._haloCenter.copyFrom(hit.pickedPoint);
  17046. this._teleportationTarget.position.copyFrom(hit.pickedPoint);
  17047. }
  17048. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
  17049. if (pickNormal) {
  17050. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17051. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17052. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
  17053. }
  17054. this._teleportationTarget.position.y += 0.1;
  17055. }
  17056. };
  17057. /**
  17058. * Teleports the users feet to the desired location
  17059. * @param location The location where the user's feet should be placed
  17060. */
  17061. VRExperienceHelper.prototype.teleportCamera = function (location) {
  17062. var _this = this;
  17063. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17064. return;
  17065. }
  17066. // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
  17067. // offset of the headset from the anchor.
  17068. if (this.webVRCamera.leftCamera) {
  17069. this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
  17070. this._workingVector.subtractInPlace(this.webVRCamera.position);
  17071. location.subtractToRef(this._workingVector, this._workingVector);
  17072. }
  17073. else {
  17074. this._workingVector.copyFrom(location);
  17075. }
  17076. // Add height to account for user's height offset
  17077. if (this.isInVRMode) {
  17078. this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor;
  17079. }
  17080. else {
  17081. this._workingVector.y += this._defaultHeight;
  17082. }
  17083. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  17084. // Create animation from the camera's position to the new location
  17085. this.currentVRCamera.animations = [];
  17086. 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);
  17087. var animationCameraTeleportationKeys = [{
  17088. frame: 0,
  17089. value: this.currentVRCamera.position
  17090. },
  17091. {
  17092. frame: 11,
  17093. value: this._workingVector
  17094. }
  17095. ];
  17096. animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
  17097. animationCameraTeleportation.setEasingFunction(this._circleEase);
  17098. this.currentVRCamera.animations.push(animationCameraTeleportation);
  17099. this._postProcessMove.animations = [];
  17100. 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);
  17101. var vignetteWeightKeys = [];
  17102. vignetteWeightKeys.push({
  17103. frame: 0,
  17104. value: 0
  17105. });
  17106. vignetteWeightKeys.push({
  17107. frame: 5,
  17108. value: 8
  17109. });
  17110. vignetteWeightKeys.push({
  17111. frame: 11,
  17112. value: 0
  17113. });
  17114. animationPP.setKeys(vignetteWeightKeys);
  17115. this._postProcessMove.animations.push(animationPP);
  17116. 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);
  17117. var vignetteStretchKeys = [];
  17118. vignetteStretchKeys.push({
  17119. frame: 0,
  17120. value: 0
  17121. });
  17122. vignetteStretchKeys.push({
  17123. frame: 5,
  17124. value: 10
  17125. });
  17126. vignetteStretchKeys.push({
  17127. frame: 11,
  17128. value: 0
  17129. });
  17130. animationPP2.setKeys(vignetteStretchKeys);
  17131. this._postProcessMove.animations.push(animationPP2);
  17132. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17133. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17134. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17135. this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, function () {
  17136. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17137. });
  17138. this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, function () {
  17139. _this.onAfterCameraTeleport.notifyObservers(_this._workingVector);
  17140. });
  17141. this._hideTeleportationTarget();
  17142. };
  17143. VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  17144. if (normal) {
  17145. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Dot(normal, ray.direction));
  17146. if (angle < Math.PI / 2) {
  17147. normal.scaleInPlace(-1);
  17148. }
  17149. }
  17150. return normal;
  17151. };
  17152. VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
  17153. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17154. return;
  17155. }
  17156. var ray = gazer._getForwardRay(this._rayLength);
  17157. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17158. if (hit) {
  17159. // Populate the contrllers mesh that can be used for drag/drop
  17160. if (gazer._laserPointer) {
  17161. hit.originMesh = gazer._laserPointer.parent;
  17162. }
  17163. this._scene.simulatePointerMove(hit, { pointerId: gazer._id });
  17164. }
  17165. gazer._currentHit = hit;
  17166. // Moving the gazeTracker on the mesh face targetted
  17167. if (hit && hit.pickedPoint) {
  17168. if (this._displayGaze) {
  17169. var multiplier = 1;
  17170. gazer._gazeTracker.isVisible = true;
  17171. if (gazer._isActionableMesh) {
  17172. multiplier = 3;
  17173. }
  17174. if (this.updateGazeTrackerScale) {
  17175. gazer._gazeTracker.scaling.x = hit.distance * multiplier;
  17176. gazer._gazeTracker.scaling.y = hit.distance * multiplier;
  17177. gazer._gazeTracker.scaling.z = hit.distance * multiplier;
  17178. }
  17179. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
  17180. // To avoid z-fighting
  17181. var deltaFighting = 0.002;
  17182. if (pickNormal) {
  17183. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17184. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17185. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, gazer._gazeTracker.rotation);
  17186. }
  17187. gazer._gazeTracker.position.copyFrom(hit.pickedPoint);
  17188. if (gazer._gazeTracker.position.x < 0) {
  17189. gazer._gazeTracker.position.x += deltaFighting;
  17190. }
  17191. else {
  17192. gazer._gazeTracker.position.x -= deltaFighting;
  17193. }
  17194. if (gazer._gazeTracker.position.y < 0) {
  17195. gazer._gazeTracker.position.y += deltaFighting;
  17196. }
  17197. else {
  17198. gazer._gazeTracker.position.y -= deltaFighting;
  17199. }
  17200. if (gazer._gazeTracker.position.z < 0) {
  17201. gazer._gazeTracker.position.z += deltaFighting;
  17202. }
  17203. else {
  17204. gazer._gazeTracker.position.z -= deltaFighting;
  17205. }
  17206. }
  17207. // Changing the size of the laser pointer based on the distance from the targetted point
  17208. gazer._updatePointerDistance(hit.distance);
  17209. }
  17210. else {
  17211. gazer._updatePointerDistance();
  17212. gazer._gazeTracker.isVisible = false;
  17213. }
  17214. if (hit && hit.pickedMesh) {
  17215. // The object selected is the floor, we're in a teleportation scenario
  17216. if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
  17217. // Moving the teleportation area to this targetted point
  17218. //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
  17219. if (gazer._currentMeshSelected && !this._isTeleportationFloor(gazer._currentMeshSelected)) {
  17220. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17221. }
  17222. gazer._currentMeshSelected = null;
  17223. if (gazer._teleportationRequestInitiated) {
  17224. this._moveTeleportationSelectorTo(hit, gazer, ray);
  17225. }
  17226. return;
  17227. }
  17228. // If not, we're in a selection scenario
  17229. //this._teleportationAllowed = false;
  17230. if (hit.pickedMesh !== gazer._currentMeshSelected) {
  17231. if (this.meshSelectionPredicate(hit.pickedMesh)) {
  17232. this.onNewMeshPicked.notifyObservers(hit);
  17233. gazer._currentMeshSelected = hit.pickedMesh;
  17234. if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
  17235. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0, 0, 1));
  17236. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.2, 0.2, 1));
  17237. gazer._isActionableMesh = true;
  17238. }
  17239. else {
  17240. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17241. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17242. gazer._isActionableMesh = false;
  17243. }
  17244. try {
  17245. this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
  17246. }
  17247. catch (err) {
  17248. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onNewMeshSelected: " + err);
  17249. }
  17250. }
  17251. else {
  17252. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17253. gazer._currentMeshSelected = null;
  17254. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17255. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17256. }
  17257. }
  17258. }
  17259. else {
  17260. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17261. gazer._currentMeshSelected = null;
  17262. //this._teleportationAllowed = false;
  17263. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17264. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17265. }
  17266. };
  17267. VRExperienceHelper.prototype._notifySelectedMeshUnselected = function (mesh) {
  17268. if (mesh) {
  17269. this.onSelectedMeshUnselected.notifyObservers(mesh);
  17270. }
  17271. };
  17272. /**
  17273. * Sets the color of the laser ray from the vr controllers.
  17274. * @param color new color for the ray.
  17275. */
  17276. VRExperienceHelper.prototype.changeLaserColor = function (color) {
  17277. if (this._leftController) {
  17278. this._leftController._setLaserPointerColor(color);
  17279. }
  17280. if (this._rightController) {
  17281. this._rightController._setLaserPointerColor(color);
  17282. }
  17283. };
  17284. /**
  17285. * Sets the color of the ray from the vr headsets gaze.
  17286. * @param color new color for the ray.
  17287. */
  17288. VRExperienceHelper.prototype.changeGazeColor = function (color) {
  17289. if (!this.updateGazeTrackerColor) {
  17290. return;
  17291. }
  17292. if (!this._cameraGazer._gazeTracker.material) {
  17293. return;
  17294. }
  17295. this._cameraGazer._gazeTracker.material.emissiveColor = color;
  17296. if (this._leftController) {
  17297. this._leftController._gazeTracker.material.emissiveColor = color;
  17298. }
  17299. if (this._rightController) {
  17300. this._rightController._gazeTracker.material.emissiveColor = color;
  17301. }
  17302. };
  17303. /**
  17304. * Exits VR and disposes of the vr experience helper
  17305. */
  17306. VRExperienceHelper.prototype.dispose = function () {
  17307. if (this.isInVRMode) {
  17308. this.exitVR();
  17309. }
  17310. if (this._postProcessMove) {
  17311. this._postProcessMove.dispose();
  17312. }
  17313. if (this._webVRCamera) {
  17314. this._webVRCamera.dispose();
  17315. }
  17316. if (this._vrDeviceOrientationCamera) {
  17317. this._vrDeviceOrientationCamera.dispose();
  17318. }
  17319. if (!this._useCustomVRButton && this._btnVR.parentNode) {
  17320. document.body.removeChild(this._btnVR);
  17321. }
  17322. if (this._deviceOrientationCamera && (this._scene.activeCamera != this._deviceOrientationCamera)) {
  17323. this._deviceOrientationCamera.dispose();
  17324. }
  17325. if (this._cameraGazer) {
  17326. this._cameraGazer.dispose();
  17327. }
  17328. if (this._leftController) {
  17329. this._leftController.dispose();
  17330. }
  17331. if (this._rightController) {
  17332. this._rightController.dispose();
  17333. }
  17334. if (this._teleportationTarget) {
  17335. this._teleportationTarget.dispose();
  17336. }
  17337. this._floorMeshesCollection = [];
  17338. document.removeEventListener("keydown", this._onKeyDown);
  17339. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17340. window.removeEventListener("resize", this._onResize);
  17341. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  17342. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  17343. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  17344. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  17345. document.onmsfullscreenchange = null;
  17346. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged);
  17347. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart);
  17348. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete);
  17349. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17350. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected);
  17351. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected);
  17352. this._scene.unregisterBeforeRender(this.beforeRender);
  17353. };
  17354. /**
  17355. * Gets the name of the VRExperienceHelper class
  17356. * @returns "VRExperienceHelper"
  17357. */
  17358. VRExperienceHelper.prototype.getClassName = function () {
  17359. return "VRExperienceHelper";
  17360. };
  17361. return VRExperienceHelper;
  17362. }());
  17363. /***/ }),
  17364. /***/ "./Cameras/VR/webVRCamera.ts":
  17365. /*!***********************************!*\
  17366. !*** ./Cameras/VR/webVRCamera.ts ***!
  17367. \***********************************/
  17368. /*! exports provided: WebVRFreeCamera */
  17369. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17370. "use strict";
  17371. __webpack_require__.r(__webpack_exports__);
  17372. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return WebVRFreeCamera; });
  17373. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17374. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17375. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  17376. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  17377. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17378. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  17379. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  17380. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../node */ "./node.ts");
  17381. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  17382. /* harmony import */ var _RigModes_webVRRigMode__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../RigModes/webVRRigMode */ "./Cameras/RigModes/webVRRigMode.ts");
  17383. // Side effect import to define the stereoscopic mode.
  17384. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRFreeCamera", function (name, scene) {
  17385. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17386. });
  17387. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRGamepadCamera", function (name, scene) {
  17388. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17389. });
  17390. /**
  17391. * This represents a WebVR camera.
  17392. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17393. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17394. */
  17395. var WebVRFreeCamera = /** @class */ (function (_super) {
  17396. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRFreeCamera, _super);
  17397. /**
  17398. * Instantiates a WebVRFreeCamera.
  17399. * @param name The name of the WebVRFreeCamera
  17400. * @param position The starting anchor position for the camera
  17401. * @param scene The scene the camera belongs to
  17402. * @param webVROptions a set of customizable options for the webVRCamera
  17403. */
  17404. function WebVRFreeCamera(name, position, scene, webVROptions) {
  17405. if (webVROptions === void 0) { webVROptions = {}; }
  17406. var _this = _super.call(this, name, position, scene) || this;
  17407. _this.webVROptions = webVROptions;
  17408. /**
  17409. * @hidden
  17410. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17411. */
  17412. _this._vrDevice = null;
  17413. /**
  17414. * The rawPose of the vrDevice.
  17415. */
  17416. _this.rawPose = null;
  17417. _this._specsVersion = "1.1";
  17418. _this._attached = false;
  17419. _this._descendants = [];
  17420. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  17421. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17422. /** @hidden */
  17423. _this._deviceRoomRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17424. _this._standingMatrix = null;
  17425. /**
  17426. * Represents device position in babylon space.
  17427. */
  17428. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17429. /**
  17430. * Represents device rotation in babylon space.
  17431. */
  17432. _this.deviceRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17433. /**
  17434. * The scale of the device to be used when translating from device space to babylon space.
  17435. */
  17436. _this.deviceScaleFactor = 1;
  17437. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17438. _this._worldToDevice = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17439. /**
  17440. * References to the webVR controllers for the vrDevice.
  17441. */
  17442. _this.controllers = [];
  17443. /**
  17444. * Emits an event when a controller is attached.
  17445. */
  17446. _this.onControllersAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17447. /**
  17448. * Emits an event when a controller's mesh has been loaded;
  17449. */
  17450. _this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17451. /**
  17452. * Emits an event when the HMD's pose has been updated.
  17453. */
  17454. _this.onPoseUpdatedFromDeviceObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17455. _this._poseSet = false;
  17456. /**
  17457. * If the rig cameras be used as parent instead of this camera.
  17458. */
  17459. _this.rigParenting = true;
  17460. _this._defaultHeight = undefined;
  17461. _this._htmlElementAttached = null;
  17462. _this._detachIfAttached = function () {
  17463. var vrDisplay = _this.getEngine().getVRDevice();
  17464. if (vrDisplay && !vrDisplay.isPresenting && _this._htmlElementAttached) {
  17465. _this.detachControl(_this._htmlElementAttached);
  17466. }
  17467. };
  17468. _this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17469. _this._oneVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  17470. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17471. _this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17472. _this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17473. if (webVROptions.defaultHeight) {
  17474. _this._defaultHeight = webVROptions.defaultHeight;
  17475. _this.position.y = _this._defaultHeight;
  17476. }
  17477. _this.minZ = 0.1;
  17478. //legacy support - the compensation boolean was removed.
  17479. if (arguments.length === 5) {
  17480. _this.webVROptions = arguments[4];
  17481. }
  17482. // default webVR options
  17483. if (_this.webVROptions.trackPosition == undefined) {
  17484. _this.webVROptions.trackPosition = true;
  17485. }
  17486. if (_this.webVROptions.controllerMeshes == undefined) {
  17487. _this.webVROptions.controllerMeshes = true;
  17488. }
  17489. if (_this.webVROptions.defaultLightingOnControllers == undefined) {
  17490. _this.webVROptions.defaultLightingOnControllers = true;
  17491. }
  17492. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  17493. if (_this.webVROptions && _this.webVROptions.positionScale) {
  17494. _this.deviceScaleFactor = _this.webVROptions.positionScale;
  17495. }
  17496. //enable VR
  17497. var engine = _this.getEngine();
  17498. _this._onVREnabled = function (success) { if (success) {
  17499. _this.initControllers();
  17500. } };
  17501. engine.onVRRequestPresentComplete.add(_this._onVREnabled);
  17502. engine.initWebVR().add(function (event) {
  17503. if (!event.vrDisplay || _this._vrDevice === event.vrDisplay) {
  17504. return;
  17505. }
  17506. _this._vrDevice = event.vrDisplay;
  17507. //reset the rig parameters.
  17508. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].RIG_MODE_WEBVR, { parentCamera: _this, vrDisplay: _this._vrDevice, frameData: _this._frameData, specs: _this._specsVersion });
  17509. if (_this._attached) {
  17510. _this.getEngine().enableVR();
  17511. }
  17512. });
  17513. if (typeof (VRFrameData) !== "undefined") {
  17514. _this._frameData = new VRFrameData();
  17515. }
  17516. /**
  17517. * The idea behind the following lines:
  17518. * objects that have the camera as parent should actually have the rig cameras as a parent.
  17519. * BUT, each of those cameras has a different view matrix, which means that if we set the parent to the first rig camera,
  17520. * the second will not show it correctly.
  17521. *
  17522. * To solve this - each object that has the camera as parent will be added to a protected array.
  17523. * When the rig camera renders, it will take this array and set all of those to be its children.
  17524. * This way, the right camera will be used as a parent, and the mesh will be rendered correctly.
  17525. * Amazing!
  17526. */
  17527. scene.onBeforeCameraRenderObservable.add(function (camera) {
  17528. if (camera.parent === _this && _this.rigParenting) {
  17529. _this._descendants = _this.getDescendants(true, function (n) {
  17530. // don't take the cameras or the controllers!
  17531. var isController = _this.controllers.some(function (controller) { return controller._mesh === n; });
  17532. var isRigCamera = _this._rigCameras.indexOf(n) !== -1;
  17533. return !isController && !isRigCamera;
  17534. });
  17535. _this._descendants.forEach(function (node) {
  17536. node.parent = camera;
  17537. });
  17538. }
  17539. });
  17540. scene.onAfterCameraRenderObservable.add(function (camera) {
  17541. if (camera.parent === _this && _this.rigParenting) {
  17542. _this._descendants.forEach(function (node) {
  17543. node.parent = _this;
  17544. });
  17545. }
  17546. });
  17547. return _this;
  17548. }
  17549. /**
  17550. * Gets the device distance from the ground in meters.
  17551. * @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.
  17552. */
  17553. WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
  17554. if (this._standingMatrix) {
  17555. // Add standing matrix offset to get real offset from ground in room
  17556. this._standingMatrix.getTranslationToRef(this._workingVector);
  17557. return this._deviceRoomPosition.y + this._workingVector.y;
  17558. }
  17559. //If VRDisplay does not inform stage parameters and no default height is set we fallback to zero.
  17560. return this._defaultHeight || 0;
  17561. };
  17562. /**
  17563. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17564. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17565. */
  17566. WebVRFreeCamera.prototype.useStandingMatrix = function (callback) {
  17567. var _this = this;
  17568. if (callback === void 0) { callback = function (bool) { }; }
  17569. // Use standing matrix if available
  17570. this.getEngine().initWebVRAsync().then(function (result) {
  17571. if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform || !_this.webVROptions.trackPosition) {
  17572. callback(false);
  17573. }
  17574. else {
  17575. _this._standingMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17576. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
  17577. if (!_this.getScene().useRightHandedSystem) {
  17578. if (_this._standingMatrix) {
  17579. _this._standingMatrix.toggleModelMatrixHandInPlace();
  17580. }
  17581. }
  17582. callback(true);
  17583. }
  17584. });
  17585. };
  17586. /**
  17587. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17588. * @returns A promise with a boolean set to if the standing matrix is supported.
  17589. */
  17590. WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
  17591. var _this = this;
  17592. return new Promise(function (res) {
  17593. _this.useStandingMatrix(function (supported) {
  17594. res(supported);
  17595. });
  17596. });
  17597. };
  17598. /**
  17599. * Disposes the camera
  17600. */
  17601. WebVRFreeCamera.prototype.dispose = function () {
  17602. this._detachIfAttached();
  17603. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
  17604. if (this._updateCacheWhenTrackingDisabledObserver) {
  17605. this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver);
  17606. }
  17607. _super.prototype.dispose.call(this);
  17608. };
  17609. /**
  17610. * Gets a vrController by name.
  17611. * @param name The name of the controller to retreive
  17612. * @returns the controller matching the name specified or null if not found
  17613. */
  17614. WebVRFreeCamera.prototype.getControllerByName = function (name) {
  17615. for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
  17616. var gp = _a[_i];
  17617. if (gp.hand === name) {
  17618. return gp;
  17619. }
  17620. }
  17621. return null;
  17622. };
  17623. Object.defineProperty(WebVRFreeCamera.prototype, "leftController", {
  17624. /**
  17625. * The controller corrisponding to the users left hand.
  17626. */
  17627. get: function () {
  17628. if (!this._leftController) {
  17629. this._leftController = this.getControllerByName("left");
  17630. }
  17631. return this._leftController;
  17632. },
  17633. enumerable: true,
  17634. configurable: true
  17635. });
  17636. Object.defineProperty(WebVRFreeCamera.prototype, "rightController", {
  17637. /**
  17638. * The controller corrisponding to the users right hand.
  17639. */
  17640. get: function () {
  17641. if (!this._rightController) {
  17642. this._rightController = this.getControllerByName("right");
  17643. }
  17644. return this._rightController;
  17645. },
  17646. enumerable: true,
  17647. configurable: true
  17648. });
  17649. /**
  17650. * Casts a ray forward from the vrCamera's gaze.
  17651. * @param length Length of the ray (default: 100)
  17652. * @returns the ray corrisponding to the gaze
  17653. */
  17654. WebVRFreeCamera.prototype.getForwardRay = function (length) {
  17655. if (length === void 0) { length = 100; }
  17656. if (this.leftCamera) {
  17657. // Use left eye to avoid computation to compute center on every call
  17658. return _super.prototype.getForwardRay.call(this, length, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition); // Need the actual rendered camera
  17659. }
  17660. else {
  17661. return _super.prototype.getForwardRay.call(this, length);
  17662. }
  17663. };
  17664. /**
  17665. * @hidden
  17666. * Updates the camera based on device's frame data
  17667. */
  17668. WebVRFreeCamera.prototype._checkInputs = function () {
  17669. if (this._vrDevice && this._vrDevice.isPresenting) {
  17670. this._vrDevice.getFrameData(this._frameData);
  17671. this.updateFromDevice(this._frameData.pose);
  17672. }
  17673. _super.prototype._checkInputs.call(this);
  17674. };
  17675. /**
  17676. * Updates the poseControlled values based on the input device pose.
  17677. * @param poseData Pose coming from the device
  17678. */
  17679. WebVRFreeCamera.prototype.updateFromDevice = function (poseData) {
  17680. if (poseData && poseData.orientation) {
  17681. this.rawPose = poseData;
  17682. this._deviceRoomRotationQuaternion.copyFromFloats(poseData.orientation[0], poseData.orientation[1], -poseData.orientation[2], -poseData.orientation[3]);
  17683. if (this.getScene().useRightHandedSystem) {
  17684. this._deviceRoomRotationQuaternion.z *= -1;
  17685. this._deviceRoomRotationQuaternion.w *= -1;
  17686. }
  17687. if (this.webVROptions.trackPosition && this.rawPose.position) {
  17688. this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]);
  17689. if (this.getScene().useRightHandedSystem) {
  17690. this._deviceRoomPosition.z *= -1;
  17691. }
  17692. }
  17693. this._poseSet = true;
  17694. }
  17695. };
  17696. /**
  17697. * WebVR's attach control will start broadcasting frames to the device.
  17698. * Note that in certain browsers (chrome for example) this function must be called
  17699. * within a user-interaction callback. Example:
  17700. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  17701. *
  17702. * @param element html element to attach the vrDevice to
  17703. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  17704. */
  17705. WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  17706. _super.prototype.attachControl.call(this, element, noPreventDefault);
  17707. this._attached = true;
  17708. this._htmlElementAttached = element;
  17709. noPreventDefault = _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  17710. if (this._vrDevice) {
  17711. this.getEngine().enableVR();
  17712. }
  17713. window.addEventListener('vrdisplaypresentchange', this._detachIfAttached);
  17714. };
  17715. /**
  17716. * Detaches the camera from the html element and disables VR
  17717. *
  17718. * @param element html element to detach from
  17719. */
  17720. WebVRFreeCamera.prototype.detachControl = function (element) {
  17721. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  17722. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  17723. _super.prototype.detachControl.call(this, element);
  17724. this._attached = false;
  17725. this.getEngine().disableVR();
  17726. window.removeEventListener('vrdisplaypresentchange', this._detachIfAttached);
  17727. };
  17728. /**
  17729. * @returns the name of this class
  17730. */
  17731. WebVRFreeCamera.prototype.getClassName = function () {
  17732. return "WebVRFreeCamera";
  17733. };
  17734. /**
  17735. * Calls resetPose on the vrDisplay
  17736. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  17737. */
  17738. WebVRFreeCamera.prototype.resetToCurrentRotation = function () {
  17739. //uses the vrDisplay's "resetPose()".
  17740. //pitch and roll won't be affected.
  17741. this._vrDevice.resetPose();
  17742. };
  17743. /**
  17744. * @hidden
  17745. * Updates the rig cameras (left and right eye)
  17746. */
  17747. WebVRFreeCamera.prototype._updateRigCameras = function () {
  17748. var camLeft = this._rigCameras[0];
  17749. var camRight = this._rigCameras[1];
  17750. camLeft.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  17751. camRight.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  17752. camLeft.position.copyFrom(this._deviceRoomPosition);
  17753. camRight.position.copyFrom(this._deviceRoomPosition);
  17754. };
  17755. // Remove translation from 6dof headset if trackposition is set to false
  17756. WebVRFreeCamera.prototype._correctPositionIfNotTrackPosition = function (matrix, isViewMatrix) {
  17757. if (isViewMatrix === void 0) { isViewMatrix = false; }
  17758. if (this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition) {
  17759. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix);
  17760. if (!isViewMatrix) {
  17761. this._tmpMatrix.invert();
  17762. }
  17763. this._tmpMatrix.multiplyToRef(matrix, matrix);
  17764. }
  17765. };
  17766. /**
  17767. * @hidden
  17768. * Updates the cached values of the camera
  17769. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  17770. */
  17771. WebVRFreeCamera.prototype._updateCache = function (ignoreParentClass) {
  17772. var _this = this;
  17773. if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
  17774. // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
  17775. if (!this.updateCacheCalled) {
  17776. // make sure it is only called once per loop. this.update() might cause an infinite loop.
  17777. this.updateCacheCalled = true;
  17778. this.update();
  17779. }
  17780. // Set working vector to the device position in room space rotated by the new rotation
  17781. this.rotationQuaternion.toRotationMatrix(this._workingMatrix);
  17782. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector);
  17783. // Subtract this vector from the current device position in world to get the translation for the device world matrix
  17784. this.devicePosition.subtractToRef(this._workingVector, this._workingVector);
  17785. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
  17786. // Add translation from anchor position
  17787. this._deviceToWorld.getTranslationToRef(this._workingVector);
  17788. this._workingVector.addInPlace(this.position);
  17789. this._workingVector.subtractInPlace(this._cache.position);
  17790. this._deviceToWorld.setTranslation(this._workingVector);
  17791. // Set an inverted matrix to be used when updating the camera
  17792. this._deviceToWorld.invertToRef(this._worldToDevice);
  17793. // Update the gamepad to ensure the mesh is updated on the same frame as camera
  17794. this.controllers.forEach(function (controller) {
  17795. controller._deviceToWorld.copyFrom(_this._deviceToWorld);
  17796. _this._correctPositionIfNotTrackPosition(controller._deviceToWorld);
  17797. controller.update();
  17798. });
  17799. }
  17800. if (!ignoreParentClass) {
  17801. _super.prototype._updateCache.call(this);
  17802. }
  17803. this.updateCacheCalled = false;
  17804. };
  17805. /**
  17806. * @hidden
  17807. * Get current device position in babylon world
  17808. */
  17809. WebVRFreeCamera.prototype._computeDevicePosition = function () {
  17810. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
  17811. };
  17812. /**
  17813. * Updates the current device position and rotation in the babylon world
  17814. */
  17815. WebVRFreeCamera.prototype.update = function () {
  17816. this._computeDevicePosition();
  17817. // Get current device rotation in babylon world
  17818. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
  17819. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
  17820. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  17821. if (this._poseSet) {
  17822. this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
  17823. }
  17824. _super.prototype.update.call(this);
  17825. };
  17826. /**
  17827. * @hidden
  17828. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  17829. * @returns an identity matrix
  17830. */
  17831. WebVRFreeCamera.prototype._getViewMatrix = function () {
  17832. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17833. };
  17834. /**
  17835. * This function is called by the two RIG cameras.
  17836. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  17837. * @hidden
  17838. */
  17839. WebVRFreeCamera.prototype._getWebVRViewMatrix = function () {
  17840. // Update the parent camera prior to using a child camera to avoid desynchronization
  17841. var parentCamera = this._cameraRigParams["parentCamera"];
  17842. parentCamera._updateCache();
  17843. //WebVR 1.1
  17844. var viewArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftViewMatrix : this._cameraRigParams["frameData"].rightViewMatrix;
  17845. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(viewArray, 0, this._webvrViewMatrix);
  17846. if (!this.getScene().useRightHandedSystem) {
  17847. this._webvrViewMatrix.toggleModelMatrixHandInPlace();
  17848. }
  17849. // update the camera rotation matrix
  17850. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
  17851. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  17852. // Computing target and final matrix
  17853. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  17854. // should the view matrix be updated with scale and position offset?
  17855. if (parentCamera.deviceScaleFactor !== 1) {
  17856. this._webvrViewMatrix.invert();
  17857. // scale the position, if set
  17858. if (parentCamera.deviceScaleFactor) {
  17859. this._webvrViewMatrix.multiplyAtIndex(12, parentCamera.deviceScaleFactor);
  17860. this._webvrViewMatrix.multiplyAtIndex(13, parentCamera.deviceScaleFactor);
  17861. this._webvrViewMatrix.multiplyAtIndex(14, parentCamera.deviceScaleFactor);
  17862. }
  17863. this._webvrViewMatrix.invert();
  17864. }
  17865. // Remove translation from 6dof headset if trackposition is set to false
  17866. parentCamera._correctPositionIfNotTrackPosition(this._webvrViewMatrix, true);
  17867. parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
  17868. // Compute global position
  17869. this._workingMatrix = this._workingMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17870. this._webvrViewMatrix.invertToRef(this._workingMatrix);
  17871. this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
  17872. this._workingMatrix.getTranslationToRef(this._globalPosition);
  17873. this._markSyncedWithParent();
  17874. return this._webvrViewMatrix;
  17875. };
  17876. /** @hidden */
  17877. WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
  17878. var parentCamera = this.parent;
  17879. parentCamera._vrDevice.depthNear = parentCamera.minZ;
  17880. parentCamera._vrDevice.depthFar = parentCamera.maxZ;
  17881. var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
  17882. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(projectionArray, 0, this._projectionMatrix);
  17883. //babylon compatible matrix
  17884. if (!this.getScene().useRightHandedSystem) {
  17885. this._projectionMatrix.toggleProjectionMatrixHandInPlace();
  17886. }
  17887. return this._projectionMatrix;
  17888. };
  17889. /**
  17890. * Initializes the controllers and their meshes
  17891. */
  17892. WebVRFreeCamera.prototype.initControllers = function () {
  17893. var _this = this;
  17894. this.controllers = [];
  17895. var manager = this.getScene().gamepadManager;
  17896. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  17897. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  17898. var webVrController = gamepad;
  17899. if (webVrController.defaultModel) {
  17900. webVrController.defaultModel.setEnabled(false);
  17901. }
  17902. if (webVrController.hand === "right") {
  17903. _this._rightController = null;
  17904. }
  17905. if (webVrController.hand === "left") {
  17906. _this._leftController = null;
  17907. }
  17908. var controllerIndex = _this.controllers.indexOf(webVrController);
  17909. if (controllerIndex !== -1) {
  17910. _this.controllers.splice(controllerIndex, 1);
  17911. }
  17912. }
  17913. });
  17914. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  17915. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  17916. var webVrController_1 = gamepad;
  17917. if (!_this.webVROptions.trackPosition) {
  17918. webVrController_1._disableTrackPosition(new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](webVrController_1.hand == "left" ? -0.15 : 0.15, -0.5, 0.25));
  17919. // Cache must be updated before rendering controllers to avoid them being one frame behind
  17920. if (!_this._updateCacheWhenTrackingDisabledObserver) {
  17921. _this._updateCacheWhenTrackingDisabledObserver = _this._scene.onBeforeRenderObservable.add(function () {
  17922. _this._updateCache();
  17923. });
  17924. }
  17925. }
  17926. webVrController_1.deviceScaleFactor = _this.deviceScaleFactor;
  17927. webVrController_1._deviceToWorld.copyFrom(_this._deviceToWorld);
  17928. _this._correctPositionIfNotTrackPosition(webVrController_1._deviceToWorld);
  17929. if (_this.webVROptions.controllerMeshes) {
  17930. if (webVrController_1.defaultModel) {
  17931. webVrController_1.defaultModel.setEnabled(true);
  17932. }
  17933. else {
  17934. // Load the meshes
  17935. webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
  17936. loadedMesh.scaling.scaleInPlace(_this.deviceScaleFactor);
  17937. _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
  17938. if (_this.webVROptions.defaultLightingOnControllers) {
  17939. if (!_this._lightOnControllers) {
  17940. _this._lightOnControllers = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__["HemisphericLight"]("vrControllersLight", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0), _this.getScene());
  17941. }
  17942. var activateLightOnSubMeshes_1 = function (mesh, light) {
  17943. var children = mesh.getChildren();
  17944. if (children && children.length !== 0) {
  17945. children.forEach(function (mesh) {
  17946. light.includedOnlyMeshes.push(mesh);
  17947. activateLightOnSubMeshes_1(mesh, light);
  17948. });
  17949. }
  17950. };
  17951. _this._lightOnControllers.includedOnlyMeshes.push(loadedMesh);
  17952. activateLightOnSubMeshes_1(loadedMesh, _this._lightOnControllers);
  17953. }
  17954. });
  17955. }
  17956. }
  17957. webVrController_1.attachToPoseControlledCamera(_this);
  17958. // since this is async - sanity check. Is the controller already stored?
  17959. if (_this.controllers.indexOf(webVrController_1) === -1) {
  17960. //add to the controllers array
  17961. _this.controllers.push(webVrController_1);
  17962. // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
  17963. // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
  17964. // So we're overriding setting left & right manually to be sure
  17965. var firstViveWandDetected = false;
  17966. for (var i = 0; i < _this.controllers.length; i++) {
  17967. if (_this.controllers[i].controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__["PoseEnabledControllerType"].VIVE) {
  17968. if (!firstViveWandDetected) {
  17969. firstViveWandDetected = true;
  17970. _this.controllers[i].hand = "left";
  17971. }
  17972. else {
  17973. _this.controllers[i].hand = "right";
  17974. }
  17975. }
  17976. }
  17977. //did we find enough controllers? Great! let the developer know.
  17978. if (_this.controllers.length >= 2) {
  17979. _this.onControllersAttachedObservable.notifyObservers(_this.controllers);
  17980. }
  17981. }
  17982. }
  17983. });
  17984. };
  17985. return WebVRFreeCamera;
  17986. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  17987. /***/ }),
  17988. /***/ "./Cameras/XR/index.ts":
  17989. /*!*****************************!*\
  17990. !*** ./Cameras/XR/index.ts ***!
  17991. \*****************************/
  17992. /*! exports provided: WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  17993. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17994. "use strict";
  17995. __webpack_require__.r(__webpack_exports__);
  17996. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  17997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _webXRCamera__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  17998. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  17999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIButton"]; });
  18000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIOptions"]; });
  18001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUI"]; });
  18002. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"]; });
  18004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRExperienceHelper"]; });
  18005. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  18006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRController"]; });
  18007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRInput"]; });
  18008. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  18009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__["WebXRManagedOutputCanvas"]; });
  18010. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__["WebXRSessionManager"]; });
  18012. /***/ }),
  18013. /***/ "./Cameras/XR/webXRCamera.ts":
  18014. /*!***********************************!*\
  18015. !*** ./Cameras/XR/webXRCamera.ts ***!
  18016. \***********************************/
  18017. /*! exports provided: WebXRCamera */
  18018. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18019. "use strict";
  18020. __webpack_require__.r(__webpack_exports__);
  18021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return WebXRCamera; });
  18022. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18023. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18024. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  18025. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  18026. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  18027. /**
  18028. * WebXR Camera which holds the views for the xrSession
  18029. * @see https://doc.babylonjs.com/how_to/webxr
  18030. */
  18031. var WebXRCamera = /** @class */ (function (_super) {
  18032. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebXRCamera, _super);
  18033. /**
  18034. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  18035. * @param name the name of the camera
  18036. * @param scene the scene to add the camera to
  18037. */
  18038. function WebXRCamera(name, scene) {
  18039. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), scene) || this;
  18040. // Initial camera configuration
  18041. _this.minZ = 0;
  18042. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18043. _this.cameraRigMode = _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_CUSTOM;
  18044. _this.updateUpVectorFromRotation = true;
  18045. _this._updateNumberOfRigCameras(1);
  18046. return _this;
  18047. }
  18048. WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
  18049. if (viewCount === void 0) { viewCount = 1; }
  18050. while (this.rigCameras.length < viewCount) {
  18051. var newCamera = new _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]("view: " + this.rigCameras.length, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), this.getScene());
  18052. newCamera.minZ = 0;
  18053. newCamera.parent = this;
  18054. newCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18055. newCamera.updateUpVectorFromRotation = true;
  18056. this.rigCameras.push(newCamera);
  18057. }
  18058. while (this.rigCameras.length > viewCount) {
  18059. var removedCamera = this.rigCameras.pop();
  18060. if (removedCamera) {
  18061. removedCamera.dispose();
  18062. }
  18063. }
  18064. };
  18065. /** @hidden */
  18066. WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
  18067. if (pupilDistance === void 0) { pupilDistance = 0.01; }
  18068. // Create initial camera rigs
  18069. this._updateNumberOfRigCameras(2);
  18070. this.rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  18071. this.rigCameras[0].position.x = -pupilDistance / 2;
  18072. this.rigCameras[0].outputRenderTarget = null;
  18073. this.rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  18074. this.rigCameras[1].position.x = pupilDistance / 2;
  18075. this.rigCameras[1].outputRenderTarget = null;
  18076. };
  18077. /**
  18078. * Updates the cameras position from the current pose information of the XR session
  18079. * @param xrSessionManager the session containing pose information
  18080. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  18081. */
  18082. WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
  18083. var _this = this;
  18084. // Ensure all frame data is available
  18085. if (!xrSessionManager._currentXRFrame || !xrSessionManager._currentXRFrame.getDevicePose) {
  18086. return false;
  18087. }
  18088. var pose = xrSessionManager._currentXRFrame.getDevicePose(xrSessionManager._frameOfReference);
  18089. if (!pose || !pose.poseModelMatrix) {
  18090. return false;
  18091. }
  18092. // Update the parent cameras matrix
  18093. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.poseModelMatrix, 0, 1, WebXRCamera._TmpMatrix);
  18094. if (!this._scene.useRightHandedSystem) {
  18095. WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
  18096. }
  18097. WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
  18098. WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
  18099. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
  18100. this.computeWorldMatrix();
  18101. // Update camera rigs
  18102. this._updateNumberOfRigCameras(xrSessionManager._currentXRFrame.views.length);
  18103. xrSessionManager._currentXRFrame.views.forEach(function (view, i) {
  18104. // Update view/projection matrix
  18105. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.getViewMatrix(view), 0, 1, _this.rigCameras[i]._computedViewMatrix);
  18106. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
  18107. if (!_this._scene.useRightHandedSystem) {
  18108. _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
  18109. _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18110. }
  18111. // Update viewport
  18112. var viewport = xrSessionManager._xrSession.baseLayer.getViewport(view);
  18113. var width = xrSessionManager._xrSession.baseLayer.framebufferWidth;
  18114. var height = xrSessionManager._xrSession.baseLayer.framebufferHeight;
  18115. _this.rigCameras[i].viewport.width = viewport.width / width;
  18116. _this.rigCameras[i].viewport.height = viewport.height / height;
  18117. _this.rigCameras[i].viewport.x = viewport.x / width;
  18118. _this.rigCameras[i].viewport.y = viewport.y / height;
  18119. // Set cameras to render to the session's render target
  18120. _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
  18121. });
  18122. return true;
  18123. };
  18124. WebXRCamera._TmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  18125. return WebXRCamera;
  18126. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"]));
  18127. /***/ }),
  18128. /***/ "./Cameras/XR/webXREnterExitUI.ts":
  18129. /*!****************************************!*\
  18130. !*** ./Cameras/XR/webXREnterExitUI.ts ***!
  18131. \****************************************/
  18132. /*! exports provided: WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI */
  18133. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18134. "use strict";
  18135. __webpack_require__.r(__webpack_exports__);
  18136. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return WebXREnterExitUIButton; });
  18137. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return WebXREnterExitUIOptions; });
  18138. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return WebXREnterExitUI; });
  18139. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18140. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18141. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18142. /**
  18143. * Button which can be used to enter a different mode of XR
  18144. */
  18145. var WebXREnterExitUIButton = /** @class */ (function () {
  18146. /**
  18147. * Creates a WebXREnterExitUIButton
  18148. * @param element button element
  18149. * @param initializationOptions XR initialization options for the button
  18150. */
  18151. function WebXREnterExitUIButton(
  18152. /** button element */
  18153. element,
  18154. /** XR initialization options for the button */
  18155. initializationOptions) {
  18156. this.element = element;
  18157. this.initializationOptions = initializationOptions;
  18158. }
  18159. /**
  18160. * Overwritable function which can be used to update the button's visuals when the state changes
  18161. * @param activeButton the current active button in the UI
  18162. */
  18163. WebXREnterExitUIButton.prototype.update = function (activeButton) {
  18164. };
  18165. return WebXREnterExitUIButton;
  18166. }());
  18167. /**
  18168. * Options to create the webXR UI
  18169. */
  18170. var WebXREnterExitUIOptions = /** @class */ (function () {
  18171. function WebXREnterExitUIOptions() {
  18172. }
  18173. return WebXREnterExitUIOptions;
  18174. }());
  18175. /**
  18176. * UI to allow the user to enter/exit XR mode
  18177. */
  18178. var WebXREnterExitUI = /** @class */ (function () {
  18179. function WebXREnterExitUI(scene, options) {
  18180. var _this = this;
  18181. this.scene = scene;
  18182. this._buttons = [];
  18183. this._activeButton = null;
  18184. /**
  18185. * Fired every time the active button is changed.
  18186. *
  18187. * When xr is entered via a button that launches xr that button will be the callback parameter
  18188. *
  18189. * When exiting xr the callback parameter will be null)
  18190. */
  18191. this.activeButtonChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18192. this._overlay = document.createElement("div");
  18193. this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
  18194. if (options.customButtons) {
  18195. this._buttons = options.customButtons;
  18196. }
  18197. else {
  18198. var hmdBtn = document.createElement("button");
  18199. 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;";
  18200. hmdBtn.innerText = "HMD";
  18201. this._buttons.push(new WebXREnterExitUIButton(hmdBtn, { immersive: true, outputContext: options.outputCanvasContext }));
  18202. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18203. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18204. this.element.innerText = activeButton === this ? "EXIT" : "HMD";
  18205. };
  18206. var windowBtn = document.createElement("button");
  18207. windowBtn.style.cssText = hmdBtn.style.cssText;
  18208. windowBtn.innerText = "Window";
  18209. this._buttons.push(new WebXREnterExitUIButton(windowBtn, { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext }));
  18210. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18211. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18212. this.element.innerText = activeButton === this ? "EXIT" : "Window";
  18213. };
  18214. this._updateButtons(null);
  18215. }
  18216. var renderCanvas = scene.getEngine().getRenderingCanvas();
  18217. if (renderCanvas && renderCanvas.parentNode) {
  18218. renderCanvas.parentNode.appendChild(this._overlay);
  18219. scene.onDisposeObservable.addOnce(function () {
  18220. _this.dispose();
  18221. });
  18222. }
  18223. }
  18224. /**
  18225. * Creates UI to allow the user to enter/exit XR mode
  18226. * @param scene the scene to add the ui to
  18227. * @param helper the xr experience helper to enter/exit xr with
  18228. * @param options options to configure the UI
  18229. * @returns the created ui
  18230. */
  18231. WebXREnterExitUI.CreateAsync = function (scene, helper, options) {
  18232. var _this = this;
  18233. var ui = new WebXREnterExitUI(scene, options);
  18234. var supportedPromises = ui._buttons.map(function (btn) {
  18235. return helper.supportsSessionAsync(btn.initializationOptions);
  18236. });
  18237. helper.onStateChangedObservable.add(function (state) {
  18238. if (state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR) {
  18239. ui._updateButtons(null);
  18240. }
  18241. });
  18242. return Promise.all(supportedPromises).then(function (results) {
  18243. results.forEach(function (supported, i) {
  18244. if (supported) {
  18245. ui._overlay.appendChild(ui._buttons[i].element);
  18246. ui._buttons[i].element.onclick = function () { return tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"](_this, void 0, void 0, function () {
  18247. return tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"](this, function (_a) {
  18248. switch (_a.label) {
  18249. case 0:
  18250. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].IN_XR)) return [3 /*break*/, 2];
  18251. ui._updateButtons(null);
  18252. return [4 /*yield*/, helper.exitXRAsync()];
  18253. case 1:
  18254. _a.sent();
  18255. return [2 /*return*/];
  18256. case 2:
  18257. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR)) return [3 /*break*/, 4];
  18258. ui._updateButtons(ui._buttons[i]);
  18259. return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].initializationOptions, "eye-level")];
  18260. case 3:
  18261. _a.sent();
  18262. _a.label = 4;
  18263. case 4: return [2 /*return*/];
  18264. }
  18265. });
  18266. }); };
  18267. }
  18268. });
  18269. return ui;
  18270. });
  18271. };
  18272. WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
  18273. var _this = this;
  18274. this._activeButton = activeButton;
  18275. this._buttons.forEach(function (b) {
  18276. b.update(_this._activeButton);
  18277. });
  18278. this.activeButtonChangedObservable.notifyObservers(this._activeButton);
  18279. };
  18280. /**
  18281. * Disposes of the object
  18282. */
  18283. WebXREnterExitUI.prototype.dispose = function () {
  18284. var renderCanvas = this.scene.getEngine().getRenderingCanvas();
  18285. if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
  18286. renderCanvas.parentNode.removeChild(this._overlay);
  18287. }
  18288. this.activeButtonChangedObservable.clear();
  18289. };
  18290. return WebXREnterExitUI;
  18291. }());
  18292. /***/ }),
  18293. /***/ "./Cameras/XR/webXRExperienceHelper.ts":
  18294. /*!*********************************************!*\
  18295. !*** ./Cameras/XR/webXRExperienceHelper.ts ***!
  18296. \*********************************************/
  18297. /*! exports provided: WebXRState, WebXRExperienceHelper */
  18298. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18299. "use strict";
  18300. __webpack_require__.r(__webpack_exports__);
  18301. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return WebXRState; });
  18302. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return WebXRExperienceHelper; });
  18303. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18304. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18305. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18306. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18307. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18308. /**
  18309. * States of the webXR experience
  18310. */
  18311. var WebXRState;
  18312. (function (WebXRState) {
  18313. /**
  18314. * Transitioning to being in XR mode
  18315. */
  18316. WebXRState[WebXRState["ENTERING_XR"] = 0] = "ENTERING_XR";
  18317. /**
  18318. * Transitioning to non XR mode
  18319. */
  18320. WebXRState[WebXRState["EXITING_XR"] = 1] = "EXITING_XR";
  18321. /**
  18322. * In XR mode and presenting
  18323. */
  18324. WebXRState[WebXRState["IN_XR"] = 2] = "IN_XR";
  18325. /**
  18326. * Not entered XR mode
  18327. */
  18328. WebXRState[WebXRState["NOT_IN_XR"] = 3] = "NOT_IN_XR";
  18329. })(WebXRState || (WebXRState = {}));
  18330. /**
  18331. * Helper class used to enable XR
  18332. * @see https://doc.babylonjs.com/how_to/webxr
  18333. */
  18334. var WebXRExperienceHelper = /** @class */ (function () {
  18335. /**
  18336. * Creates a WebXRExperienceHelper
  18337. * @param scene The scene the helper should be created in
  18338. */
  18339. function WebXRExperienceHelper(scene) {
  18340. this.scene = scene;
  18341. /**
  18342. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  18343. */
  18344. this.state = WebXRState.NOT_IN_XR;
  18345. /**
  18346. * Fires when the state of the experience helper has changed
  18347. */
  18348. this.onStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  18349. this._nonVRCamera = null;
  18350. this._originalSceneAutoClear = true;
  18351. this._supported = false;
  18352. this.camera = new _webXRCamera__WEBPACK_IMPORTED_MODULE_4__["WebXRCamera"]("", scene);
  18353. this._sessionManager = new _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__["WebXRSessionManager"](scene);
  18354. this.container = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", scene);
  18355. this.camera.parent = this.container;
  18356. }
  18357. WebXRExperienceHelper.prototype._setState = function (val) {
  18358. this.state = val;
  18359. this.onStateChangedObservable.notifyObservers(this.state);
  18360. };
  18361. /**
  18362. * Creates the experience helper
  18363. * @param scene the scene to attach the experience helper to
  18364. * @returns a promise for the experience helper
  18365. */
  18366. WebXRExperienceHelper.CreateAsync = function (scene) {
  18367. var helper = new WebXRExperienceHelper(scene);
  18368. return helper._sessionManager.initializeAsync().then(function () {
  18369. helper._supported = true;
  18370. return helper;
  18371. }).catch(function () {
  18372. return helper;
  18373. });
  18374. };
  18375. /**
  18376. * Exits XR mode and returns the scene to its original state
  18377. * @returns promise that resolves after xr mode has exited
  18378. */
  18379. WebXRExperienceHelper.prototype.exitXRAsync = function () {
  18380. this._setState(WebXRState.EXITING_XR);
  18381. return this._sessionManager.exitXRAsync();
  18382. };
  18383. /**
  18384. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  18385. * @param sessionCreationOptions options for the XR session
  18386. * @param frameOfReference frame of reference of the XR session
  18387. * @returns promise that resolves after xr mode has entered
  18388. */
  18389. WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReference) {
  18390. var _this = this;
  18391. if (!this._supported) {
  18392. throw "XR session not supported by this browser";
  18393. }
  18394. this._setState(WebXRState.ENTERING_XR);
  18395. return this._sessionManager.enterXRAsync(sessionCreationOptions, frameOfReference).then(function () {
  18396. // Cache pre xr scene settings
  18397. _this._originalSceneAutoClear = _this.scene.autoClear;
  18398. _this._nonVRCamera = _this.scene.activeCamera;
  18399. // Overwrite current scene settings
  18400. _this.scene.autoClear = false;
  18401. _this.scene.activeCamera = _this.camera;
  18402. _this._sessionManager.onXRFrameObservable.add(function () {
  18403. _this.camera.updateFromXRSessionManager(_this._sessionManager);
  18404. });
  18405. _this._sessionManager.onXRSessionEnded.addOnce(function () {
  18406. // Reset camera rigs output render target to ensure sessions render target is not drawn after it ends
  18407. _this.camera.rigCameras.forEach(function (c) {
  18408. c.outputRenderTarget = null;
  18409. });
  18410. // Restore scene settings
  18411. _this.scene.autoClear = _this._originalSceneAutoClear;
  18412. _this.scene.activeCamera = _this._nonVRCamera;
  18413. _this._sessionManager.onXRFrameObservable.clear();
  18414. _this._setState(WebXRState.NOT_IN_XR);
  18415. });
  18416. _this._setState(WebXRState.IN_XR);
  18417. });
  18418. };
  18419. /**
  18420. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18421. * @param ray ray to cast into the environment
  18422. * @returns Promise which resolves with a collision point in the environment if it exists
  18423. */
  18424. WebXRExperienceHelper.prototype.environmentPointHitTestAsync = function (ray) {
  18425. return this._sessionManager.environmentPointHitTestAsync(ray);
  18426. };
  18427. /**
  18428. * Updates the global position of the camera by moving the camera's container
  18429. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  18430. * @param position The desired global position of the camera
  18431. */
  18432. WebXRExperienceHelper.prototype.setPositionOfCameraUsingContainer = function (position) {
  18433. this.camera.globalPosition.subtractToRef(position, WebXRExperienceHelper._TmpVector);
  18434. this.container.position.subtractInPlace(WebXRExperienceHelper._TmpVector);
  18435. };
  18436. /**
  18437. * Rotates the xr camera by rotating the camera's container around the camera's position
  18438. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  18439. * @param rotation the desired quaternion rotation to apply to the camera
  18440. */
  18441. WebXRExperienceHelper.prototype.rotateCameraByQuaternionUsingContainer = function (rotation) {
  18442. if (!this.container.rotationQuaternion) {
  18443. this.container.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromEulerVector(this.container.rotation);
  18444. }
  18445. this.container.rotationQuaternion.multiplyInPlace(rotation);
  18446. this.container.position.rotateByQuaternionAroundPointToRef(rotation, this.camera.globalPosition, this.container.position);
  18447. };
  18448. /**
  18449. * Checks if the creation options are supported by the xr session
  18450. * @param options creation options
  18451. * @returns true if supported
  18452. */
  18453. WebXRExperienceHelper.prototype.supportsSessionAsync = function (options) {
  18454. if (!this._supported) {
  18455. return Promise.resolve(false);
  18456. }
  18457. return this._sessionManager.supportsSessionAsync(options);
  18458. };
  18459. /**
  18460. * Disposes of the experience helper
  18461. */
  18462. WebXRExperienceHelper.prototype.dispose = function () {
  18463. this.camera.dispose();
  18464. this.container.dispose();
  18465. this.onStateChangedObservable.clear();
  18466. this._sessionManager.dispose();
  18467. };
  18468. WebXRExperienceHelper._TmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  18469. return WebXRExperienceHelper;
  18470. }());
  18471. /***/ }),
  18472. /***/ "./Cameras/XR/webXRInput.ts":
  18473. /*!**********************************!*\
  18474. !*** ./Cameras/XR/webXRInput.ts ***!
  18475. \**********************************/
  18476. /*! exports provided: WebXRController, WebXRInput */
  18477. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18478. "use strict";
  18479. __webpack_require__.r(__webpack_exports__);
  18480. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return WebXRController; });
  18481. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return WebXRInput; });
  18482. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18483. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18484. /**
  18485. * Represents an XR input
  18486. */
  18487. var WebXRController = /** @class */ (function () {
  18488. /**
  18489. * Creates the controller
  18490. * @see https://doc.babylonjs.com/how_to/webxr
  18491. * @param scene the scene which the controller should be associated to
  18492. */
  18493. function WebXRController(scene) {
  18494. this.pointer = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerPointer", scene);
  18495. }
  18496. /**
  18497. * Disposes of the object
  18498. */
  18499. WebXRController.prototype.dispose = function () {
  18500. if (this.grip) {
  18501. this.grip.dispose();
  18502. }
  18503. this.pointer.dispose();
  18504. };
  18505. return WebXRController;
  18506. }());
  18507. /**
  18508. * XR input used to track XR inputs such as controllers/rays
  18509. */
  18510. var WebXRInput = /** @class */ (function () {
  18511. /**
  18512. * Initializes the WebXRInput
  18513. * @param helper experience helper which the input should be created for
  18514. */
  18515. function WebXRInput(helper) {
  18516. var _this = this;
  18517. this.helper = helper;
  18518. /**
  18519. * XR controllers being tracked
  18520. */
  18521. this.controllers = [];
  18522. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  18523. this._frameObserver = helper._sessionManager.onXRFrameObservable.add(function () {
  18524. if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
  18525. return;
  18526. }
  18527. var xrFrame = helper._sessionManager._currentXRFrame;
  18528. var inputSources = helper._sessionManager._xrSession.getInputSources();
  18529. inputSources.forEach(function (input, i) {
  18530. var inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
  18531. if (inputPose) {
  18532. if (_this.controllers.length <= i) {
  18533. _this.controllers.push(new WebXRController(helper.container.getScene()));
  18534. }
  18535. var controller = _this.controllers[i];
  18536. // Manage the grip if it exists
  18537. if (inputPose.gripMatrix) {
  18538. if (!controller.grip) {
  18539. controller.grip = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerGrip", helper.container.getScene());
  18540. }
  18541. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, _this._tmpMatrix);
  18542. if (!controller.grip.getScene().useRightHandedSystem) {
  18543. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18544. }
  18545. if (!controller.grip.rotationQuaternion) {
  18546. controller.grip.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18547. }
  18548. _this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
  18549. }
  18550. // Manager pointer of controller
  18551. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, _this._tmpMatrix);
  18552. if (!controller.pointer.getScene().useRightHandedSystem) {
  18553. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18554. }
  18555. if (!controller.pointer.rotationQuaternion) {
  18556. controller.pointer.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18557. }
  18558. _this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
  18559. }
  18560. });
  18561. });
  18562. }
  18563. /**
  18564. * Disposes of the object
  18565. */
  18566. WebXRInput.prototype.dispose = function () {
  18567. this.controllers.forEach(function (c) {
  18568. c.dispose();
  18569. });
  18570. this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
  18571. };
  18572. return WebXRInput;
  18573. }());
  18574. /***/ }),
  18575. /***/ "./Cameras/XR/webXRManagedOutputCanvas.ts":
  18576. /*!************************************************!*\
  18577. !*** ./Cameras/XR/webXRManagedOutputCanvas.ts ***!
  18578. \************************************************/
  18579. /*! exports provided: WebXRManagedOutputCanvas */
  18580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18581. "use strict";
  18582. __webpack_require__.r(__webpack_exports__);
  18583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return WebXRManagedOutputCanvas; });
  18584. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18585. /**
  18586. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  18587. */
  18588. var WebXRManagedOutputCanvas = /** @class */ (function () {
  18589. /**
  18590. * Initializes the canvas to be added/removed upon entering/exiting xr
  18591. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  18592. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  18593. */
  18594. function WebXRManagedOutputCanvas(helper, canvas) {
  18595. var _this = this;
  18596. this._canvas = null;
  18597. /**
  18598. * xrpresent context of the canvas which can be used to display/mirror xr content
  18599. */
  18600. this.canvasContext = null;
  18601. if (!canvas) {
  18602. canvas = document.createElement('canvas');
  18603. canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;";
  18604. }
  18605. this._setManagedOutputCanvas(canvas);
  18606. helper.onStateChangedObservable.add(function (stateInfo) {
  18607. if (stateInfo == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].ENTERING_XR) {
  18608. // 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
  18609. _this._addCanvas();
  18610. }
  18611. else if (helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].NOT_IN_XR) {
  18612. _this._removeCanvas();
  18613. }
  18614. });
  18615. }
  18616. /**
  18617. * Disposes of the object
  18618. */
  18619. WebXRManagedOutputCanvas.prototype.dispose = function () {
  18620. this._removeCanvas();
  18621. this._setManagedOutputCanvas(null);
  18622. };
  18623. WebXRManagedOutputCanvas.prototype._setManagedOutputCanvas = function (canvas) {
  18624. this._removeCanvas();
  18625. if (!canvas) {
  18626. this._canvas = null;
  18627. this.canvasContext = null;
  18628. }
  18629. else {
  18630. this._canvas = canvas;
  18631. this.canvasContext = this._canvas.getContext('xrpresent');
  18632. }
  18633. };
  18634. WebXRManagedOutputCanvas.prototype._addCanvas = function () {
  18635. if (this._canvas) {
  18636. document.body.appendChild(this._canvas);
  18637. }
  18638. };
  18639. WebXRManagedOutputCanvas.prototype._removeCanvas = function () {
  18640. if (this._canvas && document.body.contains(this._canvas)) {
  18641. document.body.removeChild(this._canvas);
  18642. }
  18643. };
  18644. return WebXRManagedOutputCanvas;
  18645. }());
  18646. /***/ }),
  18647. /***/ "./Cameras/XR/webXRSessionManager.ts":
  18648. /*!*******************************************!*\
  18649. !*** ./Cameras/XR/webXRSessionManager.ts ***!
  18650. \*******************************************/
  18651. /*! exports provided: WebXRSessionManager */
  18652. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18653. "use strict";
  18654. __webpack_require__.r(__webpack_exports__);
  18655. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return WebXRSessionManager; });
  18656. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  18657. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18658. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18659. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  18660. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  18661. /**
  18662. * Manages an XRSession
  18663. * @see https://doc.babylonjs.com/how_to/webxr
  18664. */
  18665. var WebXRSessionManager = /** @class */ (function () {
  18666. /**
  18667. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  18668. * @param scene The scene which the session should be created for
  18669. */
  18670. function WebXRSessionManager(scene) {
  18671. this.scene = scene;
  18672. /**
  18673. * Fires every time a new xrFrame arrives which can be used to update the camera
  18674. */
  18675. this.onXRFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18676. /**
  18677. * Fires when the xr session is ended either by the device or manually done
  18678. */
  18679. this.onXRSessionEnded = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18680. /** @hidden */
  18681. this._sessionRenderTargetTexture = null;
  18682. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  18683. }
  18684. /**
  18685. * Initializes the manager
  18686. * After initialization enterXR can be called to start an XR session
  18687. * @returns Promise which resolves after it is initialized
  18688. */
  18689. WebXRSessionManager.prototype.initializeAsync = function () {
  18690. var _this = this;
  18691. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The WebXR APIs are still under development and are subject to change in the future.");
  18692. // Check if the browser supports webXR
  18693. this._xrNavigator = navigator;
  18694. if (!this._xrNavigator.xr) {
  18695. return Promise.reject("webXR not supported by this browser");
  18696. }
  18697. // Request the webXR device
  18698. return this._xrNavigator.xr.requestDevice().then(function (device) {
  18699. _this._xrDevice = device;
  18700. return _this.scene.getEngine()._gl.setCompatibleXRDevice(_this._xrDevice);
  18701. });
  18702. };
  18703. /**
  18704. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  18705. * @param sessionCreationOptions xr options to create the session with
  18706. * @param frameOfReferenceType option to configure how the xr pose is expressed
  18707. * @returns Promise which resolves after it enters XR
  18708. */
  18709. WebXRSessionManager.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReferenceType) {
  18710. var _this = this;
  18711. // initialize session
  18712. return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
  18713. _this._xrSession = session;
  18714. // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
  18715. _this._xrSession.addEventListener("end", function () {
  18716. // Remove render target texture and notify frame obervers
  18717. _this._sessionRenderTargetTexture = null;
  18718. // Restore frame buffer to avoid clear on xr framebuffer after session end
  18719. _this.scene.getEngine().restoreDefaultFramebuffer();
  18720. // Need to restart render loop as after the session is ended the last request for new frame will never call callback
  18721. _this.scene.getEngine().customAnimationFrameRequester = null;
  18722. _this.onXRSessionEnded.notifyObservers(null);
  18723. _this.scene.getEngine()._renderLoop();
  18724. }, { once: true });
  18725. _this._xrSession.baseLayer = new XRWebGLLayer(_this._xrSession, _this.scene.getEngine()._gl);
  18726. return _this._xrSession.requestFrameOfReference(frameOfReferenceType);
  18727. }).then(function (frameOfRef) {
  18728. _this._frameOfReference = frameOfRef;
  18729. // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
  18730. _this.scene.getEngine().customAnimationFrameRequester = {
  18731. requestAnimationFrame: _this._xrSession.requestAnimationFrame.bind(_this._xrSession),
  18732. renderFunction: function (timestamp, xrFrame) {
  18733. // Store the XR frame in the manager to be consumed by the XR camera to update pose
  18734. _this._currentXRFrame = xrFrame;
  18735. _this.onXRFrameObservable.notifyObservers(null);
  18736. _this.scene.getEngine()._renderLoop();
  18737. }
  18738. };
  18739. // Create render target texture from xr's webgl render target
  18740. _this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(_this._xrSession, _this.scene);
  18741. // Stop window's animation frame and trigger sessions animation frame
  18742. window.cancelAnimationFrame(_this.scene.getEngine()._frameHandler);
  18743. _this.scene.getEngine()._renderLoop();
  18744. });
  18745. };
  18746. /**
  18747. * Stops the xrSession and restores the renderloop
  18748. * @returns Promise which resolves after it exits XR
  18749. */
  18750. WebXRSessionManager.prototype.exitXRAsync = function () {
  18751. return this._xrSession.end();
  18752. };
  18753. /**
  18754. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18755. * @param ray ray to cast into the environment
  18756. * @returns Promise which resolves with a collision point in the environment if it exists
  18757. */
  18758. WebXRSessionManager.prototype.environmentPointHitTestAsync = function (ray) {
  18759. var _this = this;
  18760. return new Promise(function (res) {
  18761. // Compute left handed inputs to request hit test
  18762. var origin = new Float32Array([ray.origin.x, ray.origin.y, ray.origin.z]);
  18763. var direction = new Float32Array([ray.direction.x, ray.direction.y, ray.direction.z]);
  18764. if (!_this.scene.useRightHandedSystem) {
  18765. origin[2] *= -1;
  18766. direction[2] *= -1;
  18767. }
  18768. // Fire hittest
  18769. _this._xrSession.requestHitTest(origin, direction, _this._frameOfReference)
  18770. .then(function (hits) {
  18771. if (hits.length > 0) {
  18772. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(hits[0].hitMatrix, 0, 1.0, _this._tmpMatrix);
  18773. var hitPoint = _this._tmpMatrix.getTranslation();
  18774. if (!_this.scene.useRightHandedSystem) {
  18775. hitPoint.z *= -1;
  18776. }
  18777. res(hitPoint);
  18778. }
  18779. else {
  18780. res(null);
  18781. }
  18782. }).catch(function () {
  18783. res(null);
  18784. });
  18785. });
  18786. };
  18787. /**
  18788. * Checks if a session would be supported for the creation options specified
  18789. * @param options creation options to check if they are supported
  18790. * @returns true if supported
  18791. */
  18792. WebXRSessionManager.prototype.supportsSessionAsync = function (options) {
  18793. return this._xrDevice.supportsSession(options).then(function () {
  18794. return true;
  18795. }).catch(function () {
  18796. return false;
  18797. });
  18798. };
  18799. /**
  18800. * @hidden
  18801. * Converts the render layer of xrSession to a render target
  18802. * @param session session to create render target for
  18803. * @param scene scene the new render target should be created for
  18804. */
  18805. WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene) {
  18806. // Create internal texture
  18807. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](scene.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  18808. internalTexture.width = session.baseLayer.framebufferWidth;
  18809. internalTexture.height = session.baseLayer.framebufferHeight;
  18810. internalTexture._framebuffer = session.baseLayer.framebuffer;
  18811. // Create render target texture from the internal texture
  18812. 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);
  18813. renderTargetTexture._texture = internalTexture;
  18814. return renderTargetTexture;
  18815. };
  18816. /**
  18817. * Disposes of the session manager
  18818. */
  18819. WebXRSessionManager.prototype.dispose = function () {
  18820. this.onXRFrameObservable.clear();
  18821. this.onXRSessionEnded.clear();
  18822. };
  18823. return WebXRSessionManager;
  18824. }());
  18825. /***/ }),
  18826. /***/ "./Cameras/arcRotateCamera.ts":
  18827. /*!************************************!*\
  18828. !*** ./Cameras/arcRotateCamera.ts ***!
  18829. \************************************/
  18830. /*! exports provided: ArcRotateCamera */
  18831. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18832. "use strict";
  18833. __webpack_require__.r(__webpack_exports__);
  18834. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return ArcRotateCamera; });
  18835. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18836. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  18837. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  18838. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  18839. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  18840. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  18841. /* harmony import */ var _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Cameras/autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  18842. /* harmony import */ var _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Cameras/bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  18843. /* harmony import */ var _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Behaviors/Cameras/framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  18844. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  18845. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  18846. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  18847. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("ArcRotateCamera", function (name, scene) {
  18848. return function () { return new ArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  18849. });
  18850. /**
  18851. * This represents an orbital type of camera.
  18852. *
  18853. * 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.
  18854. * 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.
  18855. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  18856. */
  18857. var ArcRotateCamera = /** @class */ (function (_super) {
  18858. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCamera, _super);
  18859. /**
  18860. * Instantiates a new ArcRotateCamera in a given scene
  18861. * @param name Defines the name of the camera
  18862. * @param alpha Defines the camera rotation along the logitudinal axis
  18863. * @param beta Defines the camera rotation along the latitudinal axis
  18864. * @param radius Defines the camera distance from its target
  18865. * @param target Defines the camera target
  18866. * @param scene Defines the scene the camera belongs to
  18867. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18868. */
  18869. function ArcRotateCamera(name, alpha, beta, radius, target, scene, setActiveOnSceneIfNoneActive) {
  18870. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  18871. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene, setActiveOnSceneIfNoneActive) || this;
  18872. /**
  18873. * Current inertia value on the longitudinal axis.
  18874. * The bigger this number the longer it will take for the camera to stop.
  18875. */
  18876. _this.inertialAlphaOffset = 0;
  18877. /**
  18878. * Current inertia value on the latitudinal axis.
  18879. * The bigger this number the longer it will take for the camera to stop.
  18880. */
  18881. _this.inertialBetaOffset = 0;
  18882. /**
  18883. * Current inertia value on the radius axis.
  18884. * The bigger this number the longer it will take for the camera to stop.
  18885. */
  18886. _this.inertialRadiusOffset = 0;
  18887. /**
  18888. * Minimum allowed angle on the longitudinal axis.
  18889. * This can help limiting how the Camera is able to move in the scene.
  18890. */
  18891. _this.lowerAlphaLimit = null;
  18892. /**
  18893. * Maximum allowed angle on the longitudinal axis.
  18894. * This can help limiting how the Camera is able to move in the scene.
  18895. */
  18896. _this.upperAlphaLimit = null;
  18897. /**
  18898. * Minimum allowed angle on the latitudinal axis.
  18899. * This can help limiting how the Camera is able to move in the scene.
  18900. */
  18901. _this.lowerBetaLimit = 0.01;
  18902. /**
  18903. * Maximum allowed angle on the latitudinal axis.
  18904. * This can help limiting how the Camera is able to move in the scene.
  18905. */
  18906. _this.upperBetaLimit = Math.PI - 0.01;
  18907. /**
  18908. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  18909. * This can help limiting how the Camera is able to move in the scene.
  18910. */
  18911. _this.lowerRadiusLimit = null;
  18912. /**
  18913. * Maximum allowed distance of the camera to the target (The camera can not get further).
  18914. * This can help limiting how the Camera is able to move in the scene.
  18915. */
  18916. _this.upperRadiusLimit = null;
  18917. /**
  18918. * Defines the current inertia value used during panning of the camera along the X axis.
  18919. */
  18920. _this.inertialPanningX = 0;
  18921. /**
  18922. * Defines the current inertia value used during panning of the camera along the Y axis.
  18923. */
  18924. _this.inertialPanningY = 0;
  18925. /**
  18926. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  18927. * Basically if your fingers moves away from more than this distance you will be considered
  18928. * in pinch mode.
  18929. */
  18930. _this.pinchToPanMaxDistance = 20;
  18931. /**
  18932. * Defines the maximum distance the camera can pan.
  18933. * This could help keeping the cammera always in your scene.
  18934. */
  18935. _this.panningDistanceLimit = null;
  18936. /**
  18937. * Defines the target of the camera before paning.
  18938. */
  18939. _this.panningOriginTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18940. /**
  18941. * Defines the value of the inertia used during panning.
  18942. * 0 would mean stop inertia and one would mean no decelleration at all.
  18943. */
  18944. _this.panningInertia = 0.9;
  18945. //-- end properties for backward compatibility for inputs
  18946. /**
  18947. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  18948. */
  18949. _this.zoomOnFactor = 1;
  18950. /**
  18951. * Defines a screen offset for the camera position.
  18952. */
  18953. _this.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  18954. /**
  18955. * Allows the camera to be completely reversed.
  18956. * If false the camera can not arrive upside down.
  18957. */
  18958. _this.allowUpsideDown = true;
  18959. /**
  18960. * Define if double tap/click is used to restore the previously saved state of the camera.
  18961. */
  18962. _this.useInputToRestoreState = true;
  18963. /** @hidden */
  18964. _this._viewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  18965. /**
  18966. * Defines the allowed panning axis.
  18967. */
  18968. _this.panningAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 0);
  18969. /**
  18970. * Observable triggered when the mesh target has been changed on the camera.
  18971. */
  18972. _this.onMeshTargetChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  18973. /**
  18974. * Defines whether the camera should check collision with the objects oh the scene.
  18975. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  18976. */
  18977. _this.checkCollisions = false;
  18978. /**
  18979. * Defines the collision radius of the camera.
  18980. * This simulates a sphere around the camera.
  18981. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18982. */
  18983. _this.collisionRadius = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 0.5, 0.5);
  18984. _this._previousPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18985. _this._collisionVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18986. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18987. _this._computationVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18988. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  18989. if (collidedMesh === void 0) { collidedMesh = null; }
  18990. if (!collidedMesh) {
  18991. _this._previousPosition.copyFrom(_this.position);
  18992. }
  18993. else {
  18994. _this.setPosition(newPosition);
  18995. if (_this.onCollide) {
  18996. _this.onCollide(collidedMesh);
  18997. }
  18998. }
  18999. // Recompute because of constraints
  19000. var cosa = Math.cos(_this.alpha);
  19001. var sina = Math.sin(_this.alpha);
  19002. var cosb = Math.cos(_this.beta);
  19003. var sinb = Math.sin(_this.beta);
  19004. if (sinb === 0) {
  19005. sinb = 0.0001;
  19006. }
  19007. var target = _this._getTargetPosition();
  19008. _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
  19009. target.addToRef(_this._computationVector, _this._newPosition);
  19010. _this.position.copyFrom(_this._newPosition);
  19011. var up = _this.upVector;
  19012. if (_this.allowUpsideDown && _this.beta < 0) {
  19013. up = up.clone();
  19014. up = up.negate();
  19015. }
  19016. _this._computeViewMatrix(_this.position, target, up);
  19017. _this._viewMatrix.addAtIndex(12, _this.targetScreenOffset.x);
  19018. _this._viewMatrix.addAtIndex(13, _this.targetScreenOffset.y);
  19019. _this._collisionTriggered = false;
  19020. };
  19021. _this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19022. if (target) {
  19023. _this.setTarget(target);
  19024. }
  19025. _this.alpha = alpha;
  19026. _this.beta = beta;
  19027. _this.radius = radius;
  19028. _this.getViewMatrix();
  19029. _this.inputs = new _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["ArcRotateCameraInputsManager"](_this);
  19030. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  19031. return _this;
  19032. }
  19033. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  19034. /**
  19035. * Defines the target point of the camera.
  19036. * The camera looks towards it form the radius distance.
  19037. */
  19038. get: function () {
  19039. return this._target;
  19040. },
  19041. set: function (value) {
  19042. this.setTarget(value);
  19043. },
  19044. enumerable: true,
  19045. configurable: true
  19046. });
  19047. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  19048. //-- begin properties for backward compatibility for inputs
  19049. /**
  19050. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  19051. */
  19052. get: function () {
  19053. var pointers = this.inputs.attached["pointers"];
  19054. if (pointers) {
  19055. return pointers.angularSensibilityX;
  19056. }
  19057. return 0;
  19058. },
  19059. set: function (value) {
  19060. var pointers = this.inputs.attached["pointers"];
  19061. if (pointers) {
  19062. pointers.angularSensibilityX = value;
  19063. }
  19064. },
  19065. enumerable: true,
  19066. configurable: true
  19067. });
  19068. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  19069. /**
  19070. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  19071. */
  19072. get: function () {
  19073. var pointers = this.inputs.attached["pointers"];
  19074. if (pointers) {
  19075. return pointers.angularSensibilityY;
  19076. }
  19077. return 0;
  19078. },
  19079. set: function (value) {
  19080. var pointers = this.inputs.attached["pointers"];
  19081. if (pointers) {
  19082. pointers.angularSensibilityY = value;
  19083. }
  19084. },
  19085. enumerable: true,
  19086. configurable: true
  19087. });
  19088. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  19089. /**
  19090. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  19091. */
  19092. get: function () {
  19093. var pointers = this.inputs.attached["pointers"];
  19094. if (pointers) {
  19095. return pointers.pinchPrecision;
  19096. }
  19097. return 0;
  19098. },
  19099. set: function (value) {
  19100. var pointers = this.inputs.attached["pointers"];
  19101. if (pointers) {
  19102. pointers.pinchPrecision = value;
  19103. }
  19104. },
  19105. enumerable: true,
  19106. configurable: true
  19107. });
  19108. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  19109. /**
  19110. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  19111. * It will be used instead of pinchDeltaPrecision if different from 0.
  19112. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19113. */
  19114. get: function () {
  19115. var pointers = this.inputs.attached["pointers"];
  19116. if (pointers) {
  19117. return pointers.pinchDeltaPercentage;
  19118. }
  19119. return 0;
  19120. },
  19121. set: function (value) {
  19122. var pointers = this.inputs.attached["pointers"];
  19123. if (pointers) {
  19124. pointers.pinchDeltaPercentage = value;
  19125. }
  19126. },
  19127. enumerable: true,
  19128. configurable: true
  19129. });
  19130. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  19131. /**
  19132. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  19133. */
  19134. get: function () {
  19135. var pointers = this.inputs.attached["pointers"];
  19136. if (pointers) {
  19137. return pointers.panningSensibility;
  19138. }
  19139. return 0;
  19140. },
  19141. set: function (value) {
  19142. var pointers = this.inputs.attached["pointers"];
  19143. if (pointers) {
  19144. pointers.panningSensibility = value;
  19145. }
  19146. },
  19147. enumerable: true,
  19148. configurable: true
  19149. });
  19150. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  19151. /**
  19152. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  19153. */
  19154. get: function () {
  19155. var keyboard = this.inputs.attached["keyboard"];
  19156. if (keyboard) {
  19157. return keyboard.keysUp;
  19158. }
  19159. return [];
  19160. },
  19161. set: function (value) {
  19162. var keyboard = this.inputs.attached["keyboard"];
  19163. if (keyboard) {
  19164. keyboard.keysUp = value;
  19165. }
  19166. },
  19167. enumerable: true,
  19168. configurable: true
  19169. });
  19170. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  19171. /**
  19172. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  19173. */
  19174. get: function () {
  19175. var keyboard = this.inputs.attached["keyboard"];
  19176. if (keyboard) {
  19177. return keyboard.keysDown;
  19178. }
  19179. return [];
  19180. },
  19181. set: function (value) {
  19182. var keyboard = this.inputs.attached["keyboard"];
  19183. if (keyboard) {
  19184. keyboard.keysDown = value;
  19185. }
  19186. },
  19187. enumerable: true,
  19188. configurable: true
  19189. });
  19190. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  19191. /**
  19192. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  19193. */
  19194. get: function () {
  19195. var keyboard = this.inputs.attached["keyboard"];
  19196. if (keyboard) {
  19197. return keyboard.keysLeft;
  19198. }
  19199. return [];
  19200. },
  19201. set: function (value) {
  19202. var keyboard = this.inputs.attached["keyboard"];
  19203. if (keyboard) {
  19204. keyboard.keysLeft = value;
  19205. }
  19206. },
  19207. enumerable: true,
  19208. configurable: true
  19209. });
  19210. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  19211. /**
  19212. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  19213. */
  19214. get: function () {
  19215. var keyboard = this.inputs.attached["keyboard"];
  19216. if (keyboard) {
  19217. return keyboard.keysRight;
  19218. }
  19219. return [];
  19220. },
  19221. set: function (value) {
  19222. var keyboard = this.inputs.attached["keyboard"];
  19223. if (keyboard) {
  19224. keyboard.keysRight = value;
  19225. }
  19226. },
  19227. enumerable: true,
  19228. configurable: true
  19229. });
  19230. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  19231. /**
  19232. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  19233. */
  19234. get: function () {
  19235. var mousewheel = this.inputs.attached["mousewheel"];
  19236. if (mousewheel) {
  19237. return mousewheel.wheelPrecision;
  19238. }
  19239. return 0;
  19240. },
  19241. set: function (value) {
  19242. var mousewheel = this.inputs.attached["mousewheel"];
  19243. if (mousewheel) {
  19244. mousewheel.wheelPrecision = value;
  19245. }
  19246. },
  19247. enumerable: true,
  19248. configurable: true
  19249. });
  19250. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  19251. /**
  19252. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  19253. * It will be used instead of pinchDeltaPrecision if different from 0.
  19254. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19255. */
  19256. get: function () {
  19257. var mousewheel = this.inputs.attached["mousewheel"];
  19258. if (mousewheel) {
  19259. return mousewheel.wheelDeltaPercentage;
  19260. }
  19261. return 0;
  19262. },
  19263. set: function (value) {
  19264. var mousewheel = this.inputs.attached["mousewheel"];
  19265. if (mousewheel) {
  19266. mousewheel.wheelDeltaPercentage = value;
  19267. }
  19268. },
  19269. enumerable: true,
  19270. configurable: true
  19271. });
  19272. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  19273. /**
  19274. * Gets the bouncing behavior of the camera if it has been enabled.
  19275. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19276. */
  19277. get: function () {
  19278. return this._bouncingBehavior;
  19279. },
  19280. enumerable: true,
  19281. configurable: true
  19282. });
  19283. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  19284. /**
  19285. * Defines if the bouncing behavior of the camera is enabled on the camera.
  19286. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19287. */
  19288. get: function () {
  19289. return this._bouncingBehavior != null;
  19290. },
  19291. set: function (value) {
  19292. if (value === this.useBouncingBehavior) {
  19293. return;
  19294. }
  19295. if (value) {
  19296. this._bouncingBehavior = new _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__["BouncingBehavior"]();
  19297. this.addBehavior(this._bouncingBehavior);
  19298. }
  19299. else if (this._bouncingBehavior) {
  19300. this.removeBehavior(this._bouncingBehavior);
  19301. this._bouncingBehavior = null;
  19302. }
  19303. },
  19304. enumerable: true,
  19305. configurable: true
  19306. });
  19307. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  19308. /**
  19309. * Gets the framing behavior of the camera if it has been enabled.
  19310. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19311. */
  19312. get: function () {
  19313. return this._framingBehavior;
  19314. },
  19315. enumerable: true,
  19316. configurable: true
  19317. });
  19318. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  19319. /**
  19320. * Defines if the framing behavior of the camera is enabled on the camera.
  19321. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19322. */
  19323. get: function () {
  19324. return this._framingBehavior != null;
  19325. },
  19326. set: function (value) {
  19327. if (value === this.useFramingBehavior) {
  19328. return;
  19329. }
  19330. if (value) {
  19331. this._framingBehavior = new _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__["FramingBehavior"]();
  19332. this.addBehavior(this._framingBehavior);
  19333. }
  19334. else if (this._framingBehavior) {
  19335. this.removeBehavior(this._framingBehavior);
  19336. this._framingBehavior = null;
  19337. }
  19338. },
  19339. enumerable: true,
  19340. configurable: true
  19341. });
  19342. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  19343. /**
  19344. * Gets the auto rotation behavior of the camera if it has been enabled.
  19345. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19346. */
  19347. get: function () {
  19348. return this._autoRotationBehavior;
  19349. },
  19350. enumerable: true,
  19351. configurable: true
  19352. });
  19353. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  19354. /**
  19355. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  19356. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19357. */
  19358. get: function () {
  19359. return this._autoRotationBehavior != null;
  19360. },
  19361. set: function (value) {
  19362. if (value === this.useAutoRotationBehavior) {
  19363. return;
  19364. }
  19365. if (value) {
  19366. this._autoRotationBehavior = new _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__["AutoRotationBehavior"]();
  19367. this.addBehavior(this._autoRotationBehavior);
  19368. }
  19369. else if (this._autoRotationBehavior) {
  19370. this.removeBehavior(this._autoRotationBehavior);
  19371. this._autoRotationBehavior = null;
  19372. }
  19373. },
  19374. enumerable: true,
  19375. configurable: true
  19376. });
  19377. // Cache
  19378. /** @hidden */
  19379. ArcRotateCamera.prototype._initCache = function () {
  19380. _super.prototype._initCache.call(this);
  19381. this._cache._target = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19382. this._cache.alpha = undefined;
  19383. this._cache.beta = undefined;
  19384. this._cache.radius = undefined;
  19385. this._cache.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19386. };
  19387. /** @hidden */
  19388. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  19389. if (!ignoreParentClass) {
  19390. _super.prototype._updateCache.call(this);
  19391. }
  19392. this._cache._target.copyFrom(this._getTargetPosition());
  19393. this._cache.alpha = this.alpha;
  19394. this._cache.beta = this.beta;
  19395. this._cache.radius = this.radius;
  19396. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  19397. };
  19398. ArcRotateCamera.prototype._getTargetPosition = function () {
  19399. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  19400. var pos = this._targetHost.absolutePosition;
  19401. if (this._targetBoundingCenter) {
  19402. pos.addToRef(this._targetBoundingCenter, this._target);
  19403. }
  19404. else {
  19405. this._target.copyFrom(pos);
  19406. }
  19407. }
  19408. var lockedTargetPosition = this._getLockedTargetPosition();
  19409. if (lockedTargetPosition) {
  19410. return lockedTargetPosition;
  19411. }
  19412. return this._target;
  19413. };
  19414. /**
  19415. * Stores the current state of the camera (alpha, beta, radius and target)
  19416. * @returns the camera itself
  19417. */
  19418. ArcRotateCamera.prototype.storeState = function () {
  19419. this._storedAlpha = this.alpha;
  19420. this._storedBeta = this.beta;
  19421. this._storedRadius = this.radius;
  19422. this._storedTarget = this._getTargetPosition().clone();
  19423. return _super.prototype.storeState.call(this);
  19424. };
  19425. /**
  19426. * @hidden
  19427. * Restored camera state. You must call storeState() first
  19428. */
  19429. ArcRotateCamera.prototype._restoreStateValues = function () {
  19430. if (!_super.prototype._restoreStateValues.call(this)) {
  19431. return false;
  19432. }
  19433. this.alpha = this._storedAlpha;
  19434. this.beta = this._storedBeta;
  19435. this.radius = this._storedRadius;
  19436. this.setTarget(this._storedTarget.clone());
  19437. this.inertialAlphaOffset = 0;
  19438. this.inertialBetaOffset = 0;
  19439. this.inertialRadiusOffset = 0;
  19440. this.inertialPanningX = 0;
  19441. this.inertialPanningY = 0;
  19442. return true;
  19443. };
  19444. // Synchronized
  19445. /** @hidden */
  19446. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  19447. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  19448. return false;
  19449. }
  19450. return this._cache._target.equals(this._getTargetPosition())
  19451. && this._cache.alpha === this.alpha
  19452. && this._cache.beta === this.beta
  19453. && this._cache.radius === this.radius
  19454. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  19455. };
  19456. /**
  19457. * Attached controls to the current camera.
  19458. * @param element Defines the element the controls should be listened from
  19459. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19460. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  19461. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  19462. */
  19463. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  19464. var _this = this;
  19465. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  19466. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  19467. this._useCtrlForPanning = useCtrlForPanning;
  19468. this._panningMouseButton = panningMouseButton;
  19469. this.inputs.attachElement(element, noPreventDefault);
  19470. this._reset = function () {
  19471. _this.inertialAlphaOffset = 0;
  19472. _this.inertialBetaOffset = 0;
  19473. _this.inertialRadiusOffset = 0;
  19474. _this.inertialPanningX = 0;
  19475. _this.inertialPanningY = 0;
  19476. };
  19477. };
  19478. /**
  19479. * Detach the current controls from the camera.
  19480. * The camera will stop reacting to inputs.
  19481. * @param element Defines the element to stop listening the inputs from
  19482. */
  19483. ArcRotateCamera.prototype.detachControl = function (element) {
  19484. this.inputs.detachElement(element);
  19485. if (this._reset) {
  19486. this._reset();
  19487. }
  19488. };
  19489. /** @hidden */
  19490. ArcRotateCamera.prototype._checkInputs = function () {
  19491. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  19492. if (this._collisionTriggered) {
  19493. return;
  19494. }
  19495. this.inputs.checkInputs();
  19496. // Inertia
  19497. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  19498. var inertialAlphaOffset = this.inertialAlphaOffset;
  19499. if (this.beta <= 0) {
  19500. inertialAlphaOffset *= -1;
  19501. }
  19502. if (this.getScene().useRightHandedSystem) {
  19503. inertialAlphaOffset *= -1;
  19504. }
  19505. if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
  19506. inertialAlphaOffset *= -1;
  19507. }
  19508. this.alpha += inertialAlphaOffset;
  19509. this.beta += this.inertialBetaOffset;
  19510. this.radius -= this.inertialRadiusOffset;
  19511. this.inertialAlphaOffset *= this.inertia;
  19512. this.inertialBetaOffset *= this.inertia;
  19513. this.inertialRadiusOffset *= this.inertia;
  19514. if (Math.abs(this.inertialAlphaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19515. this.inertialAlphaOffset = 0;
  19516. }
  19517. if (Math.abs(this.inertialBetaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19518. this.inertialBetaOffset = 0;
  19519. }
  19520. if (Math.abs(this.inertialRadiusOffset) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19521. this.inertialRadiusOffset = 0;
  19522. }
  19523. }
  19524. // Panning inertia
  19525. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  19526. if (!this._localDirection) {
  19527. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19528. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19529. }
  19530. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  19531. this._localDirection.multiplyInPlace(this.panningAxis);
  19532. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  19533. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  19534. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  19535. if (!this.panningAxis.y) {
  19536. this._transformedDirection.y = 0;
  19537. }
  19538. if (!this._targetHost) {
  19539. if (this.panningDistanceLimit) {
  19540. this._transformedDirection.addInPlace(this._target);
  19541. var distanceSquared = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  19542. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  19543. this._target.copyFrom(this._transformedDirection);
  19544. }
  19545. }
  19546. else {
  19547. this._target.addInPlace(this._transformedDirection);
  19548. }
  19549. }
  19550. this.inertialPanningX *= this.panningInertia;
  19551. this.inertialPanningY *= this.panningInertia;
  19552. if (Math.abs(this.inertialPanningX) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19553. this.inertialPanningX = 0;
  19554. }
  19555. if (Math.abs(this.inertialPanningY) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19556. this.inertialPanningY = 0;
  19557. }
  19558. }
  19559. // Limits
  19560. this._checkLimits();
  19561. _super.prototype._checkInputs.call(this);
  19562. };
  19563. ArcRotateCamera.prototype._checkLimits = function () {
  19564. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  19565. if (this.allowUpsideDown && this.beta > Math.PI) {
  19566. this.beta = this.beta - (2 * Math.PI);
  19567. }
  19568. }
  19569. else {
  19570. if (this.beta < this.lowerBetaLimit) {
  19571. this.beta = this.lowerBetaLimit;
  19572. }
  19573. }
  19574. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  19575. if (this.allowUpsideDown && this.beta < -Math.PI) {
  19576. this.beta = this.beta + (2 * Math.PI);
  19577. }
  19578. }
  19579. else {
  19580. if (this.beta > this.upperBetaLimit) {
  19581. this.beta = this.upperBetaLimit;
  19582. }
  19583. }
  19584. if (this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit) {
  19585. this.alpha = this.lowerAlphaLimit;
  19586. }
  19587. if (this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit) {
  19588. this.alpha = this.upperAlphaLimit;
  19589. }
  19590. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  19591. this.radius = this.lowerRadiusLimit;
  19592. this.inertialRadiusOffset = 0;
  19593. }
  19594. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  19595. this.radius = this.upperRadiusLimit;
  19596. this.inertialRadiusOffset = 0;
  19597. }
  19598. };
  19599. /**
  19600. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  19601. */
  19602. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
  19603. this.position.subtractToRef(this._getTargetPosition(), this._computationVector);
  19604. this.radius = this._computationVector.length();
  19605. if (this.radius === 0) {
  19606. this.radius = 0.0001; // Just to avoid division by zero
  19607. }
  19608. // Alpha
  19609. this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
  19610. if (this._computationVector.z < 0) {
  19611. this.alpha = 2 * Math.PI - this.alpha;
  19612. }
  19613. // Beta
  19614. this.beta = Math.acos(this._computationVector.y / this.radius);
  19615. this._checkLimits();
  19616. };
  19617. /**
  19618. * Use a position to define the current camera related information like aplha, beta and radius
  19619. * @param position Defines the position to set the camera at
  19620. */
  19621. ArcRotateCamera.prototype.setPosition = function (position) {
  19622. if (this.position.equals(position)) {
  19623. return;
  19624. }
  19625. this.position.copyFrom(position);
  19626. this.rebuildAnglesAndRadius();
  19627. };
  19628. /**
  19629. * Defines the target the camera should look at.
  19630. * This will automatically adapt alpha beta and radius to fit within the new target.
  19631. * @param target Defines the new target as a Vector or a mesh
  19632. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  19633. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  19634. */
  19635. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  19636. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  19637. if (allowSamePosition === void 0) { allowSamePosition = false; }
  19638. if (target.getBoundingInfo) {
  19639. if (toBoundingCenter) {
  19640. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  19641. }
  19642. else {
  19643. this._targetBoundingCenter = null;
  19644. }
  19645. this._targetHost = target;
  19646. this._target = this._getTargetPosition();
  19647. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  19648. }
  19649. else {
  19650. var newTarget = target;
  19651. var currentTarget = this._getTargetPosition();
  19652. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  19653. return;
  19654. }
  19655. this._targetHost = null;
  19656. this._target = newTarget;
  19657. this._targetBoundingCenter = null;
  19658. this.onMeshTargetChangedObservable.notifyObservers(null);
  19659. }
  19660. this.rebuildAnglesAndRadius();
  19661. };
  19662. /** @hidden */
  19663. ArcRotateCamera.prototype._getViewMatrix = function () {
  19664. // Compute
  19665. var cosa = Math.cos(this.alpha);
  19666. var sina = Math.sin(this.alpha);
  19667. var cosb = Math.cos(this.beta);
  19668. var sinb = Math.sin(this.beta);
  19669. if (sinb === 0) {
  19670. sinb = 0.0001;
  19671. }
  19672. var target = this._getTargetPosition();
  19673. this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
  19674. // Rotate according to up vector
  19675. if (this.upVector.x !== 0 || this.upVector.y !== 1.0 || this.upVector.z !== 0) {
  19676. if (!this._tempAxisVector) {
  19677. this._tempAxisVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  19678. this._tempAxisRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19679. }
  19680. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), this.upVector, this._tempAxisVector);
  19681. this._tempAxisVector.normalize();
  19682. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this.upVector));
  19683. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(this._tempAxisVector, angle, this._tempAxisRotationMatrix);
  19684. this._tempAxisVector.copyFrom(this._computationVector);
  19685. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._tempAxisVector, this._tempAxisRotationMatrix, this._computationVector);
  19686. }
  19687. target.addToRef(this._computationVector, this._newPosition);
  19688. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  19689. var coordinator = this.getScene().collisionCoordinator;
  19690. if (!this._collider) {
  19691. this._collider = coordinator.createCollider();
  19692. }
  19693. this._collider._radius = this.collisionRadius;
  19694. this._newPosition.subtractToRef(this.position, this._collisionVelocity);
  19695. this._collisionTriggered = true;
  19696. coordinator.getNewPosition(this.position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  19697. }
  19698. else {
  19699. this.position.copyFrom(this._newPosition);
  19700. var up = this.upVector;
  19701. if (this.allowUpsideDown && sinb < 0) {
  19702. up = up.clone();
  19703. up = up.negate();
  19704. }
  19705. this._computeViewMatrix(this.position, target, up);
  19706. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x);
  19707. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
  19708. }
  19709. this._currentTarget = target;
  19710. return this._viewMatrix;
  19711. };
  19712. /**
  19713. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  19714. * @param meshes Defines the mesh to zoom on
  19715. * @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)
  19716. */
  19717. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  19718. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  19719. meshes = meshes || this.getScene().meshes;
  19720. var minMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  19721. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(minMaxVector.min, minMaxVector.max);
  19722. this.radius = distance * this.zoomOnFactor;
  19723. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  19724. };
  19725. /**
  19726. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  19727. * The target will be changed but the radius
  19728. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  19729. * @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)
  19730. */
  19731. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  19732. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  19733. var meshesOrMinMaxVector;
  19734. var distance;
  19735. if (meshesOrMinMaxVectorAndDistance.min === undefined) { // meshes
  19736. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  19737. meshesOrMinMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  19738. distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  19739. }
  19740. else { //minMaxVector and distance
  19741. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  19742. meshesOrMinMaxVector = minMaxVectorAndDistance;
  19743. distance = minMaxVectorAndDistance.distance;
  19744. }
  19745. this._target = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].Center(meshesOrMinMaxVector);
  19746. if (!doNotUpdateMaxZ) {
  19747. this.maxZ = distance * 2;
  19748. }
  19749. };
  19750. /**
  19751. * @override
  19752. * Override Camera.createRigCamera
  19753. */
  19754. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  19755. var alphaShift = 0;
  19756. switch (this.cameraRigMode) {
  19757. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  19758. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  19759. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  19760. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  19761. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  19762. break;
  19763. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  19764. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  19765. break;
  19766. }
  19767. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  19768. rigCam._cameraRigParams = {};
  19769. return rigCam;
  19770. };
  19771. /**
  19772. * @hidden
  19773. * @override
  19774. * Override Camera._updateRigCameras
  19775. */
  19776. ArcRotateCamera.prototype._updateRigCameras = function () {
  19777. var camLeft = this._rigCameras[0];
  19778. var camRight = this._rigCameras[1];
  19779. camLeft.beta = camRight.beta = this.beta;
  19780. switch (this.cameraRigMode) {
  19781. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  19782. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  19783. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  19784. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  19785. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  19786. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  19787. break;
  19788. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  19789. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  19790. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  19791. break;
  19792. }
  19793. _super.prototype._updateRigCameras.call(this);
  19794. };
  19795. /**
  19796. * Destroy the camera and release the current resources hold by it.
  19797. */
  19798. ArcRotateCamera.prototype.dispose = function () {
  19799. this.inputs.clear();
  19800. _super.prototype.dispose.call(this);
  19801. };
  19802. /**
  19803. * Gets the current object class name.
  19804. * @return the class name
  19805. */
  19806. ArcRotateCamera.prototype.getClassName = function () {
  19807. return "ArcRotateCamera";
  19808. };
  19809. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19810. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19811. ], ArcRotateCamera.prototype, "alpha", void 0);
  19812. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19813. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19814. ], ArcRotateCamera.prototype, "beta", void 0);
  19815. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19816. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19817. ], ArcRotateCamera.prototype, "radius", void 0);
  19818. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19819. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("target")
  19820. ], ArcRotateCamera.prototype, "_target", void 0);
  19821. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19823. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  19824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19826. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  19827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19829. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  19830. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19831. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19832. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  19833. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19834. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19835. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  19836. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19838. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  19839. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19840. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19841. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  19842. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19843. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19844. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  19845. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19846. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19847. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  19848. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19850. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  19851. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19852. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19853. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  19854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19855. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19856. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  19857. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19859. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  19860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  19862. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  19863. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19864. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19865. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  19866. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19867. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19868. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  19869. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19870. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19871. ], ArcRotateCamera.prototype, "targetScreenOffset", void 0);
  19872. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19873. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19874. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  19875. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19876. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19877. ], ArcRotateCamera.prototype, "useInputToRestoreState", void 0);
  19878. return ArcRotateCamera;
  19879. }(_targetCamera__WEBPACK_IMPORTED_MODULE_10__["TargetCamera"]));
  19880. /***/ }),
  19881. /***/ "./Cameras/arcRotateCameraInputsManager.ts":
  19882. /*!*************************************************!*\
  19883. !*** ./Cameras/arcRotateCameraInputsManager.ts ***!
  19884. \*************************************************/
  19885. /*! exports provided: ArcRotateCameraInputsManager */
  19886. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19887. "use strict";
  19888. __webpack_require__.r(__webpack_exports__);
  19889. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return ArcRotateCameraInputsManager; });
  19890. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19891. /* harmony import */ var _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  19892. /* harmony import */ var _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  19893. /* harmony import */ var _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  19894. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  19895. /**
  19896. * Default Inputs manager for the ArcRotateCamera.
  19897. * It groups all the default supported inputs for ease of use.
  19898. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19899. */
  19900. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  19901. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraInputsManager, _super);
  19902. /**
  19903. * Instantiates a new ArcRotateCameraInputsManager.
  19904. * @param camera Defines the camera the inputs belong to
  19905. */
  19906. function ArcRotateCameraInputsManager(camera) {
  19907. return _super.call(this, camera) || this;
  19908. }
  19909. /**
  19910. * Add mouse wheel input support to the input manager.
  19911. * @returns the current input manager
  19912. */
  19913. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  19914. this.add(new _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraMouseWheelInput"]());
  19915. return this;
  19916. };
  19917. /**
  19918. * Add pointers input support to the input manager.
  19919. * @returns the current input manager
  19920. */
  19921. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  19922. this.add(new _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraPointersInput"]());
  19923. return this;
  19924. };
  19925. /**
  19926. * Add keyboard input support to the input manager.
  19927. * @returns the current input manager
  19928. */
  19929. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  19930. this.add(new _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraKeyboardMoveInput"]());
  19931. return this;
  19932. };
  19933. return ArcRotateCameraInputsManager;
  19934. }(_Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__["CameraInputsManager"]));
  19935. /***/ }),
  19936. /***/ "./Cameras/camera.ts":
  19937. /*!***************************!*\
  19938. !*** ./Cameras/camera.ts ***!
  19939. \***************************/
  19940. /*! exports provided: Camera */
  19941. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19942. "use strict";
  19943. __webpack_require__.r(__webpack_exports__);
  19944. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return Camera; });
  19945. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19946. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  19947. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  19948. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  19949. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  19950. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  19951. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  19952. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  19953. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  19954. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  19955. /**
  19956. * This is the base class of all the camera used in the application.
  19957. * @see http://doc.babylonjs.com/features/cameras
  19958. */
  19959. var Camera = /** @class */ (function (_super) {
  19960. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Camera, _super);
  19961. /**
  19962. * Instantiates a new camera object.
  19963. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  19964. * @see http://doc.babylonjs.com/features/cameras
  19965. * @param name Defines the name of the camera in the scene
  19966. * @param position Defines the position of the camera
  19967. * @param scene Defines the scene the camera belongs too
  19968. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  19969. */
  19970. function Camera(name, position, scene, setActiveOnSceneIfNoneActive) {
  19971. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  19972. var _this = _super.call(this, name, scene) || this;
  19973. /**
  19974. * The vector the camera should consider as up.
  19975. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  19976. */
  19977. _this.upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Up();
  19978. /**
  19979. * Define the current limit on the left side for an orthographic camera
  19980. * In scene unit
  19981. */
  19982. _this.orthoLeft = null;
  19983. /**
  19984. * Define the current limit on the right side for an orthographic camera
  19985. * In scene unit
  19986. */
  19987. _this.orthoRight = null;
  19988. /**
  19989. * Define the current limit on the bottom side for an orthographic camera
  19990. * In scene unit
  19991. */
  19992. _this.orthoBottom = null;
  19993. /**
  19994. * Define the current limit on the top side for an orthographic camera
  19995. * In scene unit
  19996. */
  19997. _this.orthoTop = null;
  19998. /**
  19999. * Field Of View is set in Radians. (default is 0.8)
  20000. */
  20001. _this.fov = 0.8;
  20002. /**
  20003. * Define the minimum distance the camera can see from.
  20004. * This is important to note that the depth buffer are not infinite and the closer it starts
  20005. * the more your scene might encounter depth fighting issue.
  20006. */
  20007. _this.minZ = 1;
  20008. /**
  20009. * Define the maximum distance the camera can see to.
  20010. * This is important to note that the depth buffer are not infinite and the further it end
  20011. * the more your scene might encounter depth fighting issue.
  20012. */
  20013. _this.maxZ = 10000.0;
  20014. /**
  20015. * Define the default inertia of the camera.
  20016. * This helps giving a smooth feeling to the camera movement.
  20017. */
  20018. _this.inertia = 0.9;
  20019. /**
  20020. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  20021. */
  20022. _this.mode = Camera.PERSPECTIVE_CAMERA;
  20023. /**
  20024. * Define wether the camera is intermediate.
  20025. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  20026. */
  20027. _this.isIntermediate = false;
  20028. /**
  20029. * Define the viewport of the camera.
  20030. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  20031. */
  20032. _this.viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 1.0, 1.0);
  20033. /**
  20034. * Restricts the camera to viewing objects with the same layerMask.
  20035. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  20036. */
  20037. _this.layerMask = 0x0FFFFFFF;
  20038. /**
  20039. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  20040. */
  20041. _this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
  20042. /**
  20043. * Rig mode of the camera.
  20044. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  20045. * This is normally controlled byt the camera themselves as internal use.
  20046. */
  20047. _this.cameraRigMode = Camera.RIG_MODE_NONE;
  20048. /**
  20049. * 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
  20050. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  20051. * else in the scene.
  20052. */
  20053. _this.customRenderTargets = new Array();
  20054. /**
  20055. * When set, the camera will render to this render target instead of the default canvas
  20056. */
  20057. _this.outputRenderTarget = null;
  20058. /**
  20059. * Observable triggered when the camera view matrix has changed.
  20060. */
  20061. _this.onViewMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20062. /**
  20063. * Observable triggered when the camera Projection matrix has changed.
  20064. */
  20065. _this.onProjectionMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20066. /**
  20067. * Observable triggered when the inputs have been processed.
  20068. */
  20069. _this.onAfterCheckInputsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20070. /**
  20071. * Observable triggered when reset has been called and applied to the camera.
  20072. */
  20073. _this.onRestoreStateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20074. /** @hidden */
  20075. _this._rigCameras = new Array();
  20076. _this._webvrViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20077. /** @hidden */
  20078. _this._skipRendering = false;
  20079. /** @hidden */
  20080. _this._projectionMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  20081. /** @hidden */
  20082. _this._postProcesses = new Array();
  20083. /** @hidden */
  20084. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](256);
  20085. _this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20086. /** hidden */
  20087. _this._computedViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20088. _this._doNotComputeProjectionMatrix = false;
  20089. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Zero();
  20090. _this._refreshFrustumPlanes = true;
  20091. /** @hidden */
  20092. _this._isCamera = true;
  20093. _this.getScene().addCamera(_this);
  20094. if (setActiveOnSceneIfNoneActive && !_this.getScene().activeCamera) {
  20095. _this.getScene().activeCamera = _this;
  20096. }
  20097. _this.position = position;
  20098. return _this;
  20099. }
  20100. /**
  20101. * Store current camera state (fov, position, etc..)
  20102. * @returns the camera
  20103. */
  20104. Camera.prototype.storeState = function () {
  20105. this._stateStored = true;
  20106. this._storedFov = this.fov;
  20107. return this;
  20108. };
  20109. /**
  20110. * Restores the camera state values if it has been stored. You must call storeState() first
  20111. */
  20112. Camera.prototype._restoreStateValues = function () {
  20113. if (!this._stateStored) {
  20114. return false;
  20115. }
  20116. this.fov = this._storedFov;
  20117. return true;
  20118. };
  20119. /**
  20120. * Restored camera state. You must call storeState() first.
  20121. * @returns true if restored and false otherwise
  20122. */
  20123. Camera.prototype.restoreState = function () {
  20124. if (this._restoreStateValues()) {
  20125. this.onRestoreStateObservable.notifyObservers(this);
  20126. return true;
  20127. }
  20128. return false;
  20129. };
  20130. /**
  20131. * Gets the class name of the camera.
  20132. * @returns the class name
  20133. */
  20134. Camera.prototype.getClassName = function () {
  20135. return "Camera";
  20136. };
  20137. /**
  20138. * Gets a string representation of the camera useful for debug purpose.
  20139. * @param fullDetails Defines that a more verboe level of logging is required
  20140. * @returns the string representation
  20141. */
  20142. Camera.prototype.toString = function (fullDetails) {
  20143. var ret = "Name: " + this.name;
  20144. ret += ", type: " + this.getClassName();
  20145. if (this.animations) {
  20146. for (var i = 0; i < this.animations.length; i++) {
  20147. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  20148. }
  20149. }
  20150. if (fullDetails) {
  20151. }
  20152. return ret;
  20153. };
  20154. Object.defineProperty(Camera.prototype, "globalPosition", {
  20155. /**
  20156. * Gets the current world space position of the camera.
  20157. */
  20158. get: function () {
  20159. return this._globalPosition;
  20160. },
  20161. enumerable: true,
  20162. configurable: true
  20163. });
  20164. /**
  20165. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  20166. * @returns the active meshe list
  20167. */
  20168. Camera.prototype.getActiveMeshes = function () {
  20169. return this._activeMeshes;
  20170. };
  20171. /**
  20172. * Check wether a mesh is part of the current active mesh list of the camera
  20173. * @param mesh Defines the mesh to check
  20174. * @returns true if active, false otherwise
  20175. */
  20176. Camera.prototype.isActiveMesh = function (mesh) {
  20177. return (this._activeMeshes.indexOf(mesh) !== -1);
  20178. };
  20179. /**
  20180. * Is this camera ready to be used/rendered
  20181. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  20182. * @return true if the camera is ready
  20183. */
  20184. Camera.prototype.isReady = function (completeCheck) {
  20185. if (completeCheck === void 0) { completeCheck = false; }
  20186. if (completeCheck) {
  20187. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  20188. var pp = _a[_i];
  20189. if (pp && !pp.isReady()) {
  20190. return false;
  20191. }
  20192. }
  20193. }
  20194. return _super.prototype.isReady.call(this, completeCheck);
  20195. };
  20196. /** @hidden */
  20197. Camera.prototype._initCache = function () {
  20198. _super.prototype._initCache.call(this);
  20199. this._cache.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20200. this._cache.upVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20201. this._cache.mode = undefined;
  20202. this._cache.minZ = undefined;
  20203. this._cache.maxZ = undefined;
  20204. this._cache.fov = undefined;
  20205. this._cache.fovMode = undefined;
  20206. this._cache.aspectRatio = undefined;
  20207. this._cache.orthoLeft = undefined;
  20208. this._cache.orthoRight = undefined;
  20209. this._cache.orthoBottom = undefined;
  20210. this._cache.orthoTop = undefined;
  20211. this._cache.renderWidth = undefined;
  20212. this._cache.renderHeight = undefined;
  20213. };
  20214. /** @hidden */
  20215. Camera.prototype._updateCache = function (ignoreParentClass) {
  20216. if (!ignoreParentClass) {
  20217. _super.prototype._updateCache.call(this);
  20218. }
  20219. this._cache.position.copyFrom(this.position);
  20220. this._cache.upVector.copyFrom(this.upVector);
  20221. };
  20222. /** @hidden */
  20223. Camera.prototype._isSynchronized = function () {
  20224. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
  20225. };
  20226. /** @hidden */
  20227. Camera.prototype._isSynchronizedViewMatrix = function () {
  20228. if (!_super.prototype._isSynchronized.call(this)) {
  20229. return false;
  20230. }
  20231. return this._cache.position.equals(this.position)
  20232. && this._cache.upVector.equals(this.upVector)
  20233. && this.isSynchronizedWithParent();
  20234. };
  20235. /** @hidden */
  20236. Camera.prototype._isSynchronizedProjectionMatrix = function () {
  20237. var check = this._cache.mode === this.mode
  20238. && this._cache.minZ === this.minZ
  20239. && this._cache.maxZ === this.maxZ;
  20240. if (!check) {
  20241. return false;
  20242. }
  20243. var engine = this.getEngine();
  20244. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20245. check = this._cache.fov === this.fov
  20246. && this._cache.fovMode === this.fovMode
  20247. && this._cache.aspectRatio === engine.getAspectRatio(this);
  20248. }
  20249. else {
  20250. check = this._cache.orthoLeft === this.orthoLeft
  20251. && this._cache.orthoRight === this.orthoRight
  20252. && this._cache.orthoBottom === this.orthoBottom
  20253. && this._cache.orthoTop === this.orthoTop
  20254. && this._cache.renderWidth === engine.getRenderWidth()
  20255. && this._cache.renderHeight === engine.getRenderHeight();
  20256. }
  20257. return check;
  20258. };
  20259. /**
  20260. * Attach the input controls to a specific dom element to get the input from.
  20261. * @param element Defines the element the controls should be listened from
  20262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20263. */
  20264. Camera.prototype.attachControl = function (element, noPreventDefault) {
  20265. };
  20266. /**
  20267. * Detach the current controls from the specified dom element.
  20268. * @param element Defines the element to stop listening the inputs from
  20269. */
  20270. Camera.prototype.detachControl = function (element) {
  20271. };
  20272. /**
  20273. * Update the camera state according to the different inputs gathered during the frame.
  20274. */
  20275. Camera.prototype.update = function () {
  20276. this._checkInputs();
  20277. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20278. this._updateRigCameras();
  20279. }
  20280. };
  20281. /** @hidden */
  20282. Camera.prototype._checkInputs = function () {
  20283. this.onAfterCheckInputsObservable.notifyObservers(this);
  20284. };
  20285. Object.defineProperty(Camera.prototype, "rigCameras", {
  20286. /** @hidden */
  20287. get: function () {
  20288. return this._rigCameras;
  20289. },
  20290. enumerable: true,
  20291. configurable: true
  20292. });
  20293. Object.defineProperty(Camera.prototype, "rigPostProcess", {
  20294. /**
  20295. * Gets the post process used by the rig cameras
  20296. */
  20297. get: function () {
  20298. return this._rigPostProcess;
  20299. },
  20300. enumerable: true,
  20301. configurable: true
  20302. });
  20303. /**
  20304. * Internal, gets the first post proces.
  20305. * @returns the first post process to be run on this camera.
  20306. */
  20307. Camera.prototype._getFirstPostProcess = function () {
  20308. for (var ppIndex = 0; ppIndex < this._postProcesses.length; ppIndex++) {
  20309. if (this._postProcesses[ppIndex] !== null) {
  20310. return this._postProcesses[ppIndex];
  20311. }
  20312. }
  20313. return null;
  20314. };
  20315. Camera.prototype._cascadePostProcessesToRigCams = function () {
  20316. // invalidate framebuffer
  20317. var firstPostProcess = this._getFirstPostProcess();
  20318. if (firstPostProcess) {
  20319. firstPostProcess.markTextureDirty();
  20320. }
  20321. // glue the rigPostProcess to the end of the user postprocesses & assign to each sub-camera
  20322. for (var i = 0, len = this._rigCameras.length; i < len; i++) {
  20323. var cam = this._rigCameras[i];
  20324. var rigPostProcess = cam._rigPostProcess;
  20325. // for VR rig, there does not have to be a post process
  20326. if (rigPostProcess) {
  20327. var isPass = rigPostProcess.getEffectName() === "pass";
  20328. if (isPass) {
  20329. // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
  20330. cam.isIntermediate = this._postProcesses.length === 0;
  20331. }
  20332. cam._postProcesses = this._postProcesses.slice(0).concat(rigPostProcess);
  20333. rigPostProcess.markTextureDirty();
  20334. }
  20335. else {
  20336. cam._postProcesses = this._postProcesses.slice(0);
  20337. }
  20338. }
  20339. };
  20340. /**
  20341. * Attach a post process to the camera.
  20342. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20343. * @param postProcess The post process to attach to the camera
  20344. * @param insertAt The position of the post process in case several of them are in use in the scene
  20345. * @returns the position the post process has been inserted at
  20346. */
  20347. Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
  20348. if (insertAt === void 0) { insertAt = null; }
  20349. if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
  20350. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("You're trying to reuse a post process not defined as reusable.");
  20351. return 0;
  20352. }
  20353. if (insertAt == null || insertAt < 0) {
  20354. this._postProcesses.push(postProcess);
  20355. }
  20356. else if (this._postProcesses[insertAt] === null) {
  20357. this._postProcesses[insertAt] = postProcess;
  20358. }
  20359. else {
  20360. this._postProcesses.splice(insertAt, 0, postProcess);
  20361. }
  20362. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20363. return this._postProcesses.indexOf(postProcess);
  20364. };
  20365. /**
  20366. * Detach a post process to the camera.
  20367. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20368. * @param postProcess The post process to detach from the camera
  20369. */
  20370. Camera.prototype.detachPostProcess = function (postProcess) {
  20371. var idx = this._postProcesses.indexOf(postProcess);
  20372. if (idx !== -1) {
  20373. this._postProcesses[idx] = null;
  20374. }
  20375. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20376. };
  20377. /**
  20378. * Gets the current world matrix of the camera
  20379. */
  20380. Camera.prototype.getWorldMatrix = function () {
  20381. if (this._isSynchronizedViewMatrix()) {
  20382. return this._worldMatrix;
  20383. }
  20384. // Getting the the view matrix will also compute the world matrix.
  20385. this.getViewMatrix();
  20386. return this._worldMatrix;
  20387. };
  20388. /** @hidden */
  20389. Camera.prototype._getViewMatrix = function () {
  20390. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20391. };
  20392. /**
  20393. * Gets the current view matrix of the camera.
  20394. * @param force forces the camera to recompute the matrix without looking at the cached state
  20395. * @returns the view matrix
  20396. */
  20397. Camera.prototype.getViewMatrix = function (force) {
  20398. if (!force && this._isSynchronizedViewMatrix()) {
  20399. return this._computedViewMatrix;
  20400. }
  20401. this.updateCache();
  20402. this._computedViewMatrix = this._getViewMatrix();
  20403. this._currentRenderId = this.getScene().getRenderId();
  20404. this._childRenderId = this._currentRenderId;
  20405. this._refreshFrustumPlanes = true;
  20406. if (this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix) {
  20407. this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix);
  20408. }
  20409. this.onViewMatrixChangedObservable.notifyObservers(this);
  20410. this._computedViewMatrix.invertToRef(this._worldMatrix);
  20411. return this._computedViewMatrix;
  20412. };
  20413. /**
  20414. * Freeze the projection matrix.
  20415. * It will prevent the cache check of the camera projection compute and can speed up perf
  20416. * if no parameter of the camera are meant to change
  20417. * @param projection Defines manually a projection if necessary
  20418. */
  20419. Camera.prototype.freezeProjectionMatrix = function (projection) {
  20420. this._doNotComputeProjectionMatrix = true;
  20421. if (projection !== undefined) {
  20422. this._projectionMatrix = projection;
  20423. }
  20424. };
  20425. /**
  20426. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  20427. */
  20428. Camera.prototype.unfreezeProjectionMatrix = function () {
  20429. this._doNotComputeProjectionMatrix = false;
  20430. };
  20431. /**
  20432. * Gets the current projection matrix of the camera.
  20433. * @param force forces the camera to recompute the matrix without looking at the cached state
  20434. * @returns the projection matrix
  20435. */
  20436. Camera.prototype.getProjectionMatrix = function (force) {
  20437. if (this._doNotComputeProjectionMatrix || (!force && this._isSynchronizedProjectionMatrix())) {
  20438. return this._projectionMatrix;
  20439. }
  20440. // Cache
  20441. this._cache.mode = this.mode;
  20442. this._cache.minZ = this.minZ;
  20443. this._cache.maxZ = this.maxZ;
  20444. // Matrix
  20445. this._refreshFrustumPlanes = true;
  20446. var engine = this.getEngine();
  20447. var scene = this.getScene();
  20448. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20449. this._cache.fov = this.fov;
  20450. this._cache.fovMode = this.fovMode;
  20451. this._cache.aspectRatio = engine.getAspectRatio(this);
  20452. if (this.minZ <= 0) {
  20453. this.minZ = 0.1;
  20454. }
  20455. if (scene.useRightHandedSystem) {
  20456. _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);
  20457. }
  20458. else {
  20459. _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);
  20460. }
  20461. }
  20462. else {
  20463. var halfWidth = engine.getRenderWidth() / 2.0;
  20464. var halfHeight = engine.getRenderHeight() / 2.0;
  20465. if (scene.useRightHandedSystem) {
  20466. _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);
  20467. }
  20468. else {
  20469. _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);
  20470. }
  20471. this._cache.orthoLeft = this.orthoLeft;
  20472. this._cache.orthoRight = this.orthoRight;
  20473. this._cache.orthoBottom = this.orthoBottom;
  20474. this._cache.orthoTop = this.orthoTop;
  20475. this._cache.renderWidth = engine.getRenderWidth();
  20476. this._cache.renderHeight = engine.getRenderHeight();
  20477. }
  20478. this.onProjectionMatrixChangedObservable.notifyObservers(this);
  20479. return this._projectionMatrix;
  20480. };
  20481. /**
  20482. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  20483. * @returns a Matrix
  20484. */
  20485. Camera.prototype.getTransformationMatrix = function () {
  20486. this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  20487. return this._transformMatrix;
  20488. };
  20489. Camera.prototype._updateFrustumPlanes = function () {
  20490. if (!this._refreshFrustumPlanes) {
  20491. return;
  20492. }
  20493. this.getTransformationMatrix();
  20494. if (!this._frustumPlanes) {
  20495. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanes(this._transformMatrix);
  20496. }
  20497. else {
  20498. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  20499. }
  20500. this._refreshFrustumPlanes = false;
  20501. };
  20502. /**
  20503. * Checks if a cullable object (mesh...) is in the camera frustum
  20504. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  20505. * @param target The object to check
  20506. * @returns true if the object is in frustum otherwise false
  20507. */
  20508. Camera.prototype.isInFrustum = function (target) {
  20509. this._updateFrustumPlanes();
  20510. return target.isInFrustum(this._frustumPlanes);
  20511. };
  20512. /**
  20513. * Checks if a cullable object (mesh...) is in the camera frustum
  20514. * Unlike isInFrustum this cheks the full bounding box
  20515. * @param target The object to check
  20516. * @returns true if the object is in frustum otherwise false
  20517. */
  20518. Camera.prototype.isCompletelyInFrustum = function (target) {
  20519. this._updateFrustumPlanes();
  20520. return target.isCompletelyInFrustum(this._frustumPlanes);
  20521. };
  20522. /**
  20523. * Gets a ray in the forward direction from the camera.
  20524. * @param length Defines the length of the ray to create
  20525. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  20526. * @param origin Defines the start point of the ray which defaults to the camera position
  20527. * @returns the forward ray
  20528. */
  20529. Camera.prototype.getForwardRay = function (length, transform, origin) {
  20530. if (length === void 0) { length = 100; }
  20531. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("Ray");
  20532. };
  20533. /**
  20534. * Releases resources associated with this node.
  20535. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20536. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20537. */
  20538. Camera.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  20539. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  20540. // Observables
  20541. this.onViewMatrixChangedObservable.clear();
  20542. this.onProjectionMatrixChangedObservable.clear();
  20543. this.onAfterCheckInputsObservable.clear();
  20544. this.onRestoreStateObservable.clear();
  20545. // Inputs
  20546. if (this.inputs) {
  20547. this.inputs.clear();
  20548. }
  20549. // Animations
  20550. this.getScene().stopAnimation(this);
  20551. // Remove from scene
  20552. this.getScene().removeCamera(this);
  20553. while (this._rigCameras.length > 0) {
  20554. var camera = this._rigCameras.pop();
  20555. if (camera) {
  20556. camera.dispose();
  20557. }
  20558. }
  20559. // Postprocesses
  20560. if (this._rigPostProcess) {
  20561. this._rigPostProcess.dispose(this);
  20562. this._rigPostProcess = null;
  20563. this._postProcesses = [];
  20564. }
  20565. else if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20566. this._rigPostProcess = null;
  20567. this._postProcesses = [];
  20568. }
  20569. else {
  20570. var i = this._postProcesses.length;
  20571. while (--i >= 0) {
  20572. var postProcess = this._postProcesses[i];
  20573. if (postProcess) {
  20574. postProcess.dispose(this);
  20575. }
  20576. }
  20577. }
  20578. // Render targets
  20579. var i = this.customRenderTargets.length;
  20580. while (--i >= 0) {
  20581. this.customRenderTargets[i].dispose();
  20582. }
  20583. this.customRenderTargets = [];
  20584. // Active Meshes
  20585. this._activeMeshes.dispose();
  20586. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  20587. };
  20588. Object.defineProperty(Camera.prototype, "leftCamera", {
  20589. /**
  20590. * Gets the left camera of a rig setup in case of Rigged Camera
  20591. */
  20592. get: function () {
  20593. if (this._rigCameras.length < 1) {
  20594. return null;
  20595. }
  20596. return this._rigCameras[0];
  20597. },
  20598. enumerable: true,
  20599. configurable: true
  20600. });
  20601. Object.defineProperty(Camera.prototype, "rightCamera", {
  20602. /**
  20603. * Gets the right camera of a rig setup in case of Rigged Camera
  20604. */
  20605. get: function () {
  20606. if (this._rigCameras.length < 2) {
  20607. return null;
  20608. }
  20609. return this._rigCameras[1];
  20610. },
  20611. enumerable: true,
  20612. configurable: true
  20613. });
  20614. /**
  20615. * Gets the left camera target of a rig setup in case of Rigged Camera
  20616. * @returns the target position
  20617. */
  20618. Camera.prototype.getLeftTarget = function () {
  20619. if (this._rigCameras.length < 1) {
  20620. return null;
  20621. }
  20622. return this._rigCameras[0].getTarget();
  20623. };
  20624. /**
  20625. * Gets the right camera target of a rig setup in case of Rigged Camera
  20626. * @returns the target position
  20627. */
  20628. Camera.prototype.getRightTarget = function () {
  20629. if (this._rigCameras.length < 2) {
  20630. return null;
  20631. }
  20632. return this._rigCameras[1].getTarget();
  20633. };
  20634. /**
  20635. * @hidden
  20636. */
  20637. Camera.prototype.setCameraRigMode = function (mode, rigParams) {
  20638. if (this.cameraRigMode === mode) {
  20639. return;
  20640. }
  20641. while (this._rigCameras.length > 0) {
  20642. var camera = this._rigCameras.pop();
  20643. if (camera) {
  20644. camera.dispose();
  20645. }
  20646. }
  20647. this.cameraRigMode = mode;
  20648. this._cameraRigParams = {};
  20649. //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
  20650. //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
  20651. this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
  20652. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
  20653. // create the rig cameras, unless none
  20654. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20655. var leftCamera = this.createRigCamera(this.name + "_L", 0);
  20656. var rightCamera = this.createRigCamera(this.name + "_R", 1);
  20657. if (leftCamera && rightCamera) {
  20658. this._rigCameras.push(leftCamera);
  20659. this._rigCameras.push(rightCamera);
  20660. }
  20661. }
  20662. switch (this.cameraRigMode) {
  20663. case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20664. Camera._setStereoscopicAnaglyphRigMode(this);
  20665. break;
  20666. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20667. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20668. case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20669. Camera._setStereoscopicRigMode(this);
  20670. break;
  20671. case Camera.RIG_MODE_VR:
  20672. Camera._setVRRigMode(this, rigParams);
  20673. break;
  20674. case Camera.RIG_MODE_WEBVR:
  20675. Camera._setWebVRRigMode(this, rigParams);
  20676. break;
  20677. }
  20678. this._cascadePostProcessesToRigCams();
  20679. this.update();
  20680. };
  20681. /** @hidden */
  20682. Camera._setStereoscopicRigMode = function (camera) {
  20683. throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
  20684. };
  20685. /** @hidden */
  20686. Camera._setStereoscopicAnaglyphRigMode = function (camera) {
  20687. throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
  20688. };
  20689. /** @hidden */
  20690. Camera._setVRRigMode = function (camera, rigParams) {
  20691. throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
  20692. };
  20693. /** @hidden */
  20694. Camera._setWebVRRigMode = function (camera, rigParams) {
  20695. throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
  20696. };
  20697. /** @hidden */
  20698. Camera.prototype._getVRProjectionMatrix = function () {
  20699. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
  20700. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
  20701. return this._projectionMatrix;
  20702. };
  20703. Camera.prototype._updateCameraRotationMatrix = function () {
  20704. //Here for WebVR
  20705. };
  20706. Camera.prototype._updateWebVRCameraRotationMatrix = function () {
  20707. //Here for WebVR
  20708. };
  20709. /**
  20710. * This function MUST be overwritten by the different WebVR cameras available.
  20711. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  20712. * @hidden
  20713. */
  20714. Camera.prototype._getWebVRProjectionMatrix = function () {
  20715. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20716. };
  20717. /**
  20718. * This function MUST be overwritten by the different WebVR cameras available.
  20719. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  20720. * @hidden
  20721. */
  20722. Camera.prototype._getWebVRViewMatrix = function () {
  20723. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20724. };
  20725. /** @hidden */
  20726. Camera.prototype.setCameraRigParameter = function (name, value) {
  20727. if (!this._cameraRigParams) {
  20728. this._cameraRigParams = {};
  20729. }
  20730. this._cameraRigParams[name] = value;
  20731. //provisionnally:
  20732. if (name === "interaxialDistance") {
  20733. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(value / 0.0637);
  20734. }
  20735. };
  20736. /**
  20737. * needs to be overridden by children so sub has required properties to be copied
  20738. * @hidden
  20739. */
  20740. Camera.prototype.createRigCamera = function (name, cameraIndex) {
  20741. return null;
  20742. };
  20743. /**
  20744. * May need to be overridden by children
  20745. * @hidden
  20746. */
  20747. Camera.prototype._updateRigCameras = function () {
  20748. for (var i = 0; i < this._rigCameras.length; i++) {
  20749. this._rigCameras[i].minZ = this.minZ;
  20750. this._rigCameras[i].maxZ = this.maxZ;
  20751. this._rigCameras[i].fov = this.fov;
  20752. this._rigCameras[i].upVector.copyFrom(this.upVector);
  20753. }
  20754. // only update viewport when ANAGLYPH
  20755. if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
  20756. this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
  20757. }
  20758. };
  20759. /** @hidden */
  20760. Camera.prototype._setupInputs = function () {
  20761. };
  20762. /**
  20763. * Serialiaze the camera setup to a json represention
  20764. * @returns the JSON representation
  20765. */
  20766. Camera.prototype.serialize = function () {
  20767. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  20768. // Type
  20769. serializationObject.type = this.getClassName();
  20770. // Parent
  20771. if (this.parent) {
  20772. serializationObject.parentId = this.parent.id;
  20773. }
  20774. if (this.inputs) {
  20775. this.inputs.serialize(serializationObject);
  20776. }
  20777. // Animations
  20778. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  20779. serializationObject.ranges = this.serializeAnimationRanges();
  20780. return serializationObject;
  20781. };
  20782. /**
  20783. * Clones the current camera.
  20784. * @param name The cloned camera name
  20785. * @returns the cloned camera
  20786. */
  20787. Camera.prototype.clone = function (name) {
  20788. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  20789. };
  20790. /**
  20791. * Gets the direction of the camera relative to a given local axis.
  20792. * @param localAxis Defines the reference axis to provide a relative direction.
  20793. * @return the direction
  20794. */
  20795. Camera.prototype.getDirection = function (localAxis) {
  20796. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20797. this.getDirectionToRef(localAxis, result);
  20798. return result;
  20799. };
  20800. /**
  20801. * Gets the direction of the camera relative to a given local axis into a passed vector.
  20802. * @param localAxis Defines the reference axis to provide a relative direction.
  20803. * @param result Defines the vector to store the result in
  20804. */
  20805. Camera.prototype.getDirectionToRef = function (localAxis, result) {
  20806. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  20807. };
  20808. /**
  20809. * Gets a camera constructor for a given camera type
  20810. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  20811. * @param name The name of the camera the result will be able to instantiate
  20812. * @param scene The scene the result will construct the camera in
  20813. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  20814. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  20815. * @returns a factory method to construc the camera
  20816. */
  20817. Camera.GetConstructorFromName = function (type, name, scene, interaxial_distance, isStereoscopicSideBySide) {
  20818. if (interaxial_distance === void 0) { interaxial_distance = 0; }
  20819. if (isStereoscopicSideBySide === void 0) { isStereoscopicSideBySide = true; }
  20820. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_6__["Node"].Construct(type, name, scene, {
  20821. interaxial_distance: interaxial_distance,
  20822. isStereoscopicSideBySide: isStereoscopicSideBySide
  20823. });
  20824. if (constructorFunc) {
  20825. return constructorFunc;
  20826. }
  20827. // Default to universal camera
  20828. return function () { return Camera._createDefaultParsedCamera(name, scene); };
  20829. };
  20830. /**
  20831. * Compute the world matrix of the camera.
  20832. * @returns the camera workd matrix
  20833. */
  20834. Camera.prototype.computeWorldMatrix = function () {
  20835. return this.getWorldMatrix();
  20836. };
  20837. /**
  20838. * Parse a JSON and creates the camera from the parsed information
  20839. * @param parsedCamera The JSON to parse
  20840. * @param scene The scene to instantiate the camera in
  20841. * @returns the newly constructed camera
  20842. */
  20843. Camera.Parse = function (parsedCamera, scene) {
  20844. var type = parsedCamera.type;
  20845. var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
  20846. var camera = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(construct, parsedCamera, scene);
  20847. // Parent
  20848. if (parsedCamera.parentId) {
  20849. camera._waitingParentId = parsedCamera.parentId;
  20850. }
  20851. //If camera has an input manager, let it parse inputs settings
  20852. if (camera.inputs) {
  20853. camera.inputs.parse(parsedCamera);
  20854. camera._setupInputs();
  20855. }
  20856. if (camera.setPosition) { // need to force position
  20857. camera.position.copyFromFloats(0, 0, 0);
  20858. camera.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.position));
  20859. }
  20860. // Target
  20861. if (parsedCamera.target) {
  20862. if (camera.setTarget) {
  20863. camera.setTarget(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.target));
  20864. }
  20865. }
  20866. // Apply 3d rig, when found
  20867. if (parsedCamera.cameraRigMode) {
  20868. var rigParams = (parsedCamera.interaxial_distance) ? { interaxialDistance: parsedCamera.interaxial_distance } : {};
  20869. camera.setCameraRigMode(parsedCamera.cameraRigMode, rigParams);
  20870. }
  20871. // Animations
  20872. if (parsedCamera.animations) {
  20873. for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
  20874. var parsedAnimation = parsedCamera.animations[animationIndex];
  20875. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON.Animation");
  20876. if (internalClass) {
  20877. camera.animations.push(internalClass.Parse(parsedAnimation));
  20878. }
  20879. }
  20880. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(camera, parsedCamera, scene);
  20881. }
  20882. if (parsedCamera.autoAnimate) {
  20883. scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, parsedCamera.autoAnimateSpeed || 1.0);
  20884. }
  20885. return camera;
  20886. };
  20887. /** @hidden */
  20888. Camera._createDefaultParsedCamera = function (name, scene) {
  20889. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("UniversalCamera");
  20890. };
  20891. /**
  20892. * This is the default projection mode used by the cameras.
  20893. * It helps recreating a feeling of perspective and better appreciate depth.
  20894. * This is the best way to simulate real life cameras.
  20895. */
  20896. Camera.PERSPECTIVE_CAMERA = 0;
  20897. /**
  20898. * This helps creating camera with an orthographic mode.
  20899. * 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.
  20900. */
  20901. Camera.ORTHOGRAPHIC_CAMERA = 1;
  20902. /**
  20903. * This is the default FOV mode for perspective cameras.
  20904. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  20905. */
  20906. Camera.FOVMODE_VERTICAL_FIXED = 0;
  20907. /**
  20908. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  20909. */
  20910. Camera.FOVMODE_HORIZONTAL_FIXED = 1;
  20911. /**
  20912. * This specifies ther is no need for a camera rig.
  20913. * Basically only one eye is rendered corresponding to the camera.
  20914. */
  20915. Camera.RIG_MODE_NONE = 0;
  20916. /**
  20917. * Simulates a camera Rig with one blue eye and one red eye.
  20918. * This can be use with 3d blue and red glasses.
  20919. */
  20920. Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
  20921. /**
  20922. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  20923. */
  20924. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
  20925. /**
  20926. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  20927. */
  20928. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
  20929. /**
  20930. * Defines that both eyes of the camera will be rendered over under each other.
  20931. */
  20932. Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
  20933. /**
  20934. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  20935. */
  20936. Camera.RIG_MODE_VR = 20;
  20937. /**
  20938. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  20939. */
  20940. Camera.RIG_MODE_WEBVR = 21;
  20941. /**
  20942. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  20943. */
  20944. Camera.RIG_MODE_CUSTOM = 22;
  20945. /**
  20946. * Defines if by default attaching controls should prevent the default javascript event to continue.
  20947. */
  20948. Camera.ForceAttachControlToAlwaysPreventDefault = false;
  20949. /**
  20950. * @hidden
  20951. * Might be removed once multiview will be a thing
  20952. */
  20953. Camera.UseAlternateWebVRRendering = false;
  20954. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20955. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20956. ], Camera.prototype, "position", void 0);
  20957. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20958. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20959. ], Camera.prototype, "upVector", void 0);
  20960. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20961. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20962. ], Camera.prototype, "orthoLeft", void 0);
  20963. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20964. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20965. ], Camera.prototype, "orthoRight", void 0);
  20966. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20967. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20968. ], Camera.prototype, "orthoBottom", void 0);
  20969. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20970. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20971. ], Camera.prototype, "orthoTop", void 0);
  20972. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20973. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20974. ], Camera.prototype, "fov", void 0);
  20975. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20976. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20977. ], Camera.prototype, "minZ", void 0);
  20978. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20980. ], Camera.prototype, "maxZ", void 0);
  20981. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20982. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20983. ], Camera.prototype, "inertia", void 0);
  20984. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20985. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20986. ], Camera.prototype, "mode", void 0);
  20987. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20988. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20989. ], Camera.prototype, "layerMask", void 0);
  20990. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20991. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20992. ], Camera.prototype, "fovMode", void 0);
  20993. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20994. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20995. ], Camera.prototype, "cameraRigMode", void 0);
  20996. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20997. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20998. ], Camera.prototype, "interaxialDistance", void 0);
  20999. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21000. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21001. ], Camera.prototype, "isStereoscopicSideBySide", void 0);
  21002. return Camera;
  21003. }(_node__WEBPACK_IMPORTED_MODULE_6__["Node"]));
  21004. /***/ }),
  21005. /***/ "./Cameras/cameraInputsManager.ts":
  21006. /*!****************************************!*\
  21007. !*** ./Cameras/cameraInputsManager.ts ***!
  21008. \****************************************/
  21009. /*! exports provided: CameraInputTypes, CameraInputsManager */
  21010. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21011. "use strict";
  21012. __webpack_require__.r(__webpack_exports__);
  21013. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return CameraInputTypes; });
  21014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return CameraInputsManager; });
  21015. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  21016. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21017. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  21018. /**
  21019. * @ignore
  21020. * This is a list of all the different input types that are available in the application.
  21021. * Fo instance: ArcRotateCameraGamepadInput...
  21022. */
  21023. var CameraInputTypes = {};
  21024. /**
  21025. * This represents the input manager used within a camera.
  21026. * It helps dealing with all the different kind of input attached to a camera.
  21027. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21028. */
  21029. var CameraInputsManager = /** @class */ (function () {
  21030. /**
  21031. * Instantiate a new Camera Input Manager.
  21032. * @param camera Defines the camera the input manager blongs to
  21033. */
  21034. function CameraInputsManager(camera) {
  21035. this.attached = {};
  21036. this.camera = camera;
  21037. this.checkInputs = function () { };
  21038. }
  21039. /**
  21040. * Add an input method to a camera
  21041. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21042. * @param input camera input method
  21043. */
  21044. CameraInputsManager.prototype.add = function (input) {
  21045. var type = input.getSimpleName();
  21046. if (this.attached[type]) {
  21047. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("camera input of type " + type + " already exists on camera");
  21048. return;
  21049. }
  21050. this.attached[type] = input;
  21051. input.camera = this.camera;
  21052. //for checkInputs, we are dynamically creating a function
  21053. //the goal is to avoid the performance penalty of looping for inputs in the render loop
  21054. if (input.checkInputs) {
  21055. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21056. }
  21057. if (this.attachedElement) {
  21058. input.attachControl(this.attachedElement);
  21059. }
  21060. };
  21061. /**
  21062. * Remove a specific input method from a camera
  21063. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  21064. * @param inputToRemove camera input method
  21065. */
  21066. CameraInputsManager.prototype.remove = function (inputToRemove) {
  21067. for (var cam in this.attached) {
  21068. var input = this.attached[cam];
  21069. if (input === inputToRemove) {
  21070. input.detachControl(this.attachedElement);
  21071. input.camera = null;
  21072. delete this.attached[cam];
  21073. this.rebuildInputCheck();
  21074. }
  21075. }
  21076. };
  21077. /**
  21078. * Remove a specific input type from a camera
  21079. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  21080. * @param inputType the type of the input to remove
  21081. */
  21082. CameraInputsManager.prototype.removeByType = function (inputType) {
  21083. for (var cam in this.attached) {
  21084. var input = this.attached[cam];
  21085. if (input.getClassName() === inputType) {
  21086. input.detachControl(this.attachedElement);
  21087. input.camera = null;
  21088. delete this.attached[cam];
  21089. this.rebuildInputCheck();
  21090. }
  21091. }
  21092. };
  21093. CameraInputsManager.prototype._addCheckInputs = function (fn) {
  21094. var current = this.checkInputs;
  21095. return function () {
  21096. current();
  21097. fn();
  21098. };
  21099. };
  21100. /**
  21101. * Attach the input controls to the currently attached dom element to listen the events from.
  21102. * @param input Defines the input to attach
  21103. */
  21104. CameraInputsManager.prototype.attachInput = function (input) {
  21105. if (this.attachedElement) {
  21106. input.attachControl(this.attachedElement, this.noPreventDefault);
  21107. }
  21108. };
  21109. /**
  21110. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  21111. * @param element Defines the dom element to collect the events from
  21112. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21113. */
  21114. CameraInputsManager.prototype.attachElement = function (element, noPreventDefault) {
  21115. if (noPreventDefault === void 0) { noPreventDefault = false; }
  21116. if (this.attachedElement) {
  21117. return;
  21118. }
  21119. noPreventDefault = _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  21120. this.attachedElement = element;
  21121. this.noPreventDefault = noPreventDefault;
  21122. for (var cam in this.attached) {
  21123. this.attached[cam].attachControl(element, noPreventDefault);
  21124. }
  21125. };
  21126. /**
  21127. * Detach the current manager inputs controls from a specific dom element.
  21128. * @param element Defines the dom element to collect the events from
  21129. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  21130. */
  21131. CameraInputsManager.prototype.detachElement = function (element, disconnect) {
  21132. if (disconnect === void 0) { disconnect = false; }
  21133. if (this.attachedElement !== element) {
  21134. return;
  21135. }
  21136. for (var cam in this.attached) {
  21137. this.attached[cam].detachControl(element);
  21138. if (disconnect) {
  21139. this.attached[cam].camera = null;
  21140. }
  21141. }
  21142. this.attachedElement = null;
  21143. };
  21144. /**
  21145. * Rebuild the dynamic inputCheck function from the current list of
  21146. * defined inputs in the manager.
  21147. */
  21148. CameraInputsManager.prototype.rebuildInputCheck = function () {
  21149. this.checkInputs = function () { };
  21150. for (var cam in this.attached) {
  21151. var input = this.attached[cam];
  21152. if (input.checkInputs) {
  21153. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21154. }
  21155. }
  21156. };
  21157. /**
  21158. * Remove all attached input methods from a camera
  21159. */
  21160. CameraInputsManager.prototype.clear = function () {
  21161. if (this.attachedElement) {
  21162. this.detachElement(this.attachedElement, true);
  21163. }
  21164. this.attached = {};
  21165. this.attachedElement = null;
  21166. this.checkInputs = function () { };
  21167. };
  21168. /**
  21169. * Serialize the current input manager attached to a camera.
  21170. * This ensures than once parsed,
  21171. * the input associated to the camera will be identical to the current ones
  21172. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  21173. */
  21174. CameraInputsManager.prototype.serialize = function (serializedCamera) {
  21175. var inputs = {};
  21176. for (var cam in this.attached) {
  21177. var input = this.attached[cam];
  21178. var res = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(input);
  21179. inputs[input.getClassName()] = res;
  21180. }
  21181. serializedCamera.inputsmgr = inputs;
  21182. };
  21183. /**
  21184. * Parses an input manager serialized JSON to restore the previous list of inputs
  21185. * and states associated to a camera.
  21186. * @param parsedCamera Defines the JSON to parse
  21187. */
  21188. CameraInputsManager.prototype.parse = function (parsedCamera) {
  21189. var parsedInputs = parsedCamera.inputsmgr;
  21190. if (parsedInputs) {
  21191. this.clear();
  21192. for (var n in parsedInputs) {
  21193. var construct = CameraInputTypes[n];
  21194. if (construct) {
  21195. var parsedinput = parsedInputs[n];
  21196. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedinput, null);
  21197. this.add(input);
  21198. }
  21199. }
  21200. }
  21201. else {
  21202. //2016-03-08 this part is for managing backward compatibility
  21203. for (var n in this.attached) {
  21204. var construct = CameraInputTypes[this.attached[n].getClassName()];
  21205. if (construct) {
  21206. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedCamera, null);
  21207. this.remove(this.attached[n]);
  21208. this.add(input);
  21209. }
  21210. }
  21211. }
  21212. };
  21213. return CameraInputsManager;
  21214. }());
  21215. /***/ }),
  21216. /***/ "./Cameras/deviceOrientationCamera.ts":
  21217. /*!********************************************!*\
  21218. !*** ./Cameras/deviceOrientationCamera.ts ***!
  21219. \********************************************/
  21220. /*! exports provided: DeviceOrientationCamera */
  21221. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21222. "use strict";
  21223. __webpack_require__.r(__webpack_exports__);
  21224. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return DeviceOrientationCamera; });
  21225. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21226. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  21227. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21228. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  21229. /* harmony import */ var _Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  21230. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("DeviceOrientationCamera", function (name, scene) {
  21231. return function () { return new DeviceOrientationCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  21232. });
  21233. // We're mainly based on the logic defined into the FreeCamera code
  21234. /**
  21235. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  21236. * being tilted forward or back and left or right.
  21237. */
  21238. var DeviceOrientationCamera = /** @class */ (function (_super) {
  21239. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DeviceOrientationCamera, _super);
  21240. /**
  21241. * Creates a new device orientation camera
  21242. * @param name The name of the camera
  21243. * @param position The start position camera
  21244. * @param scene The scene the camera belongs to
  21245. */
  21246. function DeviceOrientationCamera(name, position, scene) {
  21247. var _this = _super.call(this, name, position, scene) || this;
  21248. _this._quaternionCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21249. _this.inputs.addDeviceOrientation();
  21250. return _this;
  21251. }
  21252. /**
  21253. * Gets the current instance class name ("DeviceOrientationCamera").
  21254. * This helps avoiding instanceof at run time.
  21255. * @returns the class name
  21256. */
  21257. DeviceOrientationCamera.prototype.getClassName = function () {
  21258. return "DeviceOrientationCamera";
  21259. };
  21260. /**
  21261. * @hidden
  21262. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  21263. */
  21264. DeviceOrientationCamera.prototype._checkInputs = function () {
  21265. _super.prototype._checkInputs.call(this);
  21266. this._quaternionCache.copyFrom(this.rotationQuaternion);
  21267. if (this._initialQuaternion) {
  21268. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21269. }
  21270. };
  21271. /**
  21272. * Reset the camera to its default orientation on the specified axis only.
  21273. * @param axis The axis to reset
  21274. */
  21275. DeviceOrientationCamera.prototype.resetToCurrentRotation = function (axis) {
  21276. var _this = this;
  21277. if (axis === void 0) { axis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y; }
  21278. //can only work if this camera has a rotation quaternion already.
  21279. if (!this.rotationQuaternion) {
  21280. return;
  21281. }
  21282. if (!this._initialQuaternion) {
  21283. this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21284. }
  21285. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
  21286. ['x', 'y', 'z'].forEach(function (axisName) {
  21287. if (!axis[axisName]) {
  21288. _this._initialQuaternion[axisName] = 0;
  21289. }
  21290. else {
  21291. _this._initialQuaternion[axisName] *= -1;
  21292. }
  21293. });
  21294. this._initialQuaternion.normalize();
  21295. //force rotation update
  21296. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21297. };
  21298. return DeviceOrientationCamera;
  21299. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  21300. /***/ }),
  21301. /***/ "./Cameras/flyCamera.ts":
  21302. /*!******************************!*\
  21303. !*** ./Cameras/flyCamera.ts ***!
  21304. \******************************/
  21305. /*! exports provided: FlyCamera */
  21306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21307. "use strict";
  21308. __webpack_require__.r(__webpack_exports__);
  21309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return FlyCamera; });
  21310. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21311. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21312. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21313. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  21314. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21315. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  21316. /**
  21317. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21318. * such as in a 3D Space Shooter or a Flight Simulator.
  21319. */
  21320. var FlyCamera = /** @class */ (function (_super) {
  21321. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCamera, _super);
  21322. /**
  21323. * Instantiates a FlyCamera.
  21324. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21325. * such as in a 3D Space Shooter or a Flight Simulator.
  21326. * @param name Define the name of the camera in the scene.
  21327. * @param position Define the starting position of the camera in the scene.
  21328. * @param scene Define the scene the camera belongs to.
  21329. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  21330. */
  21331. function FlyCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  21332. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  21333. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  21334. /**
  21335. * Define the collision ellipsoid of the camera.
  21336. * This is helpful for simulating a camera body, like a player's body.
  21337. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  21338. */
  21339. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  21340. /**
  21341. * Define an offset for the position of the ellipsoid around the camera.
  21342. * This can be helpful if the camera is attached away from the player's body center,
  21343. * such as at its head.
  21344. */
  21345. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21346. /**
  21347. * Enable or disable collisions of the camera with the rest of the scene objects.
  21348. */
  21349. _this.checkCollisions = false;
  21350. /**
  21351. * Enable or disable gravity on the camera.
  21352. */
  21353. _this.applyGravity = false;
  21354. /**
  21355. * Define the current direction the camera is moving to.
  21356. */
  21357. _this.cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21358. /**
  21359. * Track Roll to maintain the wanted Rolling when looking around.
  21360. */
  21361. _this._trackRoll = 0;
  21362. /**
  21363. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  21364. */
  21365. _this.rollCorrect = 100;
  21366. /**
  21367. * Mimic a banked turn, Rolling the camera when Yawing.
  21368. * It's recommended to use rollCorrect = 10 for faster banking correction.
  21369. */
  21370. _this.bankedTurn = false;
  21371. /**
  21372. * Limit in radians for how much Roll banking will add. (Default: 90°)
  21373. */
  21374. _this.bankedTurnLimit = Math.PI / 2;
  21375. /**
  21376. * Value of 0 disables the banked Roll.
  21377. * Value of 1 is equal to the Yaw angle in radians.
  21378. */
  21379. _this.bankedTurnMultiplier = 1;
  21380. _this._needMoveForGravity = false;
  21381. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21382. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21383. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21384. // Collisions.
  21385. _this._collisionMask = -1;
  21386. /** @hidden */
  21387. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  21388. if (collidedMesh === void 0) { collidedMesh = null; }
  21389. var updatePosition = function (newPos) {
  21390. _this._newPosition.copyFrom(newPos);
  21391. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  21392. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  21393. _this.position.addInPlace(_this._diffPosition);
  21394. if (_this.onCollide && collidedMesh) {
  21395. _this.onCollide(collidedMesh);
  21396. }
  21397. }
  21398. };
  21399. updatePosition(newPosition);
  21400. };
  21401. _this.inputs = new _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FlyCameraInputsManager"](_this);
  21402. _this.inputs.addKeyboard().addMouse();
  21403. return _this;
  21404. }
  21405. Object.defineProperty(FlyCamera.prototype, "angularSensibility", {
  21406. /**
  21407. * Gets the input sensibility for mouse input.
  21408. * Higher values reduce sensitivity.
  21409. */
  21410. get: function () {
  21411. var mouse = this.inputs.attached["mouse"];
  21412. if (mouse) {
  21413. return mouse.angularSensibility;
  21414. }
  21415. return 0;
  21416. },
  21417. /**
  21418. * Sets the input sensibility for a mouse input.
  21419. * Higher values reduce sensitivity.
  21420. */
  21421. set: function (value) {
  21422. var mouse = this.inputs.attached["mouse"];
  21423. if (mouse) {
  21424. mouse.angularSensibility = value;
  21425. }
  21426. },
  21427. enumerable: true,
  21428. configurable: true
  21429. });
  21430. Object.defineProperty(FlyCamera.prototype, "keysForward", {
  21431. /**
  21432. * Get the keys for camera movement forward.
  21433. */
  21434. get: function () {
  21435. var keyboard = this.inputs.attached["keyboard"];
  21436. if (keyboard) {
  21437. return keyboard.keysForward;
  21438. }
  21439. return [];
  21440. },
  21441. /**
  21442. * Set the keys for camera movement forward.
  21443. */
  21444. set: function (value) {
  21445. var keyboard = this.inputs.attached["keyboard"];
  21446. if (keyboard) {
  21447. keyboard.keysForward = value;
  21448. }
  21449. },
  21450. enumerable: true,
  21451. configurable: true
  21452. });
  21453. Object.defineProperty(FlyCamera.prototype, "keysBackward", {
  21454. /**
  21455. * Get the keys for camera movement backward.
  21456. */
  21457. get: function () {
  21458. var keyboard = this.inputs.attached["keyboard"];
  21459. if (keyboard) {
  21460. return keyboard.keysBackward;
  21461. }
  21462. return [];
  21463. },
  21464. set: function (value) {
  21465. var keyboard = this.inputs.attached["keyboard"];
  21466. if (keyboard) {
  21467. keyboard.keysBackward = value;
  21468. }
  21469. },
  21470. enumerable: true,
  21471. configurable: true
  21472. });
  21473. Object.defineProperty(FlyCamera.prototype, "keysUp", {
  21474. /**
  21475. * Get the keys for camera movement up.
  21476. */
  21477. get: function () {
  21478. var keyboard = this.inputs.attached["keyboard"];
  21479. if (keyboard) {
  21480. return keyboard.keysUp;
  21481. }
  21482. return [];
  21483. },
  21484. /**
  21485. * Set the keys for camera movement up.
  21486. */
  21487. set: function (value) {
  21488. var keyboard = this.inputs.attached["keyboard"];
  21489. if (keyboard) {
  21490. keyboard.keysUp = value;
  21491. }
  21492. },
  21493. enumerable: true,
  21494. configurable: true
  21495. });
  21496. Object.defineProperty(FlyCamera.prototype, "keysDown", {
  21497. /**
  21498. * Get the keys for camera movement down.
  21499. */
  21500. get: function () {
  21501. var keyboard = this.inputs.attached["keyboard"];
  21502. if (keyboard) {
  21503. return keyboard.keysDown;
  21504. }
  21505. return [];
  21506. },
  21507. /**
  21508. * Set the keys for camera movement down.
  21509. */
  21510. set: function (value) {
  21511. var keyboard = this.inputs.attached["keyboard"];
  21512. if (keyboard) {
  21513. keyboard.keysDown = value;
  21514. }
  21515. },
  21516. enumerable: true,
  21517. configurable: true
  21518. });
  21519. Object.defineProperty(FlyCamera.prototype, "keysLeft", {
  21520. /**
  21521. * Get the keys for camera movement left.
  21522. */
  21523. get: function () {
  21524. var keyboard = this.inputs.attached["keyboard"];
  21525. if (keyboard) {
  21526. return keyboard.keysLeft;
  21527. }
  21528. return [];
  21529. },
  21530. /**
  21531. * Set the keys for camera movement left.
  21532. */
  21533. set: function (value) {
  21534. var keyboard = this.inputs.attached["keyboard"];
  21535. if (keyboard) {
  21536. keyboard.keysLeft = value;
  21537. }
  21538. },
  21539. enumerable: true,
  21540. configurable: true
  21541. });
  21542. Object.defineProperty(FlyCamera.prototype, "keysRight", {
  21543. /**
  21544. * Set the keys for camera movement right.
  21545. */
  21546. get: function () {
  21547. var keyboard = this.inputs.attached["keyboard"];
  21548. if (keyboard) {
  21549. return keyboard.keysRight;
  21550. }
  21551. return [];
  21552. },
  21553. /**
  21554. * Set the keys for camera movement right.
  21555. */
  21556. set: function (value) {
  21557. var keyboard = this.inputs.attached["keyboard"];
  21558. if (keyboard) {
  21559. keyboard.keysRight = value;
  21560. }
  21561. },
  21562. enumerable: true,
  21563. configurable: true
  21564. });
  21565. /**
  21566. * Attach a control to the HTML DOM element.
  21567. * @param element Defines the element that listens to the input events.
  21568. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  21569. */
  21570. FlyCamera.prototype.attachControl = function (element, noPreventDefault) {
  21571. this.inputs.attachElement(element, noPreventDefault);
  21572. };
  21573. /**
  21574. * Detach a control from the HTML DOM element.
  21575. * The camera will stop reacting to that input.
  21576. * @param element Defines the element that listens to the input events.
  21577. */
  21578. FlyCamera.prototype.detachControl = function (element) {
  21579. this.inputs.detachElement(element);
  21580. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21581. };
  21582. Object.defineProperty(FlyCamera.prototype, "collisionMask", {
  21583. /**
  21584. * Get the mask that the camera ignores in collision events.
  21585. */
  21586. get: function () {
  21587. return this._collisionMask;
  21588. },
  21589. /**
  21590. * Set the mask that the camera ignores in collision events.
  21591. */
  21592. set: function (mask) {
  21593. this._collisionMask = !isNaN(mask) ? mask : -1;
  21594. },
  21595. enumerable: true,
  21596. configurable: true
  21597. });
  21598. /** @hidden */
  21599. FlyCamera.prototype._collideWithWorld = function (displacement) {
  21600. var globalPosition;
  21601. if (this.parent) {
  21602. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  21603. }
  21604. else {
  21605. globalPosition = this.position;
  21606. }
  21607. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  21608. this._oldPosition.addInPlace(this.ellipsoidOffset);
  21609. var coordinator = this.getScene().collisionCoordinator;
  21610. if (!this._collider) {
  21611. this._collider = coordinator.createCollider();
  21612. }
  21613. this._collider._radius = this.ellipsoid;
  21614. this._collider.collisionMask = this._collisionMask;
  21615. // No need for clone, as long as gravity is not on.
  21616. var actualDisplacement = displacement;
  21617. // Add gravity to direction to prevent dual-collision checking.
  21618. if (this.applyGravity) {
  21619. // This prevents mending with cameraDirection, a global variable of the fly camera class.
  21620. actualDisplacement = displacement.add(this.getScene().gravity);
  21621. }
  21622. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  21623. };
  21624. /** @hidden */
  21625. FlyCamera.prototype._checkInputs = function () {
  21626. if (!this._localDirection) {
  21627. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21628. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21629. }
  21630. this.inputs.checkInputs();
  21631. _super.prototype._checkInputs.call(this);
  21632. };
  21633. /** @hidden */
  21634. FlyCamera.prototype._decideIfNeedsToMove = function () {
  21635. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  21636. };
  21637. /** @hidden */
  21638. FlyCamera.prototype._updatePosition = function () {
  21639. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  21640. this._collideWithWorld(this.cameraDirection);
  21641. }
  21642. else {
  21643. _super.prototype._updatePosition.call(this);
  21644. }
  21645. };
  21646. /**
  21647. * Restore the Roll to its target value at the rate specified.
  21648. * @param rate - Higher means slower restoring.
  21649. * @hidden
  21650. */
  21651. FlyCamera.prototype.restoreRoll = function (rate) {
  21652. var limit = this._trackRoll; // Target Roll.
  21653. var z = this.rotation.z; // Current Roll.
  21654. var delta = limit - z; // Difference in Roll.
  21655. var minRad = 0.001; // Tenth of a radian is a barely noticable difference.
  21656. // If the difference is noticable, restore the Roll.
  21657. if (Math.abs(delta) >= minRad) {
  21658. // Change Z rotation towards the target Roll.
  21659. this.rotation.z += delta / rate;
  21660. // Match when near enough.
  21661. if (Math.abs(limit - this.rotation.z) <= minRad) {
  21662. this.rotation.z = limit;
  21663. }
  21664. }
  21665. };
  21666. /**
  21667. * Destroy the camera and release the current resources held by it.
  21668. */
  21669. FlyCamera.prototype.dispose = function () {
  21670. this.inputs.clear();
  21671. _super.prototype.dispose.call(this);
  21672. };
  21673. /**
  21674. * Get the current object class name.
  21675. * @returns the class name.
  21676. */
  21677. FlyCamera.prototype.getClassName = function () {
  21678. return "FlyCamera";
  21679. };
  21680. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21681. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21682. ], FlyCamera.prototype, "ellipsoid", void 0);
  21683. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21684. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21685. ], FlyCamera.prototype, "ellipsoidOffset", void 0);
  21686. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21687. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21688. ], FlyCamera.prototype, "checkCollisions", void 0);
  21689. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21690. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21691. ], FlyCamera.prototype, "applyGravity", void 0);
  21692. return FlyCamera;
  21693. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  21694. /***/ }),
  21695. /***/ "./Cameras/flyCameraInputsManager.ts":
  21696. /*!*******************************************!*\
  21697. !*** ./Cameras/flyCameraInputsManager.ts ***!
  21698. \*******************************************/
  21699. /*! exports provided: FlyCameraInputsManager */
  21700. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21701. "use strict";
  21702. __webpack_require__.r(__webpack_exports__);
  21703. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return FlyCameraInputsManager; });
  21704. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21705. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  21706. /* harmony import */ var _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  21707. /* harmony import */ var _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  21708. /**
  21709. * Default Inputs manager for the FlyCamera.
  21710. * It groups all the default supported inputs for ease of use.
  21711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21712. */
  21713. var FlyCameraInputsManager = /** @class */ (function (_super) {
  21714. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCameraInputsManager, _super);
  21715. /**
  21716. * Instantiates a new FlyCameraInputsManager.
  21717. * @param camera Defines the camera the inputs belong to.
  21718. */
  21719. function FlyCameraInputsManager(camera) {
  21720. return _super.call(this, camera) || this;
  21721. }
  21722. /**
  21723. * Add keyboard input support to the input manager.
  21724. * @returns the new FlyCameraKeyboardMoveInput().
  21725. */
  21726. FlyCameraInputsManager.prototype.addKeyboard = function () {
  21727. this.add(new _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__["FlyCameraKeyboardInput"]());
  21728. return this;
  21729. };
  21730. /**
  21731. * Add mouse input support to the input manager.
  21732. * @param touchEnabled Enable touch screen support.
  21733. * @returns the new FlyCameraMouseInput().
  21734. */
  21735. FlyCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  21736. if (touchEnabled === void 0) { touchEnabled = true; }
  21737. this.add(new _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__["FlyCameraMouseInput"](touchEnabled));
  21738. return this;
  21739. };
  21740. return FlyCameraInputsManager;
  21741. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  21742. /***/ }),
  21743. /***/ "./Cameras/followCamera.ts":
  21744. /*!*********************************!*\
  21745. !*** ./Cameras/followCamera.ts ***!
  21746. \*********************************/
  21747. /*! exports provided: FollowCamera, ArcFollowCamera */
  21748. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21749. "use strict";
  21750. __webpack_require__.r(__webpack_exports__);
  21751. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return FollowCamera; });
  21752. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return ArcFollowCamera; });
  21753. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21754. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21755. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  21756. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21757. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21758. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  21759. /* harmony import */ var _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./followCameraInputsManager */ "./Cameras/followCameraInputsManager.ts");
  21760. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("FollowCamera", function (name, scene) {
  21761. return function () { return new FollowCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  21762. });
  21763. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("ArcFollowCamera", function (name, scene) {
  21764. return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
  21765. });
  21766. /**
  21767. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  21768. * an arc rotate version arcFollowCamera are available.
  21769. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21770. */
  21771. var FollowCamera = /** @class */ (function (_super) {
  21772. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCamera, _super);
  21773. /**
  21774. * Instantiates the follow camera.
  21775. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21776. * @param name Define the name of the camera in the scene
  21777. * @param position Define the position of the camera
  21778. * @param scene Define the scene the camera belong to
  21779. * @param lockedTarget Define the target of the camera
  21780. */
  21781. function FollowCamera(name, position, scene, lockedTarget) {
  21782. if (lockedTarget === void 0) { lockedTarget = null; }
  21783. var _this = _super.call(this, name, position, scene) || this;
  21784. /**
  21785. * Distance the follow camera should follow an object at
  21786. */
  21787. _this.radius = 12;
  21788. /**
  21789. * Minimum allowed distance of the camera to the axis of rotation
  21790. * (The camera can not get closer).
  21791. * This can help limiting how the Camera is able to move in the scene.
  21792. */
  21793. _this.lowerRadiusLimit = null;
  21794. /**
  21795. * Maximum allowed distance of the camera to the axis of rotation
  21796. * (The camera can not get further).
  21797. * This can help limiting how the Camera is able to move in the scene.
  21798. */
  21799. _this.upperRadiusLimit = null;
  21800. /**
  21801. * Define a rotation offset between the camera and the object it follows
  21802. */
  21803. _this.rotationOffset = 0;
  21804. /**
  21805. * Minimum allowed angle to camera position relative to target object.
  21806. * This can help limiting how the Camera is able to move in the scene.
  21807. */
  21808. _this.lowerRotationOffsetLimit = null;
  21809. /**
  21810. * Maximum allowed angle to camera position relative to target object.
  21811. * This can help limiting how the Camera is able to move in the scene.
  21812. */
  21813. _this.upperRotationOffsetLimit = null;
  21814. /**
  21815. * Define a height offset between the camera and the object it follows.
  21816. * It can help following an object from the top (like a car chaing a plane)
  21817. */
  21818. _this.heightOffset = 4;
  21819. /**
  21820. * Minimum allowed height of camera position relative to target object.
  21821. * This can help limiting how the Camera is able to move in the scene.
  21822. */
  21823. _this.lowerHeightOffsetLimit = null;
  21824. /**
  21825. * Maximum allowed height of camera position relative to target object.
  21826. * This can help limiting how the Camera is able to move in the scene.
  21827. */
  21828. _this.upperHeightOffsetLimit = null;
  21829. /**
  21830. * Define how fast the camera can accelerate to follow it s target.
  21831. */
  21832. _this.cameraAcceleration = 0.05;
  21833. /**
  21834. * Define the speed limit of the camera following an object.
  21835. */
  21836. _this.maxCameraSpeed = 20;
  21837. _this.lockedTarget = lockedTarget;
  21838. _this.inputs = new _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FollowCameraInputsManager"](_this);
  21839. _this.inputs.addKeyboard().addMouseWheel();
  21840. return _this;
  21841. // Uncomment the following line when the relevant handlers have been implemented.
  21842. // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
  21843. }
  21844. FollowCamera.prototype._follow = function (cameraTarget) {
  21845. if (!cameraTarget) {
  21846. return;
  21847. }
  21848. var yRotation;
  21849. if (cameraTarget.rotationQuaternion) {
  21850. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  21851. cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
  21852. yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
  21853. }
  21854. else {
  21855. yRotation = cameraTarget.rotation.y;
  21856. }
  21857. var radians = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this.rotationOffset) + yRotation;
  21858. var targetPosition = cameraTarget.getAbsolutePosition();
  21859. var targetX = targetPosition.x + Math.sin(radians) * this.radius;
  21860. var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
  21861. var dx = targetX - this.position.x;
  21862. var dy = (targetPosition.y + this.heightOffset) - this.position.y;
  21863. var dz = (targetZ) - this.position.z;
  21864. var vx = dx * this.cameraAcceleration * 2; //this is set to .05
  21865. var vy = dy * this.cameraAcceleration;
  21866. var vz = dz * this.cameraAcceleration * 2;
  21867. if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
  21868. vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21869. }
  21870. if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
  21871. vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21872. }
  21873. if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
  21874. vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21875. }
  21876. this.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](this.position.x + vx, this.position.y + vy, this.position.z + vz);
  21877. this.setTarget(targetPosition);
  21878. };
  21879. /**
  21880. * Attached controls to the current camera.
  21881. * @param element Defines the element the controls should be listened from
  21882. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21883. */
  21884. FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
  21885. this.inputs.attachElement(element, noPreventDefault);
  21886. this._reset = function () {
  21887. };
  21888. };
  21889. /**
  21890. * Detach the current controls from the camera.
  21891. * The camera will stop reacting to inputs.
  21892. * @param element Defines the element to stop listening the inputs from
  21893. */
  21894. FollowCamera.prototype.detachControl = function (element) {
  21895. this.inputs.detachElement(element);
  21896. if (this._reset) {
  21897. this._reset();
  21898. }
  21899. };
  21900. /** @hidden */
  21901. FollowCamera.prototype._checkInputs = function () {
  21902. this.inputs.checkInputs();
  21903. this._checkLimits();
  21904. _super.prototype._checkInputs.call(this);
  21905. if (this.lockedTarget) {
  21906. this._follow(this.lockedTarget);
  21907. }
  21908. };
  21909. FollowCamera.prototype._checkLimits = function () {
  21910. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  21911. this.radius = this.lowerRadiusLimit;
  21912. }
  21913. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  21914. this.radius = this.upperRadiusLimit;
  21915. }
  21916. if (this.lowerHeightOffsetLimit !== null &&
  21917. this.heightOffset < this.lowerHeightOffsetLimit) {
  21918. this.heightOffset = this.lowerHeightOffsetLimit;
  21919. }
  21920. if (this.upperHeightOffsetLimit !== null &&
  21921. this.heightOffset > this.upperHeightOffsetLimit) {
  21922. this.heightOffset = this.upperHeightOffsetLimit;
  21923. }
  21924. if (this.lowerRotationOffsetLimit !== null &&
  21925. this.rotationOffset < this.lowerRotationOffsetLimit) {
  21926. this.rotationOffset = this.lowerRotationOffsetLimit;
  21927. }
  21928. if (this.upperRotationOffsetLimit !== null &&
  21929. this.rotationOffset > this.upperRotationOffsetLimit) {
  21930. this.rotationOffset = this.upperRotationOffsetLimit;
  21931. }
  21932. };
  21933. /**
  21934. * Gets the camera class name.
  21935. * @returns the class name
  21936. */
  21937. FollowCamera.prototype.getClassName = function () {
  21938. return "FollowCamera";
  21939. };
  21940. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21941. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21942. ], FollowCamera.prototype, "radius", void 0);
  21943. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21944. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21945. ], FollowCamera.prototype, "lowerRadiusLimit", void 0);
  21946. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21947. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21948. ], FollowCamera.prototype, "upperRadiusLimit", void 0);
  21949. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21950. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21951. ], FollowCamera.prototype, "rotationOffset", void 0);
  21952. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21953. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21954. ], FollowCamera.prototype, "lowerRotationOffsetLimit", void 0);
  21955. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21956. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21957. ], FollowCamera.prototype, "upperRotationOffsetLimit", void 0);
  21958. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21959. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21960. ], FollowCamera.prototype, "heightOffset", void 0);
  21961. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21962. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21963. ], FollowCamera.prototype, "lowerHeightOffsetLimit", void 0);
  21964. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21965. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21966. ], FollowCamera.prototype, "upperHeightOffsetLimit", void 0);
  21967. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21968. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21969. ], FollowCamera.prototype, "cameraAcceleration", void 0);
  21970. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21971. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21972. ], FollowCamera.prototype, "maxCameraSpeed", void 0);
  21973. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21974. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  21975. ], FollowCamera.prototype, "lockedTarget", void 0);
  21976. return FollowCamera;
  21977. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  21978. /**
  21979. * Arc Rotate version of the follow camera.
  21980. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  21981. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21982. */
  21983. var ArcFollowCamera = /** @class */ (function (_super) {
  21984. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcFollowCamera, _super);
  21985. /**
  21986. * Instantiates a new ArcFollowCamera
  21987. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21988. * @param name Define the name of the camera
  21989. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  21990. * @param beta Define the rotation angle of the camera around the elevation axis
  21991. * @param radius Define the radius of the camera from its target point
  21992. * @param target Define the target of the camera
  21993. * @param scene Define the scene the camera belongs to
  21994. */
  21995. function ArcFollowCamera(name,
  21996. /** The longitudinal angle of the camera */
  21997. alpha,
  21998. /** The latitudinal angle of the camera */
  21999. beta,
  22000. /** The radius of the camera from its target */
  22001. radius,
  22002. /** Define the camera target (the messh it should follow) */
  22003. target, scene) {
  22004. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene) || this;
  22005. _this.alpha = alpha;
  22006. _this.beta = beta;
  22007. _this.radius = radius;
  22008. _this.target = target;
  22009. _this._cartesianCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  22010. _this._follow();
  22011. return _this;
  22012. }
  22013. ArcFollowCamera.prototype._follow = function () {
  22014. if (!this.target) {
  22015. return;
  22016. }
  22017. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
  22018. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
  22019. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  22020. var targetPosition = this.target.getAbsolutePosition();
  22021. this.position = targetPosition.add(this._cartesianCoordinates);
  22022. this.setTarget(targetPosition);
  22023. };
  22024. /** @hidden */
  22025. ArcFollowCamera.prototype._checkInputs = function () {
  22026. _super.prototype._checkInputs.call(this);
  22027. this._follow();
  22028. };
  22029. /**
  22030. * Returns the class name of the object.
  22031. * It is mostly used internally for serialization purposes.
  22032. */
  22033. ArcFollowCamera.prototype.getClassName = function () {
  22034. return "ArcFollowCamera";
  22035. };
  22036. return ArcFollowCamera;
  22037. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22038. /***/ }),
  22039. /***/ "./Cameras/followCameraInputsManager.ts":
  22040. /*!**********************************************!*\
  22041. !*** ./Cameras/followCameraInputsManager.ts ***!
  22042. \**********************************************/
  22043. /*! exports provided: FollowCameraInputsManager */
  22044. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22045. "use strict";
  22046. __webpack_require__.r(__webpack_exports__);
  22047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraInputsManager", function() { return FollowCameraInputsManager; });
  22048. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22049. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22050. /* harmony import */ var _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Inputs/followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  22051. /* harmony import */ var _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Inputs/followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  22052. /**
  22053. * Default Inputs manager for the FollowCamera.
  22054. * It groups all the default supported inputs for ease of use.
  22055. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22056. */
  22057. var FollowCameraInputsManager = /** @class */ (function (_super) {
  22058. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraInputsManager, _super);
  22059. /**
  22060. * Instantiates a new FollowCameraInputsManager.
  22061. * @param camera Defines the camera the inputs belong to
  22062. */
  22063. function FollowCameraInputsManager(camera) {
  22064. return _super.call(this, camera) || this;
  22065. }
  22066. /**
  22067. * Add keyboard input support to the input manager.
  22068. * @returns the current input manager
  22069. */
  22070. FollowCameraInputsManager.prototype.addKeyboard = function () {
  22071. this.add(new _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FollowCameraKeyboardMoveInput"]());
  22072. return this;
  22073. };
  22074. /**
  22075. * Add mouse wheel input support to the input manager.
  22076. * @returns the current input manager
  22077. */
  22078. FollowCameraInputsManager.prototype.addMouseWheel = function () {
  22079. this.add(new _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["FollowCameraMouseWheelInput"]());
  22080. return this;
  22081. };
  22082. /**
  22083. * Add pointers input support to the input manager.
  22084. * @returns the current input manager
  22085. */
  22086. FollowCameraInputsManager.prototype.addPointers = function () {
  22087. console.warn("Pointer support not yet implemented for FollowCamera.");
  22088. return this;
  22089. };
  22090. /**
  22091. * Add orientation input support to the input manager.
  22092. * @returns the current input manager
  22093. */
  22094. FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  22095. console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
  22096. return this;
  22097. };
  22098. return FollowCameraInputsManager;
  22099. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22100. /***/ }),
  22101. /***/ "./Cameras/freeCamera.ts":
  22102. /*!*******************************!*\
  22103. !*** ./Cameras/freeCamera.ts ***!
  22104. \*******************************/
  22105. /*! exports provided: FreeCamera */
  22106. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22107. "use strict";
  22108. __webpack_require__.r(__webpack_exports__);
  22109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return FreeCamera; });
  22110. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22111. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22112. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22113. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  22114. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22115. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22116. /**
  22117. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22118. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  22119. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22120. */
  22121. var FreeCamera = /** @class */ (function (_super) {
  22122. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCamera, _super);
  22123. /**
  22124. * Instantiates a Free Camera.
  22125. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22126. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  22127. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22128. * @param name Define the name of the camera in the scene
  22129. * @param position Define the start position of the camera in the scene
  22130. * @param scene Define the scene the camera belongs to
  22131. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22132. */
  22133. function FreeCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22134. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22135. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22136. /**
  22137. * Define the collision ellipsoid of the camera.
  22138. * This is helpful to simulate a camera body like the player body around the camera
  22139. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22140. */
  22141. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.5, 1, 0.5);
  22142. /**
  22143. * Define an offset for the position of the ellipsoid around the camera.
  22144. * This can be helpful to determine the center of the body near the gravity center of the body
  22145. * instead of its head.
  22146. */
  22147. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22148. /**
  22149. * Enable or disable collisions of the camera with the rest of the scene objects.
  22150. */
  22151. _this.checkCollisions = false;
  22152. /**
  22153. * Enable or disable gravity on the camera.
  22154. */
  22155. _this.applyGravity = false;
  22156. _this._needMoveForGravity = false;
  22157. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22158. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22159. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22160. // Collisions
  22161. _this._collisionMask = -1;
  22162. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22163. if (collidedMesh === void 0) { collidedMesh = null; }
  22164. var updatePosition = function (newPos) {
  22165. _this._newPosition.copyFrom(newPos);
  22166. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22167. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22168. _this.position.addInPlace(_this._diffPosition);
  22169. if (_this.onCollide && collidedMesh) {
  22170. _this.onCollide(collidedMesh);
  22171. }
  22172. }
  22173. };
  22174. updatePosition(newPosition);
  22175. };
  22176. _this.inputs = new _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"](_this);
  22177. _this.inputs.addKeyboard().addMouse();
  22178. return _this;
  22179. }
  22180. Object.defineProperty(FreeCamera.prototype, "angularSensibility", {
  22181. /**
  22182. * Gets the input sensibility for a mouse input. (default is 2000.0)
  22183. * Higher values reduce sensitivity.
  22184. */
  22185. get: function () {
  22186. var mouse = this.inputs.attached["mouse"];
  22187. if (mouse) {
  22188. return mouse.angularSensibility;
  22189. }
  22190. return 0;
  22191. },
  22192. /**
  22193. * Sets the input sensibility for a mouse input. (default is 2000.0)
  22194. * Higher values reduce sensitivity.
  22195. */
  22196. set: function (value) {
  22197. var mouse = this.inputs.attached["mouse"];
  22198. if (mouse) {
  22199. mouse.angularSensibility = value;
  22200. }
  22201. },
  22202. enumerable: true,
  22203. configurable: true
  22204. });
  22205. Object.defineProperty(FreeCamera.prototype, "keysUp", {
  22206. /**
  22207. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  22208. */
  22209. get: function () {
  22210. var keyboard = this.inputs.attached["keyboard"];
  22211. if (keyboard) {
  22212. return keyboard.keysUp;
  22213. }
  22214. return [];
  22215. },
  22216. set: function (value) {
  22217. var keyboard = this.inputs.attached["keyboard"];
  22218. if (keyboard) {
  22219. keyboard.keysUp = value;
  22220. }
  22221. },
  22222. enumerable: true,
  22223. configurable: true
  22224. });
  22225. Object.defineProperty(FreeCamera.prototype, "keysDown", {
  22226. /**
  22227. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  22228. */
  22229. get: function () {
  22230. var keyboard = this.inputs.attached["keyboard"];
  22231. if (keyboard) {
  22232. return keyboard.keysDown;
  22233. }
  22234. return [];
  22235. },
  22236. set: function (value) {
  22237. var keyboard = this.inputs.attached["keyboard"];
  22238. if (keyboard) {
  22239. keyboard.keysDown = value;
  22240. }
  22241. },
  22242. enumerable: true,
  22243. configurable: true
  22244. });
  22245. Object.defineProperty(FreeCamera.prototype, "keysLeft", {
  22246. /**
  22247. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  22248. */
  22249. get: function () {
  22250. var keyboard = this.inputs.attached["keyboard"];
  22251. if (keyboard) {
  22252. return keyboard.keysLeft;
  22253. }
  22254. return [];
  22255. },
  22256. set: function (value) {
  22257. var keyboard = this.inputs.attached["keyboard"];
  22258. if (keyboard) {
  22259. keyboard.keysLeft = value;
  22260. }
  22261. },
  22262. enumerable: true,
  22263. configurable: true
  22264. });
  22265. Object.defineProperty(FreeCamera.prototype, "keysRight", {
  22266. /**
  22267. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  22268. */
  22269. get: function () {
  22270. var keyboard = this.inputs.attached["keyboard"];
  22271. if (keyboard) {
  22272. return keyboard.keysRight;
  22273. }
  22274. return [];
  22275. },
  22276. set: function (value) {
  22277. var keyboard = this.inputs.attached["keyboard"];
  22278. if (keyboard) {
  22279. keyboard.keysRight = value;
  22280. }
  22281. },
  22282. enumerable: true,
  22283. configurable: true
  22284. });
  22285. /**
  22286. * Attached controls to the current camera.
  22287. * @param element Defines the element the controls should be listened from
  22288. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22289. */
  22290. FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  22291. this.inputs.attachElement(element, noPreventDefault);
  22292. };
  22293. /**
  22294. * Detach the current controls from the camera.
  22295. * The camera will stop reacting to inputs.
  22296. * @param element Defines the element to stop listening the inputs from
  22297. */
  22298. FreeCamera.prototype.detachControl = function (element) {
  22299. this.inputs.detachElement(element);
  22300. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22301. this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  22302. };
  22303. Object.defineProperty(FreeCamera.prototype, "collisionMask", {
  22304. /**
  22305. * Define a collision mask to limit the list of object the camera can collide with
  22306. */
  22307. get: function () {
  22308. return this._collisionMask;
  22309. },
  22310. set: function (mask) {
  22311. this._collisionMask = !isNaN(mask) ? mask : -1;
  22312. },
  22313. enumerable: true,
  22314. configurable: true
  22315. });
  22316. /** @hidden */
  22317. FreeCamera.prototype._collideWithWorld = function (displacement) {
  22318. var globalPosition;
  22319. if (this.parent) {
  22320. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22321. }
  22322. else {
  22323. globalPosition = this.position;
  22324. }
  22325. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22326. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22327. var coordinator = this.getScene().collisionCoordinator;
  22328. if (!this._collider) {
  22329. this._collider = coordinator.createCollider();
  22330. }
  22331. this._collider._radius = this.ellipsoid;
  22332. this._collider.collisionMask = this._collisionMask;
  22333. //no need for clone, as long as gravity is not on.
  22334. var actualDisplacement = displacement;
  22335. //add gravity to the direction to prevent the dual-collision checking
  22336. if (this.applyGravity) {
  22337. //this prevents mending with cameraDirection, a global variable of the free camera class.
  22338. actualDisplacement = displacement.add(this.getScene().gravity);
  22339. }
  22340. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22341. };
  22342. /** @hidden */
  22343. FreeCamera.prototype._checkInputs = function () {
  22344. if (!this._localDirection) {
  22345. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22346. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22347. }
  22348. this.inputs.checkInputs();
  22349. _super.prototype._checkInputs.call(this);
  22350. };
  22351. /** @hidden */
  22352. FreeCamera.prototype._decideIfNeedsToMove = function () {
  22353. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22354. };
  22355. /** @hidden */
  22356. FreeCamera.prototype._updatePosition = function () {
  22357. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22358. this._collideWithWorld(this.cameraDirection);
  22359. }
  22360. else {
  22361. _super.prototype._updatePosition.call(this);
  22362. }
  22363. };
  22364. /**
  22365. * Destroy the camera and release the current resources hold by it.
  22366. */
  22367. FreeCamera.prototype.dispose = function () {
  22368. this.inputs.clear();
  22369. _super.prototype.dispose.call(this);
  22370. };
  22371. /**
  22372. * Gets the current object class name.
  22373. * @return the class name
  22374. */
  22375. FreeCamera.prototype.getClassName = function () {
  22376. return "FreeCamera";
  22377. };
  22378. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22379. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22380. ], FreeCamera.prototype, "ellipsoid", void 0);
  22381. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22382. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22383. ], FreeCamera.prototype, "ellipsoidOffset", void 0);
  22384. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22385. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22386. ], FreeCamera.prototype, "checkCollisions", void 0);
  22387. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22388. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22389. ], FreeCamera.prototype, "applyGravity", void 0);
  22390. return FreeCamera;
  22391. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22392. /***/ }),
  22393. /***/ "./Cameras/freeCameraInputsManager.ts":
  22394. /*!********************************************!*\
  22395. !*** ./Cameras/freeCameraInputsManager.ts ***!
  22396. \********************************************/
  22397. /*! exports provided: FreeCameraInputsManager */
  22398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22399. "use strict";
  22400. __webpack_require__.r(__webpack_exports__);
  22401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return FreeCameraInputsManager; });
  22402. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22403. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22404. /* harmony import */ var _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  22405. /* harmony import */ var _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  22406. /* harmony import */ var _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  22407. /**
  22408. * Default Inputs manager for the FreeCamera.
  22409. * It groups all the default supported inputs for ease of use.
  22410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22411. */
  22412. var FreeCameraInputsManager = /** @class */ (function (_super) {
  22413. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCameraInputsManager, _super);
  22414. /**
  22415. * Instantiates a new FreeCameraInputsManager.
  22416. * @param camera Defines the camera the inputs belong to
  22417. */
  22418. function FreeCameraInputsManager(camera) {
  22419. return _super.call(this, camera) || this;
  22420. }
  22421. /**
  22422. * Add keyboard input support to the input manager.
  22423. * @returns the current input manager
  22424. */
  22425. FreeCameraInputsManager.prototype.addKeyboard = function () {
  22426. this.add(new _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FreeCameraKeyboardMoveInput"]());
  22427. return this;
  22428. };
  22429. /**
  22430. * Add mouse input support to the input manager.
  22431. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  22432. * @returns the current input manager
  22433. */
  22434. FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  22435. if (touchEnabled === void 0) { touchEnabled = true; }
  22436. this.add(new _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__["FreeCameraMouseInput"](touchEnabled));
  22437. return this;
  22438. };
  22439. /**
  22440. * Add touch input support to the input manager.
  22441. * @returns the current input manager
  22442. */
  22443. FreeCameraInputsManager.prototype.addTouch = function () {
  22444. this.add(new _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraTouchInput"]());
  22445. return this;
  22446. };
  22447. return FreeCameraInputsManager;
  22448. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22449. /***/ }),
  22450. /***/ "./Cameras/gamepadCamera.ts":
  22451. /*!**********************************!*\
  22452. !*** ./Cameras/gamepadCamera.ts ***!
  22453. \**********************************/
  22454. /*! exports provided: GamepadCamera */
  22455. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22456. "use strict";
  22457. __webpack_require__.r(__webpack_exports__);
  22458. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return GamepadCamera; });
  22459. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22460. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  22461. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22462. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  22463. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("GamepadCamera", function (name, scene) {
  22464. return function () { return new GamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  22465. });
  22466. /**
  22467. * This represents a FPS type of camera. This is only here for back compat purpose.
  22468. * Please use the UniversalCamera instead as both are identical.
  22469. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22470. */
  22471. var GamepadCamera = /** @class */ (function (_super) {
  22472. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GamepadCamera, _super);
  22473. /**
  22474. * Instantiates a new Gamepad Camera
  22475. * This represents a FPS type of camera. This is only here for back compat purpose.
  22476. * Please use the UniversalCamera instead as both are identical.
  22477. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22478. * @param name Define the name of the camera in the scene
  22479. * @param position Define the start position of the camera in the scene
  22480. * @param scene Define the scene the camera belongs to
  22481. */
  22482. function GamepadCamera(name, position, scene) {
  22483. return _super.call(this, name, position, scene) || this;
  22484. }
  22485. /**
  22486. * Gets the current object class name.
  22487. * @return the class name
  22488. */
  22489. GamepadCamera.prototype.getClassName = function () {
  22490. return "GamepadCamera";
  22491. };
  22492. return GamepadCamera;
  22493. }(_universalCamera__WEBPACK_IMPORTED_MODULE_1__["UniversalCamera"]));
  22494. /***/ }),
  22495. /***/ "./Cameras/index.ts":
  22496. /*!**************************!*\
  22497. !*** ./Cameras/index.ts ***!
  22498. \**************************/
  22499. /*! exports provided: CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  22500. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22501. "use strict";
  22502. __webpack_require__.r(__webpack_exports__);
  22503. /* harmony import */ var _Inputs_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Inputs/index */ "./Cameras/Inputs/index.ts");
  22504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  22505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  22506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  22507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  22508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  22509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  22510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  22511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  22512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  22513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  22514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  22515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  22516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  22517. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]; });
  22519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]; });
  22520. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]; });
  22522. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]; });
  22524. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  22525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _freeCamera__WEBPACK_IMPORTED_MODULE_4__["FreeCamera"]; });
  22526. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"]; });
  22528. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  22529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _touchCamera__WEBPACK_IMPORTED_MODULE_6__["TouchCamera"]; });
  22530. /* harmony import */ var _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  22531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  22532. /* harmony import */ var _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  22533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__["ArcRotateCameraInputsManager"]; });
  22534. /* harmony import */ var _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  22535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__["DeviceOrientationCamera"]; });
  22536. /* harmony import */ var _flyCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./flyCamera */ "./Cameras/flyCamera.ts");
  22537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _flyCamera__WEBPACK_IMPORTED_MODULE_10__["FlyCamera"]; });
  22538. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  22539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["FlyCameraInputsManager"]; });
  22540. /* harmony import */ var _followCamera__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./followCamera */ "./Cameras/followCamera.ts");
  22541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["FollowCamera"]; });
  22542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["ArcFollowCamera"]; });
  22543. /* harmony import */ var _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gamepadCamera */ "./Cameras/gamepadCamera.ts");
  22544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__["GamepadCamera"]; });
  22545. /* harmony import */ var _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Stereoscopic/index */ "./Cameras/Stereoscopic/index.ts");
  22546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphArcRotateCamera"]; });
  22547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphFreeCamera"]; });
  22548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphGamepadCamera"]; });
  22549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphUniversalCamera"]; });
  22550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicArcRotateCamera"]; });
  22551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicFreeCamera"]; });
  22552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicGamepadCamera"]; });
  22553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicUniversalCamera"]; });
  22554. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  22555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _universalCamera__WEBPACK_IMPORTED_MODULE_15__["UniversalCamera"]; });
  22556. /* harmony import */ var _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtualJoysticksCamera */ "./Cameras/virtualJoysticksCamera.ts");
  22557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__["VirtualJoysticksCamera"]; });
  22558. /* harmony import */ var _VR_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./VR/index */ "./Cameras/VR/index.ts");
  22559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRCameraMetrics"]; });
  22560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationArcRotateCamera"]; });
  22561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationFreeCamera"]; });
  22562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationGamepadCamera"]; });
  22563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRExperienceHelper"]; });
  22564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["WebVRFreeCamera"]; });
  22565. /* harmony import */ var _XR_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./XR/index */ "./Cameras/XR/index.ts");
  22566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRCamera"]; });
  22567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIButton"]; });
  22568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIOptions"]; });
  22569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUI"]; });
  22570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRState"]; });
  22571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRExperienceHelper"]; });
  22572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRController"]; });
  22573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRInput"]; });
  22574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRManagedOutputCanvas"]; });
  22575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRSessionManager"]; });
  22576. /***/ }),
  22577. /***/ "./Cameras/targetCamera.ts":
  22578. /*!*********************************!*\
  22579. !*** ./Cameras/targetCamera.ts ***!
  22580. \*********************************/
  22581. /*! exports provided: TargetCamera */
  22582. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22583. "use strict";
  22584. __webpack_require__.r(__webpack_exports__);
  22585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return TargetCamera; });
  22586. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22587. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22588. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22589. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22590. /**
  22591. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  22592. * This is the base of the follow, arc rotate cameras and Free camera
  22593. * @see http://doc.babylonjs.com/features/cameras
  22594. */
  22595. var TargetCamera = /** @class */ (function (_super) {
  22596. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TargetCamera, _super);
  22597. /**
  22598. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  22599. * This is the base of the follow, arc rotate cameras and Free camera
  22600. * @see http://doc.babylonjs.com/features/cameras
  22601. * @param name Defines the name of the camera in the scene
  22602. * @param position Defines the start position of the camera in the scene
  22603. * @param scene Defines the scene the camera belongs to
  22604. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22605. */
  22606. function TargetCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22607. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22608. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22609. /**
  22610. * Define the current direction the camera is moving to
  22611. */
  22612. _this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  22613. /**
  22614. * Define the current rotation the camera is rotating to
  22615. */
  22616. _this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  22617. /**
  22618. * When set, the up vector of the camera will be updated by the rotation of the camera
  22619. */
  22620. _this.updateUpVectorFromRotation = false;
  22621. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22622. /**
  22623. * Define the current rotation of the camera
  22624. */
  22625. _this.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  22626. /**
  22627. * Define the current speed of the camera
  22628. */
  22629. _this.speed = 2.0;
  22630. /**
  22631. * Add cconstraint to the camera to prevent it to move freely in all directions and
  22632. * around all axis.
  22633. */
  22634. _this.noRotationConstraint = false;
  22635. /**
  22636. * Define the current target of the camera as an object or a position.
  22637. */
  22638. _this.lockedTarget = null;
  22639. /** @hidden */
  22640. _this._currentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22641. /** @hidden */
  22642. _this._initialFocalDistance = 1;
  22643. /** @hidden */
  22644. _this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22645. /** @hidden */
  22646. _this._camMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22647. /** @hidden */
  22648. _this._cameraTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22649. /** @hidden */
  22650. _this._cameraRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22651. /** @hidden */
  22652. _this._referencePoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  22653. /** @hidden */
  22654. _this._transformedReferencePoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22655. _this._globalCurrentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22656. _this._globalCurrentUpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22657. _this._defaultUp = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  22658. _this._cachedRotationZ = 0;
  22659. _this._cachedQuaternionRotationZ = 0;
  22660. return _this;
  22661. }
  22662. /**
  22663. * Gets the position in front of the camera at a given distance.
  22664. * @param distance The distance from the camera we want the position to be
  22665. * @returns the position
  22666. */
  22667. TargetCamera.prototype.getFrontPosition = function (distance) {
  22668. this.getWorldMatrix();
  22669. var direction = this.getTarget().subtract(this.position);
  22670. direction.normalize();
  22671. direction.scaleInPlace(distance);
  22672. return this.globalPosition.add(direction);
  22673. };
  22674. /** @hidden */
  22675. TargetCamera.prototype._getLockedTargetPosition = function () {
  22676. if (!this.lockedTarget) {
  22677. return null;
  22678. }
  22679. if (this.lockedTarget.absolutePosition) {
  22680. this.lockedTarget.computeWorldMatrix();
  22681. }
  22682. return this.lockedTarget.absolutePosition || this.lockedTarget;
  22683. };
  22684. /**
  22685. * Store current camera state of the camera (fov, position, rotation, etc..)
  22686. * @returns the camera
  22687. */
  22688. TargetCamera.prototype.storeState = function () {
  22689. this._storedPosition = this.position.clone();
  22690. this._storedRotation = this.rotation.clone();
  22691. if (this.rotationQuaternion) {
  22692. this._storedRotationQuaternion = this.rotationQuaternion.clone();
  22693. }
  22694. return _super.prototype.storeState.call(this);
  22695. };
  22696. /**
  22697. * Restored camera state. You must call storeState() first
  22698. * @returns whether it was successful or not
  22699. * @hidden
  22700. */
  22701. TargetCamera.prototype._restoreStateValues = function () {
  22702. if (!_super.prototype._restoreStateValues.call(this)) {
  22703. return false;
  22704. }
  22705. this.position = this._storedPosition.clone();
  22706. this.rotation = this._storedRotation.clone();
  22707. if (this.rotationQuaternion) {
  22708. this.rotationQuaternion = this._storedRotationQuaternion.clone();
  22709. }
  22710. this.cameraDirection.copyFromFloats(0, 0, 0);
  22711. this.cameraRotation.copyFromFloats(0, 0);
  22712. return true;
  22713. };
  22714. /** @hidden */
  22715. TargetCamera.prototype._initCache = function () {
  22716. _super.prototype._initCache.call(this);
  22717. this._cache.lockedTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22718. this._cache.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22719. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22720. };
  22721. /** @hidden */
  22722. TargetCamera.prototype._updateCache = function (ignoreParentClass) {
  22723. if (!ignoreParentClass) {
  22724. _super.prototype._updateCache.call(this);
  22725. }
  22726. var lockedTargetPosition = this._getLockedTargetPosition();
  22727. if (!lockedTargetPosition) {
  22728. this._cache.lockedTarget = null;
  22729. }
  22730. else {
  22731. if (!this._cache.lockedTarget) {
  22732. this._cache.lockedTarget = lockedTargetPosition.clone();
  22733. }
  22734. else {
  22735. this._cache.lockedTarget.copyFrom(lockedTargetPosition);
  22736. }
  22737. }
  22738. this._cache.rotation.copyFrom(this.rotation);
  22739. if (this.rotationQuaternion) {
  22740. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22741. }
  22742. };
  22743. // Synchronized
  22744. /** @hidden */
  22745. TargetCamera.prototype._isSynchronizedViewMatrix = function () {
  22746. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  22747. return false;
  22748. }
  22749. var lockedTargetPosition = this._getLockedTargetPosition();
  22750. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
  22751. && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
  22752. };
  22753. // Methods
  22754. /** @hidden */
  22755. TargetCamera.prototype._computeLocalCameraSpeed = function () {
  22756. var engine = this.getEngine();
  22757. return this.speed * Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 100.0)));
  22758. };
  22759. // Target
  22760. /** @hidden */
  22761. TargetCamera.prototype.setTarget = function (target) {
  22762. this.upVector.normalize();
  22763. this._initialFocalDistance = target.subtract(this.position).length();
  22764. if (this.position.z === target.z) {
  22765. this.position.z += _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  22766. }
  22767. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this.position, target, this._defaultUp, this._camMatrix);
  22768. this._camMatrix.invert();
  22769. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  22770. var vDir = target.subtract(this.position);
  22771. if (vDir.x >= 0.0) {
  22772. this.rotation.y = (-Math.atan(vDir.z / vDir.x) + Math.PI / 2.0);
  22773. }
  22774. else {
  22775. this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
  22776. }
  22777. this.rotation.z = 0;
  22778. if (isNaN(this.rotation.x)) {
  22779. this.rotation.x = 0;
  22780. }
  22781. if (isNaN(this.rotation.y)) {
  22782. this.rotation.y = 0;
  22783. }
  22784. if (isNaN(this.rotation.z)) {
  22785. this.rotation.z = 0;
  22786. }
  22787. if (this.rotationQuaternion) {
  22788. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  22789. }
  22790. };
  22791. /**
  22792. * Return the current target position of the camera. This value is expressed in local space.
  22793. * @returns the target position
  22794. */
  22795. TargetCamera.prototype.getTarget = function () {
  22796. return this._currentTarget;
  22797. };
  22798. /** @hidden */
  22799. TargetCamera.prototype._decideIfNeedsToMove = function () {
  22800. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22801. };
  22802. /** @hidden */
  22803. TargetCamera.prototype._updatePosition = function () {
  22804. if (this.parent) {
  22805. this.parent.getWorldMatrix().invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  22806. _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]);
  22807. this.position.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  22808. return;
  22809. }
  22810. this.position.addInPlace(this.cameraDirection);
  22811. };
  22812. /** @hidden */
  22813. TargetCamera.prototype._checkInputs = function () {
  22814. var needToMove = this._decideIfNeedsToMove();
  22815. var needToRotate = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  22816. // Move
  22817. if (needToMove) {
  22818. this._updatePosition();
  22819. }
  22820. // Rotate
  22821. if (needToRotate) {
  22822. this.rotation.x += this.cameraRotation.x;
  22823. this.rotation.y += this.cameraRotation.y;
  22824. //rotate, if quaternion is set and rotation was used
  22825. if (this.rotationQuaternion) {
  22826. var len = this.rotation.lengthSquared();
  22827. if (len) {
  22828. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  22829. }
  22830. }
  22831. if (!this.noRotationConstraint) {
  22832. var limit = (Math.PI / 2) * 0.95;
  22833. if (this.rotation.x > limit) {
  22834. this.rotation.x = limit;
  22835. }
  22836. if (this.rotation.x < -limit) {
  22837. this.rotation.x = -limit;
  22838. }
  22839. }
  22840. }
  22841. // Inertia
  22842. if (needToMove) {
  22843. if (Math.abs(this.cameraDirection.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22844. this.cameraDirection.x = 0;
  22845. }
  22846. if (Math.abs(this.cameraDirection.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22847. this.cameraDirection.y = 0;
  22848. }
  22849. if (Math.abs(this.cameraDirection.z) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22850. this.cameraDirection.z = 0;
  22851. }
  22852. this.cameraDirection.scaleInPlace(this.inertia);
  22853. }
  22854. if (needToRotate) {
  22855. if (Math.abs(this.cameraRotation.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22856. this.cameraRotation.x = 0;
  22857. }
  22858. if (Math.abs(this.cameraRotation.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22859. this.cameraRotation.y = 0;
  22860. }
  22861. this.cameraRotation.scaleInPlace(this.inertia);
  22862. }
  22863. _super.prototype._checkInputs.call(this);
  22864. };
  22865. TargetCamera.prototype._updateCameraRotationMatrix = function () {
  22866. if (this.rotationQuaternion) {
  22867. this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
  22868. }
  22869. else {
  22870. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
  22871. }
  22872. };
  22873. /**
  22874. * 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)
  22875. * @returns the current camera
  22876. */
  22877. TargetCamera.prototype._rotateUpVectorWithCameraRotationMatrix = function () {
  22878. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector);
  22879. return this;
  22880. };
  22881. /** @hidden */
  22882. TargetCamera.prototype._getViewMatrix = function () {
  22883. if (this.lockedTarget) {
  22884. this.setTarget(this._getLockedTargetPosition());
  22885. }
  22886. // Compute
  22887. this._updateCameraRotationMatrix();
  22888. // Apply the changed rotation to the upVector
  22889. if (this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z) {
  22890. this._rotateUpVectorWithCameraRotationMatrix();
  22891. this._cachedQuaternionRotationZ = this.rotationQuaternion.z;
  22892. }
  22893. else if (this._cachedRotationZ != this.rotation.z) {
  22894. this._rotateUpVectorWithCameraRotationMatrix();
  22895. this._cachedRotationZ = this.rotation.z;
  22896. }
  22897. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  22898. // Computing target and final matrix
  22899. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  22900. if (this.updateUpVectorFromRotation) {
  22901. if (this.rotationQuaternion) {
  22902. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
  22903. }
  22904. else {
  22905. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
  22906. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
  22907. }
  22908. }
  22909. this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
  22910. return this._viewMatrix;
  22911. };
  22912. TargetCamera.prototype._computeViewMatrix = function (position, target, up) {
  22913. if (this.parent) {
  22914. var parentWorldMatrix = this.parent.getWorldMatrix();
  22915. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, parentWorldMatrix, this._globalPosition);
  22916. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(target, parentWorldMatrix, this._globalCurrentTarget);
  22917. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(up, parentWorldMatrix, this._globalCurrentUpVector);
  22918. this._markSyncedWithParent();
  22919. }
  22920. else {
  22921. this._globalPosition.copyFrom(position);
  22922. this._globalCurrentTarget.copyFrom(target);
  22923. this._globalCurrentUpVector.copyFrom(up);
  22924. }
  22925. if (this.getScene().useRightHandedSystem) {
  22926. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtRHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  22927. }
  22928. else {
  22929. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  22930. }
  22931. };
  22932. /**
  22933. * @hidden
  22934. */
  22935. TargetCamera.prototype.createRigCamera = function (name, cameraIndex) {
  22936. if (this.cameraRigMode !== _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_NONE) {
  22937. var rigCamera = new TargetCamera(name, this.position.clone(), this.getScene());
  22938. if (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR || this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_WEBVR) {
  22939. if (!this.rotationQuaternion) {
  22940. this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22941. }
  22942. rigCamera._cameraRigParams = {};
  22943. rigCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22944. }
  22945. return rigCamera;
  22946. }
  22947. return null;
  22948. };
  22949. /**
  22950. * @hidden
  22951. */
  22952. TargetCamera.prototype._updateRigCameras = function () {
  22953. var camLeft = this._rigCameras[0];
  22954. var camRight = this._rigCameras[1];
  22955. this.computeWorldMatrix();
  22956. switch (this.cameraRigMode) {
  22957. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  22958. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  22959. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  22960. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  22961. //provisionnaly using _cameraRigParams.stereoHalfAngle instead of calculations based on _cameraRigParams.interaxialDistance:
  22962. var leftSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : -1;
  22963. var rightSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? -1 : 1;
  22964. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * leftSign, camLeft);
  22965. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * rightSign, camRight);
  22966. break;
  22967. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR:
  22968. if (camLeft.rotationQuaternion) {
  22969. camLeft.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22970. camRight.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22971. }
  22972. else {
  22973. camLeft.rotation.copyFrom(this.rotation);
  22974. camRight.rotation.copyFrom(this.rotation);
  22975. }
  22976. camLeft.position.copyFrom(this.position);
  22977. camRight.position.copyFrom(this.position);
  22978. break;
  22979. }
  22980. _super.prototype._updateRigCameras.call(this);
  22981. };
  22982. TargetCamera.prototype._getRigCamPositionAndTarget = function (halfSpace, rigCamera) {
  22983. var target = this.getTarget();
  22984. target.subtractToRef(this.position, TargetCamera._TargetFocalPoint);
  22985. TargetCamera._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  22986. var newFocalTarget = TargetCamera._TargetFocalPoint.addInPlace(this.position);
  22987. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-newFocalTarget.x, -newFocalTarget.y, -newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  22988. TargetCamera._TargetTransformMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(halfSpace), TargetCamera._RigCamTransformMatrix);
  22989. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(newFocalTarget.x, newFocalTarget.y, newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  22990. TargetCamera._RigCamTransformMatrix.multiplyToRef(TargetCamera._TargetTransformMatrix, TargetCamera._RigCamTransformMatrix);
  22991. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, TargetCamera._RigCamTransformMatrix, rigCamera.position);
  22992. rigCamera.setTarget(newFocalTarget);
  22993. };
  22994. /**
  22995. * Gets the current object class name.
  22996. * @return the class name
  22997. */
  22998. TargetCamera.prototype.getClassName = function () {
  22999. return "TargetCamera";
  23000. };
  23001. TargetCamera._RigCamTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23002. TargetCamera._TargetTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23003. TargetCamera._TargetFocalPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  23004. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23005. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23006. ], TargetCamera.prototype, "rotation", void 0);
  23007. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23008. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23009. ], TargetCamera.prototype, "speed", void 0);
  23010. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23011. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  23012. ], TargetCamera.prototype, "lockedTarget", void 0);
  23013. return TargetCamera;
  23014. }(_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]));
  23015. /***/ }),
  23016. /***/ "./Cameras/touchCamera.ts":
  23017. /*!********************************!*\
  23018. !*** ./Cameras/touchCamera.ts ***!
  23019. \********************************/
  23020. /*! exports provided: TouchCamera */
  23021. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23022. "use strict";
  23023. __webpack_require__.r(__webpack_exports__);
  23024. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return TouchCamera; });
  23025. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23026. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23027. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23028. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23029. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("TouchCamera", function (name, scene) {
  23030. return function () { return new TouchCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23031. });
  23032. /**
  23033. * This represents a FPS type of camera controlled by touch.
  23034. * This is like a universal camera minus the Gamepad controls.
  23035. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23036. */
  23037. var TouchCamera = /** @class */ (function (_super) {
  23038. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TouchCamera, _super);
  23039. /**
  23040. * Instantiates a new touch camera.
  23041. * This represents a FPS type of camera controlled by touch.
  23042. * This is like a universal camera minus the Gamepad controls.
  23043. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23044. * @param name Define the name of the camera in the scene
  23045. * @param position Define the start position of the camera in the scene
  23046. * @param scene Define the scene the camera belongs to
  23047. */
  23048. function TouchCamera(name, position, scene) {
  23049. var _this = _super.call(this, name, position, scene) || this;
  23050. _this.inputs.addTouch();
  23051. _this._setupInputs();
  23052. return _this;
  23053. }
  23054. Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
  23055. /**
  23056. * Defines the touch sensibility for rotation.
  23057. * The higher the faster.
  23058. */
  23059. get: function () {
  23060. var touch = this.inputs.attached["touch"];
  23061. if (touch) {
  23062. return touch.touchAngularSensibility;
  23063. }
  23064. return 0;
  23065. },
  23066. set: function (value) {
  23067. var touch = this.inputs.attached["touch"];
  23068. if (touch) {
  23069. touch.touchAngularSensibility = value;
  23070. }
  23071. },
  23072. enumerable: true,
  23073. configurable: true
  23074. });
  23075. Object.defineProperty(TouchCamera.prototype, "touchMoveSensibility", {
  23076. /**
  23077. * Defines the touch sensibility for move.
  23078. * The higher the faster.
  23079. */
  23080. get: function () {
  23081. var touch = this.inputs.attached["touch"];
  23082. if (touch) {
  23083. return touch.touchMoveSensibility;
  23084. }
  23085. return 0;
  23086. },
  23087. set: function (value) {
  23088. var touch = this.inputs.attached["touch"];
  23089. if (touch) {
  23090. touch.touchMoveSensibility = value;
  23091. }
  23092. },
  23093. enumerable: true,
  23094. configurable: true
  23095. });
  23096. /**
  23097. * Gets the current object class name.
  23098. * @return the class name
  23099. */
  23100. TouchCamera.prototype.getClassName = function () {
  23101. return "TouchCamera";
  23102. };
  23103. /** @hidden */
  23104. TouchCamera.prototype._setupInputs = function () {
  23105. var mouse = this.inputs.attached["mouse"];
  23106. if (mouse) {
  23107. mouse.touchEnabled = false;
  23108. }
  23109. };
  23110. return TouchCamera;
  23111. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23112. /***/ }),
  23113. /***/ "./Cameras/universalCamera.ts":
  23114. /*!************************************!*\
  23115. !*** ./Cameras/universalCamera.ts ***!
  23116. \************************************/
  23117. /*! exports provided: UniversalCamera */
  23118. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23119. "use strict";
  23120. __webpack_require__.r(__webpack_exports__);
  23121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return UniversalCamera; });
  23122. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23123. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23124. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  23125. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23126. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23127. _node__WEBPACK_IMPORTED_MODULE_2__["Node"].AddNodeConstructor("FreeCamera", function (name, scene) {
  23128. // Forcing to use the Universal camera
  23129. return function () { return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  23130. });
  23131. /**
  23132. * 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,
  23133. * which still works and will still be found in many Playgrounds.
  23134. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23135. */
  23136. var UniversalCamera = /** @class */ (function (_super) {
  23137. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](UniversalCamera, _super);
  23138. /**
  23139. * 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,
  23140. * which still works and will still be found in many Playgrounds.
  23141. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23142. * @param name Define the name of the camera in the scene
  23143. * @param position Define the start position of the camera in the scene
  23144. * @param scene Define the scene the camera belongs to
  23145. */
  23146. function UniversalCamera(name, position, scene) {
  23147. var _this = _super.call(this, name, position, scene) || this;
  23148. _this.inputs.addGamepad();
  23149. return _this;
  23150. }
  23151. Object.defineProperty(UniversalCamera.prototype, "gamepadAngularSensibility", {
  23152. /**
  23153. * Defines the gamepad rotation sensiblity.
  23154. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  23155. */
  23156. get: function () {
  23157. var gamepad = this.inputs.attached["gamepad"];
  23158. if (gamepad) {
  23159. return gamepad.gamepadAngularSensibility;
  23160. }
  23161. return 0;
  23162. },
  23163. set: function (value) {
  23164. var gamepad = this.inputs.attached["gamepad"];
  23165. if (gamepad) {
  23166. gamepad.gamepadAngularSensibility = value;
  23167. }
  23168. },
  23169. enumerable: true,
  23170. configurable: true
  23171. });
  23172. Object.defineProperty(UniversalCamera.prototype, "gamepadMoveSensibility", {
  23173. /**
  23174. * Defines the gamepad move sensiblity.
  23175. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  23176. */
  23177. get: function () {
  23178. var gamepad = this.inputs.attached["gamepad"];
  23179. if (gamepad) {
  23180. return gamepad.gamepadMoveSensibility;
  23181. }
  23182. return 0;
  23183. },
  23184. set: function (value) {
  23185. var gamepad = this.inputs.attached["gamepad"];
  23186. if (gamepad) {
  23187. gamepad.gamepadMoveSensibility = value;
  23188. }
  23189. },
  23190. enumerable: true,
  23191. configurable: true
  23192. });
  23193. /**
  23194. * Gets the current object class name.
  23195. * @return the class name
  23196. */
  23197. UniversalCamera.prototype.getClassName = function () {
  23198. return "UniversalCamera";
  23199. };
  23200. return UniversalCamera;
  23201. }(_touchCamera__WEBPACK_IMPORTED_MODULE_1__["TouchCamera"]));
  23202. _camera__WEBPACK_IMPORTED_MODULE_4__["Camera"]._createDefaultParsedCamera = function (name, scene) {
  23203. return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene);
  23204. };
  23205. /***/ }),
  23206. /***/ "./Cameras/virtualJoysticksCamera.ts":
  23207. /*!*******************************************!*\
  23208. !*** ./Cameras/virtualJoysticksCamera.ts ***!
  23209. \*******************************************/
  23210. /*! exports provided: VirtualJoysticksCamera */
  23211. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23212. "use strict";
  23213. __webpack_require__.r(__webpack_exports__);
  23214. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return VirtualJoysticksCamera; });
  23215. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23216. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23217. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23218. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23219. /* harmony import */ var _Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  23220. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("VirtualJoysticksCamera", function (name, scene) {
  23221. return function () { return new VirtualJoysticksCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23222. });
  23223. /**
  23224. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  23225. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23226. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23227. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23228. */
  23229. var VirtualJoysticksCamera = /** @class */ (function (_super) {
  23230. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualJoysticksCamera, _super);
  23231. /**
  23232. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  23233. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23234. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23235. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23236. * @param name Define the name of the camera in the scene
  23237. * @param position Define the start position of the camera in the scene
  23238. * @param scene Define the scene the camera belongs to
  23239. */
  23240. function VirtualJoysticksCamera(name, position, scene) {
  23241. var _this = _super.call(this, name, position, scene) || this;
  23242. _this.inputs.addVirtualJoystick();
  23243. return _this;
  23244. }
  23245. /**
  23246. * Gets the current object class name.
  23247. * @return the class name
  23248. */
  23249. VirtualJoysticksCamera.prototype.getClassName = function () {
  23250. return "VirtualJoysticksCamera";
  23251. };
  23252. return VirtualJoysticksCamera;
  23253. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23254. /***/ }),
  23255. /***/ "./Collisions/collider.ts":
  23256. /*!********************************!*\
  23257. !*** ./Collisions/collider.ts ***!
  23258. \********************************/
  23259. /*! exports provided: Collider */
  23260. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23261. "use strict";
  23262. __webpack_require__.r(__webpack_exports__);
  23263. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return Collider; });
  23264. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23265. var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
  23266. if (boxMin.x > sphereCenter.x + sphereRadius) {
  23267. return false;
  23268. }
  23269. if (sphereCenter.x - sphereRadius > boxMax.x) {
  23270. return false;
  23271. }
  23272. if (boxMin.y > sphereCenter.y + sphereRadius) {
  23273. return false;
  23274. }
  23275. if (sphereCenter.y - sphereRadius > boxMax.y) {
  23276. return false;
  23277. }
  23278. if (boxMin.z > sphereCenter.z + sphereRadius) {
  23279. return false;
  23280. }
  23281. if (sphereCenter.z - sphereRadius > boxMax.z) {
  23282. return false;
  23283. }
  23284. return true;
  23285. };
  23286. var getLowestRoot = (function () {
  23287. var result = { root: 0, found: false };
  23288. return function (a, b, c, maxR) {
  23289. result.root = 0;
  23290. result.found = false;
  23291. var determinant = b * b - 4.0 * a * c;
  23292. if (determinant < 0) {
  23293. return result;
  23294. }
  23295. var sqrtD = Math.sqrt(determinant);
  23296. var r1 = (-b - sqrtD) / (2.0 * a);
  23297. var r2 = (-b + sqrtD) / (2.0 * a);
  23298. if (r1 > r2) {
  23299. var temp = r2;
  23300. r2 = r1;
  23301. r1 = temp;
  23302. }
  23303. if (r1 > 0 && r1 < maxR) {
  23304. result.root = r1;
  23305. result.found = true;
  23306. return result;
  23307. }
  23308. if (r2 > 0 && r2 < maxR) {
  23309. result.root = r2;
  23310. result.found = true;
  23311. return result;
  23312. }
  23313. return result;
  23314. };
  23315. })();
  23316. /** @hidden */
  23317. var Collider = /** @class */ (function () {
  23318. function Collider() {
  23319. this._collisionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23320. this._planeIntersectionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23321. this._tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23322. this._tempVector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23323. this._tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23324. this._tempVector4 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23325. this._edge = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23326. this._baseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23327. this._destinationPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23328. this._slidePlaneNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23329. this._displacementVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23330. /** @hidden */
  23331. this._radius = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  23332. /** @hidden */
  23333. this._retry = 0;
  23334. /** @hidden */
  23335. this._basePointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23336. this._velocityWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23337. this._normalizedVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23338. this._collisionMask = -1;
  23339. }
  23340. Object.defineProperty(Collider.prototype, "collisionMask", {
  23341. get: function () {
  23342. return this._collisionMask;
  23343. },
  23344. set: function (mask) {
  23345. this._collisionMask = !isNaN(mask) ? mask : -1;
  23346. },
  23347. enumerable: true,
  23348. configurable: true
  23349. });
  23350. Object.defineProperty(Collider.prototype, "slidePlaneNormal", {
  23351. /**
  23352. * Gets the plane normal used to compute the sliding response (in local space)
  23353. */
  23354. get: function () {
  23355. return this._slidePlaneNormal;
  23356. },
  23357. enumerable: true,
  23358. configurable: true
  23359. });
  23360. // Methods
  23361. /** @hidden */
  23362. Collider.prototype._initialize = function (source, dir, e) {
  23363. this._velocity = dir;
  23364. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].NormalizeToRef(dir, this._normalizedVelocity);
  23365. this._basePoint = source;
  23366. source.multiplyToRef(this._radius, this._basePointWorld);
  23367. dir.multiplyToRef(this._radius, this._velocityWorld);
  23368. this._velocityWorldLength = this._velocityWorld.length();
  23369. this._epsilon = e;
  23370. this.collisionFound = false;
  23371. };
  23372. /** @hidden */
  23373. Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
  23374. pa.subtractToRef(point, this._tempVector);
  23375. pb.subtractToRef(point, this._tempVector2);
  23376. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  23377. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23378. if (d < 0) {
  23379. return false;
  23380. }
  23381. pc.subtractToRef(point, this._tempVector3);
  23382. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
  23383. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23384. if (d < 0) {
  23385. return false;
  23386. }
  23387. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
  23388. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23389. return d >= 0;
  23390. };
  23391. /** @hidden */
  23392. Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
  23393. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._basePointWorld, sphereCenter);
  23394. var max = Math.max(this._radius.x, this._radius.y, this._radius.z);
  23395. if (distance > this._velocityWorldLength + max + sphereRadius) {
  23396. return false;
  23397. }
  23398. if (!intersectBoxAASphere(vecMin, vecMax, this._basePointWorld, this._velocityWorldLength + max)) {
  23399. return false;
  23400. }
  23401. return true;
  23402. };
  23403. /** @hidden */
  23404. Collider.prototype._testTriangle = function (faceIndex, trianglePlaneArray, p1, p2, p3, hasMaterial) {
  23405. var t0;
  23406. var embeddedInPlane = false;
  23407. //defensive programming, actually not needed.
  23408. if (!trianglePlaneArray) {
  23409. trianglePlaneArray = [];
  23410. }
  23411. if (!trianglePlaneArray[faceIndex]) {
  23412. trianglePlaneArray[faceIndex] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"](0, 0, 0, 0);
  23413. trianglePlaneArray[faceIndex].copyFromPoints(p1, p2, p3);
  23414. }
  23415. var trianglePlane = trianglePlaneArray[faceIndex];
  23416. if ((!hasMaterial) && !trianglePlane.isFrontFacingTo(this._normalizedVelocity, 0)) {
  23417. return;
  23418. }
  23419. var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint);
  23420. var normalDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(trianglePlane.normal, this._velocity);
  23421. if (normalDotVelocity == 0) {
  23422. if (Math.abs(signedDistToTrianglePlane) >= 1.0) {
  23423. return;
  23424. }
  23425. embeddedInPlane = true;
  23426. t0 = 0;
  23427. }
  23428. else {
  23429. t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  23430. var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  23431. if (t0 > t1) {
  23432. var temp = t1;
  23433. t1 = t0;
  23434. t0 = temp;
  23435. }
  23436. if (t0 > 1.0 || t1 < 0.0) {
  23437. return;
  23438. }
  23439. if (t0 < 0) {
  23440. t0 = 0;
  23441. }
  23442. if (t0 > 1.0) {
  23443. t0 = 1.0;
  23444. }
  23445. }
  23446. this._collisionPoint.copyFromFloats(0, 0, 0);
  23447. var found = false;
  23448. var t = 1.0;
  23449. if (!embeddedInPlane) {
  23450. this._basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
  23451. this._velocity.scaleToRef(t0, this._tempVector);
  23452. this._planeIntersectionPoint.addInPlace(this._tempVector);
  23453. if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
  23454. found = true;
  23455. t = t0;
  23456. this._collisionPoint.copyFrom(this._planeIntersectionPoint);
  23457. }
  23458. }
  23459. if (!found) {
  23460. var velocitySquaredLength = this._velocity.lengthSquared();
  23461. var a = velocitySquaredLength;
  23462. this._basePoint.subtractToRef(p1, this._tempVector);
  23463. var b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23464. var c = this._tempVector.lengthSquared() - 1.0;
  23465. var lowestRoot = getLowestRoot(a, b, c, t);
  23466. if (lowestRoot.found) {
  23467. t = lowestRoot.root;
  23468. found = true;
  23469. this._collisionPoint.copyFrom(p1);
  23470. }
  23471. this._basePoint.subtractToRef(p2, this._tempVector);
  23472. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23473. c = this._tempVector.lengthSquared() - 1.0;
  23474. lowestRoot = getLowestRoot(a, b, c, t);
  23475. if (lowestRoot.found) {
  23476. t = lowestRoot.root;
  23477. found = true;
  23478. this._collisionPoint.copyFrom(p2);
  23479. }
  23480. this._basePoint.subtractToRef(p3, this._tempVector);
  23481. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23482. c = this._tempVector.lengthSquared() - 1.0;
  23483. lowestRoot = getLowestRoot(a, b, c, t);
  23484. if (lowestRoot.found) {
  23485. t = lowestRoot.root;
  23486. found = true;
  23487. this._collisionPoint.copyFrom(p3);
  23488. }
  23489. p2.subtractToRef(p1, this._edge);
  23490. p1.subtractToRef(this._basePoint, this._baseToVertex);
  23491. var edgeSquaredLength = this._edge.lengthSquared();
  23492. var edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23493. var edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23494. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23495. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23496. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23497. lowestRoot = getLowestRoot(a, b, c, t);
  23498. if (lowestRoot.found) {
  23499. var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23500. if (f >= 0.0 && f <= 1.0) {
  23501. t = lowestRoot.root;
  23502. found = true;
  23503. this._edge.scaleInPlace(f);
  23504. p1.addToRef(this._edge, this._collisionPoint);
  23505. }
  23506. }
  23507. p3.subtractToRef(p2, this._edge);
  23508. p2.subtractToRef(this._basePoint, this._baseToVertex);
  23509. edgeSquaredLength = this._edge.lengthSquared();
  23510. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23511. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23512. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23513. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23514. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23515. lowestRoot = getLowestRoot(a, b, c, t);
  23516. if (lowestRoot.found) {
  23517. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23518. if (f >= 0.0 && f <= 1.0) {
  23519. t = lowestRoot.root;
  23520. found = true;
  23521. this._edge.scaleInPlace(f);
  23522. p2.addToRef(this._edge, this._collisionPoint);
  23523. }
  23524. }
  23525. p1.subtractToRef(p3, this._edge);
  23526. p3.subtractToRef(this._basePoint, this._baseToVertex);
  23527. edgeSquaredLength = this._edge.lengthSquared();
  23528. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23529. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23530. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23531. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23532. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23533. lowestRoot = getLowestRoot(a, b, c, t);
  23534. if (lowestRoot.found) {
  23535. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23536. if (f >= 0.0 && f <= 1.0) {
  23537. t = lowestRoot.root;
  23538. found = true;
  23539. this._edge.scaleInPlace(f);
  23540. p3.addToRef(this._edge, this._collisionPoint);
  23541. }
  23542. }
  23543. }
  23544. if (found) {
  23545. var distToCollision = t * this._velocity.length();
  23546. if (!this.collisionFound || distToCollision < this._nearestDistance) {
  23547. if (!this.intersectionPoint) {
  23548. this.intersectionPoint = this._collisionPoint.clone();
  23549. }
  23550. else {
  23551. this.intersectionPoint.copyFrom(this._collisionPoint);
  23552. }
  23553. this._nearestDistance = distToCollision;
  23554. this.collisionFound = true;
  23555. }
  23556. }
  23557. };
  23558. /** @hidden */
  23559. Collider.prototype._collide = function (trianglePlaneArray, pts, indices, indexStart, indexEnd, decal, hasMaterial) {
  23560. for (var i = indexStart; i < indexEnd; i += 3) {
  23561. var p1 = pts[indices[i] - decal];
  23562. var p2 = pts[indices[i + 1] - decal];
  23563. var p3 = pts[indices[i + 2] - decal];
  23564. this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial);
  23565. }
  23566. };
  23567. /** @hidden */
  23568. Collider.prototype._getResponse = function (pos, vel) {
  23569. pos.addToRef(vel, this._destinationPoint);
  23570. vel.scaleInPlace((this._nearestDistance / vel.length()));
  23571. this._basePoint.addToRef(vel, pos);
  23572. pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
  23573. this._slidePlaneNormal.normalize();
  23574. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector);
  23575. pos.addInPlace(this._displacementVector);
  23576. this.intersectionPoint.addInPlace(this._displacementVector);
  23577. this._slidePlaneNormal.scaleInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"].SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
  23578. this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
  23579. this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
  23580. };
  23581. return Collider;
  23582. }());
  23583. /***/ }),
  23584. /***/ "./Collisions/collisionCoordinator.ts":
  23585. /*!********************************************!*\
  23586. !*** ./Collisions/collisionCoordinator.ts ***!
  23587. \********************************************/
  23588. /*! exports provided: DefaultCollisionCoordinator */
  23589. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23590. "use strict";
  23591. __webpack_require__.r(__webpack_exports__);
  23592. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return DefaultCollisionCoordinator; });
  23593. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  23594. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23595. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  23596. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  23597. /** @hidden */
  23598. var DefaultCollisionCoordinator = /** @class */ (function () {
  23599. function DefaultCollisionCoordinator() {
  23600. this._scaledPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23601. this._scaledVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23602. this._finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23603. }
  23604. DefaultCollisionCoordinator.prototype.getNewPosition = function (position, displacement, collider, maximumRetry, excludedMesh, onNewPosition, collisionIndex) {
  23605. position.divideToRef(collider._radius, this._scaledPosition);
  23606. displacement.divideToRef(collider._radius, this._scaledVelocity);
  23607. collider.collidedMesh = null;
  23608. collider._retry = 0;
  23609. collider._initialVelocity = this._scaledVelocity;
  23610. collider._initialPosition = this._scaledPosition;
  23611. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, this._finalPosition, excludedMesh);
  23612. this._finalPosition.multiplyInPlace(collider._radius);
  23613. //run the callback
  23614. onNewPosition(collisionIndex, this._finalPosition, collider.collidedMesh);
  23615. };
  23616. DefaultCollisionCoordinator.prototype.createCollider = function () {
  23617. return new _collider__WEBPACK_IMPORTED_MODULE_3__["Collider"]();
  23618. };
  23619. DefaultCollisionCoordinator.prototype.init = function (scene) {
  23620. this._scene = scene;
  23621. };
  23622. DefaultCollisionCoordinator.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  23623. if (excludedMesh === void 0) { excludedMesh = null; }
  23624. var closeDistance = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].CollisionsEpsilon * 10.0;
  23625. if (collider._retry >= maximumRetry) {
  23626. finalPosition.copyFrom(position);
  23627. return;
  23628. }
  23629. // Check if this is a mesh else camera or -1
  23630. var collisionMask = (excludedMesh ? excludedMesh.collisionMask : collider.collisionMask);
  23631. collider._initialize(position, velocity, closeDistance);
  23632. // Check all meshes
  23633. for (var index = 0; index < this._scene.meshes.length; index++) {
  23634. var mesh = this._scene.meshes[index];
  23635. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh && ((collisionMask & mesh.collisionGroup) !== 0)) {
  23636. mesh._checkCollision(collider);
  23637. }
  23638. }
  23639. if (!collider.collisionFound) {
  23640. position.addToRef(velocity, finalPosition);
  23641. return;
  23642. }
  23643. if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
  23644. collider._getResponse(position, velocity);
  23645. }
  23646. if (velocity.length() <= closeDistance) {
  23647. finalPosition.copyFrom(position);
  23648. return;
  23649. }
  23650. collider._retry++;
  23651. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  23652. };
  23653. return DefaultCollisionCoordinator;
  23654. }());
  23655. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].CollisionCoordinatorFactory = function () {
  23656. return new DefaultCollisionCoordinator();
  23657. };
  23658. /***/ }),
  23659. /***/ "./Collisions/index.ts":
  23660. /*!*****************************!*\
  23661. !*** ./Collisions/index.ts ***!
  23662. \*****************************/
  23663. /*! exports provided: Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo */
  23664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23665. "use strict";
  23666. __webpack_require__.r(__webpack_exports__);
  23667. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  23668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _collider__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  23669. /* harmony import */ var _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  23670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__["DefaultCollisionCoordinator"]; });
  23671. /* harmony import */ var _pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pickingInfo */ "./Collisions/pickingInfo.ts");
  23672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]; });
  23673. /* harmony import */ var _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersectionInfo */ "./Collisions/intersectionInfo.ts");
  23674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"]; });
  23675. /***/ }),
  23676. /***/ "./Collisions/intersectionInfo.ts":
  23677. /*!****************************************!*\
  23678. !*** ./Collisions/intersectionInfo.ts ***!
  23679. \****************************************/
  23680. /*! exports provided: IntersectionInfo */
  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__, "IntersectionInfo", function() { return IntersectionInfo; });
  23685. /**
  23686. * @hidden
  23687. */
  23688. var IntersectionInfo = /** @class */ (function () {
  23689. function IntersectionInfo(bu, bv, distance) {
  23690. this.bu = bu;
  23691. this.bv = bv;
  23692. this.distance = distance;
  23693. this.faceId = 0;
  23694. this.subMeshId = 0;
  23695. }
  23696. return IntersectionInfo;
  23697. }());
  23698. /***/ }),
  23699. /***/ "./Collisions/pickingInfo.ts":
  23700. /*!***********************************!*\
  23701. !*** ./Collisions/pickingInfo.ts ***!
  23702. \***********************************/
  23703. /*! exports provided: PickingInfo */
  23704. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23705. "use strict";
  23706. __webpack_require__.r(__webpack_exports__);
  23707. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return PickingInfo; });
  23708. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23709. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  23710. /**
  23711. * Information about the result of picking within a scene
  23712. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  23713. */
  23714. var PickingInfo = /** @class */ (function () {
  23715. function PickingInfo() {
  23716. /** @hidden */
  23717. this._pickingUnavailable = false;
  23718. /**
  23719. * If the pick collided with an object
  23720. */
  23721. this.hit = false;
  23722. /**
  23723. * Distance away where the pick collided
  23724. */
  23725. this.distance = 0;
  23726. /**
  23727. * The location of pick collision
  23728. */
  23729. this.pickedPoint = null;
  23730. /**
  23731. * The mesh corresponding the the pick collision
  23732. */
  23733. this.pickedMesh = null;
  23734. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  23735. this.bu = 0;
  23736. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  23737. this.bv = 0;
  23738. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23739. this.faceId = -1;
  23740. /** Id of the the submesh that was picked */
  23741. this.subMeshId = 0;
  23742. /** If a sprite was picked, this will be the sprite the pick collided with */
  23743. this.pickedSprite = null;
  23744. /**
  23745. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  23746. */
  23747. this.originMesh = null;
  23748. /**
  23749. * The ray that was used to perform the picking.
  23750. */
  23751. this.ray = null;
  23752. }
  23753. /**
  23754. * Gets the normal correspodning to the face the pick collided with
  23755. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  23756. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  23757. * @returns The normal correspodning to the face the pick collided with
  23758. */
  23759. PickingInfo.prototype.getNormal = function (useWorldCoordinates, useVerticesNormals) {
  23760. if (useWorldCoordinates === void 0) { useWorldCoordinates = false; }
  23761. if (useVerticesNormals === void 0) { useVerticesNormals = true; }
  23762. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  23763. return null;
  23764. }
  23765. var indices = this.pickedMesh.getIndices();
  23766. if (!indices) {
  23767. return null;
  23768. }
  23769. var result;
  23770. if (useVerticesNormals) {
  23771. var normals = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  23772. var normal0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3] * 3);
  23773. var normal1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  23774. var normal2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  23775. normal0 = normal0.scale(this.bu);
  23776. normal1 = normal1.scale(this.bv);
  23777. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  23778. 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);
  23779. }
  23780. else {
  23781. var positions = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  23782. var vertex1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3] * 3);
  23783. var vertex2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 1] * 3);
  23784. var vertex3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 2] * 3);
  23785. var p1p2 = vertex1.subtract(vertex2);
  23786. var p3p2 = vertex3.subtract(vertex2);
  23787. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(p1p2, p3p2);
  23788. }
  23789. if (useWorldCoordinates) {
  23790. var wm = this.pickedMesh.getWorldMatrix();
  23791. if (this.pickedMesh.nonUniformScaling) {
  23792. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0].copyFrom(wm);
  23793. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  23794. wm.setTranslationFromFloats(0, 0, 0);
  23795. wm.invert();
  23796. wm.transposeToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1]);
  23797. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  23798. }
  23799. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result, wm);
  23800. }
  23801. result.normalize();
  23802. return result;
  23803. };
  23804. /**
  23805. * Gets the texture coordinates of where the pick occured
  23806. * @returns the vector containing the coordnates of the texture
  23807. */
  23808. PickingInfo.prototype.getTextureCoordinates = function () {
  23809. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  23810. return null;
  23811. }
  23812. var indices = this.pickedMesh.getIndices();
  23813. if (!indices) {
  23814. return null;
  23815. }
  23816. var uvs = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  23817. if (!uvs) {
  23818. return null;
  23819. }
  23820. var uv0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3] * 2);
  23821. var uv1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
  23822. var uv2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
  23823. uv0 = uv0.scale(1.0 - this.bu - this.bv);
  23824. uv1 = uv1.scale(this.bu);
  23825. uv2 = uv2.scale(this.bv);
  23826. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
  23827. };
  23828. return PickingInfo;
  23829. }());
  23830. /***/ }),
  23831. /***/ "./Culling/Octrees/index.ts":
  23832. /*!**********************************!*\
  23833. !*** ./Culling/Octrees/index.ts ***!
  23834. \**********************************/
  23835. /*! exports provided: Octree, OctreeBlock, OctreeSceneComponent */
  23836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23837. "use strict";
  23838. __webpack_require__.r(__webpack_exports__);
  23839. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  23840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _octree__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  23841. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  23842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]; });
  23843. /* harmony import */ var _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./octreeSceneComponent */ "./Culling/Octrees/octreeSceneComponent.ts");
  23844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__["OctreeSceneComponent"]; });
  23845. /***/ }),
  23846. /***/ "./Culling/Octrees/octree.ts":
  23847. /*!***********************************!*\
  23848. !*** ./Culling/Octrees/octree.ts ***!
  23849. \***********************************/
  23850. /*! exports provided: Octree */
  23851. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23852. "use strict";
  23853. __webpack_require__.r(__webpack_exports__);
  23854. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return Octree; });
  23855. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  23856. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  23857. /**
  23858. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  23859. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23860. */
  23861. var Octree = /** @class */ (function () {
  23862. /**
  23863. * Creates a octree
  23864. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23865. * @param creationFunc function to be used to instatiate the octree
  23866. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  23867. * @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.)
  23868. */
  23869. function Octree(creationFunc, maxBlockCapacity,
  23870. /** 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.) */
  23871. maxDepth) {
  23872. if (maxDepth === void 0) { maxDepth = 2; }
  23873. this.maxDepth = maxDepth;
  23874. /**
  23875. * Content stored in the octree
  23876. */
  23877. this.dynamicContent = new Array();
  23878. this._maxBlockCapacity = maxBlockCapacity || 64;
  23879. this._selectionContent = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"](1024);
  23880. this._creationFunc = creationFunc;
  23881. }
  23882. // Methods
  23883. /**
  23884. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  23885. * @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);
  23886. * @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);
  23887. * @param entries meshes to be added to the octree blocks
  23888. */
  23889. Octree.prototype.update = function (worldMin, worldMax, entries) {
  23890. _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
  23891. };
  23892. /**
  23893. * Adds a mesh to the octree
  23894. * @param entry Mesh to add to the octree
  23895. */
  23896. Octree.prototype.addMesh = function (entry) {
  23897. for (var index = 0; index < this.blocks.length; index++) {
  23898. var block = this.blocks[index];
  23899. block.addEntry(entry);
  23900. }
  23901. };
  23902. /**
  23903. * Remove an element from the octree
  23904. * @param entry defines the element to remove
  23905. */
  23906. Octree.prototype.removeMesh = function (entry) {
  23907. for (var index = 0; index < this.blocks.length; index++) {
  23908. var block = this.blocks[index];
  23909. block.removeEntry(entry);
  23910. }
  23911. };
  23912. /**
  23913. * Selects an array of meshes within the frustum
  23914. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  23915. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  23916. * @returns array of meshes within the frustum
  23917. */
  23918. Octree.prototype.select = function (frustumPlanes, allowDuplicate) {
  23919. this._selectionContent.reset();
  23920. for (var index = 0; index < this.blocks.length; index++) {
  23921. var block = this.blocks[index];
  23922. block.select(frustumPlanes, this._selectionContent, allowDuplicate);
  23923. }
  23924. if (allowDuplicate) {
  23925. this._selectionContent.concat(this.dynamicContent);
  23926. }
  23927. else {
  23928. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23929. }
  23930. return this._selectionContent;
  23931. };
  23932. /**
  23933. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  23934. * @param sphereCenter defines the bounding sphere center
  23935. * @param sphereRadius defines the bounding sphere radius
  23936. * @param allowDuplicate defines if the selection array can contains duplicated entries
  23937. * @returns an array of objects that intersect the sphere
  23938. */
  23939. Octree.prototype.intersects = function (sphereCenter, sphereRadius, allowDuplicate) {
  23940. this._selectionContent.reset();
  23941. for (var index = 0; index < this.blocks.length; index++) {
  23942. var block = this.blocks[index];
  23943. block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);
  23944. }
  23945. if (allowDuplicate) {
  23946. this._selectionContent.concat(this.dynamicContent);
  23947. }
  23948. else {
  23949. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23950. }
  23951. return this._selectionContent;
  23952. };
  23953. /**
  23954. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  23955. * @param ray defines the ray to test with
  23956. * @returns array of intersected objects
  23957. */
  23958. Octree.prototype.intersectsRay = function (ray) {
  23959. this._selectionContent.reset();
  23960. for (var index = 0; index < this.blocks.length; index++) {
  23961. var block = this.blocks[index];
  23962. block.intersectsRay(ray, this._selectionContent);
  23963. }
  23964. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23965. return this._selectionContent;
  23966. };
  23967. /**
  23968. * Adds a mesh into the octree block if it intersects the block
  23969. */
  23970. Octree.CreationFuncForMeshes = function (entry, block) {
  23971. var boundingInfo = entry.getBoundingInfo();
  23972. if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  23973. block.entries.push(entry);
  23974. }
  23975. };
  23976. /**
  23977. * Adds a submesh into the octree block if it intersects the block
  23978. */
  23979. Octree.CreationFuncForSubMeshes = function (entry, block) {
  23980. var boundingInfo = entry.getBoundingInfo();
  23981. if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  23982. block.entries.push(entry);
  23983. }
  23984. };
  23985. return Octree;
  23986. }());
  23987. /***/ }),
  23988. /***/ "./Culling/Octrees/octreeBlock.ts":
  23989. /*!****************************************!*\
  23990. !*** ./Culling/Octrees/octreeBlock.ts ***!
  23991. \****************************************/
  23992. /*! exports provided: OctreeBlock */
  23993. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23994. "use strict";
  23995. __webpack_require__.r(__webpack_exports__);
  23996. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return OctreeBlock; });
  23997. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  23998. /* harmony import */ var _Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Culling/boundingBox */ "./Culling/boundingBox.ts");
  23999. /**
  24000. * Class used to store a cell in an octree
  24001. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24002. */
  24003. var OctreeBlock = /** @class */ (function () {
  24004. /**
  24005. * Creates a new block
  24006. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  24007. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  24008. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24009. * @param depth defines the current depth of this block in the octree
  24010. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  24011. * @param creationFunc defines a callback to call when an element is added to the block
  24012. */
  24013. function OctreeBlock(minPoint, maxPoint, capacity, depth, maxDepth, creationFunc) {
  24014. /**
  24015. * Gets the content of the current block
  24016. */
  24017. this.entries = new Array();
  24018. this._boundingVectors = new Array();
  24019. this._capacity = capacity;
  24020. this._depth = depth;
  24021. this._maxDepth = maxDepth;
  24022. this._creationFunc = creationFunc;
  24023. this._minPoint = minPoint;
  24024. this._maxPoint = maxPoint;
  24025. this._boundingVectors.push(minPoint.clone());
  24026. this._boundingVectors.push(maxPoint.clone());
  24027. this._boundingVectors.push(minPoint.clone());
  24028. this._boundingVectors[2].x = maxPoint.x;
  24029. this._boundingVectors.push(minPoint.clone());
  24030. this._boundingVectors[3].y = maxPoint.y;
  24031. this._boundingVectors.push(minPoint.clone());
  24032. this._boundingVectors[4].z = maxPoint.z;
  24033. this._boundingVectors.push(maxPoint.clone());
  24034. this._boundingVectors[5].z = minPoint.z;
  24035. this._boundingVectors.push(maxPoint.clone());
  24036. this._boundingVectors[6].x = minPoint.x;
  24037. this._boundingVectors.push(maxPoint.clone());
  24038. this._boundingVectors[7].y = minPoint.y;
  24039. }
  24040. Object.defineProperty(OctreeBlock.prototype, "capacity", {
  24041. // Property
  24042. /**
  24043. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24044. */
  24045. get: function () {
  24046. return this._capacity;
  24047. },
  24048. enumerable: true,
  24049. configurable: true
  24050. });
  24051. Object.defineProperty(OctreeBlock.prototype, "minPoint", {
  24052. /**
  24053. * Gets the minimum vector (in world space) of the block's bounding box
  24054. */
  24055. get: function () {
  24056. return this._minPoint;
  24057. },
  24058. enumerable: true,
  24059. configurable: true
  24060. });
  24061. Object.defineProperty(OctreeBlock.prototype, "maxPoint", {
  24062. /**
  24063. * Gets the maximum vector (in world space) of the block's bounding box
  24064. */
  24065. get: function () {
  24066. return this._maxPoint;
  24067. },
  24068. enumerable: true,
  24069. configurable: true
  24070. });
  24071. // Methods
  24072. /**
  24073. * Add a new element to this block
  24074. * @param entry defines the element to add
  24075. */
  24076. OctreeBlock.prototype.addEntry = function (entry) {
  24077. if (this.blocks) {
  24078. for (var index = 0; index < this.blocks.length; index++) {
  24079. var block = this.blocks[index];
  24080. block.addEntry(entry);
  24081. }
  24082. return;
  24083. }
  24084. this._creationFunc(entry, this);
  24085. if (this.entries.length > this.capacity && this._depth < this._maxDepth) {
  24086. this.createInnerBlocks();
  24087. }
  24088. };
  24089. /**
  24090. * Remove an element from this block
  24091. * @param entry defines the element to remove
  24092. */
  24093. OctreeBlock.prototype.removeEntry = function (entry) {
  24094. if (this.blocks) {
  24095. for (var index = 0; index < this.blocks.length; index++) {
  24096. var block = this.blocks[index];
  24097. block.removeEntry(entry);
  24098. }
  24099. return;
  24100. }
  24101. var entryIndex = this.entries.indexOf(entry);
  24102. if (entryIndex > -1) {
  24103. this.entries.splice(entryIndex, 1);
  24104. }
  24105. };
  24106. /**
  24107. * Add an array of elements to this block
  24108. * @param entries defines the array of elements to add
  24109. */
  24110. OctreeBlock.prototype.addEntries = function (entries) {
  24111. for (var index = 0; index < entries.length; index++) {
  24112. var mesh = entries[index];
  24113. this.addEntry(mesh);
  24114. }
  24115. };
  24116. /**
  24117. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  24118. * @param frustumPlanes defines the frustum planes to test
  24119. * @param selection defines the array to store current content if selection is positive
  24120. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24121. */
  24122. OctreeBlock.prototype.select = function (frustumPlanes, selection, allowDuplicate) {
  24123. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IsInFrustum(this._boundingVectors, frustumPlanes)) {
  24124. if (this.blocks) {
  24125. for (var index = 0; index < this.blocks.length; index++) {
  24126. var block = this.blocks[index];
  24127. block.select(frustumPlanes, selection, allowDuplicate);
  24128. }
  24129. return;
  24130. }
  24131. if (allowDuplicate) {
  24132. selection.concat(this.entries);
  24133. }
  24134. else {
  24135. selection.concatWithNoDuplicate(this.entries);
  24136. }
  24137. }
  24138. };
  24139. /**
  24140. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  24141. * @param sphereCenter defines the bounding sphere center
  24142. * @param sphereRadius defines the bounding sphere radius
  24143. * @param selection defines the array to store current content if selection is positive
  24144. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24145. */
  24146. OctreeBlock.prototype.intersects = function (sphereCenter, sphereRadius, selection, allowDuplicate) {
  24147. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {
  24148. if (this.blocks) {
  24149. for (var index = 0; index < this.blocks.length; index++) {
  24150. var block = this.blocks[index];
  24151. block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
  24152. }
  24153. return;
  24154. }
  24155. if (allowDuplicate) {
  24156. selection.concat(this.entries);
  24157. }
  24158. else {
  24159. selection.concatWithNoDuplicate(this.entries);
  24160. }
  24161. }
  24162. };
  24163. /**
  24164. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  24165. * @param ray defines the ray to test with
  24166. * @param selection defines the array to store current content if selection is positive
  24167. */
  24168. OctreeBlock.prototype.intersectsRay = function (ray, selection) {
  24169. if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  24170. if (this.blocks) {
  24171. for (var index = 0; index < this.blocks.length; index++) {
  24172. var block = this.blocks[index];
  24173. block.intersectsRay(ray, selection);
  24174. }
  24175. return;
  24176. }
  24177. selection.concatWithNoDuplicate(this.entries);
  24178. }
  24179. };
  24180. /**
  24181. * Subdivide the content into child blocks (this block will then be empty)
  24182. */
  24183. OctreeBlock.prototype.createInnerBlocks = function () {
  24184. OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
  24185. };
  24186. /**
  24187. * @hidden
  24188. */
  24189. OctreeBlock._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
  24190. target.blocks = new Array();
  24191. 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);
  24192. // Segmenting space
  24193. for (var x = 0; x < 2; x++) {
  24194. for (var y = 0; y < 2; y++) {
  24195. for (var z = 0; z < 2; z++) {
  24196. var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
  24197. var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
  24198. var block = new OctreeBlock(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);
  24199. block.addEntries(entries);
  24200. target.blocks.push(block);
  24201. }
  24202. }
  24203. }
  24204. };
  24205. return OctreeBlock;
  24206. }());
  24207. /***/ }),
  24208. /***/ "./Culling/Octrees/octreeSceneComponent.ts":
  24209. /*!*************************************************!*\
  24210. !*** ./Culling/Octrees/octreeSceneComponent.ts ***!
  24211. \*************************************************/
  24212. /*! exports provided: OctreeSceneComponent */
  24213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24214. "use strict";
  24215. __webpack_require__.r(__webpack_exports__);
  24216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return OctreeSceneComponent; });
  24217. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  24218. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24219. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  24220. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  24221. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  24222. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24223. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  24224. if (maxCapacity === void 0) { maxCapacity = 64; }
  24225. if (maxDepth === void 0) { maxDepth = 2; }
  24226. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24227. if (!component) {
  24228. component = new OctreeSceneComponent(this);
  24229. this._addComponent(component);
  24230. }
  24231. if (!this._selectionOctree) {
  24232. this._selectionOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForMeshes, maxCapacity, maxDepth);
  24233. }
  24234. var worldExtends = this.getWorldExtends();
  24235. // Update octree
  24236. this._selectionOctree.update(worldExtends.min, worldExtends.max, this.meshes);
  24237. return this._selectionOctree;
  24238. };
  24239. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "selectionOctree", {
  24240. get: function () {
  24241. return this._selectionOctree;
  24242. },
  24243. enumerable: true,
  24244. configurable: true
  24245. });
  24246. /**
  24247. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  24248. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24249. * @param maxCapacity defines the maximum size of each block (64 by default)
  24250. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  24251. * @returns the new octree
  24252. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  24253. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24254. */
  24255. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
  24256. if (maxCapacity === void 0) { maxCapacity = 64; }
  24257. if (maxDepth === void 0) { maxDepth = 2; }
  24258. var scene = this.getScene();
  24259. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24260. if (!component) {
  24261. component = new OctreeSceneComponent(scene);
  24262. scene._addComponent(component);
  24263. }
  24264. if (!this._submeshesOctree) {
  24265. this._submeshesOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForSubMeshes, maxCapacity, maxDepth);
  24266. }
  24267. this.computeWorldMatrix(true);
  24268. var boundingInfo = this.getBoundingInfo();
  24269. // Update octree
  24270. var bbox = boundingInfo.boundingBox;
  24271. this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
  24272. return this._submeshesOctree;
  24273. };
  24274. /**
  24275. * Defines the octree scene component responsible to manage any octrees
  24276. * in a given scene.
  24277. */
  24278. var OctreeSceneComponent = /** @class */ (function () {
  24279. /**
  24280. * Creates a new instance of the component for the given scene
  24281. * @param scene Defines the scene to register the component in
  24282. */
  24283. function OctreeSceneComponent(scene) {
  24284. /**
  24285. * The component name helpfull to identify the component in the list of scene components.
  24286. */
  24287. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE;
  24288. /**
  24289. * Indicates if the meshes have been checked to make sure they are isEnabled()
  24290. */
  24291. this.checksIsEnabled = true;
  24292. 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));
  24293. this.scene = scene;
  24294. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this);
  24295. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this);
  24296. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this);
  24297. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
  24298. }
  24299. /**
  24300. * Registers the component in a given scene
  24301. */
  24302. OctreeSceneComponent.prototype.register = function () {
  24303. var _this = this;
  24304. this.scene.onMeshRemovedObservable.add(function (mesh) {
  24305. var sceneOctree = _this.scene.selectionOctree;
  24306. if (sceneOctree !== undefined && sceneOctree !== null) {
  24307. var index = sceneOctree.dynamicContent.indexOf(mesh);
  24308. if (index !== -1) {
  24309. sceneOctree.dynamicContent.splice(index, 1);
  24310. }
  24311. }
  24312. });
  24313. this.scene.onMeshImportedObservable.add(function (mesh) {
  24314. var sceneOctree = _this.scene.selectionOctree;
  24315. if (sceneOctree !== undefined && sceneOctree !== null) {
  24316. sceneOctree.addMesh(mesh);
  24317. }
  24318. });
  24319. };
  24320. /**
  24321. * Return the list of active meshes
  24322. * @returns the list of active meshes
  24323. */
  24324. OctreeSceneComponent.prototype.getActiveMeshCandidates = function () {
  24325. if (this.scene._selectionOctree) {
  24326. var selection = this.scene._selectionOctree.select(this.scene.frustumPlanes);
  24327. return selection;
  24328. }
  24329. return this.scene._getDefaultMeshCandidates();
  24330. };
  24331. /**
  24332. * Return the list of active sub meshes
  24333. * @param mesh The mesh to get the candidates sub meshes from
  24334. * @returns the list of active sub meshes
  24335. */
  24336. OctreeSceneComponent.prototype.getActiveSubMeshCandidates = function (mesh) {
  24337. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  24338. var intersections = mesh._submeshesOctree.select(this.scene.frustumPlanes);
  24339. return intersections;
  24340. }
  24341. return this.scene._getDefaultSubMeshCandidates(mesh);
  24342. };
  24343. /**
  24344. * Return the list of sub meshes intersecting with a given local ray
  24345. * @param mesh defines the mesh to find the submesh for
  24346. * @param localRay defines the ray in local space
  24347. * @returns the list of intersecting sub meshes
  24348. */
  24349. OctreeSceneComponent.prototype.getIntersectingSubMeshCandidates = function (mesh, localRay) {
  24350. if (mesh._submeshesOctree && mesh.useOctreeForPicking) {
  24351. _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"].TransformToRef(localRay, mesh.getWorldMatrix(), this._tempRay);
  24352. var intersections = mesh._submeshesOctree.intersectsRay(this._tempRay);
  24353. return intersections;
  24354. }
  24355. return this.scene._getDefaultSubMeshCandidates(mesh);
  24356. };
  24357. /**
  24358. * Return the list of sub meshes colliding with a collider
  24359. * @param mesh defines the mesh to find the submesh for
  24360. * @param collider defines the collider to evaluate the collision against
  24361. * @returns the list of colliding sub meshes
  24362. */
  24363. OctreeSceneComponent.prototype.getCollidingSubMeshCandidates = function (mesh, collider) {
  24364. if (mesh._submeshesOctree && mesh.useOctreeForCollisions) {
  24365. var radius = collider._velocityWorldLength + Math.max(collider._radius.x, collider._radius.y, collider._radius.z);
  24366. var intersections = mesh._submeshesOctree.intersects(collider._basePointWorld, radius);
  24367. return intersections;
  24368. }
  24369. return this.scene._getDefaultSubMeshCandidates(mesh);
  24370. };
  24371. /**
  24372. * Rebuilds the elements related to this component in case of
  24373. * context lost for instance.
  24374. */
  24375. OctreeSceneComponent.prototype.rebuild = function () {
  24376. // Nothing to do here.
  24377. };
  24378. /**
  24379. * Disposes the component and the associated ressources.
  24380. */
  24381. OctreeSceneComponent.prototype.dispose = function () {
  24382. // Nothing to do here.
  24383. };
  24384. return OctreeSceneComponent;
  24385. }());
  24386. /***/ }),
  24387. /***/ "./Culling/boundingBox.ts":
  24388. /*!********************************!*\
  24389. !*** ./Culling/boundingBox.ts ***!
  24390. \********************************/
  24391. /*! exports provided: BoundingBox */
  24392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24393. "use strict";
  24394. __webpack_require__.r(__webpack_exports__);
  24395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
  24396. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24397. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24398. /**
  24399. * Class used to store bounding box information
  24400. */
  24401. var BoundingBox = /** @class */ (function () {
  24402. /**
  24403. * Creates a new bounding box
  24404. * @param min defines the minimum vector (in local space)
  24405. * @param max defines the maximum vector (in local space)
  24406. * @param worldMatrix defines the new world matrix
  24407. */
  24408. function BoundingBox(min, max, worldMatrix) {
  24409. /**
  24410. * Gets the 8 vectors representing the bounding box in local space
  24411. */
  24412. this.vectors = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24413. /**
  24414. * Gets the center of the bounding box in local space
  24415. */
  24416. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24417. /**
  24418. * Gets the center of the bounding box in world space
  24419. */
  24420. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24421. /**
  24422. * Gets the extend size in local space
  24423. */
  24424. this.extendSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24425. /**
  24426. * Gets the extend size in world space
  24427. */
  24428. this.extendSizeWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24429. /**
  24430. * Gets the OBB (object bounding box) directions
  24431. */
  24432. this.directions = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24433. /**
  24434. * Gets the 8 vectors representing the bounding box in world space
  24435. */
  24436. this.vectorsWorld = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24437. /**
  24438. * Gets the minimum vector in world space
  24439. */
  24440. this.minimumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24441. /**
  24442. * Gets the maximum vector in world space
  24443. */
  24444. this.maximumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24445. /**
  24446. * Gets the minimum vector in local space
  24447. */
  24448. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24449. /**
  24450. * Gets the maximum vector in local space
  24451. */
  24452. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24453. this.reConstruct(min, max, worldMatrix);
  24454. }
  24455. // Methods
  24456. /**
  24457. * Recreates the entire bounding box from scratch as if we call the constructor in place
  24458. * @param min defines the new minimum vector (in local space)
  24459. * @param max defines the new maximum vector (in local space)
  24460. * @param worldMatrix defines the new world matrix
  24461. */
  24462. BoundingBox.prototype.reConstruct = function (min, max, worldMatrix) {
  24463. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24464. var vectors = this.vectors;
  24465. this.minimum.copyFromFloats(minX, minY, minZ);
  24466. this.maximum.copyFromFloats(maxX, maxY, maxZ);
  24467. vectors[0].copyFromFloats(minX, minY, minZ);
  24468. vectors[1].copyFromFloats(maxX, maxY, maxZ);
  24469. vectors[2].copyFromFloats(maxX, minY, minZ);
  24470. vectors[3].copyFromFloats(minX, maxY, minZ);
  24471. vectors[4].copyFromFloats(minX, minY, maxZ);
  24472. vectors[5].copyFromFloats(maxX, maxY, minZ);
  24473. vectors[6].copyFromFloats(minX, maxY, maxZ);
  24474. vectors[7].copyFromFloats(maxX, minY, maxZ);
  24475. // OBB
  24476. max.addToRef(min, this.center).scaleInPlace(0.5);
  24477. max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);
  24478. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  24479. };
  24480. /**
  24481. * Scale the current bounding box by applying a scale factor
  24482. * @param factor defines the scale factor to apply
  24483. * @returns the current bounding box
  24484. */
  24485. BoundingBox.prototype.scale = function (factor) {
  24486. var tmpVectors = BoundingBox.TmpVector3;
  24487. var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
  24488. var len = diff.length();
  24489. diff.normalizeFromLength(len);
  24490. var distance = len * factor;
  24491. var newRadius = diff.scaleInPlace(distance * 0.5);
  24492. var min = this.center.subtractToRef(newRadius, tmpVectors[1]);
  24493. var max = this.center.addToRef(newRadius, tmpVectors[2]);
  24494. this.reConstruct(min, max, this._worldMatrix);
  24495. return this;
  24496. };
  24497. /**
  24498. * Gets the world matrix of the bounding box
  24499. * @returns a matrix
  24500. */
  24501. BoundingBox.prototype.getWorldMatrix = function () {
  24502. return this._worldMatrix;
  24503. };
  24504. /** @hidden */
  24505. BoundingBox.prototype._update = function (world) {
  24506. var minWorld = this.minimumWorld;
  24507. var maxWorld = this.maximumWorld;
  24508. var directions = this.directions;
  24509. var vectorsWorld = this.vectorsWorld;
  24510. var vectors = this.vectors;
  24511. if (!world.isIdentity()) {
  24512. minWorld.setAll(Number.MAX_VALUE);
  24513. maxWorld.setAll(-Number.MAX_VALUE);
  24514. for (var index = 0; index < 8; ++index) {
  24515. var v = vectorsWorld[index];
  24516. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vectors[index], world, v);
  24517. minWorld.minimizeInPlace(v);
  24518. maxWorld.maximizeInPlace(v);
  24519. }
  24520. // Extend
  24521. maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);
  24522. maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);
  24523. }
  24524. else {
  24525. minWorld.copyFrom(this.minimum);
  24526. maxWorld.copyFrom(this.maximum);
  24527. for (var index = 0; index < 8; ++index) {
  24528. vectorsWorld[index].copyFrom(vectors[index]);
  24529. }
  24530. // Extend
  24531. this.extendSizeWorld.copyFrom(this.extendSize);
  24532. this.centerWorld.copyFrom(this.center);
  24533. }
  24534. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 0, directions[0]);
  24535. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 4, directions[1]);
  24536. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 8, directions[2]);
  24537. this._worldMatrix = world;
  24538. };
  24539. /**
  24540. * Tests if the bounding box is intersecting the frustum planes
  24541. * @param frustumPlanes defines the frustum planes to test
  24542. * @returns true if there is an intersection
  24543. */
  24544. BoundingBox.prototype.isInFrustum = function (frustumPlanes) {
  24545. return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);
  24546. };
  24547. /**
  24548. * Tests if the bounding box is entirely inside the frustum planes
  24549. * @param frustumPlanes defines the frustum planes to test
  24550. * @returns true if there is an inclusion
  24551. */
  24552. BoundingBox.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  24553. return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);
  24554. };
  24555. /**
  24556. * Tests if a point is inside the bounding box
  24557. * @param point defines the point to test
  24558. * @returns true if the point is inside the bounding box
  24559. */
  24560. BoundingBox.prototype.intersectsPoint = function (point) {
  24561. var min = this.minimumWorld;
  24562. var max = this.maximumWorld;
  24563. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24564. var pointX = point.x, pointY = point.y, pointZ = point.z;
  24565. var delta = -_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"];
  24566. if (maxX - pointX < delta || delta > pointX - minX) {
  24567. return false;
  24568. }
  24569. if (maxY - pointY < delta || delta > pointY - minY) {
  24570. return false;
  24571. }
  24572. if (maxZ - pointZ < delta || delta > pointZ - minZ) {
  24573. return false;
  24574. }
  24575. return true;
  24576. };
  24577. /**
  24578. * Tests if the bounding box intersects with a bounding sphere
  24579. * @param sphere defines the sphere to test
  24580. * @returns true if there is an intersection
  24581. */
  24582. BoundingBox.prototype.intersectsSphere = function (sphere) {
  24583. return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);
  24584. };
  24585. /**
  24586. * Tests if the bounding box intersects with a box defined by a min and max vectors
  24587. * @param min defines the min vector to use
  24588. * @param max defines the max vector to use
  24589. * @returns true if there is an intersection
  24590. */
  24591. BoundingBox.prototype.intersectsMinMax = function (min, max) {
  24592. var myMin = this.minimumWorld;
  24593. var myMax = this.maximumWorld;
  24594. var myMinX = myMin.x, myMinY = myMin.y, myMinZ = myMin.z, myMaxX = myMax.x, myMaxY = myMax.y, myMaxZ = myMax.z;
  24595. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24596. if (myMaxX < minX || myMinX > maxX) {
  24597. return false;
  24598. }
  24599. if (myMaxY < minY || myMinY > maxY) {
  24600. return false;
  24601. }
  24602. if (myMaxZ < minZ || myMinZ > maxZ) {
  24603. return false;
  24604. }
  24605. return true;
  24606. };
  24607. // Statics
  24608. /**
  24609. * Tests if two bounding boxes are intersections
  24610. * @param box0 defines the first box to test
  24611. * @param box1 defines the second box to test
  24612. * @returns true if there is an intersection
  24613. */
  24614. BoundingBox.Intersects = function (box0, box1) {
  24615. return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);
  24616. };
  24617. /**
  24618. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  24619. * @param minPoint defines the minimum vector of the bounding box
  24620. * @param maxPoint defines the maximum vector of the bounding box
  24621. * @param sphereCenter defines the sphere center
  24622. * @param sphereRadius defines the sphere radius
  24623. * @returns true if there is an intersection
  24624. */
  24625. BoundingBox.IntersectsSphere = function (minPoint, maxPoint, sphereCenter, sphereRadius) {
  24626. var vector = BoundingBox.TmpVector3[0];
  24627. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ClampToRef(sphereCenter, minPoint, maxPoint, vector);
  24628. var num = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphereCenter, vector);
  24629. return (num <= (sphereRadius * sphereRadius));
  24630. };
  24631. /**
  24632. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  24633. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  24634. * @param frustumPlanes defines the frustum planes to test
  24635. * @return true if there is an inclusion
  24636. */
  24637. BoundingBox.IsCompletelyInFrustum = function (boundingVectors, frustumPlanes) {
  24638. for (var p = 0; p < 6; ++p) {
  24639. var frustumPlane = frustumPlanes[p];
  24640. for (var i = 0; i < 8; ++i) {
  24641. if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {
  24642. return false;
  24643. }
  24644. }
  24645. }
  24646. return true;
  24647. };
  24648. /**
  24649. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  24650. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  24651. * @param frustumPlanes defines the frustum planes to test
  24652. * @return true if there is an intersection
  24653. */
  24654. BoundingBox.IsInFrustum = function (boundingVectors, frustumPlanes) {
  24655. for (var p = 0; p < 6; ++p) {
  24656. var canReturnFalse = true;
  24657. var frustumPlane = frustumPlanes[p];
  24658. for (var i = 0; i < 8; ++i) {
  24659. if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {
  24660. canReturnFalse = false;
  24661. break;
  24662. }
  24663. }
  24664. if (canReturnFalse) {
  24665. return false;
  24666. }
  24667. }
  24668. return true;
  24669. };
  24670. BoundingBox.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24671. return BoundingBox;
  24672. }());
  24673. /***/ }),
  24674. /***/ "./Culling/boundingInfo.ts":
  24675. /*!*********************************!*\
  24676. !*** ./Culling/boundingInfo.ts ***!
  24677. \*********************************/
  24678. /*! exports provided: BoundingInfo */
  24679. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24680. "use strict";
  24681. __webpack_require__.r(__webpack_exports__);
  24682. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return BoundingInfo; });
  24683. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24684. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24685. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  24686. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  24687. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  24688. var _result0 = { min: 0, max: 0 };
  24689. var _result1 = { min: 0, max: 0 };
  24690. var computeBoxExtents = function (axis, box, result) {
  24691. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.centerWorld, axis);
  24692. var r0 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[0], axis)) * box.extendSize.x;
  24693. var r1 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[1], axis)) * box.extendSize.y;
  24694. var r2 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[2], axis)) * box.extendSize.z;
  24695. var r = r0 + r1 + r2;
  24696. result.min = p - r;
  24697. result.max = p + r;
  24698. };
  24699. var axisOverlap = function (axis, box0, box1) {
  24700. computeBoxExtents(axis, box0, _result0);
  24701. computeBoxExtents(axis, box1, _result1);
  24702. return !(_result0.min > _result1.max || _result1.min > _result0.max);
  24703. };
  24704. /**
  24705. * Info for a bounding data of a mesh
  24706. */
  24707. var BoundingInfo = /** @class */ (function () {
  24708. /**
  24709. * Constructs bounding info
  24710. * @param minimum min vector of the bounding box/sphere
  24711. * @param maximum max vector of the bounding box/sphere
  24712. * @param worldMatrix defines the new world matrix
  24713. */
  24714. function BoundingInfo(minimum, maximum, worldMatrix) {
  24715. this._isLocked = false;
  24716. this.boundingBox = new _boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"](minimum, maximum, worldMatrix);
  24717. this.boundingSphere = new _boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"](minimum, maximum, worldMatrix);
  24718. }
  24719. /**
  24720. * Recreates the entire bounding info from scratch as if we call the constructor in place
  24721. * @param min defines the new minimum vector (in local space)
  24722. * @param max defines the new maximum vector (in local space)
  24723. * @param worldMatrix defines the new world matrix
  24724. */
  24725. BoundingInfo.prototype.reConstruct = function (min, max, worldMatrix) {
  24726. this.boundingBox.reConstruct(min, max, worldMatrix);
  24727. this.boundingSphere.reConstruct(min, max, worldMatrix);
  24728. };
  24729. Object.defineProperty(BoundingInfo.prototype, "minimum", {
  24730. /**
  24731. * min vector of the bounding box/sphere
  24732. */
  24733. get: function () {
  24734. return this.boundingBox.minimum;
  24735. },
  24736. enumerable: true,
  24737. configurable: true
  24738. });
  24739. Object.defineProperty(BoundingInfo.prototype, "maximum", {
  24740. /**
  24741. * max vector of the bounding box/sphere
  24742. */
  24743. get: function () {
  24744. return this.boundingBox.maximum;
  24745. },
  24746. enumerable: true,
  24747. configurable: true
  24748. });
  24749. Object.defineProperty(BoundingInfo.prototype, "isLocked", {
  24750. /**
  24751. * If the info is locked and won't be updated to avoid perf overhead
  24752. */
  24753. get: function () {
  24754. return this._isLocked;
  24755. },
  24756. set: function (value) {
  24757. this._isLocked = value;
  24758. },
  24759. enumerable: true,
  24760. configurable: true
  24761. });
  24762. // Methods
  24763. /**
  24764. * Updates the bounding sphere and box
  24765. * @param world world matrix to be used to update
  24766. */
  24767. BoundingInfo.prototype.update = function (world) {
  24768. if (this._isLocked) {
  24769. return;
  24770. }
  24771. this.boundingBox._update(world);
  24772. this.boundingSphere._update(world);
  24773. };
  24774. /**
  24775. * Recreate the bounding info to be centered around a specific point given a specific extend.
  24776. * @param center New center of the bounding info
  24777. * @param extend New extend of the bounding info
  24778. * @returns the current bounding info
  24779. */
  24780. BoundingInfo.prototype.centerOn = function (center, extend) {
  24781. var minimum = BoundingInfo.TmpVector3[0].copyFrom(center).subtractInPlace(extend);
  24782. var maximum = BoundingInfo.TmpVector3[1].copyFrom(center).addInPlace(extend);
  24783. this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  24784. this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  24785. return this;
  24786. };
  24787. /**
  24788. * Scale the current bounding info by applying a scale factor
  24789. * @param factor defines the scale factor to apply
  24790. * @returns the current bounding info
  24791. */
  24792. BoundingInfo.prototype.scale = function (factor) {
  24793. this.boundingBox.scale(factor);
  24794. this.boundingSphere.scale(factor);
  24795. return this;
  24796. };
  24797. /**
  24798. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  24799. * @param frustumPlanes defines the frustum to test
  24800. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  24801. * @returns true if the bounding info is in the frustum planes
  24802. */
  24803. BoundingInfo.prototype.isInFrustum = function (frustumPlanes, strategy) {
  24804. if (strategy === void 0) { strategy = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD; }
  24805. 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);
  24806. if (inclusionTest) {
  24807. if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {
  24808. return true;
  24809. }
  24810. }
  24811. if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
  24812. return false;
  24813. }
  24814. 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);
  24815. if (bSphereOnlyTest) {
  24816. return true;
  24817. }
  24818. return this.boundingBox.isInFrustum(frustumPlanes);
  24819. };
  24820. Object.defineProperty(BoundingInfo.prototype, "diagonalLength", {
  24821. /**
  24822. * Gets the world distance between the min and max points of the bounding box
  24823. */
  24824. get: function () {
  24825. var boundingBox = this.boundingBox;
  24826. var diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo.TmpVector3[0]);
  24827. return diag.length();
  24828. },
  24829. enumerable: true,
  24830. configurable: true
  24831. });
  24832. /**
  24833. * Checks if a cullable object (mesh...) is in the camera frustum
  24834. * Unlike isInFrustum this cheks the full bounding box
  24835. * @param frustumPlanes Camera near/planes
  24836. * @returns true if the object is in frustum otherwise false
  24837. */
  24838. BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  24839. return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
  24840. };
  24841. /** @hidden */
  24842. BoundingInfo.prototype._checkCollision = function (collider) {
  24843. return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
  24844. };
  24845. /**
  24846. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  24847. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24848. * @param point the point to check intersection with
  24849. * @returns if the point intersects
  24850. */
  24851. BoundingInfo.prototype.intersectsPoint = function (point) {
  24852. if (!this.boundingSphere.centerWorld) {
  24853. return false;
  24854. }
  24855. if (!this.boundingSphere.intersectsPoint(point)) {
  24856. return false;
  24857. }
  24858. if (!this.boundingBox.intersectsPoint(point)) {
  24859. return false;
  24860. }
  24861. return true;
  24862. };
  24863. /**
  24864. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  24865. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24866. * @param boundingInfo the bounding info to check intersection with
  24867. * @param precise if the intersection should be done using OBB
  24868. * @returns if the bounding info intersects
  24869. */
  24870. BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
  24871. if (!_boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"].Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
  24872. return false;
  24873. }
  24874. if (!_boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"].Intersects(this.boundingBox, boundingInfo.boundingBox)) {
  24875. return false;
  24876. }
  24877. if (!precise) {
  24878. return true;
  24879. }
  24880. var box0 = this.boundingBox;
  24881. var box1 = boundingInfo.boundingBox;
  24882. if (!axisOverlap(box0.directions[0], box0, box1)) {
  24883. return false;
  24884. }
  24885. if (!axisOverlap(box0.directions[1], box0, box1)) {
  24886. return false;
  24887. }
  24888. if (!axisOverlap(box0.directions[2], box0, box1)) {
  24889. return false;
  24890. }
  24891. if (!axisOverlap(box1.directions[0], box0, box1)) {
  24892. return false;
  24893. }
  24894. if (!axisOverlap(box1.directions[1], box0, box1)) {
  24895. return false;
  24896. }
  24897. if (!axisOverlap(box1.directions[2], box0, box1)) {
  24898. return false;
  24899. }
  24900. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[0]), box0, box1)) {
  24901. return false;
  24902. }
  24903. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[1]), box0, box1)) {
  24904. return false;
  24905. }
  24906. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[2]), box0, box1)) {
  24907. return false;
  24908. }
  24909. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[0]), box0, box1)) {
  24910. return false;
  24911. }
  24912. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[1]), box0, box1)) {
  24913. return false;
  24914. }
  24915. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[2]), box0, box1)) {
  24916. return false;
  24917. }
  24918. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[0]), box0, box1)) {
  24919. return false;
  24920. }
  24921. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[1]), box0, box1)) {
  24922. return false;
  24923. }
  24924. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[2]), box0, box1)) {
  24925. return false;
  24926. }
  24927. return true;
  24928. };
  24929. BoundingInfo.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24930. return BoundingInfo;
  24931. }());
  24932. /***/ }),
  24933. /***/ "./Culling/boundingSphere.ts":
  24934. /*!***********************************!*\
  24935. !*** ./Culling/boundingSphere.ts ***!
  24936. \***********************************/
  24937. /*! exports provided: BoundingSphere */
  24938. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24939. "use strict";
  24940. __webpack_require__.r(__webpack_exports__);
  24941. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return BoundingSphere; });
  24942. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24943. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24944. /**
  24945. * Class used to store bounding sphere information
  24946. */
  24947. var BoundingSphere = /** @class */ (function () {
  24948. /**
  24949. * Creates a new bounding sphere
  24950. * @param min defines the minimum vector (in local space)
  24951. * @param max defines the maximum vector (in local space)
  24952. * @param worldMatrix defines the new world matrix
  24953. */
  24954. function BoundingSphere(min, max, worldMatrix) {
  24955. /**
  24956. * Gets the center of the bounding sphere in local space
  24957. */
  24958. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24959. /**
  24960. * Gets the center of the bounding sphere in world space
  24961. */
  24962. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24963. /**
  24964. * Gets the minimum vector in local space
  24965. */
  24966. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24967. /**
  24968. * Gets the maximum vector in local space
  24969. */
  24970. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24971. this.reConstruct(min, max, worldMatrix);
  24972. }
  24973. /**
  24974. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  24975. * @param min defines the new minimum vector (in local space)
  24976. * @param max defines the new maximum vector (in local space)
  24977. * @param worldMatrix defines the new world matrix
  24978. */
  24979. BoundingSphere.prototype.reConstruct = function (min, max, worldMatrix) {
  24980. this.minimum.copyFrom(min);
  24981. this.maximum.copyFrom(max);
  24982. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(min, max);
  24983. max.addToRef(min, this.center).scaleInPlace(0.5);
  24984. this.radius = distance * 0.5;
  24985. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  24986. };
  24987. /**
  24988. * Scale the current bounding sphere by applying a scale factor
  24989. * @param factor defines the scale factor to apply
  24990. * @returns the current bounding box
  24991. */
  24992. BoundingSphere.prototype.scale = function (factor) {
  24993. var newRadius = this.radius * factor;
  24994. var tmpVectors = BoundingSphere.TmpVector3;
  24995. var tempRadiusVector = tmpVectors[0].setAll(newRadius);
  24996. var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
  24997. var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
  24998. this.reConstruct(min, max, this._worldMatrix);
  24999. return this;
  25000. };
  25001. /**
  25002. * Gets the world matrix of the bounding box
  25003. * @returns a matrix
  25004. */
  25005. BoundingSphere.prototype.getWorldMatrix = function () {
  25006. return this._worldMatrix;
  25007. };
  25008. // Methods
  25009. /** @hidden */
  25010. BoundingSphere.prototype._update = function (worldMatrix) {
  25011. if (!worldMatrix.isIdentity()) {
  25012. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);
  25013. var tempVector = BoundingSphere.TmpVector3[0];
  25014. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);
  25015. this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
  25016. }
  25017. else {
  25018. this.centerWorld.copyFrom(this.center);
  25019. this.radiusWorld = this.radius;
  25020. }
  25021. };
  25022. /**
  25023. * Tests if the bounding sphere is intersecting the frustum planes
  25024. * @param frustumPlanes defines the frustum planes to test
  25025. * @returns true if there is an intersection
  25026. */
  25027. BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
  25028. var center = this.centerWorld;
  25029. var radius = this.radiusWorld;
  25030. for (var i = 0; i < 6; i++) {
  25031. if (frustumPlanes[i].dotCoordinate(center) <= -radius) {
  25032. return false;
  25033. }
  25034. }
  25035. return true;
  25036. };
  25037. /**
  25038. * Tests if the bounding sphere center is in between the frustum planes.
  25039. * Used for optimistic fast inclusion.
  25040. * @param frustumPlanes defines the frustum planes to test
  25041. * @returns true if the sphere center is in between the frustum planes
  25042. */
  25043. BoundingSphere.prototype.isCenterInFrustum = function (frustumPlanes) {
  25044. var center = this.centerWorld;
  25045. for (var i = 0; i < 6; i++) {
  25046. if (frustumPlanes[i].dotCoordinate(center) < 0) {
  25047. return false;
  25048. }
  25049. }
  25050. return true;
  25051. };
  25052. /**
  25053. * Tests if a point is inside the bounding sphere
  25054. * @param point defines the point to test
  25055. * @returns true if the point is inside the bounding sphere
  25056. */
  25057. BoundingSphere.prototype.intersectsPoint = function (point) {
  25058. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.centerWorld, point);
  25059. if (this.radiusWorld * this.radiusWorld < squareDistance) {
  25060. return false;
  25061. }
  25062. return true;
  25063. };
  25064. // Statics
  25065. /**
  25066. * Checks if two sphere intersct
  25067. * @param sphere0 sphere 0
  25068. * @param sphere1 sphere 1
  25069. * @returns true if the speres intersect
  25070. */
  25071. BoundingSphere.Intersects = function (sphere0, sphere1) {
  25072. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
  25073. var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
  25074. if (radiusSum * radiusSum < squareDistance) {
  25075. return false;
  25076. }
  25077. return true;
  25078. };
  25079. BoundingSphere.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25080. return BoundingSphere;
  25081. }());
  25082. /***/ }),
  25083. /***/ "./Culling/index.ts":
  25084. /*!**************************!*\
  25085. !*** ./Culling/index.ts ***!
  25086. \**************************/
  25087. /*! exports provided: BoundingBox, BoundingInfo, BoundingSphere, Ray, Octree, OctreeBlock, OctreeSceneComponent */
  25088. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25089. "use strict";
  25090. __webpack_require__.r(__webpack_exports__);
  25091. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _boundingBox__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  25093. /* harmony import */ var _boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boundingInfo */ "./Culling/boundingInfo.ts");
  25094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"]; });
  25095. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"]; });
  25097. /* harmony import */ var _Octrees_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Octrees/index */ "./Culling/Octrees/index.ts");
  25098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["Octree"]; });
  25099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeBlock"]; });
  25100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeSceneComponent"]; });
  25101. /* harmony import */ var _ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ray */ "./Culling/ray.ts");
  25102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _ray__WEBPACK_IMPORTED_MODULE_4__["Ray"]; });
  25103. /***/ }),
  25104. /***/ "./Culling/ray.ts":
  25105. /*!************************!*\
  25106. !*** ./Culling/ray.ts ***!
  25107. \************************/
  25108. /*! exports provided: Ray */
  25109. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25110. "use strict";
  25111. __webpack_require__.r(__webpack_exports__);
  25112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return Ray; });
  25113. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25114. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25115. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  25116. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  25117. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25118. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  25119. /**
  25120. * Class representing a ray with position and direction
  25121. */
  25122. var Ray = /** @class */ (function () {
  25123. /**
  25124. * Creates a new ray
  25125. * @param origin origin point
  25126. * @param direction direction
  25127. * @param length length of the ray
  25128. */
  25129. function Ray(
  25130. /** origin point */
  25131. origin,
  25132. /** direction */
  25133. direction,
  25134. /** length of the ray */
  25135. length) {
  25136. if (length === void 0) { length = Number.MAX_VALUE; }
  25137. this.origin = origin;
  25138. this.direction = direction;
  25139. this.length = length;
  25140. }
  25141. // Methods
  25142. /**
  25143. * Checks if the ray intersects a box
  25144. * @param minimum bound of the box
  25145. * @param maximum bound of the box
  25146. * @param intersectionTreshold extra extend to be added to the box in all direction
  25147. * @returns if the box was hit
  25148. */
  25149. Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
  25150. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25151. var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
  25152. var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
  25153. var d = 0.0;
  25154. var maxValue = Number.MAX_VALUE;
  25155. var inv;
  25156. var min;
  25157. var max;
  25158. var temp;
  25159. if (Math.abs(this.direction.x) < 0.0000001) {
  25160. if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
  25161. return false;
  25162. }
  25163. }
  25164. else {
  25165. inv = 1.0 / this.direction.x;
  25166. min = (newMinimum.x - this.origin.x) * inv;
  25167. max = (newMaximum.x - this.origin.x) * inv;
  25168. if (max === -Infinity) {
  25169. max = Infinity;
  25170. }
  25171. if (min > max) {
  25172. temp = min;
  25173. min = max;
  25174. max = temp;
  25175. }
  25176. d = Math.max(min, d);
  25177. maxValue = Math.min(max, maxValue);
  25178. if (d > maxValue) {
  25179. return false;
  25180. }
  25181. }
  25182. if (Math.abs(this.direction.y) < 0.0000001) {
  25183. if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
  25184. return false;
  25185. }
  25186. }
  25187. else {
  25188. inv = 1.0 / this.direction.y;
  25189. min = (newMinimum.y - this.origin.y) * inv;
  25190. max = (newMaximum.y - this.origin.y) * inv;
  25191. if (max === -Infinity) {
  25192. max = Infinity;
  25193. }
  25194. if (min > max) {
  25195. temp = min;
  25196. min = max;
  25197. max = temp;
  25198. }
  25199. d = Math.max(min, d);
  25200. maxValue = Math.min(max, maxValue);
  25201. if (d > maxValue) {
  25202. return false;
  25203. }
  25204. }
  25205. if (Math.abs(this.direction.z) < 0.0000001) {
  25206. if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
  25207. return false;
  25208. }
  25209. }
  25210. else {
  25211. inv = 1.0 / this.direction.z;
  25212. min = (newMinimum.z - this.origin.z) * inv;
  25213. max = (newMaximum.z - this.origin.z) * inv;
  25214. if (max === -Infinity) {
  25215. max = Infinity;
  25216. }
  25217. if (min > max) {
  25218. temp = min;
  25219. min = max;
  25220. max = temp;
  25221. }
  25222. d = Math.max(min, d);
  25223. maxValue = Math.min(max, maxValue);
  25224. if (d > maxValue) {
  25225. return false;
  25226. }
  25227. }
  25228. return true;
  25229. };
  25230. /**
  25231. * Checks if the ray intersects a box
  25232. * @param box the bounding box to check
  25233. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  25234. * @returns if the box was hit
  25235. */
  25236. Ray.prototype.intersectsBox = function (box, intersectionTreshold) {
  25237. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25238. return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
  25239. };
  25240. /**
  25241. * If the ray hits a sphere
  25242. * @param sphere the bounding sphere to check
  25243. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  25244. * @returns true if it hits the sphere
  25245. */
  25246. Ray.prototype.intersectsSphere = function (sphere, intersectionTreshold) {
  25247. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25248. var x = sphere.center.x - this.origin.x;
  25249. var y = sphere.center.y - this.origin.y;
  25250. var z = sphere.center.z - this.origin.z;
  25251. var pyth = (x * x) + (y * y) + (z * z);
  25252. var radius = sphere.radius + intersectionTreshold;
  25253. var rr = radius * radius;
  25254. if (pyth <= rr) {
  25255. return true;
  25256. }
  25257. var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
  25258. if (dot < 0.0) {
  25259. return false;
  25260. }
  25261. var temp = pyth - (dot * dot);
  25262. return temp <= rr;
  25263. };
  25264. /**
  25265. * If the ray hits a triange
  25266. * @param vertex0 triangle vertex
  25267. * @param vertex1 triangle vertex
  25268. * @param vertex2 triangle vertex
  25269. * @returns intersection information if hit
  25270. */
  25271. Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
  25272. var edge1 = Ray.TmpVector3[0];
  25273. var edge2 = Ray.TmpVector3[1];
  25274. var pvec = Ray.TmpVector3[2];
  25275. var tvec = Ray.TmpVector3[3];
  25276. var qvec = Ray.TmpVector3[4];
  25277. vertex1.subtractToRef(vertex0, edge1);
  25278. vertex2.subtractToRef(vertex0, edge2);
  25279. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
  25280. var det = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge1, pvec);
  25281. if (det === 0) {
  25282. return null;
  25283. }
  25284. var invdet = 1 / det;
  25285. this.origin.subtractToRef(vertex0, tvec);
  25286. var bu = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(tvec, pvec) * invdet;
  25287. if (bu < 0 || bu > 1.0) {
  25288. return null;
  25289. }
  25290. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(tvec, edge1, qvec);
  25291. var bv = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this.direction, qvec) * invdet;
  25292. if (bv < 0 || bu + bv > 1.0) {
  25293. return null;
  25294. }
  25295. //check if the distance is longer than the predefined length.
  25296. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge2, qvec) * invdet;
  25297. if (distance > this.length) {
  25298. return null;
  25299. }
  25300. return new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](bu, bv, distance);
  25301. };
  25302. /**
  25303. * Checks if ray intersects a plane
  25304. * @param plane the plane to check
  25305. * @returns the distance away it was hit
  25306. */
  25307. Ray.prototype.intersectsPlane = function (plane) {
  25308. var distance;
  25309. var result1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
  25310. if (Math.abs(result1) < 9.99999997475243E-07) {
  25311. return null;
  25312. }
  25313. else {
  25314. var result2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
  25315. distance = (-plane.d - result2) / result1;
  25316. if (distance < 0.0) {
  25317. if (distance < -9.99999997475243E-07) {
  25318. return null;
  25319. }
  25320. else {
  25321. return 0;
  25322. }
  25323. }
  25324. return distance;
  25325. }
  25326. };
  25327. /**
  25328. * Checks if ray intersects a mesh
  25329. * @param mesh the mesh to check
  25330. * @param fastCheck if only the bounding box should checked
  25331. * @returns picking info of the intersecton
  25332. */
  25333. Ray.prototype.intersectsMesh = function (mesh, fastCheck) {
  25334. var tm = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  25335. mesh.getWorldMatrix().invertToRef(tm);
  25336. if (this._tmpRay) {
  25337. Ray.TransformToRef(this, tm, this._tmpRay);
  25338. }
  25339. else {
  25340. this._tmpRay = Ray.Transform(this, tm);
  25341. }
  25342. return mesh.intersects(this._tmpRay, fastCheck);
  25343. };
  25344. /**
  25345. * Checks if ray intersects a mesh
  25346. * @param meshes the meshes to check
  25347. * @param fastCheck if only the bounding box should checked
  25348. * @param results array to store result in
  25349. * @returns Array of picking infos
  25350. */
  25351. Ray.prototype.intersectsMeshes = function (meshes, fastCheck, results) {
  25352. if (results) {
  25353. results.length = 0;
  25354. }
  25355. else {
  25356. results = [];
  25357. }
  25358. for (var i = 0; i < meshes.length; i++) {
  25359. var pickInfo = this.intersectsMesh(meshes[i], fastCheck);
  25360. if (pickInfo.hit) {
  25361. results.push(pickInfo);
  25362. }
  25363. }
  25364. results.sort(this._comparePickingInfo);
  25365. return results;
  25366. };
  25367. Ray.prototype._comparePickingInfo = function (pickingInfoA, pickingInfoB) {
  25368. if (pickingInfoA.distance < pickingInfoB.distance) {
  25369. return -1;
  25370. }
  25371. else if (pickingInfoA.distance > pickingInfoB.distance) {
  25372. return 1;
  25373. }
  25374. else {
  25375. return 0;
  25376. }
  25377. };
  25378. /**
  25379. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  25380. * @param sega the first point of the segment to test the intersection against
  25381. * @param segb the second point of the segment to test the intersection against
  25382. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  25383. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  25384. */
  25385. Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
  25386. var o = this.origin;
  25387. var u = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  25388. var rsegb = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  25389. var v = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  25390. var w = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  25391. segb.subtractToRef(sega, u);
  25392. this.direction.scaleToRef(Ray.rayl, v);
  25393. o.addToRef(v, rsegb);
  25394. sega.subtractToRef(o, w);
  25395. var a = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, u); // always >= 0
  25396. var b = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, v);
  25397. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, v); // always >= 0
  25398. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, w);
  25399. var e = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, w);
  25400. var D = a * c - b * b; // always >= 0
  25401. var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
  25402. var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
  25403. // compute the line parameters of the two closest points
  25404. if (D < Ray.smallnum) { // the lines are almost parallel
  25405. sN = 0.0; // force using point P0 on segment S1
  25406. sD = 1.0; // to prevent possible division by 0.0 later
  25407. tN = e;
  25408. tD = c;
  25409. }
  25410. else { // get the closest points on the infinite lines
  25411. sN = (b * e - c * d);
  25412. tN = (a * e - b * d);
  25413. if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
  25414. sN = 0.0;
  25415. tN = e;
  25416. tD = c;
  25417. }
  25418. else if (sN > sD) { // sc > 1 => the s=1 edge is visible
  25419. sN = sD;
  25420. tN = e + b;
  25421. tD = c;
  25422. }
  25423. }
  25424. if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
  25425. tN = 0.0;
  25426. // recompute sc for this edge
  25427. if (-d < 0.0) {
  25428. sN = 0.0;
  25429. }
  25430. else if (-d > a) {
  25431. sN = sD;
  25432. }
  25433. else {
  25434. sN = -d;
  25435. sD = a;
  25436. }
  25437. }
  25438. else if (tN > tD) { // tc > 1 => the t=1 edge is visible
  25439. tN = tD;
  25440. // recompute sc for this edge
  25441. if ((-d + b) < 0.0) {
  25442. sN = 0;
  25443. }
  25444. else if ((-d + b) > a) {
  25445. sN = sD;
  25446. }
  25447. else {
  25448. sN = (-d + b);
  25449. sD = a;
  25450. }
  25451. }
  25452. // finally do the division to get sc and tc
  25453. sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
  25454. tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
  25455. // get the difference of the two closest points
  25456. var qtc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  25457. v.scaleToRef(tc, qtc);
  25458. var qsc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  25459. u.scaleToRef(sc, qsc);
  25460. qsc.addInPlace(w);
  25461. var dP = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  25462. qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
  25463. var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
  25464. if (isIntersected) {
  25465. return qsc.length();
  25466. }
  25467. return -1;
  25468. };
  25469. /**
  25470. * Update the ray from viewport position
  25471. * @param x position
  25472. * @param y y position
  25473. * @param viewportWidth viewport width
  25474. * @param viewportHeight viewport height
  25475. * @param world world matrix
  25476. * @param view view matrix
  25477. * @param projection projection matrix
  25478. * @returns this ray updated
  25479. */
  25480. Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  25481. this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
  25482. return this;
  25483. };
  25484. // Statics
  25485. /**
  25486. * Creates a ray with origin and direction of 0,0,0
  25487. * @returns the new ray
  25488. */
  25489. Ray.Zero = function () {
  25490. return new Ray(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  25491. };
  25492. /**
  25493. * Creates a new ray from screen space and viewport
  25494. * @param x position
  25495. * @param y y position
  25496. * @param viewportWidth viewport width
  25497. * @param viewportHeight viewport height
  25498. * @param world world matrix
  25499. * @param view view matrix
  25500. * @param projection projection matrix
  25501. * @returns new ray
  25502. */
  25503. Ray.CreateNew = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  25504. var result = Ray.Zero();
  25505. return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
  25506. };
  25507. /**
  25508. * 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
  25509. * transformed to the given world matrix.
  25510. * @param origin The origin point
  25511. * @param end The end point
  25512. * @param world a matrix to transform the ray to. Default is the identity matrix.
  25513. * @returns the new ray
  25514. */
  25515. Ray.CreateNewFromTo = function (origin, end, world) {
  25516. if (world === void 0) { world = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
  25517. var direction = end.subtract(origin);
  25518. var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
  25519. direction.normalize();
  25520. return Ray.Transform(new Ray(origin, direction, length), world);
  25521. };
  25522. /**
  25523. * Transforms a ray by a matrix
  25524. * @param ray ray to transform
  25525. * @param matrix matrix to apply
  25526. * @returns the resulting new ray
  25527. */
  25528. Ray.Transform = function (ray, matrix) {
  25529. 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));
  25530. Ray.TransformToRef(ray, matrix, result);
  25531. return result;
  25532. };
  25533. /**
  25534. * Transforms a ray by a matrix
  25535. * @param ray ray to transform
  25536. * @param matrix matrix to apply
  25537. * @param result ray to store result in
  25538. */
  25539. Ray.TransformToRef = function (ray, matrix, result) {
  25540. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(ray.origin, matrix, result.origin);
  25541. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(ray.direction, matrix, result.direction);
  25542. result.length = ray.length;
  25543. var dir = result.direction;
  25544. var len = dir.length();
  25545. if (!(len === 0 || len === 1)) {
  25546. var num = 1.0 / len;
  25547. dir.x *= num;
  25548. dir.y *= num;
  25549. dir.z *= num;
  25550. result.length *= len;
  25551. }
  25552. };
  25553. /**
  25554. * Unproject a ray from screen space to object space
  25555. * @param sourceX defines the screen space x coordinate to use
  25556. * @param sourceY defines the screen space y coordinate to use
  25557. * @param viewportWidth defines the current width of the viewport
  25558. * @param viewportHeight defines the current height of the viewport
  25559. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  25560. * @param view defines the view matrix to use
  25561. * @param projection defines the projection matrix to use
  25562. */
  25563. Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
  25564. var matrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  25565. world.multiplyToRef(view, matrix);
  25566. matrix.multiplyToRef(projection, matrix);
  25567. matrix.invert();
  25568. var nearScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  25569. nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
  25570. nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
  25571. nearScreenSource.z = -1.0;
  25572. var farScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
  25573. var nearVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  25574. var farVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  25575. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
  25576. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
  25577. this.origin.copyFrom(nearVec3);
  25578. farVec3.subtractToRef(nearVec3, this.direction);
  25579. this.direction.normalize();
  25580. };
  25581. Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25582. Ray.smallnum = 0.00000001;
  25583. Ray.rayl = 10e8;
  25584. return Ray;
  25585. }());
  25586. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  25587. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  25588. var result = Ray.Zero();
  25589. this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);
  25590. return result;
  25591. };
  25592. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  25593. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  25594. var engine = this.getEngine();
  25595. if (!camera) {
  25596. if (!this.activeCamera) {
  25597. throw new Error("Active camera not set");
  25598. }
  25599. camera = this.activeCamera;
  25600. }
  25601. var cameraViewport = camera.viewport;
  25602. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  25603. // Moving coordinates to local viewport world
  25604. x = x / engine.getHardwareScalingLevel() - viewport.x;
  25605. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  25606. 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());
  25607. return this;
  25608. };
  25609. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  25610. var result = Ray.Zero();
  25611. this.createPickingRayInCameraSpaceToRef(x, y, result, camera);
  25612. return result;
  25613. };
  25614. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  25615. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25616. return this;
  25617. }
  25618. var engine = this.getEngine();
  25619. if (!camera) {
  25620. if (!this.activeCamera) {
  25621. throw new Error("Active camera not set");
  25622. }
  25623. camera = this.activeCamera;
  25624. }
  25625. var cameraViewport = camera.viewport;
  25626. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  25627. var identity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  25628. // Moving coordinates to local viewport world
  25629. x = x / engine.getHardwareScalingLevel() - viewport.x;
  25630. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  25631. result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
  25632. return this;
  25633. };
  25634. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalPick = function (rayFunction, predicate, fastCheck) {
  25635. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25636. return null;
  25637. }
  25638. var pickingInfo = null;
  25639. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  25640. var mesh = this.meshes[meshIndex];
  25641. if (predicate) {
  25642. if (!predicate(mesh)) {
  25643. continue;
  25644. }
  25645. }
  25646. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  25647. continue;
  25648. }
  25649. var world = mesh.getWorldMatrix();
  25650. var ray = rayFunction(world);
  25651. var result = mesh.intersects(ray, fastCheck);
  25652. if (!result || !result.hit) {
  25653. continue;
  25654. }
  25655. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  25656. continue;
  25657. }
  25658. pickingInfo = result;
  25659. if (fastCheck) {
  25660. break;
  25661. }
  25662. }
  25663. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]();
  25664. };
  25665. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalMultiPick = function (rayFunction, predicate) {
  25666. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25667. return null;
  25668. }
  25669. var pickingInfos = new Array();
  25670. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  25671. var mesh = this.meshes[meshIndex];
  25672. if (predicate) {
  25673. if (!predicate(mesh)) {
  25674. continue;
  25675. }
  25676. }
  25677. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  25678. continue;
  25679. }
  25680. var world = mesh.getWorldMatrix();
  25681. var ray = rayFunction(world);
  25682. var result = mesh.intersects(ray, false);
  25683. if (!result || !result.hit) {
  25684. continue;
  25685. }
  25686. pickingInfos.push(result);
  25687. }
  25688. return pickingInfos;
  25689. };
  25690. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pick = function (x, y, predicate, fastCheck, camera) {
  25691. var _this = this;
  25692. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25693. return null;
  25694. }
  25695. var result = this._internalPick(function (world) {
  25696. if (!_this._tempPickingRay) {
  25697. _this._tempPickingRay = Ray.Zero();
  25698. }
  25699. _this.createPickingRayToRef(x, y, world, _this._tempPickingRay, camera || null);
  25700. return _this._tempPickingRay;
  25701. }, predicate, fastCheck);
  25702. if (result) {
  25703. result.ray = this.createPickingRay(x, y, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), camera || null);
  25704. }
  25705. return result;
  25706. };
  25707. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pickWithRay = function (ray, predicate, fastCheck) {
  25708. var _this = this;
  25709. var result = this._internalPick(function (world) {
  25710. if (!_this._pickWithRayInverseMatrix) {
  25711. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  25712. }
  25713. world.invertToRef(_this._pickWithRayInverseMatrix);
  25714. if (!_this._cachedRayForTransform) {
  25715. _this._cachedRayForTransform = Ray.Zero();
  25716. }
  25717. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  25718. return _this._cachedRayForTransform;
  25719. }, predicate, fastCheck);
  25720. if (result) {
  25721. result.ray = ray;
  25722. }
  25723. return result;
  25724. };
  25725. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPick = function (x, y, predicate, camera) {
  25726. var _this = this;
  25727. return this._internalMultiPick(function (world) { return _this.createPickingRay(x, y, world, camera || null); }, predicate);
  25728. };
  25729. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPickWithRay = function (ray, predicate) {
  25730. var _this = this;
  25731. return this._internalMultiPick(function (world) {
  25732. if (!_this._pickWithRayInverseMatrix) {
  25733. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  25734. }
  25735. world.invertToRef(_this._pickWithRayInverseMatrix);
  25736. if (!_this._cachedRayForTransform) {
  25737. _this._cachedRayForTransform = Ray.Zero();
  25738. }
  25739. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  25740. return _this._cachedRayForTransform;
  25741. }, predicate);
  25742. };
  25743. _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].prototype.getForwardRay = function (length, transform, origin) {
  25744. if (length === void 0) { length = 100; }
  25745. if (!transform) {
  25746. transform = this.getWorldMatrix();
  25747. }
  25748. if (!origin) {
  25749. origin = this.position;
  25750. }
  25751. 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);
  25752. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(forward, transform);
  25753. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Normalize(forwardWorld);
  25754. return new Ray(origin, direction, length);
  25755. };
  25756. /***/ }),
  25757. /***/ "./Debug/axesViewer.ts":
  25758. /*!*****************************!*\
  25759. !*** ./Debug/axesViewer.ts ***!
  25760. \*****************************/
  25761. /*! exports provided: AxesViewer */
  25762. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25763. "use strict";
  25764. __webpack_require__.r(__webpack_exports__);
  25765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return AxesViewer; });
  25766. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25767. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  25768. /* harmony import */ var _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gizmos/axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  25769. /**
  25770. * The Axes viewer will show 3 axes in a specific point in space
  25771. */
  25772. var AxesViewer = /** @class */ (function () {
  25773. /**
  25774. * Creates a new AxesViewer
  25775. * @param scene defines the hosting scene
  25776. * @param scaleLines defines a number used to scale line length (1 by default)
  25777. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  25778. * @param xAxis defines the node hierarchy used to render the x-axis
  25779. * @param yAxis defines the node hierarchy used to render the y-axis
  25780. * @param zAxis defines the node hierarchy used to render the z-axis
  25781. */
  25782. function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
  25783. if (scaleLines === void 0) { scaleLines = 1; }
  25784. if (renderingGroupId === void 0) { renderingGroupId = 2; }
  25785. this._scaleLinesFactor = 4;
  25786. this._instanced = false;
  25787. /**
  25788. * Gets or sets a number used to scale line length
  25789. */
  25790. this.scaleLines = 1;
  25791. this.scaleLines = scaleLines;
  25792. if (!xAxis) {
  25793. var redColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25794. redColoredMaterial.disableLighting = true;
  25795. redColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Red().scale(0.5);
  25796. xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, redColoredMaterial);
  25797. }
  25798. if (!yAxis) {
  25799. var greenColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25800. greenColoredMaterial.disableLighting = true;
  25801. greenColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Green().scale(0.5);
  25802. yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, greenColoredMaterial);
  25803. }
  25804. if (!zAxis) {
  25805. var blueColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25806. blueColoredMaterial.disableLighting = true;
  25807. blueColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Blue().scale(0.5);
  25808. zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, blueColoredMaterial);
  25809. }
  25810. this._xAxis = xAxis;
  25811. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25812. this._yAxis = yAxis;
  25813. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25814. this._zAxis = zAxis;
  25815. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25816. if (renderingGroupId != null) {
  25817. AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
  25818. AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
  25819. AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
  25820. }
  25821. this.scene = scene;
  25822. 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());
  25823. }
  25824. Object.defineProperty(AxesViewer.prototype, "xAxis", {
  25825. /** Gets the node hierarchy used to render x-axis */
  25826. get: function () {
  25827. return this._xAxis;
  25828. },
  25829. enumerable: true,
  25830. configurable: true
  25831. });
  25832. Object.defineProperty(AxesViewer.prototype, "yAxis", {
  25833. /** Gets the node hierarchy used to render y-axis */
  25834. get: function () {
  25835. return this._yAxis;
  25836. },
  25837. enumerable: true,
  25838. configurable: true
  25839. });
  25840. Object.defineProperty(AxesViewer.prototype, "zAxis", {
  25841. /** Gets the node hierarchy used to render z-axis */
  25842. get: function () {
  25843. return this._zAxis;
  25844. },
  25845. enumerable: true,
  25846. configurable: true
  25847. });
  25848. /**
  25849. * Force the viewer to update
  25850. * @param position defines the position of the viewer
  25851. * @param xaxis defines the x axis of the viewer
  25852. * @param yaxis defines the y axis of the viewer
  25853. * @param zaxis defines the z axis of the viewer
  25854. */
  25855. AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
  25856. this._xAxis.position.copyFrom(position);
  25857. this._xAxis.setDirection(xaxis);
  25858. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25859. this._yAxis.position.copyFrom(position);
  25860. this._yAxis.setDirection(yaxis);
  25861. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25862. this._zAxis.position.copyFrom(position);
  25863. this._zAxis.setDirection(zaxis);
  25864. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25865. };
  25866. /**
  25867. * Creates an instance of this axes viewer.
  25868. * @returns a new axes viewer with instanced meshes
  25869. */
  25870. AxesViewer.prototype.createInstance = function () {
  25871. var xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._xAxis);
  25872. var yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._yAxis);
  25873. var zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._zAxis);
  25874. var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
  25875. axesViewer._instanced = true;
  25876. return axesViewer;
  25877. };
  25878. /** Releases resources */
  25879. AxesViewer.prototype.dispose = function () {
  25880. if (this._xAxis) {
  25881. this._xAxis.dispose(false, !this._instanced);
  25882. delete this._xAxis;
  25883. }
  25884. if (this._yAxis) {
  25885. this._yAxis.dispose(false, !this._instanced);
  25886. delete this._yAxis;
  25887. }
  25888. if (this._zAxis) {
  25889. this._zAxis.dispose(false, !this._instanced);
  25890. delete this._zAxis;
  25891. }
  25892. delete this.scene;
  25893. };
  25894. AxesViewer._SetRenderingGroupId = function (node, id) {
  25895. node.getChildMeshes().forEach(function (mesh) {
  25896. mesh.renderingGroupId = id;
  25897. });
  25898. };
  25899. return AxesViewer;
  25900. }());
  25901. /***/ }),
  25902. /***/ "./Debug/boneAxesViewer.ts":
  25903. /*!*********************************!*\
  25904. !*** ./Debug/boneAxesViewer.ts ***!
  25905. \*********************************/
  25906. /*! exports provided: BoneAxesViewer */
  25907. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25908. "use strict";
  25909. __webpack_require__.r(__webpack_exports__);
  25910. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return BoneAxesViewer; });
  25911. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  25912. /* harmony import */ var _Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/axesViewer */ "./Debug/axesViewer.ts");
  25913. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25914. /**
  25915. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  25916. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  25917. */
  25918. var BoneAxesViewer = /** @class */ (function (_super) {
  25919. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoneAxesViewer, _super);
  25920. /**
  25921. * Creates a new BoneAxesViewer
  25922. * @param scene defines the hosting scene
  25923. * @param bone defines the target bone
  25924. * @param mesh defines the target mesh
  25925. * @param scaleLines defines a scaling factor for line length (1 by default)
  25926. */
  25927. function BoneAxesViewer(scene, bone, mesh, scaleLines) {
  25928. if (scaleLines === void 0) { scaleLines = 1; }
  25929. var _this = _super.call(this, scene, scaleLines) || this;
  25930. /** Gets current position */
  25931. _this.pos = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25932. /** Gets direction of X axis */
  25933. _this.xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25934. /** Gets direction of Y axis */
  25935. _this.yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25936. /** Gets direction of Z axis */
  25937. _this.zaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25938. _this.mesh = mesh;
  25939. _this.bone = bone;
  25940. return _this;
  25941. }
  25942. /**
  25943. * Force the viewer to update
  25944. */
  25945. BoneAxesViewer.prototype.update = function () {
  25946. if (!this.mesh || !this.bone) {
  25947. return;
  25948. }
  25949. var bone = this.bone;
  25950. bone.getAbsolutePositionToRef(this.mesh, this.pos);
  25951. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].X, this.mesh, this.xaxis);
  25952. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y, this.mesh, this.yaxis);
  25953. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Z, this.mesh, this.zaxis);
  25954. _super.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
  25955. };
  25956. /** Releases resources */
  25957. BoneAxesViewer.prototype.dispose = function () {
  25958. if (this.mesh) {
  25959. this.mesh = null;
  25960. this.bone = null;
  25961. _super.prototype.dispose.call(this);
  25962. }
  25963. };
  25964. return BoneAxesViewer;
  25965. }(_Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"]));
  25966. /***/ }),
  25967. /***/ "./Debug/debugLayer.ts":
  25968. /*!*****************************!*\
  25969. !*** ./Debug/debugLayer.ts ***!
  25970. \*****************************/
  25971. /*! exports provided: DebugLayer */
  25972. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25973. "use strict";
  25974. __webpack_require__.r(__webpack_exports__);
  25975. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return DebugLayer; });
  25976. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  25977. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  25978. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  25979. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25980. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype, "debugLayer", {
  25981. get: function () {
  25982. if (!this._debugLayer) {
  25983. this._debugLayer = new DebugLayer(this);
  25984. }
  25985. return this._debugLayer;
  25986. },
  25987. enumerable: true,
  25988. configurable: true
  25989. });
  25990. /**
  25991. * The debug layer (aka Inspector) is the go to tool in order to better understand
  25992. * what is happening in your scene
  25993. * @see http://doc.babylonjs.com/features/playground_debuglayer
  25994. */
  25995. var DebugLayer = /** @class */ (function () {
  25996. /**
  25997. * Instantiates a new debug layer.
  25998. * The debug layer (aka Inspector) is the go to tool in order to better understand
  25999. * what is happening in your scene
  26000. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26001. * @param scene Defines the scene to inspect
  26002. */
  26003. function DebugLayer(scene) {
  26004. var _this = this;
  26005. this.BJSINSPECTOR = this._getGlobalInspector();
  26006. /**
  26007. * Observable triggered when a property is changed through the inspector.
  26008. */
  26009. this.onPropertyChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  26010. this._scene = scene;
  26011. this._scene.onDisposeObservable.add(function () {
  26012. // Debug layer
  26013. if (_this._scene._debugLayer) {
  26014. _this._scene._debugLayer.hide();
  26015. }
  26016. });
  26017. }
  26018. /** Creates the inspector window. */
  26019. DebugLayer.prototype._createInspector = function (config) {
  26020. if (this.isVisible()) {
  26021. return;
  26022. }
  26023. var userOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ overlay: false, showExplorer: true, showInspector: true, embedMode: false, handleResize: true, enablePopup: true }, config);
  26024. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
  26025. this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
  26026. };
  26027. /** Get the inspector from bundle or global */
  26028. DebugLayer.prototype._getGlobalInspector = function () {
  26029. // UMD Global name detection from Webpack Bundle UMD Name.
  26030. if (typeof INSPECTOR !== 'undefined') {
  26031. return INSPECTOR;
  26032. }
  26033. // In case of module let s check the global emitted from the Inspector entry point.
  26034. if (typeof BABYLON !== 'undefined' && typeof BABYLON.Inspector !== 'undefined') {
  26035. return BABYLON;
  26036. }
  26037. return undefined;
  26038. };
  26039. /**
  26040. * Get if the inspector is visible or not.
  26041. * @returns true if visible otherwise, false
  26042. */
  26043. DebugLayer.prototype.isVisible = function () {
  26044. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
  26045. };
  26046. /**
  26047. * Hide the inspector and close its window.
  26048. */
  26049. DebugLayer.prototype.hide = function () {
  26050. if (this.BJSINSPECTOR) {
  26051. this.BJSINSPECTOR.Inspector.Hide();
  26052. }
  26053. };
  26054. /**
  26055. * Launch the debugLayer.
  26056. * @param config Define the configuration of the inspector
  26057. */
  26058. DebugLayer.prototype.show = function (config) {
  26059. if (typeof this.BJSINSPECTOR == 'undefined') {
  26060. // Load inspector and add it to the DOM
  26061. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadScript(DebugLayer.InspectorURL, this._createInspector.bind(this, config));
  26062. }
  26063. else {
  26064. // Otherwise creates the inspector
  26065. this._createInspector(config);
  26066. }
  26067. };
  26068. /**
  26069. * Define the url to get the inspector script from.
  26070. * By default it uses the babylonjs CDN.
  26071. * @ignoreNaming
  26072. */
  26073. DebugLayer.InspectorURL = 'https://preview.babylonjs.com/inspector/babylon.inspector.bundle.js';
  26074. return DebugLayer;
  26075. }());
  26076. /***/ }),
  26077. /***/ "./Debug/index.ts":
  26078. /*!************************!*\
  26079. !*** ./Debug/index.ts ***!
  26080. \************************/
  26081. /*! exports provided: AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer */
  26082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26083. "use strict";
  26084. __webpack_require__.r(__webpack_exports__);
  26085. /* harmony import */ var _axesViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axesViewer */ "./Debug/axesViewer.ts");
  26086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _axesViewer__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  26087. /* harmony import */ var _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneAxesViewer */ "./Debug/boneAxesViewer.ts");
  26088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"]; });
  26089. /* harmony import */ var _debugLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./debugLayer */ "./Debug/debugLayer.ts");
  26090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _debugLayer__WEBPACK_IMPORTED_MODULE_2__["DebugLayer"]; });
  26091. /* harmony import */ var _physicsViewer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsViewer */ "./Debug/physicsViewer.ts");
  26092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _physicsViewer__WEBPACK_IMPORTED_MODULE_3__["PhysicsViewer"]; });
  26093. /* harmony import */ var _rayHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rayHelper */ "./Debug/rayHelper.ts");
  26094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _rayHelper__WEBPACK_IMPORTED_MODULE_4__["RayHelper"]; });
  26095. /* harmony import */ var _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./skeletonViewer */ "./Debug/skeletonViewer.ts");
  26096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__["SkeletonViewer"]; });
  26097. /***/ }),
  26098. /***/ "./Debug/physicsViewer.ts":
  26099. /*!********************************!*\
  26100. !*** ./Debug/physicsViewer.ts ***!
  26101. \********************************/
  26102. /*! exports provided: PhysicsViewer */
  26103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26104. "use strict";
  26105. __webpack_require__.r(__webpack_exports__);
  26106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return PhysicsViewer; });
  26107. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  26108. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  26109. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26110. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  26111. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26112. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  26113. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26114. /**
  26115. * Used to show the physics impostor around the specific mesh
  26116. */
  26117. var PhysicsViewer = /** @class */ (function () {
  26118. /**
  26119. * Creates a new PhysicsViewer
  26120. * @param scene defines the hosting scene
  26121. */
  26122. function PhysicsViewer(scene) {
  26123. /** @hidden */
  26124. this._impostors = [];
  26125. /** @hidden */
  26126. this._meshes = [];
  26127. /** @hidden */
  26128. this._numMeshes = 0;
  26129. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  26130. var physicEngine = this._scene.getPhysicsEngine();
  26131. if (physicEngine) {
  26132. this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
  26133. }
  26134. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"](this._scene, false);
  26135. this._utilityLayer.pickUtilitySceneFirst = false;
  26136. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26137. }
  26138. /** @hidden */
  26139. PhysicsViewer.prototype._updateDebugMeshes = function () {
  26140. var plugin = this._physicsEnginePlugin;
  26141. for (var i = 0; i < this._numMeshes; i++) {
  26142. var impostor = this._impostors[i];
  26143. if (!impostor) {
  26144. continue;
  26145. }
  26146. if (impostor.isDisposed) {
  26147. this.hideImpostor(this._impostors[i--]);
  26148. }
  26149. else {
  26150. var mesh = this._meshes[i];
  26151. if (mesh && plugin) {
  26152. plugin.syncMeshWithImpostor(mesh, impostor);
  26153. }
  26154. }
  26155. }
  26156. };
  26157. /**
  26158. * Renders a specified physic impostor
  26159. * @param impostor defines the impostor to render
  26160. * @returns the new debug mesh used to render the impostor
  26161. */
  26162. PhysicsViewer.prototype.showImpostor = function (impostor) {
  26163. if (!this._scene) {
  26164. return null;
  26165. }
  26166. for (var i = 0; i < this._numMeshes; i++) {
  26167. if (this._impostors[i] == impostor) {
  26168. return null;
  26169. }
  26170. }
  26171. var debugMesh = this._getDebugMesh(impostor);
  26172. if (debugMesh) {
  26173. this._impostors[this._numMeshes] = impostor;
  26174. this._meshes[this._numMeshes] = debugMesh;
  26175. if (this._numMeshes === 0) {
  26176. this._renderFunction = this._updateDebugMeshes.bind(this);
  26177. this._scene.registerBeforeRender(this._renderFunction);
  26178. }
  26179. this._numMeshes++;
  26180. }
  26181. return debugMesh;
  26182. };
  26183. /**
  26184. * Hides a specified physic impostor
  26185. * @param impostor defines the impostor to hide
  26186. */
  26187. PhysicsViewer.prototype.hideImpostor = function (impostor) {
  26188. if (!impostor || !this._scene || !this._utilityLayer) {
  26189. return;
  26190. }
  26191. var removed = false;
  26192. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26193. for (var i = 0; i < this._numMeshes; i++) {
  26194. if (this._impostors[i] == impostor) {
  26195. var mesh = this._meshes[i];
  26196. if (!mesh) {
  26197. continue;
  26198. }
  26199. utilityLayerScene.removeMesh(mesh);
  26200. mesh.dispose();
  26201. this._numMeshes--;
  26202. if (this._numMeshes > 0) {
  26203. this._meshes[i] = this._meshes[this._numMeshes];
  26204. this._impostors[i] = this._impostors[this._numMeshes];
  26205. this._meshes[this._numMeshes] = null;
  26206. this._impostors[this._numMeshes] = null;
  26207. }
  26208. else {
  26209. this._meshes[0] = null;
  26210. this._impostors[0] = null;
  26211. }
  26212. removed = true;
  26213. break;
  26214. }
  26215. }
  26216. if (removed && this._numMeshes === 0) {
  26217. this._scene.unregisterBeforeRender(this._renderFunction);
  26218. }
  26219. };
  26220. PhysicsViewer.prototype._getDebugMaterial = function (scene) {
  26221. if (!this._debugMaterial) {
  26222. this._debugMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_4__["StandardMaterial"]('', scene);
  26223. this._debugMaterial.wireframe = true;
  26224. this._debugMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  26225. this._debugMaterial.disableLighting = true;
  26226. }
  26227. return this._debugMaterial;
  26228. };
  26229. PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
  26230. if (!this._debugBoxMesh) {
  26231. this._debugBoxMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"].CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
  26232. this._debugBoxMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  26233. this._debugBoxMesh.material = this._getDebugMaterial(scene);
  26234. }
  26235. return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
  26236. };
  26237. PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
  26238. if (!this._debugSphereMesh) {
  26239. this._debugSphereMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
  26240. this._debugSphereMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  26241. this._debugSphereMesh.material = this._getDebugMaterial(scene);
  26242. }
  26243. return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
  26244. };
  26245. PhysicsViewer.prototype._getDebugMesh = function (impostor) {
  26246. if (!this._utilityLayer) {
  26247. return null;
  26248. }
  26249. var mesh = null;
  26250. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26251. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__["PhysicsImpostor"].BoxImpostor) {
  26252. mesh = this._getDebugBoxMesh(utilityLayerScene);
  26253. impostor.getBoxSizeToRef(mesh.scaling);
  26254. }
  26255. else if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__["PhysicsImpostor"].SphereImpostor) {
  26256. mesh = this._getDebugSphereMesh(utilityLayerScene);
  26257. var radius = impostor.getRadius();
  26258. mesh.scaling.x = radius * 2;
  26259. mesh.scaling.y = radius * 2;
  26260. mesh.scaling.z = radius * 2;
  26261. }
  26262. return mesh;
  26263. };
  26264. /** Releases all resources */
  26265. PhysicsViewer.prototype.dispose = function () {
  26266. for (var i = 0; i < this._numMeshes; i++) {
  26267. this.hideImpostor(this._impostors[i]);
  26268. }
  26269. if (this._debugBoxMesh) {
  26270. this._debugBoxMesh.dispose();
  26271. }
  26272. if (this._debugSphereMesh) {
  26273. this._debugSphereMesh.dispose();
  26274. }
  26275. if (this._debugMaterial) {
  26276. this._debugMaterial.dispose();
  26277. }
  26278. this._impostors.length = 0;
  26279. this._scene = null;
  26280. this._physicsEnginePlugin = null;
  26281. if (this._utilityLayer) {
  26282. this._utilityLayer.dispose();
  26283. this._utilityLayer = null;
  26284. }
  26285. };
  26286. return PhysicsViewer;
  26287. }());
  26288. /***/ }),
  26289. /***/ "./Debug/rayHelper.ts":
  26290. /*!****************************!*\
  26291. !*** ./Debug/rayHelper.ts ***!
  26292. \****************************/
  26293. /*! exports provided: RayHelper */
  26294. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26295. "use strict";
  26296. __webpack_require__.r(__webpack_exports__);
  26297. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return RayHelper; });
  26298. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26299. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  26300. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26301. /**
  26302. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26303. * in order to better appreciate the issue one might have.
  26304. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26305. */
  26306. var RayHelper = /** @class */ (function () {
  26307. /**
  26308. * Instantiate a new ray helper.
  26309. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26310. * in order to better appreciate the issue one might have.
  26311. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26312. * @param ray Defines the ray we are currently tryin to visualize
  26313. */
  26314. function RayHelper(ray) {
  26315. this.ray = ray;
  26316. }
  26317. /**
  26318. * Helper function to create a colored helper in a scene in one line.
  26319. * @param ray Defines the ray we are currently tryin to visualize
  26320. * @param scene Defines the scene the ray is used in
  26321. * @param color Defines the color we want to see the ray in
  26322. * @returns The newly created ray helper.
  26323. */
  26324. RayHelper.CreateAndShow = function (ray, scene, color) {
  26325. var helper = new RayHelper(ray);
  26326. helper.show(scene, color);
  26327. return helper;
  26328. };
  26329. /**
  26330. * Shows the ray we are willing to debug.
  26331. * @param scene Defines the scene the ray needs to be rendered in
  26332. * @param color Defines the color the ray needs to be rendered in
  26333. */
  26334. RayHelper.prototype.show = function (scene, color) {
  26335. if (!this._renderFunction && this.ray) {
  26336. var ray = this.ray;
  26337. this._renderFunction = this._render.bind(this);
  26338. this._scene = scene;
  26339. this._renderPoints = [ray.origin, ray.origin.add(ray.direction.scale(ray.length))];
  26340. this._renderLine = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, scene, true);
  26341. if (this._renderFunction) {
  26342. this._scene.registerBeforeRender(this._renderFunction);
  26343. }
  26344. }
  26345. if (color && this._renderLine) {
  26346. this._renderLine.color.copyFrom(color);
  26347. }
  26348. };
  26349. /**
  26350. * Hides the ray we are debugging.
  26351. */
  26352. RayHelper.prototype.hide = function () {
  26353. if (this._renderFunction && this._scene) {
  26354. this._scene.unregisterBeforeRender(this._renderFunction);
  26355. this._scene = null;
  26356. this._renderFunction = null;
  26357. if (this._renderLine) {
  26358. this._renderLine.dispose();
  26359. this._renderLine = null;
  26360. }
  26361. this._renderPoints = [];
  26362. }
  26363. };
  26364. RayHelper.prototype._render = function () {
  26365. var ray = this.ray;
  26366. if (!ray) {
  26367. return;
  26368. }
  26369. var point = this._renderPoints[1];
  26370. var len = Math.min(ray.length, 1000000);
  26371. point.copyFrom(ray.direction);
  26372. point.scaleInPlace(len);
  26373. point.addInPlace(ray.origin);
  26374. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, this._scene, true, this._renderLine);
  26375. };
  26376. /**
  26377. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  26378. * @param mesh Defines the mesh we want the helper attached to
  26379. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  26380. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  26381. * @param length Defines the length of the ray
  26382. */
  26383. RayHelper.prototype.attachToMesh = function (mesh, meshSpaceDirection, meshSpaceOrigin, length) {
  26384. this._attachedToMesh = mesh;
  26385. var ray = this.ray;
  26386. if (!ray) {
  26387. return;
  26388. }
  26389. if (!ray.direction) {
  26390. ray.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26391. }
  26392. if (!ray.origin) {
  26393. ray.origin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26394. }
  26395. if (length) {
  26396. ray.length = length;
  26397. }
  26398. if (!meshSpaceOrigin) {
  26399. meshSpaceOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26400. }
  26401. if (!meshSpaceDirection) {
  26402. // -1 so that this will work with Mesh.lookAt
  26403. meshSpaceDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1);
  26404. }
  26405. if (!this._meshSpaceDirection) {
  26406. this._meshSpaceDirection = meshSpaceDirection.clone();
  26407. this._meshSpaceOrigin = meshSpaceOrigin.clone();
  26408. }
  26409. else {
  26410. this._meshSpaceDirection.copyFrom(meshSpaceDirection);
  26411. this._meshSpaceOrigin.copyFrom(meshSpaceOrigin);
  26412. }
  26413. if (!this._updateToMeshFunction) {
  26414. this._updateToMeshFunction = this._updateToMesh.bind(this);
  26415. this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
  26416. }
  26417. this._updateToMesh();
  26418. };
  26419. /**
  26420. * Detach the ray helper from the mesh it has previously been attached to.
  26421. */
  26422. RayHelper.prototype.detachFromMesh = function () {
  26423. if (this._attachedToMesh) {
  26424. if (this._updateToMeshFunction) {
  26425. this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction);
  26426. }
  26427. this._attachedToMesh = null;
  26428. this._updateToMeshFunction = null;
  26429. }
  26430. };
  26431. RayHelper.prototype._updateToMesh = function () {
  26432. var ray = this.ray;
  26433. if (!this._attachedToMesh || !ray) {
  26434. return;
  26435. }
  26436. if (this._attachedToMesh._isDisposed) {
  26437. this.detachFromMesh();
  26438. return;
  26439. }
  26440. this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, ray.direction);
  26441. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), ray.origin);
  26442. };
  26443. /**
  26444. * Dispose the helper and release its associated resources.
  26445. */
  26446. RayHelper.prototype.dispose = function () {
  26447. this.hide();
  26448. this.detachFromMesh();
  26449. this.ray = null;
  26450. };
  26451. return RayHelper;
  26452. }());
  26453. /***/ }),
  26454. /***/ "./Debug/skeletonViewer.ts":
  26455. /*!*********************************!*\
  26456. !*** ./Debug/skeletonViewer.ts ***!
  26457. \*********************************/
  26458. /*! exports provided: SkeletonViewer */
  26459. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26460. "use strict";
  26461. __webpack_require__.r(__webpack_exports__);
  26462. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return SkeletonViewer; });
  26463. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26464. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26465. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26466. /**
  26467. * Class used to render a debug view of a given skeleton
  26468. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  26469. */
  26470. var SkeletonViewer = /** @class */ (function () {
  26471. /**
  26472. * Creates a new SkeletonViewer
  26473. * @param skeleton defines the skeleton to render
  26474. * @param mesh defines the mesh attached to the skeleton
  26475. * @param scene defines the hosting scene
  26476. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  26477. * @param renderingGroupId defines the rendering group id to use with the viewer
  26478. */
  26479. function SkeletonViewer(
  26480. /** defines the skeleton to render */
  26481. skeleton,
  26482. /** defines the mesh attached to the skeleton */
  26483. mesh, scene,
  26484. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  26485. autoUpdateBonesMatrices,
  26486. /** defines the rendering group id to use with the viewer */
  26487. renderingGroupId) {
  26488. if (autoUpdateBonesMatrices === void 0) { autoUpdateBonesMatrices = true; }
  26489. if (renderingGroupId === void 0) { renderingGroupId = 1; }
  26490. this.skeleton = skeleton;
  26491. this.mesh = mesh;
  26492. this.autoUpdateBonesMatrices = autoUpdateBonesMatrices;
  26493. this.renderingGroupId = renderingGroupId;
  26494. /** Gets or sets the color used to render the skeleton */
  26495. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  26496. this._debugLines = new Array();
  26497. this._isEnabled = false;
  26498. this._scene = scene;
  26499. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"](this._scene, false);
  26500. this._utilityLayer.pickUtilitySceneFirst = false;
  26501. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26502. this.update();
  26503. this._renderFunction = this.update.bind(this);
  26504. }
  26505. Object.defineProperty(SkeletonViewer.prototype, "debugMesh", {
  26506. /**
  26507. * Returns the mesh used to render the bones
  26508. */
  26509. get: function () {
  26510. return this._debugMesh;
  26511. },
  26512. enumerable: true,
  26513. configurable: true
  26514. });
  26515. Object.defineProperty(SkeletonViewer.prototype, "isEnabled", {
  26516. get: function () {
  26517. return this._isEnabled;
  26518. },
  26519. /** Gets or sets a boolean indicating if the viewer is enabled */
  26520. set: function (value) {
  26521. if (this._isEnabled === value) {
  26522. return;
  26523. }
  26524. this._isEnabled = value;
  26525. if (value) {
  26526. this._scene.registerBeforeRender(this._renderFunction);
  26527. }
  26528. else {
  26529. this._scene.unregisterBeforeRender(this._renderFunction);
  26530. }
  26531. },
  26532. enumerable: true,
  26533. configurable: true
  26534. });
  26535. SkeletonViewer.prototype._getBonePosition = function (position, bone, meshMat, x, y, z) {
  26536. if (x === void 0) { x = 0; }
  26537. if (y === void 0) { y = 0; }
  26538. if (z === void 0) { z = 0; }
  26539. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  26540. var parentBone = bone.getParent();
  26541. tmat.copyFrom(bone.getLocalMatrix());
  26542. if (x !== 0 || y !== 0 || z !== 0) {
  26543. var tmat2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  26544. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(tmat2);
  26545. tmat2.setTranslationFromFloats(x, y, z);
  26546. tmat2.multiplyToRef(tmat, tmat);
  26547. }
  26548. if (parentBone) {
  26549. tmat.multiplyToRef(parentBone.getAbsoluteTransform(), tmat);
  26550. }
  26551. tmat.multiplyToRef(meshMat, tmat);
  26552. position.x = tmat.m[12];
  26553. position.y = tmat.m[13];
  26554. position.z = tmat.m[14];
  26555. };
  26556. SkeletonViewer.prototype._getLinesForBonesWithLength = function (bones, meshMat) {
  26557. var len = bones.length;
  26558. var meshPos = this.mesh.position;
  26559. for (var i = 0; i < len; i++) {
  26560. var bone = bones[i];
  26561. var points = this._debugLines[i];
  26562. if (!points) {
  26563. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  26564. this._debugLines[i] = points;
  26565. }
  26566. this._getBonePosition(points[0], bone, meshMat);
  26567. this._getBonePosition(points[1], bone, meshMat, 0, bone.length, 0);
  26568. points[0].subtractInPlace(meshPos);
  26569. points[1].subtractInPlace(meshPos);
  26570. }
  26571. };
  26572. SkeletonViewer.prototype._getLinesForBonesNoLength = function (bones, meshMat) {
  26573. var len = bones.length;
  26574. var boneNum = 0;
  26575. var meshPos = this.mesh.position;
  26576. for (var i = len - 1; i >= 0; i--) {
  26577. var childBone = bones[i];
  26578. var parentBone = childBone.getParent();
  26579. if (!parentBone) {
  26580. continue;
  26581. }
  26582. var points = this._debugLines[boneNum];
  26583. if (!points) {
  26584. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  26585. this._debugLines[boneNum] = points;
  26586. }
  26587. childBone.getAbsolutePositionToRef(this.mesh, points[0]);
  26588. parentBone.getAbsolutePositionToRef(this.mesh, points[1]);
  26589. points[0].subtractInPlace(meshPos);
  26590. points[1].subtractInPlace(meshPos);
  26591. boneNum++;
  26592. }
  26593. };
  26594. /** Update the viewer to sync with current skeleton state */
  26595. SkeletonViewer.prototype.update = function () {
  26596. if (!this._utilityLayer) {
  26597. return;
  26598. }
  26599. if (this.autoUpdateBonesMatrices) {
  26600. this.skeleton.computeAbsoluteTransforms();
  26601. }
  26602. if (this.skeleton.bones[0].length === undefined) {
  26603. this._getLinesForBonesNoLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  26604. }
  26605. else {
  26606. this._getLinesForBonesWithLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  26607. }
  26608. var targetScene = this._utilityLayer.utilityLayerScene;
  26609. if (!this._debugMesh) {
  26610. this._debugMesh = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, targetScene);
  26611. this._debugMesh.renderingGroupId = this.renderingGroupId;
  26612. }
  26613. else {
  26614. _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, targetScene);
  26615. }
  26616. this._debugMesh.position.copyFrom(this.mesh.position);
  26617. this._debugMesh.color = this.color;
  26618. };
  26619. /** Release associated resources */
  26620. SkeletonViewer.prototype.dispose = function () {
  26621. this.isEnabled = false;
  26622. if (this._debugMesh) {
  26623. this.isEnabled = false;
  26624. this._debugMesh.dispose();
  26625. this._debugMesh = null;
  26626. }
  26627. if (this._utilityLayer) {
  26628. this._utilityLayer.dispose();
  26629. this._utilityLayer = null;
  26630. }
  26631. };
  26632. return SkeletonViewer;
  26633. }());
  26634. /***/ }),
  26635. /***/ "./Engines/Extensions/engine.occlusionQuery.ts":
  26636. /*!*****************************************************!*\
  26637. !*** ./Engines/Extensions/engine.occlusionQuery.ts ***!
  26638. \*****************************************************/
  26639. /*! exports provided: _OcclusionDataStorage */
  26640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26641. "use strict";
  26642. __webpack_require__.r(__webpack_exports__);
  26643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _OcclusionDataStorage; });
  26644. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  26645. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  26646. /* harmony import */ var _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Instrumentation/timeToken */ "./Instrumentation/timeToken.ts");
  26647. /** @hidden */
  26648. var _OcclusionDataStorage = /** @class */ (function () {
  26649. function _OcclusionDataStorage() {
  26650. /** @hidden */
  26651. this.occlusionInternalRetryCounter = 0;
  26652. /** @hidden */
  26653. this.isOcclusionQueryInProgress = false;
  26654. /** @hidden */
  26655. this.isOccluded = false;
  26656. /** @hidden */
  26657. this.occlusionRetryCount = -1;
  26658. /** @hidden */
  26659. this.occlusionType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE;
  26660. /** @hidden */
  26661. this.occlusionQueryAlgorithmType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
  26662. }
  26663. return _OcclusionDataStorage;
  26664. }());
  26665. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createQuery = function () {
  26666. return this._gl.createQuery();
  26667. };
  26668. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteQuery = function (query) {
  26669. this._gl.deleteQuery(query);
  26670. return this;
  26671. };
  26672. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isQueryResultAvailable = function (query) {
  26673. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT_AVAILABLE);
  26674. };
  26675. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getQueryResult = function (query) {
  26676. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT);
  26677. };
  26678. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginOcclusionQuery = function (algorithmType, query) {
  26679. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  26680. this._gl.beginQuery(glAlgorithm, query);
  26681. return this;
  26682. };
  26683. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endOcclusionQuery = function (algorithmType) {
  26684. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  26685. this._gl.endQuery(glAlgorithm);
  26686. return this;
  26687. };
  26688. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._createTimeQuery = function () {
  26689. var timerQuery = this.getCaps().timerQuery;
  26690. if (timerQuery.createQueryEXT) {
  26691. return timerQuery.createQueryEXT();
  26692. }
  26693. return this.createQuery();
  26694. };
  26695. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._deleteTimeQuery = function (query) {
  26696. var timerQuery = this.getCaps().timerQuery;
  26697. if (timerQuery.deleteQueryEXT) {
  26698. timerQuery.deleteQueryEXT(query);
  26699. return;
  26700. }
  26701. this.deleteQuery(query);
  26702. };
  26703. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryResult = function (query) {
  26704. var timerQuery = this.getCaps().timerQuery;
  26705. if (timerQuery.getQueryObjectEXT) {
  26706. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_EXT);
  26707. }
  26708. return this.getQueryResult(query);
  26709. };
  26710. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryAvailability = function (query) {
  26711. var timerQuery = this.getCaps().timerQuery;
  26712. if (timerQuery.getQueryObjectEXT) {
  26713. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_AVAILABLE_EXT);
  26714. }
  26715. return this.isQueryResultAvailable(query);
  26716. };
  26717. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.startTimeQuery = function () {
  26718. var caps = this.getCaps();
  26719. var timerQuery = caps.timerQuery;
  26720. if (!timerQuery) {
  26721. return null;
  26722. }
  26723. var token = new _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]();
  26724. this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  26725. if (caps.canUseTimestampForTimerQuery) {
  26726. token._startTimeQuery = this._createTimeQuery();
  26727. timerQuery.queryCounterEXT(token._startTimeQuery, timerQuery.TIMESTAMP_EXT);
  26728. }
  26729. else {
  26730. if (this._currentNonTimestampToken) {
  26731. return this._currentNonTimestampToken;
  26732. }
  26733. token._timeElapsedQuery = this._createTimeQuery();
  26734. if (timerQuery.beginQueryEXT) {
  26735. timerQuery.beginQueryEXT(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  26736. }
  26737. else {
  26738. this._gl.beginQuery(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  26739. }
  26740. this._currentNonTimestampToken = token;
  26741. }
  26742. return token;
  26743. };
  26744. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTimeQuery = function (token) {
  26745. var caps = this.getCaps();
  26746. var timerQuery = caps.timerQuery;
  26747. if (!timerQuery || !token) {
  26748. return -1;
  26749. }
  26750. if (caps.canUseTimestampForTimerQuery) {
  26751. if (!token._startTimeQuery) {
  26752. return -1;
  26753. }
  26754. if (!token._endTimeQuery) {
  26755. token._endTimeQuery = this._createTimeQuery();
  26756. timerQuery.queryCounterEXT(token._endTimeQuery, timerQuery.TIMESTAMP_EXT);
  26757. }
  26758. }
  26759. else if (!token._timeElapsedQueryEnded) {
  26760. if (!token._timeElapsedQuery) {
  26761. return -1;
  26762. }
  26763. if (timerQuery.endQueryEXT) {
  26764. timerQuery.endQueryEXT(timerQuery.TIME_ELAPSED_EXT);
  26765. }
  26766. else {
  26767. this._gl.endQuery(timerQuery.TIME_ELAPSED_EXT);
  26768. }
  26769. token._timeElapsedQueryEnded = true;
  26770. }
  26771. var disjoint = this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  26772. var available = false;
  26773. if (token._endTimeQuery) {
  26774. available = this._getTimeQueryAvailability(token._endTimeQuery);
  26775. }
  26776. else if (token._timeElapsedQuery) {
  26777. available = this._getTimeQueryAvailability(token._timeElapsedQuery);
  26778. }
  26779. if (available && !disjoint) {
  26780. var result = 0;
  26781. if (caps.canUseTimestampForTimerQuery) {
  26782. if (!token._startTimeQuery || !token._endTimeQuery) {
  26783. return -1;
  26784. }
  26785. var timeStart = this._getTimeQueryResult(token._startTimeQuery);
  26786. var timeEnd = this._getTimeQueryResult(token._endTimeQuery);
  26787. result = timeEnd - timeStart;
  26788. this._deleteTimeQuery(token._startTimeQuery);
  26789. this._deleteTimeQuery(token._endTimeQuery);
  26790. token._startTimeQuery = null;
  26791. token._endTimeQuery = null;
  26792. }
  26793. else {
  26794. if (!token._timeElapsedQuery) {
  26795. return -1;
  26796. }
  26797. result = this._getTimeQueryResult(token._timeElapsedQuery);
  26798. this._deleteTimeQuery(token._timeElapsedQuery);
  26799. token._timeElapsedQuery = null;
  26800. token._timeElapsedQueryEnded = false;
  26801. this._currentNonTimestampToken = null;
  26802. }
  26803. return result;
  26804. }
  26805. return -1;
  26806. };
  26807. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getGlAlgorithmType = function (algorithmType) {
  26808. return algorithmType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
  26809. };
  26810. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOcclusionQueryInProgress", {
  26811. get: function () {
  26812. return this._occlusionDataStorage.isOcclusionQueryInProgress;
  26813. },
  26814. enumerable: false,
  26815. configurable: true
  26816. });
  26817. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "_occlusionDataStorage", {
  26818. get: function () {
  26819. if (!this.__occlusionDataStorage) {
  26820. this.__occlusionDataStorage = new _OcclusionDataStorage();
  26821. }
  26822. return this.__occlusionDataStorage;
  26823. },
  26824. enumerable: false,
  26825. configurable: true
  26826. });
  26827. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOccluded", {
  26828. get: function () {
  26829. return this._occlusionDataStorage.isOccluded;
  26830. },
  26831. set: function (value) {
  26832. this._occlusionDataStorage.isOccluded = value;
  26833. },
  26834. enumerable: true,
  26835. configurable: true
  26836. });
  26837. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionQueryAlgorithmType", {
  26838. get: function () {
  26839. return this._occlusionDataStorage.occlusionQueryAlgorithmType;
  26840. },
  26841. set: function (value) {
  26842. this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
  26843. },
  26844. enumerable: true,
  26845. configurable: true
  26846. });
  26847. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionType", {
  26848. get: function () {
  26849. return this._occlusionDataStorage.occlusionType;
  26850. },
  26851. set: function (value) {
  26852. this._occlusionDataStorage.occlusionType = value;
  26853. },
  26854. enumerable: true,
  26855. configurable: true
  26856. });
  26857. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionRetryCount", {
  26858. get: function () {
  26859. return this._occlusionDataStorage.occlusionRetryCount;
  26860. },
  26861. set: function (value) {
  26862. this._occlusionDataStorage.occlusionRetryCount = value;
  26863. },
  26864. enumerable: true,
  26865. configurable: true
  26866. });
  26867. // We also need to update AbstractMesh as there is a portion of the code there
  26868. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype._checkOcclusionQuery = function () {
  26869. var dataStorage = this._occlusionDataStorage;
  26870. if (dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE) {
  26871. dataStorage.isOccluded = false;
  26872. return false;
  26873. }
  26874. var engine = this.getEngine();
  26875. if (engine.webGLVersion < 2) {
  26876. dataStorage.isOccluded = false;
  26877. return false;
  26878. }
  26879. if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
  26880. dataStorage.isOccluded = false;
  26881. return false;
  26882. }
  26883. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  26884. var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
  26885. if (isOcclusionQueryAvailable) {
  26886. var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
  26887. dataStorage.isOcclusionQueryInProgress = false;
  26888. dataStorage.occlusionInternalRetryCounter = 0;
  26889. dataStorage.isOccluded = occlusionQueryResult === 1 ? false : true;
  26890. }
  26891. else {
  26892. dataStorage.occlusionInternalRetryCounter++;
  26893. if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
  26894. dataStorage.isOcclusionQueryInProgress = false;
  26895. dataStorage.occlusionInternalRetryCounter = 0;
  26896. // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
  26897. // if strict continue the last state of the object.
  26898. dataStorage.isOccluded = dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
  26899. }
  26900. else {
  26901. return false;
  26902. }
  26903. }
  26904. }
  26905. var scene = this.getScene();
  26906. if (scene.getBoundingBoxRenderer) {
  26907. var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
  26908. if (!this._occlusionQuery) {
  26909. this._occlusionQuery = engine.createQuery();
  26910. }
  26911. engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
  26912. occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
  26913. engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
  26914. this._occlusionDataStorage.isOcclusionQueryInProgress = true;
  26915. }
  26916. return dataStorage.isOccluded;
  26917. };
  26918. /***/ }),
  26919. /***/ "./Engines/Extensions/engine.transformFeedback.ts":
  26920. /*!********************************************************!*\
  26921. !*** ./Engines/Extensions/engine.transformFeedback.ts ***!
  26922. \********************************************************/
  26923. /*! exports provided: _forceTransformFeedbackToBundle */
  26924. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26925. "use strict";
  26926. __webpack_require__.r(__webpack_exports__);
  26927. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _forceTransformFeedbackToBundle; });
  26928. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  26929. /** @hidden */
  26930. var _forceTransformFeedbackToBundle = true;
  26931. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createTransformFeedback = function () {
  26932. return this._gl.createTransformFeedback();
  26933. };
  26934. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteTransformFeedback = function (value) {
  26935. this._gl.deleteTransformFeedback(value);
  26936. };
  26937. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedback = function (value) {
  26938. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  26939. };
  26940. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginTransformFeedback = function (usePoints) {
  26941. if (usePoints === void 0) { usePoints = true; }
  26942. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  26943. };
  26944. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTransformFeedback = function () {
  26945. this._gl.endTransformFeedback();
  26946. };
  26947. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.setTranformFeedbackVaryings = function (program, value) {
  26948. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  26949. };
  26950. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedbackBuffer = function (value) {
  26951. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value);
  26952. };
  26953. /***/ }),
  26954. /***/ "./Engines/Extensions/index.ts":
  26955. /*!*************************************!*\
  26956. !*** ./Engines/Extensions/index.ts ***!
  26957. \*************************************/
  26958. /*! exports provided: _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  26959. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26960. "use strict";
  26961. __webpack_require__.r(__webpack_exports__);
  26962. /* harmony import */ var _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.occlusionQuery */ "./Engines/Extensions/engine.occlusionQuery.ts");
  26963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  26964. /* harmony import */ var _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.transformFeedback */ "./Engines/Extensions/engine.transformFeedback.ts");
  26965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__["_forceTransformFeedbackToBundle"]; });
  26966. /***/ }),
  26967. /***/ "./Engines/constants.ts":
  26968. /*!******************************!*\
  26969. !*** ./Engines/constants.ts ***!
  26970. \******************************/
  26971. /*! exports provided: Constants */
  26972. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26973. "use strict";
  26974. __webpack_require__.r(__webpack_exports__);
  26975. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return Constants; });
  26976. /** Defines the cross module used constants to avoid circular dependncies */
  26977. var Constants = /** @class */ (function () {
  26978. function Constants() {
  26979. }
  26980. /** Defines that alpha blending is disabled */
  26981. Constants.ALPHA_DISABLE = 0;
  26982. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26983. Constants.ALPHA_ADD = 1;
  26984. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26985. Constants.ALPHA_COMBINE = 2;
  26986. /** Defines that alpha blending to DEST - SRC * DEST */
  26987. Constants.ALPHA_SUBTRACT = 3;
  26988. /** Defines that alpha blending to SRC * DEST */
  26989. Constants.ALPHA_MULTIPLY = 4;
  26990. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26991. Constants.ALPHA_MAXIMIZED = 5;
  26992. /** Defines that alpha blending to SRC + DEST */
  26993. Constants.ALPHA_ONEONE = 6;
  26994. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26995. Constants.ALPHA_PREMULTIPLIED = 7;
  26996. /**
  26997. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26998. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26999. */
  27000. Constants.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;
  27001. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27002. Constants.ALPHA_INTERPOLATE = 9;
  27003. /**
  27004. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27005. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27006. */
  27007. Constants.ALPHA_SCREENMODE = 10;
  27008. /** Defines that the ressource is not delayed*/
  27009. Constants.DELAYLOADSTATE_NONE = 0;
  27010. /** Defines that the ressource was successfully delay loaded */
  27011. Constants.DELAYLOADSTATE_LOADED = 1;
  27012. /** Defines that the ressource is currently delay loading */
  27013. Constants.DELAYLOADSTATE_LOADING = 2;
  27014. /** Defines that the ressource is delayed and has not started loading */
  27015. Constants.DELAYLOADSTATE_NOTLOADED = 4;
  27016. // Depht or Stencil test Constants.
  27017. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27018. Constants.NEVER = 0x0200;
  27019. /** 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 */
  27020. Constants.ALWAYS = 0x0207;
  27021. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27022. Constants.LESS = 0x0201;
  27023. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27024. Constants.EQUAL = 0x0202;
  27025. /** 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 */
  27026. Constants.LEQUAL = 0x0203;
  27027. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27028. Constants.GREATER = 0x0204;
  27029. /** 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 */
  27030. Constants.GEQUAL = 0x0206;
  27031. /** 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 */
  27032. Constants.NOTEQUAL = 0x0205;
  27033. // Stencil Actions Constants.
  27034. /** Passed to stencilOperation to specify that stencil value must be kept */
  27035. Constants.KEEP = 0x1E00;
  27036. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27037. Constants.REPLACE = 0x1E01;
  27038. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27039. Constants.INCR = 0x1E02;
  27040. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27041. Constants.DECR = 0x1E03;
  27042. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27043. Constants.INVERT = 0x150A;
  27044. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27045. Constants.INCR_WRAP = 0x8507;
  27046. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27047. Constants.DECR_WRAP = 0x8508;
  27048. /** Texture is not repeating outside of 0..1 UVs */
  27049. Constants.TEXTURE_CLAMP_ADDRESSMODE = 0;
  27050. /** Texture is repeating outside of 0..1 UVs */
  27051. Constants.TEXTURE_WRAP_ADDRESSMODE = 1;
  27052. /** Texture is repeating and mirrored */
  27053. Constants.TEXTURE_MIRROR_ADDRESSMODE = 2;
  27054. /** ALPHA */
  27055. Constants.TEXTUREFORMAT_ALPHA = 0;
  27056. /** LUMINANCE */
  27057. Constants.TEXTUREFORMAT_LUMINANCE = 1;
  27058. /** LUMINANCE_ALPHA */
  27059. Constants.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;
  27060. /** RGB */
  27061. Constants.TEXTUREFORMAT_RGB = 4;
  27062. /** RGBA */
  27063. Constants.TEXTUREFORMAT_RGBA = 5;
  27064. /** RED */
  27065. Constants.TEXTUREFORMAT_RED = 6;
  27066. /** RED (2nd reference) */
  27067. Constants.TEXTUREFORMAT_R = 6;
  27068. /** RG */
  27069. Constants.TEXTUREFORMAT_RG = 7;
  27070. /** RED_INTEGER */
  27071. Constants.TEXTUREFORMAT_RED_INTEGER = 8;
  27072. /** RED_INTEGER (2nd reference) */
  27073. Constants.TEXTUREFORMAT_R_INTEGER = 8;
  27074. /** RG_INTEGER */
  27075. Constants.TEXTUREFORMAT_RG_INTEGER = 9;
  27076. /** RGB_INTEGER */
  27077. Constants.TEXTUREFORMAT_RGB_INTEGER = 10;
  27078. /** RGBA_INTEGER */
  27079. Constants.TEXTUREFORMAT_RGBA_INTEGER = 11;
  27080. /** UNSIGNED_BYTE */
  27081. Constants.TEXTURETYPE_UNSIGNED_BYTE = 0;
  27082. /** UNSIGNED_BYTE (2nd reference) */
  27083. Constants.TEXTURETYPE_UNSIGNED_INT = 0;
  27084. /** FLOAT */
  27085. Constants.TEXTURETYPE_FLOAT = 1;
  27086. /** HALF_FLOAT */
  27087. Constants.TEXTURETYPE_HALF_FLOAT = 2;
  27088. /** BYTE */
  27089. Constants.TEXTURETYPE_BYTE = 3;
  27090. /** SHORT */
  27091. Constants.TEXTURETYPE_SHORT = 4;
  27092. /** UNSIGNED_SHORT */
  27093. Constants.TEXTURETYPE_UNSIGNED_SHORT = 5;
  27094. /** INT */
  27095. Constants.TEXTURETYPE_INT = 6;
  27096. /** UNSIGNED_INT */
  27097. Constants.TEXTURETYPE_UNSIGNED_INTEGER = 7;
  27098. /** UNSIGNED_SHORT_4_4_4_4 */
  27099. Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;
  27100. /** UNSIGNED_SHORT_5_5_5_1 */
  27101. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;
  27102. /** UNSIGNED_SHORT_5_6_5 */
  27103. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;
  27104. /** UNSIGNED_INT_2_10_10_10_REV */
  27105. Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;
  27106. /** UNSIGNED_INT_24_8 */
  27107. Constants.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;
  27108. /** UNSIGNED_INT_10F_11F_11F_REV */
  27109. Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;
  27110. /** UNSIGNED_INT_5_9_9_9_REV */
  27111. Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;
  27112. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27113. Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
  27114. /** nearest is mag = nearest and min = nearest and mip = linear */
  27115. Constants.TEXTURE_NEAREST_SAMPLINGMODE = 1;
  27116. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27117. Constants.TEXTURE_BILINEAR_SAMPLINGMODE = 2;
  27118. /** Trilinear is mag = linear and min = linear and mip = linear */
  27119. Constants.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
  27120. /** nearest is mag = nearest and min = nearest and mip = linear */
  27121. Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
  27122. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27123. Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
  27124. /** Trilinear is mag = linear and min = linear and mip = linear */
  27125. Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
  27126. /** mag = nearest and min = nearest and mip = nearest */
  27127. Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
  27128. /** mag = nearest and min = linear and mip = nearest */
  27129. Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;
  27130. /** mag = nearest and min = linear and mip = linear */
  27131. Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
  27132. /** mag = nearest and min = linear and mip = none */
  27133. Constants.TEXTURE_NEAREST_LINEAR = 7;
  27134. /** mag = nearest and min = nearest and mip = none */
  27135. Constants.TEXTURE_NEAREST_NEAREST = 8;
  27136. /** mag = linear and min = nearest and mip = nearest */
  27137. Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
  27138. /** mag = linear and min = nearest and mip = linear */
  27139. Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
  27140. /** mag = linear and min = linear and mip = none */
  27141. Constants.TEXTURE_LINEAR_LINEAR = 11;
  27142. /** mag = linear and min = nearest and mip = none */
  27143. Constants.TEXTURE_LINEAR_NEAREST = 12;
  27144. /** Explicit coordinates mode */
  27145. Constants.TEXTURE_EXPLICIT_MODE = 0;
  27146. /** Spherical coordinates mode */
  27147. Constants.TEXTURE_SPHERICAL_MODE = 1;
  27148. /** Planar coordinates mode */
  27149. Constants.TEXTURE_PLANAR_MODE = 2;
  27150. /** Cubic coordinates mode */
  27151. Constants.TEXTURE_CUBIC_MODE = 3;
  27152. /** Projection coordinates mode */
  27153. Constants.TEXTURE_PROJECTION_MODE = 4;
  27154. /** Skybox coordinates mode */
  27155. Constants.TEXTURE_SKYBOX_MODE = 5;
  27156. /** Inverse Cubic coordinates mode */
  27157. Constants.TEXTURE_INVCUBIC_MODE = 6;
  27158. /** Equirectangular coordinates mode */
  27159. Constants.TEXTURE_EQUIRECTANGULAR_MODE = 7;
  27160. /** Equirectangular Fixed coordinates mode */
  27161. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;
  27162. /** Equirectangular Fixed Mirrored coordinates mode */
  27163. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;
  27164. // Texture rescaling mode
  27165. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27166. Constants.SCALEMODE_FLOOR = 1;
  27167. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27168. Constants.SCALEMODE_NEAREST = 2;
  27169. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27170. Constants.SCALEMODE_CEILING = 3;
  27171. /**
  27172. * The dirty texture flag value
  27173. */
  27174. Constants.MATERIAL_TextureDirtyFlag = 1;
  27175. /**
  27176. * The dirty light flag value
  27177. */
  27178. Constants.MATERIAL_LightDirtyFlag = 2;
  27179. /**
  27180. * The dirty fresnel flag value
  27181. */
  27182. Constants.MATERIAL_FresnelDirtyFlag = 4;
  27183. /**
  27184. * The dirty attribute flag value
  27185. */
  27186. Constants.MATERIAL_AttributesDirtyFlag = 8;
  27187. /**
  27188. * The dirty misc flag value
  27189. */
  27190. Constants.MATERIAL_MiscDirtyFlag = 16;
  27191. /**
  27192. * The all dirty flag value
  27193. */
  27194. Constants.MATERIAL_AllDirtyFlag = 31;
  27195. /**
  27196. * Returns the triangle fill mode
  27197. */
  27198. Constants.MATERIAL_TriangleFillMode = 0;
  27199. /**
  27200. * Returns the wireframe mode
  27201. */
  27202. Constants.MATERIAL_WireFrameFillMode = 1;
  27203. /**
  27204. * Returns the point fill mode
  27205. */
  27206. Constants.MATERIAL_PointFillMode = 2;
  27207. /**
  27208. * Returns the point list draw mode
  27209. */
  27210. Constants.MATERIAL_PointListDrawMode = 3;
  27211. /**
  27212. * Returns the line list draw mode
  27213. */
  27214. Constants.MATERIAL_LineListDrawMode = 4;
  27215. /**
  27216. * Returns the line loop draw mode
  27217. */
  27218. Constants.MATERIAL_LineLoopDrawMode = 5;
  27219. /**
  27220. * Returns the line strip draw mode
  27221. */
  27222. Constants.MATERIAL_LineStripDrawMode = 6;
  27223. /**
  27224. * Returns the triangle strip draw mode
  27225. */
  27226. Constants.MATERIAL_TriangleStripDrawMode = 7;
  27227. /**
  27228. * Returns the triangle fan draw mode
  27229. */
  27230. Constants.MATERIAL_TriangleFanDrawMode = 8;
  27231. /**
  27232. * Stores the clock-wise side orientation
  27233. */
  27234. Constants.MATERIAL_ClockWiseSideOrientation = 0;
  27235. /**
  27236. * Stores the counter clock-wise side orientation
  27237. */
  27238. Constants.MATERIAL_CounterClockWiseSideOrientation = 1;
  27239. /**
  27240. * Nothing
  27241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27242. */
  27243. Constants.ACTION_NothingTrigger = 0;
  27244. /**
  27245. * On pick
  27246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27247. */
  27248. Constants.ACTION_OnPickTrigger = 1;
  27249. /**
  27250. * On left pick
  27251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27252. */
  27253. Constants.ACTION_OnLeftPickTrigger = 2;
  27254. /**
  27255. * On right pick
  27256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27257. */
  27258. Constants.ACTION_OnRightPickTrigger = 3;
  27259. /**
  27260. * On center pick
  27261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27262. */
  27263. Constants.ACTION_OnCenterPickTrigger = 4;
  27264. /**
  27265. * On pick down
  27266. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27267. */
  27268. Constants.ACTION_OnPickDownTrigger = 5;
  27269. /**
  27270. * On double pick
  27271. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27272. */
  27273. Constants.ACTION_OnDoublePickTrigger = 6;
  27274. /**
  27275. * On pick up
  27276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27277. */
  27278. Constants.ACTION_OnPickUpTrigger = 7;
  27279. /**
  27280. * On pick out.
  27281. * This trigger will only be raised if you also declared a OnPickDown
  27282. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27283. */
  27284. Constants.ACTION_OnPickOutTrigger = 16;
  27285. /**
  27286. * On long press
  27287. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27288. */
  27289. Constants.ACTION_OnLongPressTrigger = 8;
  27290. /**
  27291. * On pointer over
  27292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27293. */
  27294. Constants.ACTION_OnPointerOverTrigger = 9;
  27295. /**
  27296. * On pointer out
  27297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27298. */
  27299. Constants.ACTION_OnPointerOutTrigger = 10;
  27300. /**
  27301. * On every frame
  27302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27303. */
  27304. Constants.ACTION_OnEveryFrameTrigger = 11;
  27305. /**
  27306. * On intersection enter
  27307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27308. */
  27309. Constants.ACTION_OnIntersectionEnterTrigger = 12;
  27310. /**
  27311. * On intersection exit
  27312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27313. */
  27314. Constants.ACTION_OnIntersectionExitTrigger = 13;
  27315. /**
  27316. * On key down
  27317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27318. */
  27319. Constants.ACTION_OnKeyDownTrigger = 14;
  27320. /**
  27321. * On key up
  27322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27323. */
  27324. Constants.ACTION_OnKeyUpTrigger = 15;
  27325. /**
  27326. * Billboard mode will only apply to Y axis
  27327. */
  27328. Constants.PARTICLES_BILLBOARDMODE_Y = 2;
  27329. /**
  27330. * Billboard mode will apply to all axes
  27331. */
  27332. Constants.PARTICLES_BILLBOARDMODE_ALL = 7;
  27333. /**
  27334. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  27335. */
  27336. Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
  27337. /**
  27338. * Gets or sets base Assets URL
  27339. */
  27340. Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
  27341. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27342. * Test order :
  27343. * Is the bounding sphere outside the frustum ?
  27344. * If not, are the bounding box vertices outside the frustum ?
  27345. * It not, then the cullable object is in the frustum.
  27346. */
  27347. Constants.MESHES_CULLINGSTRATEGY_STANDARD = 0;
  27348. /** Culling strategy : Bounding Sphere Only.
  27349. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27350. * It's also less accurate than the standard because some not visible objects can still be selected.
  27351. * Test : is the bounding sphere outside the frustum ?
  27352. * If not, then the cullable object is in the frustum.
  27353. */
  27354. Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
  27355. /** Culling strategy : Optimistic Inclusion.
  27356. * This in an inclusion test first, then the standard exclusion test.
  27357. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27358. * 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.
  27359. * Anyway, it's as accurate as the standard strategy.
  27360. * Test :
  27361. * Is the cullable object bounding sphere center in the frustum ?
  27362. * If not, apply the default culling strategy.
  27363. */
  27364. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
  27365. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27366. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27367. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27368. * 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.
  27369. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27370. * Test :
  27371. * Is the cullable object bounding sphere center in the frustum ?
  27372. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27373. */
  27374. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
  27375. /**
  27376. * No logging while loading
  27377. */
  27378. Constants.SCENELOADER_NO_LOGGING = 0;
  27379. /**
  27380. * Minimal logging while loading
  27381. */
  27382. Constants.SCENELOADER_MINIMAL_LOGGING = 1;
  27383. /**
  27384. * Summary logging while loading
  27385. */
  27386. Constants.SCENELOADER_SUMMARY_LOGGING = 2;
  27387. /**
  27388. * Detailled logging while loading
  27389. */
  27390. Constants.SCENELOADER_DETAILED_LOGGING = 3;
  27391. return Constants;
  27392. }());
  27393. /***/ }),
  27394. /***/ "./Engines/engine.ts":
  27395. /*!***************************!*\
  27396. !*** ./Engines/engine.ts ***!
  27397. \***************************/
  27398. /*! exports provided: InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine */
  27399. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27400. "use strict";
  27401. __webpack_require__.r(__webpack_exports__);
  27402. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return InstancingAttributeInfo; });
  27403. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return DepthTextureCreationOptions; });
  27404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return EngineCapabilities; });
  27405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; });
  27406. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  27407. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  27408. /* harmony import */ var _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/performanceMonitor */ "./Misc/performanceMonitor.ts");
  27409. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  27410. /* harmony import */ var _Misc_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/promise */ "./Misc/promise.ts");
  27411. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  27412. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  27413. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  27414. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  27415. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  27416. /* harmony import */ var _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  27417. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  27418. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../States/index */ "./States/index.ts");
  27419. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  27420. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  27421. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  27422. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  27423. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  27424. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  27425. /**
  27426. * Keeps track of all the buffer info used in engine.
  27427. */
  27428. var BufferPointer = /** @class */ (function () {
  27429. function BufferPointer() {
  27430. }
  27431. return BufferPointer;
  27432. }());
  27433. /**
  27434. * Interface for attribute information associated with buffer instanciation
  27435. */
  27436. var InstancingAttributeInfo = /** @class */ (function () {
  27437. function InstancingAttributeInfo() {
  27438. }
  27439. return InstancingAttributeInfo;
  27440. }());
  27441. /**
  27442. * Define options used to create a depth texture
  27443. */
  27444. var DepthTextureCreationOptions = /** @class */ (function () {
  27445. function DepthTextureCreationOptions() {
  27446. }
  27447. return DepthTextureCreationOptions;
  27448. }());
  27449. /**
  27450. * Class used to describe the capabilities of the engine relatively to the current browser
  27451. */
  27452. var EngineCapabilities = /** @class */ (function () {
  27453. function EngineCapabilities() {
  27454. }
  27455. return EngineCapabilities;
  27456. }());
  27457. /**
  27458. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27459. */
  27460. var Engine = /** @class */ (function () {
  27461. /**
  27462. * Creates a new engine
  27463. * @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
  27464. * @param antialias defines enable antialiasing (default: false)
  27465. * @param options defines further options to be sent to the getContext() function
  27466. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27467. */
  27468. function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {
  27469. if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }
  27470. var _this = this;
  27471. // Public members
  27472. /**
  27473. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27474. */
  27475. this.forcePOTTextures = false;
  27476. /**
  27477. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27478. */
  27479. this.isFullscreen = false;
  27480. /**
  27481. * Gets a boolean indicating if the pointer is currently locked
  27482. */
  27483. this.isPointerLock = false;
  27484. /**
  27485. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27486. */
  27487. this.cullBackFaces = true;
  27488. /**
  27489. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27490. */
  27491. this.renderEvenInBackground = true;
  27492. /**
  27493. * Gets or sets a boolean indicating that cache can be kept between frames
  27494. */
  27495. this.preventCacheWipeBetweenFrames = false;
  27496. /**
  27497. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27498. **/
  27499. this.enableOfflineSupport = false;
  27500. /**
  27501. * 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)
  27502. **/
  27503. this.disableManifestCheck = false;
  27504. /**
  27505. * Gets the list of created scenes
  27506. */
  27507. this.scenes = new Array();
  27508. /**
  27509. * Event raised when a new scene is created
  27510. */
  27511. this.onNewSceneAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27512. /**
  27513. * Gets the list of created postprocesses
  27514. */
  27515. this.postProcesses = new Array();
  27516. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27517. this.validateShaderPrograms = false;
  27518. // Observables
  27519. /**
  27520. * Observable event triggered each time the rendering canvas is resized
  27521. */
  27522. this.onResizeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27523. /**
  27524. * Observable event triggered each time the canvas loses focus
  27525. */
  27526. this.onCanvasBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27527. /**
  27528. * Observable event triggered each time the canvas gains focus
  27529. */
  27530. this.onCanvasFocusObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27531. /**
  27532. * Observable event triggered each time the canvas receives pointerout event
  27533. */
  27534. this.onCanvasPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27535. /**
  27536. * Observable event triggered before each texture is initialized
  27537. */
  27538. this.onBeforeTextureInitObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27539. //WebVR
  27540. this._vrDisplay = undefined;
  27541. this._vrSupported = false;
  27542. this._vrExclusivePointerMode = false;
  27543. // Uniform buffers list
  27544. /**
  27545. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27546. */
  27547. this.disableUniformBuffers = false;
  27548. /** @hidden */
  27549. this._uniformBuffers = new Array();
  27550. // Observables
  27551. /**
  27552. * Observable raised when the engine begins a new frame
  27553. */
  27554. this.onBeginFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27555. /**
  27556. * If set, will be used to request the next animation frame for the render loop
  27557. */
  27558. this.customAnimationFrameRequester = null;
  27559. /**
  27560. * Observable raised when the engine ends the current frame
  27561. */
  27562. this.onEndFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27563. /**
  27564. * Observable raised when the engine is about to compile a shader
  27565. */
  27566. this.onBeforeShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27567. /**
  27568. * Observable raised when the engine has jsut compiled a shader
  27569. */
  27570. this.onAfterShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27571. this._windowIsBackground = false;
  27572. this._webGLVersion = 1.0;
  27573. /** @hidden */
  27574. this._badOS = false;
  27575. /** @hidden */
  27576. this._badDesktopOS = false;
  27577. /**
  27578. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27579. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27580. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27581. */
  27582. this.disableTextureBindingOptimization = false;
  27583. /**
  27584. * Observable signaled when VR display mode changes
  27585. */
  27586. this.onVRDisplayChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27587. /**
  27588. * Observable signaled when VR request present is complete
  27589. */
  27590. this.onVRRequestPresentComplete = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27591. /**
  27592. * Observable signaled when VR request present starts
  27593. */
  27594. this.onVRRequestPresentStart = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27595. this._colorWrite = true;
  27596. /** @hidden */
  27597. this._drawCalls = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  27598. /** @hidden */
  27599. this._textureCollisions = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  27600. this._renderingQueueLaunched = false;
  27601. this._activeRenderLoops = new Array();
  27602. // Deterministic lockstepMaxSteps
  27603. this._deterministicLockstep = false;
  27604. this._lockstepMaxSteps = 4;
  27605. // Lost context
  27606. /**
  27607. * Observable signaled when a context lost event is raised
  27608. */
  27609. this.onContextLostObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27610. /**
  27611. * Observable signaled when a context restored event is raised
  27612. */
  27613. this.onContextRestoredObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27614. this._contextWasLost = false;
  27615. this._doNotHandleContextLost = false;
  27616. // FPS
  27617. this._performanceMonitor = new _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__["PerformanceMonitor"]();
  27618. this._fps = 60;
  27619. this._deltaTime = 0;
  27620. /**
  27621. * Turn this value on if you want to pause FPS computation when in background
  27622. */
  27623. this.disablePerformanceMonitorInBackground = false;
  27624. // States
  27625. /** @hidden */
  27626. this._depthCullingState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_DepthCullingState"]();
  27627. /** @hidden */
  27628. this._stencilState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_StencilState"]();
  27629. /** @hidden */
  27630. this._alphaState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_AlphaState"]();
  27631. /** @hidden */
  27632. this._alphaMode = Engine.ALPHA_DISABLE;
  27633. // Cache
  27634. this._internalTexturesCache = new Array();
  27635. /** @hidden */
  27636. this._activeChannel = 0;
  27637. this._currentTextureChannel = -1;
  27638. /** @hidden */
  27639. this._boundTexturesCache = {};
  27640. this._compiledEffects = {};
  27641. this._vertexAttribArraysEnabled = [];
  27642. this._uintIndicesCurrentlySet = false;
  27643. this._currentBoundBuffer = new Array();
  27644. /** @hidden */
  27645. this._currentFramebuffer = null;
  27646. this._currentBufferPointers = new Array();
  27647. this._currentInstanceLocations = new Array();
  27648. this._currentInstanceBuffers = new Array();
  27649. this._firstBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  27650. this._lastBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  27651. this._vaoRecordInProgress = false;
  27652. this._mustWipeVertexAttributes = false;
  27653. this._nextFreeTextureSlots = new Array();
  27654. this._maxSimultaneousTextures = 0;
  27655. this._activeRequests = new Array();
  27656. // Hardware supported Compressed Textures
  27657. this._texturesSupported = new Array();
  27658. /**
  27659. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27660. */
  27661. this.premultipliedAlpha = true;
  27662. this._viewportCached = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](0, 0, 0, 0);
  27663. this._onVRFullScreenTriggered = function () {
  27664. if (_this._vrDisplay && _this._vrDisplay.isPresenting) {
  27665. //get the old size before we change
  27666. _this._oldSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Size"](_this.getRenderWidth(), _this.getRenderHeight());
  27667. _this._oldHardwareScaleFactor = _this.getHardwareScalingLevel();
  27668. //get the width and height, change the render size
  27669. var leftEye = _this._vrDisplay.getEyeParameters('left');
  27670. _this.setHardwareScalingLevel(1);
  27671. _this.setSize(leftEye.renderWidth * 2, leftEye.renderHeight);
  27672. }
  27673. else {
  27674. _this.setHardwareScalingLevel(_this._oldHardwareScaleFactor);
  27675. _this.setSize(_this._oldSize.width, _this._oldSize.height);
  27676. }
  27677. };
  27678. this._unpackFlipYCached = null;
  27679. /**
  27680. * In case you are sharing the context with other applications, it might
  27681. * be interested to not cache the unpack flip y state to ensure a consistent
  27682. * value would be set.
  27683. */
  27684. this.enableUnpackFlipYCached = true;
  27685. this._boundUniforms = {};
  27686. // Register promises
  27687. _Misc_promise__WEBPACK_IMPORTED_MODULE_4__["PromisePolyfill"].Apply();
  27688. var canvas = null;
  27689. Engine.Instances.push(this);
  27690. if (!canvasOrContext) {
  27691. return;
  27692. }
  27693. options = options || {};
  27694. if (canvasOrContext.getContext) {
  27695. canvas = canvasOrContext;
  27696. this._renderingCanvas = canvas;
  27697. if (antialias != null) {
  27698. options.antialias = antialias;
  27699. }
  27700. if (options.deterministicLockstep === undefined) {
  27701. options.deterministicLockstep = false;
  27702. }
  27703. if (options.lockstepMaxSteps === undefined) {
  27704. options.lockstepMaxSteps = 4;
  27705. }
  27706. if (options.preserveDrawingBuffer === undefined) {
  27707. options.preserveDrawingBuffer = false;
  27708. }
  27709. if (options.audioEngine === undefined) {
  27710. options.audioEngine = true;
  27711. }
  27712. if (options.stencil === undefined) {
  27713. options.stencil = true;
  27714. }
  27715. if (options.premultipliedAlpha === false) {
  27716. this.premultipliedAlpha = false;
  27717. }
  27718. this._deterministicLockstep = options.deterministicLockstep;
  27719. this._lockstepMaxSteps = options.lockstepMaxSteps;
  27720. this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
  27721. // Exceptions
  27722. if (navigator && navigator.userAgent) {
  27723. var ua = navigator.userAgent;
  27724. for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
  27725. var exception = _a[_i];
  27726. var key = exception.key;
  27727. var targets = exception.targets;
  27728. if (ua.indexOf(key) > -1) {
  27729. if (exception.capture && exception.captureConstraint) {
  27730. var capture = exception.capture;
  27731. var constraint = exception.captureConstraint;
  27732. var regex = new RegExp(capture);
  27733. var matches = regex.exec(ua);
  27734. if (matches && matches.length > 0) {
  27735. var capturedValue = parseInt(matches[matches.length - 1]);
  27736. if (capturedValue >= constraint) {
  27737. continue;
  27738. }
  27739. }
  27740. }
  27741. for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
  27742. var target = targets_1[_b];
  27743. switch (target) {
  27744. case "uniformBuffer":
  27745. this.disableUniformBuffers = true;
  27746. break;
  27747. case "textureBindingOptimization":
  27748. this.disableTextureBindingOptimization = true;
  27749. break;
  27750. }
  27751. }
  27752. }
  27753. }
  27754. }
  27755. // GL
  27756. if (!options.disableWebGL2Support) {
  27757. try {
  27758. this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
  27759. if (this._gl) {
  27760. this._webGLVersion = 2.0;
  27761. // Prevent weird browsers to lie :-)
  27762. if (!this._gl.deleteQuery) {
  27763. this._webGLVersion = 1.0;
  27764. }
  27765. }
  27766. }
  27767. catch (e) {
  27768. // Do nothing
  27769. }
  27770. }
  27771. if (!this._gl) {
  27772. if (!canvas) {
  27773. throw new Error("The provided canvas is null or undefined.");
  27774. }
  27775. try {
  27776. this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
  27777. }
  27778. catch (e) {
  27779. throw new Error("WebGL not supported");
  27780. }
  27781. }
  27782. if (!this._gl) {
  27783. throw new Error("WebGL not supported");
  27784. }
  27785. this._onCanvasFocus = function () {
  27786. _this.onCanvasFocusObservable.notifyObservers(_this);
  27787. };
  27788. this._onCanvasBlur = function () {
  27789. _this.onCanvasBlurObservable.notifyObservers(_this);
  27790. };
  27791. canvas.addEventListener("focus", this._onCanvasFocus);
  27792. canvas.addEventListener("blur", this._onCanvasBlur);
  27793. this._onBlur = function () {
  27794. if (_this.disablePerformanceMonitorInBackground) {
  27795. _this._performanceMonitor.disable();
  27796. }
  27797. _this._windowIsBackground = true;
  27798. };
  27799. this._onFocus = function () {
  27800. if (_this.disablePerformanceMonitorInBackground) {
  27801. _this._performanceMonitor.enable();
  27802. }
  27803. _this._windowIsBackground = false;
  27804. };
  27805. this._onCanvasPointerOut = function (ev) {
  27806. _this.onCanvasPointerOutObservable.notifyObservers(ev);
  27807. };
  27808. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  27809. window.addEventListener("blur", this._onBlur);
  27810. window.addEventListener("focus", this._onFocus);
  27811. }
  27812. canvas.addEventListener("pointerout", this._onCanvasPointerOut);
  27813. // Context lost
  27814. if (!this._doNotHandleContextLost) {
  27815. this._onContextLost = function (evt) {
  27816. evt.preventDefault();
  27817. _this._contextWasLost = true;
  27818. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context lost.");
  27819. _this.onContextLostObservable.notifyObservers(_this);
  27820. };
  27821. this._onContextRestored = function () {
  27822. // Adding a timeout to avoid race condition at browser level
  27823. setTimeout(function () {
  27824. // Rebuild gl context
  27825. _this._initGLContext();
  27826. // Rebuild effects
  27827. _this._rebuildEffects();
  27828. // Rebuild textures
  27829. _this._rebuildInternalTextures();
  27830. // Rebuild buffers
  27831. _this._rebuildBuffers();
  27832. // Cache
  27833. _this.wipeCaches(true);
  27834. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context successfully restored.");
  27835. _this.onContextRestoredObservable.notifyObservers(_this);
  27836. _this._contextWasLost = false;
  27837. }, 0);
  27838. };
  27839. canvas.addEventListener("webglcontextlost", this._onContextLost, false);
  27840. canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
  27841. }
  27842. if (!options.doNotHandleTouchAction) {
  27843. this._disableTouchAction();
  27844. }
  27845. }
  27846. else {
  27847. this._gl = canvasOrContext;
  27848. this._renderingCanvas = this._gl.canvas;
  27849. if (this._gl.renderbufferStorageMultisample) {
  27850. this._webGLVersion = 2.0;
  27851. }
  27852. var attributes = this._gl.getContextAttributes();
  27853. if (attributes) {
  27854. options.stencil = attributes.stencil;
  27855. }
  27856. }
  27857. // Viewport
  27858. var devicePixelRatio = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
  27859. var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
  27860. this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
  27861. this.resize();
  27862. this._isStencilEnable = options.stencil ? true : false;
  27863. this._initGLContext();
  27864. if (canvas) {
  27865. // Fullscreen
  27866. this._onFullscreenChange = function () {
  27867. if (document.fullscreen !== undefined) {
  27868. _this.isFullscreen = document.fullscreen;
  27869. }
  27870. else if (document.mozFullScreen !== undefined) {
  27871. _this.isFullscreen = document.mozFullScreen;
  27872. }
  27873. else if (document.webkitIsFullScreen !== undefined) {
  27874. _this.isFullscreen = document.webkitIsFullScreen;
  27875. }
  27876. else if (document.msIsFullScreen !== undefined) {
  27877. _this.isFullscreen = document.msIsFullScreen;
  27878. }
  27879. // Pointer lock
  27880. if (_this.isFullscreen && _this._pointerLockRequested && canvas) {
  27881. canvas.requestPointerLock = canvas.requestPointerLock ||
  27882. canvas.msRequestPointerLock ||
  27883. canvas.mozRequestPointerLock ||
  27884. canvas.webkitRequestPointerLock;
  27885. if (canvas.requestPointerLock) {
  27886. canvas.requestPointerLock();
  27887. }
  27888. }
  27889. };
  27890. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  27891. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  27892. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  27893. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  27894. // Pointer lock
  27895. this._onPointerLockChange = function () {
  27896. _this.isPointerLock = (document.mozPointerLockElement === canvas ||
  27897. document.webkitPointerLockElement === canvas ||
  27898. document.msPointerLockElement === canvas ||
  27899. document.pointerLockElement === canvas);
  27900. };
  27901. document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
  27902. document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
  27903. document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
  27904. document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
  27905. this._onVRDisplayPointerRestricted = function () {
  27906. if (canvas) {
  27907. canvas.requestPointerLock();
  27908. }
  27909. };
  27910. this._onVRDisplayPointerUnrestricted = function () {
  27911. document.exitPointerLock();
  27912. };
  27913. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  27914. window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
  27915. window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
  27916. }
  27917. }
  27918. // Create Audio Engine if needed.
  27919. if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
  27920. Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
  27921. }
  27922. // Prepare buffer pointers
  27923. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  27924. this._currentBufferPointers[i] = new BufferPointer();
  27925. }
  27926. this._linkTrackers(this._firstBoundInternalTextureTracker, this._lastBoundInternalTextureTracker);
  27927. // Load WebVR Devices
  27928. if (options.autoEnableWebVR) {
  27929. this.initWebVR();
  27930. }
  27931. // Detect if we are running on a faulty buggy OS.
  27932. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  27933. // Detect if we are running on a faulty buggy desktop OS.
  27934. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  27935. console.log("Babylon.js v" + Engine.Version + " - " + this.description);
  27936. this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
  27937. }
  27938. Object.defineProperty(Engine, "Instances", {
  27939. /** Gets the list of created engines */
  27940. get: function () {
  27941. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].Instances;
  27942. },
  27943. enumerable: true,
  27944. configurable: true
  27945. });
  27946. Object.defineProperty(Engine, "LastCreatedEngine", {
  27947. /**
  27948. * Gets the latest created engine
  27949. */
  27950. get: function () {
  27951. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine;
  27952. },
  27953. enumerable: true,
  27954. configurable: true
  27955. });
  27956. Object.defineProperty(Engine, "LastCreatedScene", {
  27957. /**
  27958. * Gets the latest created scene
  27959. */
  27960. get: function () {
  27961. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  27962. },
  27963. enumerable: true,
  27964. configurable: true
  27965. });
  27966. /**
  27967. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27968. * @param flag defines which part of the materials must be marked as dirty
  27969. * @param predicate defines a predicate used to filter which materials should be affected
  27970. */
  27971. Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {
  27972. for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {
  27973. var engine = Engine.Instances[engineIndex];
  27974. for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
  27975. engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
  27976. }
  27977. }
  27978. };
  27979. Object.defineProperty(Engine, "Version", {
  27980. /**
  27981. * Returns the current version of the framework
  27982. */
  27983. get: function () {
  27984. return "4.0.0-alpha.22";
  27985. },
  27986. enumerable: true,
  27987. configurable: true
  27988. });
  27989. Object.defineProperty(Engine.prototype, "description", {
  27990. /**
  27991. * Returns a string describing the current engine
  27992. */
  27993. get: function () {
  27994. var description = "WebGL" + this.webGLVersion;
  27995. if (this._caps.parallelShaderCompile) {
  27996. description += " - Parallel shader compilation";
  27997. }
  27998. return description;
  27999. },
  28000. enumerable: true,
  28001. configurable: true
  28002. });
  28003. Object.defineProperty(Engine, "ShadersRepository", {
  28004. /**
  28005. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28006. */
  28007. get: function () {
  28008. return _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository;
  28009. },
  28010. set: function (value) {
  28011. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository = value;
  28012. },
  28013. enumerable: true,
  28014. configurable: true
  28015. });
  28016. /**
  28017. * Method called to create the default loading screen.
  28018. * This can be overriden in your own app.
  28019. * @param canvas The rendering canvas element
  28020. * @returns The loading screen
  28021. */
  28022. Engine.DefaultLoadingScreenFactory = function (canvas) {
  28023. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__["_DevTools"].WarnImport("LoadingScreen");
  28024. };
  28025. Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
  28026. /**
  28027. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28028. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28029. */
  28030. get: function () {
  28031. return this._vrExclusivePointerMode;
  28032. },
  28033. enumerable: true,
  28034. configurable: true
  28035. });
  28036. Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
  28037. /**
  28038. * Gets a boolean indicating that the engine supports uniform buffers
  28039. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28040. */
  28041. get: function () {
  28042. return this.webGLVersion > 1 && !this.disableUniformBuffers;
  28043. },
  28044. enumerable: true,
  28045. configurable: true
  28046. });
  28047. Object.defineProperty(Engine.prototype, "needPOTTextures", {
  28048. /**
  28049. * Gets a boolean indicating that only power of 2 textures are supported
  28050. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28051. */
  28052. get: function () {
  28053. return this._webGLVersion < 2 || this.forcePOTTextures;
  28054. },
  28055. enumerable: true,
  28056. configurable: true
  28057. });
  28058. Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
  28059. /**
  28060. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28061. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28062. */
  28063. get: function () {
  28064. return this._doNotHandleContextLost;
  28065. },
  28066. set: function (value) {
  28067. this._doNotHandleContextLost = value;
  28068. },
  28069. enumerable: true,
  28070. configurable: true
  28071. });
  28072. Object.defineProperty(Engine.prototype, "performanceMonitor", {
  28073. /**
  28074. * Gets the performance monitor attached to this engine
  28075. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28076. */
  28077. get: function () {
  28078. return this._performanceMonitor;
  28079. },
  28080. enumerable: true,
  28081. configurable: true
  28082. });
  28083. Object.defineProperty(Engine.prototype, "texturesSupported", {
  28084. /**
  28085. * Gets the list of texture formats supported
  28086. */
  28087. get: function () {
  28088. return this._texturesSupported;
  28089. },
  28090. enumerable: true,
  28091. configurable: true
  28092. });
  28093. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  28094. /**
  28095. * Gets the list of texture formats in use
  28096. */
  28097. get: function () {
  28098. return this._textureFormatInUse;
  28099. },
  28100. enumerable: true,
  28101. configurable: true
  28102. });
  28103. Object.defineProperty(Engine.prototype, "currentViewport", {
  28104. /**
  28105. * Gets the current viewport
  28106. */
  28107. get: function () {
  28108. return this._cachedViewport;
  28109. },
  28110. enumerable: true,
  28111. configurable: true
  28112. });
  28113. Object.defineProperty(Engine.prototype, "emptyTexture", {
  28114. /**
  28115. * Gets the default empty texture
  28116. */
  28117. get: function () {
  28118. if (!this._emptyTexture) {
  28119. this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28120. }
  28121. return this._emptyTexture;
  28122. },
  28123. enumerable: true,
  28124. configurable: true
  28125. });
  28126. Object.defineProperty(Engine.prototype, "emptyTexture3D", {
  28127. /**
  28128. * Gets the default empty 3D texture
  28129. */
  28130. get: function () {
  28131. if (!this._emptyTexture3D) {
  28132. this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28133. }
  28134. return this._emptyTexture3D;
  28135. },
  28136. enumerable: true,
  28137. configurable: true
  28138. });
  28139. Object.defineProperty(Engine.prototype, "emptyCubeTexture", {
  28140. /**
  28141. * Gets the default empty cube texture
  28142. */
  28143. get: function () {
  28144. if (!this._emptyCubeTexture) {
  28145. var faceData = new Uint8Array(4);
  28146. var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
  28147. this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28148. }
  28149. return this._emptyCubeTexture;
  28150. },
  28151. enumerable: true,
  28152. configurable: true
  28153. });
  28154. Engine.prototype._disableTouchAction = function () {
  28155. if (!this._renderingCanvas) {
  28156. return;
  28157. }
  28158. this._renderingCanvas.setAttribute("touch-action", "none");
  28159. this._renderingCanvas.style.touchAction = "none";
  28160. this._renderingCanvas.style.msTouchAction = "none";
  28161. };
  28162. Engine.prototype._rebuildInternalTextures = function () {
  28163. var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
  28164. for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {
  28165. var internalTexture = currentState_1[_i];
  28166. internalTexture._rebuild();
  28167. }
  28168. };
  28169. Engine.prototype._rebuildEffects = function () {
  28170. for (var key in this._compiledEffects) {
  28171. var effect = this._compiledEffects[key];
  28172. effect._prepareEffect();
  28173. }
  28174. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  28175. };
  28176. /**
  28177. * Gets a boolean indicating if all created effects are ready
  28178. * @returns true if all effects are ready
  28179. */
  28180. Engine.prototype.areAllEffectsReady = function () {
  28181. for (var key in this._compiledEffects) {
  28182. var effect = this._compiledEffects[key];
  28183. if (!effect.isReady()) {
  28184. return false;
  28185. }
  28186. }
  28187. return true;
  28188. };
  28189. Engine.prototype._rebuildBuffers = function () {
  28190. // Index / Vertex
  28191. for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {
  28192. var scene = _a[_i];
  28193. scene.resetCachedMaterial();
  28194. scene._rebuildGeometries();
  28195. scene._rebuildTextures();
  28196. }
  28197. // Uniforms
  28198. for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
  28199. var uniformBuffer = _c[_b];
  28200. uniformBuffer._rebuild();
  28201. }
  28202. };
  28203. Engine.prototype._initGLContext = function () {
  28204. // Caps
  28205. this._caps = new EngineCapabilities();
  28206. this._caps.maxTexturesImageUnits = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
  28207. this._caps.maxCombinedTexturesImageUnits = this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  28208. this._caps.maxVertexTextureImageUnits = this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
  28209. this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
  28210. this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
  28211. this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
  28212. this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
  28213. this._caps.maxVaryingVectors = this._gl.getParameter(this._gl.MAX_VARYING_VECTORS);
  28214. this._caps.maxFragmentUniformVectors = this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS);
  28215. this._caps.maxVertexUniformVectors = this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS);
  28216. // Infos
  28217. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  28218. var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
  28219. if (rendererInfo != null) {
  28220. this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
  28221. this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
  28222. }
  28223. if (!this._glVendor) {
  28224. this._glVendor = "Unknown vendor";
  28225. }
  28226. if (!this._glRenderer) {
  28227. this._glRenderer = "Unknown renderer";
  28228. }
  28229. // Constants
  28230. this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).
  28231. if (this._gl.RGBA16F !== 0x881A) {
  28232. this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.
  28233. }
  28234. if (this._gl.RGBA32F !== 0x8814) {
  28235. this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
  28236. }
  28237. if (this._gl.DEPTH24_STENCIL8 !== 35056) {
  28238. this._gl.DEPTH24_STENCIL8 = 35056;
  28239. }
  28240. // Extensions
  28241. this._caps.standardDerivatives = this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null);
  28242. this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc');
  28243. this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  28244. this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  28245. this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
  28246. this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||
  28247. this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3
  28248. 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');
  28249. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
  28250. this._caps.uintIndices = this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null;
  28251. this._caps.fragmentDepthSupported = this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null;
  28252. this._caps.highPrecisionShaderSupported = false;
  28253. this._caps.timerQuery = this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension("EXT_disjoint_timer_query");
  28254. if (this._caps.timerQuery) {
  28255. if (this._webGLVersion === 1) {
  28256. this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
  28257. }
  28258. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;
  28259. }
  28260. // Checks if some of the format renders first to allow the use of webgl inspector.
  28261. this._caps.colorBufferFloat = this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float');
  28262. this._caps.textureFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false;
  28263. this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;
  28264. this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
  28265. this._caps.textureHalfFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false;
  28266. this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;
  28267. if (this._webGLVersion > 1) {
  28268. this._gl.HALF_FLOAT_OES = 0x140B;
  28269. }
  28270. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
  28271. this._caps.textureLOD = (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false;
  28272. // Draw buffers
  28273. if (this._webGLVersion > 1) {
  28274. this._caps.drawBuffersExtension = true;
  28275. }
  28276. else {
  28277. var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
  28278. if (drawBuffersExtension !== null) {
  28279. this._caps.drawBuffersExtension = true;
  28280. this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
  28281. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  28282. for (var i = 0; i < 16; i++) {
  28283. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
  28284. }
  28285. }
  28286. else {
  28287. this._caps.drawBuffersExtension = false;
  28288. }
  28289. }
  28290. // Shader compiler threads
  28291. this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
  28292. if (this._caps.parallelShaderCompile) {
  28293. var threads = this._gl.getParameter(this._caps.parallelShaderCompile.MAX_SHADER_COMPILER_THREADS_KHR);
  28294. this._caps.parallelShaderCompile.maxShaderCompilerThreadsKHR(threads);
  28295. }
  28296. // Depth Texture
  28297. if (this._webGLVersion > 1) {
  28298. this._caps.depthTextureExtension = true;
  28299. }
  28300. else {
  28301. var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');
  28302. if (depthTextureExtension != null) {
  28303. this._caps.depthTextureExtension = true;
  28304. this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
  28305. }
  28306. }
  28307. // Vertex array object
  28308. if (this._webGLVersion > 1) {
  28309. this._caps.vertexArrayObject = true;
  28310. }
  28311. else {
  28312. var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');
  28313. if (vertexArrayObjectExtension != null) {
  28314. this._caps.vertexArrayObject = true;
  28315. this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
  28316. this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
  28317. this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
  28318. }
  28319. else {
  28320. this._caps.vertexArrayObject = false;
  28321. }
  28322. }
  28323. // Instances count
  28324. if (this._webGLVersion > 1) {
  28325. this._caps.instancedArrays = true;
  28326. }
  28327. else {
  28328. var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');
  28329. if (instanceExtension != null) {
  28330. this._caps.instancedArrays = true;
  28331. this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
  28332. this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
  28333. this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
  28334. }
  28335. else {
  28336. this._caps.instancedArrays = false;
  28337. }
  28338. }
  28339. // Intelligently add supported compressed formats in order to check for.
  28340. // Check for ASTC support first as it is most powerful and to be very cross platform.
  28341. // Next PVRTC & DXT, which are probably superior to ETC1/2.
  28342. // Likely no hardware which supports both PVR & DXT, so order matters little.
  28343. // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.
  28344. if (this._caps.astc) {
  28345. this.texturesSupported.push('-astc.ktx');
  28346. }
  28347. if (this._caps.s3tc) {
  28348. this.texturesSupported.push('-dxt.ktx');
  28349. }
  28350. if (this._caps.pvrtc) {
  28351. this.texturesSupported.push('-pvrtc.ktx');
  28352. }
  28353. if (this._caps.etc2) {
  28354. this.texturesSupported.push('-etc2.ktx');
  28355. }
  28356. if (this._caps.etc1) {
  28357. this.texturesSupported.push('-etc1.ktx');
  28358. }
  28359. if (this._gl.getShaderPrecisionFormat) {
  28360. var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
  28361. var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  28362. if (vertex_highp && fragment_highp) {
  28363. this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;
  28364. }
  28365. }
  28366. // Depth buffer
  28367. this.setDepthBuffer(true);
  28368. this.setDepthFunctionToLessOrEqual();
  28369. this.setDepthWrite(true);
  28370. // Texture maps
  28371. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  28372. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  28373. this._nextFreeTextureSlots.push(slot);
  28374. }
  28375. };
  28376. Object.defineProperty(Engine.prototype, "webGLVersion", {
  28377. /**
  28378. * Gets version of the current webGL context
  28379. */
  28380. get: function () {
  28381. return this._webGLVersion;
  28382. },
  28383. enumerable: true,
  28384. configurable: true
  28385. });
  28386. Object.defineProperty(Engine.prototype, "isStencilEnable", {
  28387. /**
  28388. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28389. */
  28390. get: function () {
  28391. return this._isStencilEnable;
  28392. },
  28393. enumerable: true,
  28394. configurable: true
  28395. });
  28396. Engine.prototype._prepareWorkingCanvas = function () {
  28397. if (this._workingCanvas) {
  28398. return;
  28399. }
  28400. this._workingCanvas = document.createElement("canvas");
  28401. var context = this._workingCanvas.getContext("2d");
  28402. if (context) {
  28403. this._workingContext = context;
  28404. }
  28405. };
  28406. /**
  28407. * Reset the texture cache to empty state
  28408. */
  28409. Engine.prototype.resetTextureCache = function () {
  28410. for (var key in this._boundTexturesCache) {
  28411. if (!this._boundTexturesCache.hasOwnProperty(key)) {
  28412. continue;
  28413. }
  28414. var boundTexture = this._boundTexturesCache[key];
  28415. if (boundTexture) {
  28416. this._removeDesignatedSlot(boundTexture);
  28417. }
  28418. this._boundTexturesCache[key] = null;
  28419. }
  28420. if (!this.disableTextureBindingOptimization) {
  28421. this._nextFreeTextureSlots = [];
  28422. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  28423. this._nextFreeTextureSlots.push(slot);
  28424. }
  28425. }
  28426. this._currentTextureChannel = -1;
  28427. };
  28428. /**
  28429. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28430. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28431. * @returns true if engine is in deterministic lock step mode
  28432. */
  28433. Engine.prototype.isDeterministicLockStep = function () {
  28434. return this._deterministicLockstep;
  28435. };
  28436. /**
  28437. * Gets the max steps when engine is running in deterministic lock step
  28438. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28439. * @returns the max steps
  28440. */
  28441. Engine.prototype.getLockstepMaxSteps = function () {
  28442. return this._lockstepMaxSteps;
  28443. };
  28444. /**
  28445. * Gets an object containing information about the current webGL context
  28446. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28447. */
  28448. Engine.prototype.getGlInfo = function () {
  28449. return {
  28450. vendor: this._glVendor,
  28451. renderer: this._glRenderer,
  28452. version: this._glVersion
  28453. };
  28454. };
  28455. /**
  28456. * Gets current aspect ratio
  28457. * @param camera defines the camera to use to get the aspect ratio
  28458. * @param useScreen defines if screen size must be used (or the current render target if any)
  28459. * @returns a number defining the aspect ratio
  28460. */
  28461. Engine.prototype.getAspectRatio = function (camera, useScreen) {
  28462. if (useScreen === void 0) { useScreen = false; }
  28463. var viewport = camera.viewport;
  28464. return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
  28465. };
  28466. /**
  28467. * Gets current screen aspect ratio
  28468. * @returns a number defining the aspect ratio
  28469. */
  28470. Engine.prototype.getScreenAspectRatio = function () {
  28471. return (this.getRenderWidth(true)) / (this.getRenderHeight(true));
  28472. };
  28473. /**
  28474. * Gets the current render width
  28475. * @param useScreen defines if screen size must be used (or the current render target if any)
  28476. * @returns a number defining the current render width
  28477. */
  28478. Engine.prototype.getRenderWidth = function (useScreen) {
  28479. if (useScreen === void 0) { useScreen = false; }
  28480. if (!useScreen && this._currentRenderTarget) {
  28481. return this._currentRenderTarget.width;
  28482. }
  28483. return this._gl.drawingBufferWidth;
  28484. };
  28485. /**
  28486. * Gets the current render height
  28487. * @param useScreen defines if screen size must be used (or the current render target if any)
  28488. * @returns a number defining the current render height
  28489. */
  28490. Engine.prototype.getRenderHeight = function (useScreen) {
  28491. if (useScreen === void 0) { useScreen = false; }
  28492. if (!useScreen && this._currentRenderTarget) {
  28493. return this._currentRenderTarget.height;
  28494. }
  28495. return this._gl.drawingBufferHeight;
  28496. };
  28497. /**
  28498. * Gets the HTML canvas attached with the current webGL context
  28499. * @returns a HTML canvas
  28500. */
  28501. Engine.prototype.getRenderingCanvas = function () {
  28502. return this._renderingCanvas;
  28503. };
  28504. /**
  28505. * Gets the client rect of the HTML canvas attached with the current webGL context
  28506. * @returns a client rectanglee
  28507. */
  28508. Engine.prototype.getRenderingCanvasClientRect = function () {
  28509. if (!this._renderingCanvas) {
  28510. return null;
  28511. }
  28512. return this._renderingCanvas.getBoundingClientRect();
  28513. };
  28514. /**
  28515. * Defines the hardware scaling level.
  28516. * By default the hardware scaling level is computed from the window device ratio.
  28517. * 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.
  28518. * @param level defines the level to use
  28519. */
  28520. Engine.prototype.setHardwareScalingLevel = function (level) {
  28521. this._hardwareScalingLevel = level;
  28522. this.resize();
  28523. };
  28524. /**
  28525. * Gets the current hardware scaling level.
  28526. * By default the hardware scaling level is computed from the window device ratio.
  28527. * 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.
  28528. * @returns a number indicating the current hardware scaling level
  28529. */
  28530. Engine.prototype.getHardwareScalingLevel = function () {
  28531. return this._hardwareScalingLevel;
  28532. };
  28533. /**
  28534. * Gets the list of loaded textures
  28535. * @returns an array containing all loaded textures
  28536. */
  28537. Engine.prototype.getLoadedTexturesCache = function () {
  28538. return this._internalTexturesCache;
  28539. };
  28540. /**
  28541. * Gets the object containing all engine capabilities
  28542. * @returns the EngineCapabilities object
  28543. */
  28544. Engine.prototype.getCaps = function () {
  28545. return this._caps;
  28546. };
  28547. /**
  28548. * Gets the current depth function
  28549. * @returns a number defining the depth function
  28550. */
  28551. Engine.prototype.getDepthFunction = function () {
  28552. return this._depthCullingState.depthFunc;
  28553. };
  28554. /**
  28555. * Sets the current depth function
  28556. * @param depthFunc defines the function to use
  28557. */
  28558. Engine.prototype.setDepthFunction = function (depthFunc) {
  28559. this._depthCullingState.depthFunc = depthFunc;
  28560. };
  28561. /**
  28562. * Sets the current depth function to GREATER
  28563. */
  28564. Engine.prototype.setDepthFunctionToGreater = function () {
  28565. this._depthCullingState.depthFunc = this._gl.GREATER;
  28566. };
  28567. /**
  28568. * Sets the current depth function to GEQUAL
  28569. */
  28570. Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {
  28571. this._depthCullingState.depthFunc = this._gl.GEQUAL;
  28572. };
  28573. /**
  28574. * Sets the current depth function to LESS
  28575. */
  28576. Engine.prototype.setDepthFunctionToLess = function () {
  28577. this._depthCullingState.depthFunc = this._gl.LESS;
  28578. };
  28579. /**
  28580. * Sets the current depth function to LEQUAL
  28581. */
  28582. Engine.prototype.setDepthFunctionToLessOrEqual = function () {
  28583. this._depthCullingState.depthFunc = this._gl.LEQUAL;
  28584. };
  28585. /**
  28586. * Gets a boolean indicating if stencil buffer is enabled
  28587. * @returns the current stencil buffer state
  28588. */
  28589. Engine.prototype.getStencilBuffer = function () {
  28590. return this._stencilState.stencilTest;
  28591. };
  28592. /**
  28593. * Enable or disable the stencil buffer
  28594. * @param enable defines if the stencil buffer must be enabled or disabled
  28595. */
  28596. Engine.prototype.setStencilBuffer = function (enable) {
  28597. this._stencilState.stencilTest = enable;
  28598. };
  28599. /**
  28600. * Gets the current stencil mask
  28601. * @returns a number defining the new stencil mask to use
  28602. */
  28603. Engine.prototype.getStencilMask = function () {
  28604. return this._stencilState.stencilMask;
  28605. };
  28606. /**
  28607. * Sets the current stencil mask
  28608. * @param mask defines the new stencil mask to use
  28609. */
  28610. Engine.prototype.setStencilMask = function (mask) {
  28611. this._stencilState.stencilMask = mask;
  28612. };
  28613. /**
  28614. * Gets the current stencil function
  28615. * @returns a number defining the stencil function to use
  28616. */
  28617. Engine.prototype.getStencilFunction = function () {
  28618. return this._stencilState.stencilFunc;
  28619. };
  28620. /**
  28621. * Gets the current stencil reference value
  28622. * @returns a number defining the stencil reference value to use
  28623. */
  28624. Engine.prototype.getStencilFunctionReference = function () {
  28625. return this._stencilState.stencilFuncRef;
  28626. };
  28627. /**
  28628. * Gets the current stencil mask
  28629. * @returns a number defining the stencil mask to use
  28630. */
  28631. Engine.prototype.getStencilFunctionMask = function () {
  28632. return this._stencilState.stencilFuncMask;
  28633. };
  28634. /**
  28635. * Sets the current stencil function
  28636. * @param stencilFunc defines the new stencil function to use
  28637. */
  28638. Engine.prototype.setStencilFunction = function (stencilFunc) {
  28639. this._stencilState.stencilFunc = stencilFunc;
  28640. };
  28641. /**
  28642. * Sets the current stencil reference
  28643. * @param reference defines the new stencil reference to use
  28644. */
  28645. Engine.prototype.setStencilFunctionReference = function (reference) {
  28646. this._stencilState.stencilFuncRef = reference;
  28647. };
  28648. /**
  28649. * Sets the current stencil mask
  28650. * @param mask defines the new stencil mask to use
  28651. */
  28652. Engine.prototype.setStencilFunctionMask = function (mask) {
  28653. this._stencilState.stencilFuncMask = mask;
  28654. };
  28655. /**
  28656. * Gets the current stencil operation when stencil fails
  28657. * @returns a number defining stencil operation to use when stencil fails
  28658. */
  28659. Engine.prototype.getStencilOperationFail = function () {
  28660. return this._stencilState.stencilOpStencilFail;
  28661. };
  28662. /**
  28663. * Gets the current stencil operation when depth fails
  28664. * @returns a number defining stencil operation to use when depth fails
  28665. */
  28666. Engine.prototype.getStencilOperationDepthFail = function () {
  28667. return this._stencilState.stencilOpDepthFail;
  28668. };
  28669. /**
  28670. * Gets the current stencil operation when stencil passes
  28671. * @returns a number defining stencil operation to use when stencil passes
  28672. */
  28673. Engine.prototype.getStencilOperationPass = function () {
  28674. return this._stencilState.stencilOpStencilDepthPass;
  28675. };
  28676. /**
  28677. * Sets the stencil operation to use when stencil fails
  28678. * @param operation defines the stencil operation to use when stencil fails
  28679. */
  28680. Engine.prototype.setStencilOperationFail = function (operation) {
  28681. this._stencilState.stencilOpStencilFail = operation;
  28682. };
  28683. /**
  28684. * Sets the stencil operation to use when depth fails
  28685. * @param operation defines the stencil operation to use when depth fails
  28686. */
  28687. Engine.prototype.setStencilOperationDepthFail = function (operation) {
  28688. this._stencilState.stencilOpDepthFail = operation;
  28689. };
  28690. /**
  28691. * Sets the stencil operation to use when stencil passes
  28692. * @param operation defines the stencil operation to use when stencil passes
  28693. */
  28694. Engine.prototype.setStencilOperationPass = function (operation) {
  28695. this._stencilState.stencilOpStencilDepthPass = operation;
  28696. };
  28697. /**
  28698. * Sets a boolean indicating if the dithering state is enabled or disabled
  28699. * @param value defines the dithering state
  28700. */
  28701. Engine.prototype.setDitheringState = function (value) {
  28702. if (value) {
  28703. this._gl.enable(this._gl.DITHER);
  28704. }
  28705. else {
  28706. this._gl.disable(this._gl.DITHER);
  28707. }
  28708. };
  28709. /**
  28710. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28711. * @param value defines the rasterizer state
  28712. */
  28713. Engine.prototype.setRasterizerState = function (value) {
  28714. if (value) {
  28715. this._gl.disable(this._gl.RASTERIZER_DISCARD);
  28716. }
  28717. else {
  28718. this._gl.enable(this._gl.RASTERIZER_DISCARD);
  28719. }
  28720. };
  28721. /**
  28722. * stop executing a render loop function and remove it from the execution array
  28723. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28724. */
  28725. Engine.prototype.stopRenderLoop = function (renderFunction) {
  28726. if (!renderFunction) {
  28727. this._activeRenderLoops = [];
  28728. return;
  28729. }
  28730. var index = this._activeRenderLoops.indexOf(renderFunction);
  28731. if (index >= 0) {
  28732. this._activeRenderLoops.splice(index, 1);
  28733. }
  28734. };
  28735. /** @hidden */
  28736. Engine.prototype._renderLoop = function () {
  28737. if (!this._contextWasLost) {
  28738. var shouldRender = true;
  28739. if (!this.renderEvenInBackground && this._windowIsBackground) {
  28740. shouldRender = false;
  28741. }
  28742. if (shouldRender) {
  28743. // Start new frame
  28744. this.beginFrame();
  28745. for (var index = 0; index < this._activeRenderLoops.length; index++) {
  28746. var renderFunction = this._activeRenderLoops[index];
  28747. renderFunction();
  28748. }
  28749. // Present
  28750. this.endFrame();
  28751. }
  28752. }
  28753. if (this._activeRenderLoops.length > 0) {
  28754. // Register new frame
  28755. if (this.customAnimationFrameRequester) {
  28756. this.customAnimationFrameRequester.requestID = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
  28757. this._frameHandler = this.customAnimationFrameRequester.requestID;
  28758. }
  28759. else if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28760. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
  28761. }
  28762. else {
  28763. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  28764. }
  28765. }
  28766. else {
  28767. this._renderingQueueLaunched = false;
  28768. }
  28769. };
  28770. /**
  28771. * Register and execute a render loop. The engine can have more than one render function
  28772. * @param renderFunction defines the function to continuously execute
  28773. */
  28774. Engine.prototype.runRenderLoop = function (renderFunction) {
  28775. if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
  28776. return;
  28777. }
  28778. this._activeRenderLoops.push(renderFunction);
  28779. if (!this._renderingQueueLaunched) {
  28780. this._renderingQueueLaunched = true;
  28781. this._bindedRenderFunction = this._renderLoop.bind(this);
  28782. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  28783. }
  28784. };
  28785. /**
  28786. * Toggle full screen mode
  28787. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28788. */
  28789. Engine.prototype.switchFullscreen = function (requestPointerLock) {
  28790. if (this.isFullscreen) {
  28791. this.exitFullscreen();
  28792. }
  28793. else {
  28794. this.enterFullscreen(requestPointerLock);
  28795. }
  28796. };
  28797. /**
  28798. * Enters full screen mode
  28799. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28800. */
  28801. Engine.prototype.enterFullscreen = function (requestPointerLock) {
  28802. if (!this.isFullscreen) {
  28803. this._pointerLockRequested = requestPointerLock;
  28804. if (this._renderingCanvas) {
  28805. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].RequestFullscreen(this._renderingCanvas);
  28806. }
  28807. }
  28808. };
  28809. /**
  28810. * Exits full screen mode
  28811. */
  28812. Engine.prototype.exitFullscreen = function () {
  28813. if (this.isFullscreen) {
  28814. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].ExitFullscreen();
  28815. }
  28816. };
  28817. /**
  28818. * Clear the current render buffer or the current render target (if any is set up)
  28819. * @param color defines the color to use
  28820. * @param backBuffer defines if the back buffer must be cleared
  28821. * @param depth defines if the depth buffer must be cleared
  28822. * @param stencil defines if the stencil buffer must be cleared
  28823. */
  28824. Engine.prototype.clear = function (color, backBuffer, depth, stencil) {
  28825. if (stencil === void 0) { stencil = false; }
  28826. this.applyStates();
  28827. var mode = 0;
  28828. if (backBuffer && color) {
  28829. this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
  28830. mode |= this._gl.COLOR_BUFFER_BIT;
  28831. }
  28832. if (depth) {
  28833. this._gl.clearDepth(1.0);
  28834. mode |= this._gl.DEPTH_BUFFER_BIT;
  28835. }
  28836. if (stencil) {
  28837. this._gl.clearStencil(0);
  28838. mode |= this._gl.STENCIL_BUFFER_BIT;
  28839. }
  28840. this._gl.clear(mode);
  28841. };
  28842. /**
  28843. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28844. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28845. * @param y defines the y-coordinate of the corner of the clear rectangle
  28846. * @param width defines the width of the clear rectangle
  28847. * @param height defines the height of the clear rectangle
  28848. * @param clearColor defines the clear color
  28849. */
  28850. Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
  28851. this.enableScissor(x, y, width, height);
  28852. this.clear(clearColor, true, true, true);
  28853. this.disableScissor();
  28854. };
  28855. /**
  28856. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28857. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28858. * @param y defines the y-coordinate of the corner of the clear rectangle
  28859. * @param width defines the width of the clear rectangle
  28860. * @param height defines the height of the clear rectangle
  28861. */
  28862. Engine.prototype.enableScissor = function (x, y, width, height) {
  28863. var gl = this._gl;
  28864. // Change state
  28865. gl.enable(gl.SCISSOR_TEST);
  28866. gl.scissor(x, y, width, height);
  28867. };
  28868. /**
  28869. * Disable previously set scissor test rectangle
  28870. */
  28871. Engine.prototype.disableScissor = function () {
  28872. var gl = this._gl;
  28873. gl.disable(gl.SCISSOR_TEST);
  28874. };
  28875. /** @hidden */
  28876. Engine.prototype._viewport = function (x, y, width, height) {
  28877. if (x !== this._viewportCached.x ||
  28878. y !== this._viewportCached.y ||
  28879. width !== this._viewportCached.z ||
  28880. height !== this._viewportCached.w) {
  28881. this._viewportCached.x = x;
  28882. this._viewportCached.y = y;
  28883. this._viewportCached.z = width;
  28884. this._viewportCached.w = height;
  28885. this._gl.viewport(x, y, width, height);
  28886. }
  28887. };
  28888. /**
  28889. * Set the WebGL's viewport
  28890. * @param viewport defines the viewport element to be used
  28891. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28892. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28893. */
  28894. Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  28895. var width = requiredWidth || this.getRenderWidth();
  28896. var height = requiredHeight || this.getRenderHeight();
  28897. var x = viewport.x || 0;
  28898. var y = viewport.y || 0;
  28899. this._cachedViewport = viewport;
  28900. this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
  28901. };
  28902. /**
  28903. * Directly set the WebGL Viewport
  28904. * @param x defines the x coordinate of the viewport (in screen space)
  28905. * @param y defines the y coordinate of the viewport (in screen space)
  28906. * @param width defines the width of the viewport (in screen space)
  28907. * @param height defines the height of the viewport (in screen space)
  28908. * @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
  28909. */
  28910. Engine.prototype.setDirectViewport = function (x, y, width, height) {
  28911. var currentViewport = this._cachedViewport;
  28912. this._cachedViewport = null;
  28913. this._viewport(x, y, width, height);
  28914. return currentViewport;
  28915. };
  28916. /**
  28917. * Begin a new frame
  28918. */
  28919. Engine.prototype.beginFrame = function () {
  28920. this.onBeginFrameObservable.notifyObservers(this);
  28921. this._measureFps();
  28922. };
  28923. /**
  28924. * Enf the current frame
  28925. */
  28926. Engine.prototype.endFrame = function () {
  28927. // Force a flush in case we are using a bad OS.
  28928. if (this._badOS) {
  28929. this.flushFramebuffer();
  28930. }
  28931. // Submit frame to the vr device, if enabled
  28932. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28933. // TODO: We should only submit the frame if we read frameData successfully.
  28934. try {
  28935. this._vrDisplay.submitFrame();
  28936. }
  28937. catch (e) {
  28938. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].Warn("webVR submitFrame has had an unexpected failure: " + e);
  28939. }
  28940. }
  28941. this.onEndFrameObservable.notifyObservers(this);
  28942. };
  28943. /**
  28944. * Resize the view according to the canvas' size
  28945. */
  28946. Engine.prototype.resize = function () {
  28947. // We're not resizing the size of the canvas while in VR mode & presenting
  28948. if (!(this._vrDisplay && this._vrDisplay.isPresenting)) {
  28949. var width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;
  28950. var height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;
  28951. this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
  28952. }
  28953. };
  28954. /**
  28955. * Force a specific size of the canvas
  28956. * @param width defines the new canvas' width
  28957. * @param height defines the new canvas' height
  28958. */
  28959. Engine.prototype.setSize = function (width, height) {
  28960. if (!this._renderingCanvas) {
  28961. return;
  28962. }
  28963. if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
  28964. return;
  28965. }
  28966. this._renderingCanvas.width = width;
  28967. this._renderingCanvas.height = height;
  28968. for (var index = 0; index < this.scenes.length; index++) {
  28969. var scene = this.scenes[index];
  28970. for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
  28971. var cam = scene.cameras[camIndex];
  28972. cam._currentRenderId = 0;
  28973. }
  28974. }
  28975. if (this.onResizeObservable.hasObservers) {
  28976. this.onResizeObservable.notifyObservers(this);
  28977. }
  28978. };
  28979. // WebVR functions
  28980. /**
  28981. * Gets a boolean indicating if a webVR device was detected
  28982. * @returns true if a webVR device was detected
  28983. */
  28984. Engine.prototype.isVRDevicePresent = function () {
  28985. return !!this._vrDisplay;
  28986. };
  28987. /**
  28988. * Gets the current webVR device
  28989. * @returns the current webVR device (or null)
  28990. */
  28991. Engine.prototype.getVRDevice = function () {
  28992. return this._vrDisplay;
  28993. };
  28994. /**
  28995. * Initializes a webVR display and starts listening to display change events
  28996. * The onVRDisplayChangedObservable will be notified upon these changes
  28997. * @returns The onVRDisplayChangedObservable
  28998. */
  28999. Engine.prototype.initWebVR = function () {
  29000. this.initWebVRAsync();
  29001. return this.onVRDisplayChangedObservable;
  29002. };
  29003. /**
  29004. * Initializes a webVR display and starts listening to display change events
  29005. * The onVRDisplayChangedObservable will be notified upon these changes
  29006. * @returns A promise containing a VRDisplay and if vr is supported
  29007. */
  29008. Engine.prototype.initWebVRAsync = function () {
  29009. var _this = this;
  29010. var notifyObservers = function () {
  29011. var eventArgs = {
  29012. vrDisplay: _this._vrDisplay,
  29013. vrSupported: _this._vrSupported
  29014. };
  29015. _this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
  29016. _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
  29017. };
  29018. if (!this._onVrDisplayConnect) {
  29019. this._onVrDisplayConnect = function (event) {
  29020. _this._vrDisplay = event.display;
  29021. notifyObservers();
  29022. };
  29023. this._onVrDisplayDisconnect = function () {
  29024. _this._vrDisplay.cancelAnimationFrame(_this._frameHandler);
  29025. _this._vrDisplay = undefined;
  29026. _this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(_this._bindedRenderFunction);
  29027. notifyObservers();
  29028. };
  29029. this._onVrDisplayPresentChange = function () {
  29030. _this._vrExclusivePointerMode = _this._vrDisplay && _this._vrDisplay.isPresenting;
  29031. };
  29032. window.addEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  29033. window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  29034. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  29035. }
  29036. this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
  29037. this._webVRInitPromise.then(notifyObservers);
  29038. return this._webVRInitPromise;
  29039. };
  29040. /**
  29041. * Call this function to switch to webVR mode
  29042. * Will do nothing if webVR is not supported or if there is no webVR device
  29043. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29044. */
  29045. Engine.prototype.enableVR = function () {
  29046. var _this = this;
  29047. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  29048. var onResolved = function () {
  29049. _this.onVRRequestPresentComplete.notifyObservers(true);
  29050. _this._onVRFullScreenTriggered();
  29051. };
  29052. var onRejected = function () {
  29053. _this.onVRRequestPresentComplete.notifyObservers(false);
  29054. };
  29055. this.onVRRequestPresentStart.notifyObservers(this);
  29056. this._vrDisplay.requestPresent([{ source: this.getRenderingCanvas() }]).then(onResolved).catch(onRejected);
  29057. }
  29058. };
  29059. /**
  29060. * Call this function to leave webVR mode
  29061. * Will do nothing if webVR is not supported or if there is no webVR device
  29062. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29063. */
  29064. Engine.prototype.disableVR = function () {
  29065. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29066. this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered);
  29067. }
  29068. };
  29069. Engine.prototype._getVRDisplaysAsync = function () {
  29070. var _this = this;
  29071. return new Promise(function (res) {
  29072. if (navigator.getVRDisplays) {
  29073. navigator.getVRDisplays().then(function (devices) {
  29074. _this._vrSupported = true;
  29075. // note that devices may actually be an empty array. This is fine;
  29076. // we expect this._vrDisplay to be undefined in this case.
  29077. _this._vrDisplay = devices[0];
  29078. res({
  29079. vrDisplay: _this._vrDisplay,
  29080. vrSupported: _this._vrSupported
  29081. });
  29082. });
  29083. }
  29084. else {
  29085. _this._vrDisplay = undefined;
  29086. _this._vrSupported = false;
  29087. res({
  29088. vrDisplay: _this._vrDisplay,
  29089. vrSupported: _this._vrSupported
  29090. });
  29091. }
  29092. });
  29093. };
  29094. /**
  29095. * Binds the frame buffer to the specified texture.
  29096. * @param texture The texture to render to or null for the default canvas
  29097. * @param faceIndex The face of the texture to render to in case of cube texture
  29098. * @param requiredWidth The width of the target to render to
  29099. * @param requiredHeight The height of the target to render to
  29100. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29101. * @param depthStencilTexture The depth stencil texture to use to render
  29102. * @param lodLevel defines le lod level to bind to the frame buffer
  29103. */
  29104. Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, depthStencilTexture, lodLevel) {
  29105. if (lodLevel === void 0) { lodLevel = 0; }
  29106. if (this._currentRenderTarget) {
  29107. this.unBindFramebuffer(this._currentRenderTarget);
  29108. }
  29109. this._currentRenderTarget = texture;
  29110. this.bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);
  29111. var gl = this._gl;
  29112. if (texture.isCube) {
  29113. if (faceIndex === undefined) {
  29114. faceIndex = 0;
  29115. }
  29116. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);
  29117. if (depthStencilTexture) {
  29118. if (depthStencilTexture._generateStencilBuffer) {
  29119. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29120. }
  29121. else {
  29122. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29123. }
  29124. }
  29125. }
  29126. if (this._cachedViewport && !forceFullscreenViewport) {
  29127. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  29128. }
  29129. else {
  29130. if (!requiredWidth) {
  29131. requiredWidth = texture.width;
  29132. if (lodLevel) {
  29133. requiredWidth = requiredWidth / Math.pow(2, lodLevel);
  29134. }
  29135. }
  29136. if (!requiredHeight) {
  29137. requiredHeight = texture.height;
  29138. if (lodLevel) {
  29139. requiredHeight = requiredHeight / Math.pow(2, lodLevel);
  29140. }
  29141. }
  29142. this._viewport(0, 0, requiredWidth, requiredHeight);
  29143. }
  29144. this.wipeCaches();
  29145. };
  29146. Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
  29147. if (this._currentFramebuffer !== framebuffer) {
  29148. this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
  29149. this._currentFramebuffer = framebuffer;
  29150. }
  29151. };
  29152. /**
  29153. * Unbind the current render target texture from the webGL context
  29154. * @param texture defines the render target texture to unbind
  29155. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29156. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29157. */
  29158. Engine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  29159. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  29160. this._currentRenderTarget = null;
  29161. // If MSAA, we need to bitblt back to main texture
  29162. var gl = this._gl;
  29163. if (texture._MSAAFramebuffer) {
  29164. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
  29165. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
  29166. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  29167. }
  29168. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  29169. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  29170. gl.generateMipmap(gl.TEXTURE_2D);
  29171. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  29172. }
  29173. if (onBeforeUnbind) {
  29174. if (texture._MSAAFramebuffer) {
  29175. // Bind the correct framebuffer
  29176. this.bindUnboundFramebuffer(texture._framebuffer);
  29177. }
  29178. onBeforeUnbind();
  29179. }
  29180. this.bindUnboundFramebuffer(null);
  29181. };
  29182. /**
  29183. * Unbind a list of render target textures from the webGL context
  29184. * This is used only when drawBuffer extension or webGL2 are active
  29185. * @param textures defines the render target textures to unbind
  29186. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29187. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29188. */
  29189. Engine.prototype.unBindMultiColorAttachmentFramebuffer = function (textures, disableGenerateMipMaps, onBeforeUnbind) {
  29190. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  29191. this._currentRenderTarget = null;
  29192. // If MSAA, we need to bitblt back to main texture
  29193. var gl = this._gl;
  29194. if (textures[0]._MSAAFramebuffer) {
  29195. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
  29196. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
  29197. var attachments = textures[0]._attachments;
  29198. if (!attachments) {
  29199. attachments = new Array(textures.length);
  29200. textures[0]._attachments = attachments;
  29201. }
  29202. for (var i = 0; i < textures.length; i++) {
  29203. var texture = textures[i];
  29204. for (var j = 0; j < attachments.length; j++) {
  29205. attachments[j] = gl.NONE;
  29206. }
  29207. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29208. gl.readBuffer(attachments[i]);
  29209. gl.drawBuffers(attachments);
  29210. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  29211. }
  29212. for (var i = 0; i < attachments.length; i++) {
  29213. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29214. }
  29215. gl.drawBuffers(attachments);
  29216. }
  29217. for (var i = 0; i < textures.length; i++) {
  29218. var texture = textures[i];
  29219. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  29220. this._bindTextureDirectly(gl.TEXTURE_2D, texture);
  29221. gl.generateMipmap(gl.TEXTURE_2D);
  29222. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  29223. }
  29224. }
  29225. if (onBeforeUnbind) {
  29226. if (textures[0]._MSAAFramebuffer) {
  29227. // Bind the correct framebuffer
  29228. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  29229. }
  29230. onBeforeUnbind();
  29231. }
  29232. this.bindUnboundFramebuffer(null);
  29233. };
  29234. /**
  29235. * Force the mipmap generation for the given render target texture
  29236. * @param texture defines the render target texture to use
  29237. */
  29238. Engine.prototype.generateMipMapsForCubemap = function (texture) {
  29239. if (texture.generateMipMaps) {
  29240. var gl = this._gl;
  29241. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  29242. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  29243. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  29244. }
  29245. };
  29246. /**
  29247. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29248. */
  29249. Engine.prototype.flushFramebuffer = function () {
  29250. this._gl.flush();
  29251. };
  29252. /**
  29253. * Unbind the current render target and bind the default framebuffer
  29254. */
  29255. Engine.prototype.restoreDefaultFramebuffer = function () {
  29256. if (this._currentRenderTarget) {
  29257. this.unBindFramebuffer(this._currentRenderTarget);
  29258. }
  29259. else {
  29260. this.bindUnboundFramebuffer(null);
  29261. }
  29262. if (this._cachedViewport) {
  29263. this.setViewport(this._cachedViewport);
  29264. }
  29265. this.wipeCaches();
  29266. };
  29267. // UBOs
  29268. /**
  29269. * Create an uniform buffer
  29270. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29271. * @param elements defines the content of the uniform buffer
  29272. * @returns the webGL uniform buffer
  29273. */
  29274. Engine.prototype.createUniformBuffer = function (elements) {
  29275. var ubo = this._gl.createBuffer();
  29276. if (!ubo) {
  29277. throw new Error("Unable to create uniform buffer");
  29278. }
  29279. this.bindUniformBuffer(ubo);
  29280. if (elements instanceof Float32Array) {
  29281. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.STATIC_DRAW);
  29282. }
  29283. else {
  29284. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.STATIC_DRAW);
  29285. }
  29286. this.bindUniformBuffer(null);
  29287. ubo.references = 1;
  29288. return ubo;
  29289. };
  29290. /**
  29291. * Create a dynamic uniform buffer
  29292. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29293. * @param elements defines the content of the uniform buffer
  29294. * @returns the webGL uniform buffer
  29295. */
  29296. Engine.prototype.createDynamicUniformBuffer = function (elements) {
  29297. var ubo = this._gl.createBuffer();
  29298. if (!ubo) {
  29299. throw new Error("Unable to create dynamic uniform buffer");
  29300. }
  29301. this.bindUniformBuffer(ubo);
  29302. if (elements instanceof Float32Array) {
  29303. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.DYNAMIC_DRAW);
  29304. }
  29305. else {
  29306. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.DYNAMIC_DRAW);
  29307. }
  29308. this.bindUniformBuffer(null);
  29309. ubo.references = 1;
  29310. return ubo;
  29311. };
  29312. /**
  29313. * Update an existing uniform buffer
  29314. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29315. * @param uniformBuffer defines the target uniform buffer
  29316. * @param elements defines the content to update
  29317. * @param offset defines the offset in the uniform buffer where update should start
  29318. * @param count defines the size of the data to update
  29319. */
  29320. Engine.prototype.updateUniformBuffer = function (uniformBuffer, elements, offset, count) {
  29321. this.bindUniformBuffer(uniformBuffer);
  29322. if (offset === undefined) {
  29323. offset = 0;
  29324. }
  29325. if (count === undefined) {
  29326. if (elements instanceof Float32Array) {
  29327. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, elements);
  29328. }
  29329. else {
  29330. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, new Float32Array(elements));
  29331. }
  29332. }
  29333. else {
  29334. if (elements instanceof Float32Array) {
  29335. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, elements.subarray(offset, offset + count));
  29336. }
  29337. else {
  29338. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(elements).subarray(offset, offset + count));
  29339. }
  29340. }
  29341. this.bindUniformBuffer(null);
  29342. };
  29343. // VBOs
  29344. Engine.prototype._resetVertexBufferBinding = function () {
  29345. this.bindArrayBuffer(null);
  29346. this._cachedVertexBuffers = null;
  29347. };
  29348. /**
  29349. * Creates a vertex buffer
  29350. * @param data the data for the vertex buffer
  29351. * @returns the new WebGL static buffer
  29352. */
  29353. Engine.prototype.createVertexBuffer = function (data) {
  29354. var vbo = this._gl.createBuffer();
  29355. if (!vbo) {
  29356. throw new Error("Unable to create vertex buffer");
  29357. }
  29358. this.bindArrayBuffer(vbo);
  29359. if (data instanceof Array) {
  29360. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
  29361. }
  29362. else {
  29363. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);
  29364. }
  29365. this._resetVertexBufferBinding();
  29366. vbo.references = 1;
  29367. return vbo;
  29368. };
  29369. /**
  29370. * Creates a dynamic vertex buffer
  29371. * @param data the data for the dynamic vertex buffer
  29372. * @returns the new WebGL dynamic buffer
  29373. */
  29374. Engine.prototype.createDynamicVertexBuffer = function (data) {
  29375. var vbo = this._gl.createBuffer();
  29376. if (!vbo) {
  29377. throw new Error("Unable to create dynamic vertex buffer");
  29378. }
  29379. this.bindArrayBuffer(vbo);
  29380. if (data instanceof Array) {
  29381. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
  29382. }
  29383. else {
  29384. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.DYNAMIC_DRAW);
  29385. }
  29386. this._resetVertexBufferBinding();
  29387. vbo.references = 1;
  29388. return vbo;
  29389. };
  29390. /**
  29391. * Update a dynamic index buffer
  29392. * @param indexBuffer defines the target index buffer
  29393. * @param indices defines the data to update
  29394. * @param offset defines the offset in the target index buffer where update should start
  29395. */
  29396. Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  29397. if (offset === void 0) { offset = 0; }
  29398. // Force cache update
  29399. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
  29400. this.bindIndexBuffer(indexBuffer);
  29401. var arrayBuffer;
  29402. if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
  29403. arrayBuffer = indices;
  29404. }
  29405. else {
  29406. arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  29407. }
  29408. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
  29409. this._resetIndexBufferBinding();
  29410. };
  29411. /**
  29412. * Updates a dynamic vertex buffer.
  29413. * @param vertexBuffer the vertex buffer to update
  29414. * @param data the data used to update the vertex buffer
  29415. * @param byteOffset the byte offset of the data
  29416. * @param byteLength the byte length of the data
  29417. */
  29418. Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {
  29419. this.bindArrayBuffer(vertexBuffer);
  29420. if (byteOffset === undefined) {
  29421. byteOffset = 0;
  29422. }
  29423. if (byteLength === undefined) {
  29424. if (data instanceof Array) {
  29425. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));
  29426. }
  29427. else {
  29428. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
  29429. }
  29430. }
  29431. else {
  29432. if (data instanceof Array) {
  29433. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
  29434. }
  29435. else {
  29436. if (data instanceof ArrayBuffer) {
  29437. data = new Uint8Array(data, byteOffset, byteLength);
  29438. }
  29439. else {
  29440. data = new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
  29441. }
  29442. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29443. }
  29444. }
  29445. this._resetVertexBufferBinding();
  29446. };
  29447. Engine.prototype._resetIndexBufferBinding = function () {
  29448. this.bindIndexBuffer(null);
  29449. this._cachedIndexBuffer = null;
  29450. };
  29451. /**
  29452. * Creates a new index buffer
  29453. * @param indices defines the content of the index buffer
  29454. * @param updatable defines if the index buffer must be updatable
  29455. * @returns a new webGL buffer
  29456. */
  29457. Engine.prototype.createIndexBuffer = function (indices, updatable) {
  29458. var vbo = this._gl.createBuffer();
  29459. if (!vbo) {
  29460. throw new Error("Unable to create index buffer");
  29461. }
  29462. this.bindIndexBuffer(vbo);
  29463. // Check for 32 bits indices
  29464. var arrayBuffer;
  29465. var need32Bits = false;
  29466. if (indices instanceof Uint16Array) {
  29467. arrayBuffer = indices;
  29468. }
  29469. else {
  29470. //check 32 bit support
  29471. if (this._caps.uintIndices) {
  29472. if (indices instanceof Uint32Array) {
  29473. arrayBuffer = indices;
  29474. need32Bits = true;
  29475. }
  29476. else {
  29477. //number[] or Int32Array, check if 32 bit is necessary
  29478. for (var index = 0; index < indices.length; index++) {
  29479. if (indices[index] > 65535) {
  29480. need32Bits = true;
  29481. break;
  29482. }
  29483. }
  29484. arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  29485. }
  29486. }
  29487. else {
  29488. //no 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
  29489. arrayBuffer = new Uint16Array(indices);
  29490. }
  29491. }
  29492. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
  29493. this._resetIndexBufferBinding();
  29494. vbo.references = 1;
  29495. vbo.is32Bits = need32Bits;
  29496. return vbo;
  29497. };
  29498. /**
  29499. * Bind a webGL buffer to the webGL context
  29500. * @param buffer defines the buffer to bind
  29501. */
  29502. Engine.prototype.bindArrayBuffer = function (buffer) {
  29503. if (!this._vaoRecordInProgress) {
  29504. this._unbindVertexArrayObject();
  29505. }
  29506. this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);
  29507. };
  29508. /**
  29509. * Bind an uniform buffer to the current webGL context
  29510. * @param buffer defines the buffer to bind
  29511. */
  29512. Engine.prototype.bindUniformBuffer = function (buffer) {
  29513. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer);
  29514. };
  29515. /**
  29516. * Bind a buffer to the current webGL context at a given location
  29517. * @param buffer defines the buffer to bind
  29518. * @param location defines the index where to bind the buffer
  29519. */
  29520. Engine.prototype.bindUniformBufferBase = function (buffer, location) {
  29521. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer);
  29522. };
  29523. /**
  29524. * Bind a specific block at a given index in a specific shader program
  29525. * @param shaderProgram defines the shader program
  29526. * @param blockName defines the block name
  29527. * @param index defines the index where to bind the block
  29528. */
  29529. Engine.prototype.bindUniformBlock = function (shaderProgram, blockName, index) {
  29530. var uniformLocation = this._gl.getUniformBlockIndex(shaderProgram, blockName);
  29531. this._gl.uniformBlockBinding(shaderProgram, uniformLocation, index);
  29532. };
  29533. Engine.prototype.bindIndexBuffer = function (buffer) {
  29534. if (!this._vaoRecordInProgress) {
  29535. this._unbindVertexArrayObject();
  29536. }
  29537. this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
  29538. };
  29539. Engine.prototype.bindBuffer = function (buffer, target) {
  29540. if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
  29541. this._gl.bindBuffer(target, buffer);
  29542. this._currentBoundBuffer[target] = buffer;
  29543. }
  29544. };
  29545. /**
  29546. * update the bound buffer with the given data
  29547. * @param data defines the data to update
  29548. */
  29549. Engine.prototype.updateArrayBuffer = function (data) {
  29550. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29551. };
  29552. Engine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {
  29553. var pointer = this._currentBufferPointers[indx];
  29554. var changed = false;
  29555. if (!pointer.active) {
  29556. changed = true;
  29557. pointer.active = true;
  29558. pointer.index = indx;
  29559. pointer.size = size;
  29560. pointer.type = type;
  29561. pointer.normalized = normalized;
  29562. pointer.stride = stride;
  29563. pointer.offset = offset;
  29564. pointer.buffer = buffer;
  29565. }
  29566. else {
  29567. if (pointer.buffer !== buffer) {
  29568. pointer.buffer = buffer;
  29569. changed = true;
  29570. }
  29571. if (pointer.size !== size) {
  29572. pointer.size = size;
  29573. changed = true;
  29574. }
  29575. if (pointer.type !== type) {
  29576. pointer.type = type;
  29577. changed = true;
  29578. }
  29579. if (pointer.normalized !== normalized) {
  29580. pointer.normalized = normalized;
  29581. changed = true;
  29582. }
  29583. if (pointer.stride !== stride) {
  29584. pointer.stride = stride;
  29585. changed = true;
  29586. }
  29587. if (pointer.offset !== offset) {
  29588. pointer.offset = offset;
  29589. changed = true;
  29590. }
  29591. }
  29592. if (changed || this._vaoRecordInProgress) {
  29593. this.bindArrayBuffer(buffer);
  29594. this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
  29595. }
  29596. };
  29597. Engine.prototype._bindIndexBufferWithCache = function (indexBuffer) {
  29598. if (indexBuffer == null) {
  29599. return;
  29600. }
  29601. if (this._cachedIndexBuffer !== indexBuffer) {
  29602. this._cachedIndexBuffer = indexBuffer;
  29603. this.bindIndexBuffer(indexBuffer);
  29604. this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
  29605. }
  29606. };
  29607. Engine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
  29608. var attributes = effect.getAttributesNames();
  29609. if (!this._vaoRecordInProgress) {
  29610. this._unbindVertexArrayObject();
  29611. }
  29612. this.unbindAllAttributes();
  29613. for (var index = 0; index < attributes.length; index++) {
  29614. var order = effect.getAttributeLocation(index);
  29615. if (order >= 0) {
  29616. var vertexBuffer = vertexBuffers[attributes[index]];
  29617. if (!vertexBuffer) {
  29618. continue;
  29619. }
  29620. this._gl.enableVertexAttribArray(order);
  29621. if (!this._vaoRecordInProgress) {
  29622. this._vertexAttribArraysEnabled[order] = true;
  29623. }
  29624. var buffer = vertexBuffer.getBuffer();
  29625. if (buffer) {
  29626. this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
  29627. if (vertexBuffer.getIsInstanced()) {
  29628. this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
  29629. if (!this._vaoRecordInProgress) {
  29630. this._currentInstanceLocations.push(order);
  29631. this._currentInstanceBuffers.push(buffer);
  29632. }
  29633. }
  29634. }
  29635. }
  29636. }
  29637. };
  29638. /**
  29639. * Records a vertex array object
  29640. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29641. * @param vertexBuffers defines the list of vertex buffers to store
  29642. * @param indexBuffer defines the index buffer to store
  29643. * @param effect defines the effect to store
  29644. * @returns the new vertex array object
  29645. */
  29646. Engine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
  29647. var vao = this._gl.createVertexArray();
  29648. this._vaoRecordInProgress = true;
  29649. this._gl.bindVertexArray(vao);
  29650. this._mustWipeVertexAttributes = true;
  29651. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  29652. this.bindIndexBuffer(indexBuffer);
  29653. this._vaoRecordInProgress = false;
  29654. this._gl.bindVertexArray(null);
  29655. return vao;
  29656. };
  29657. /**
  29658. * Bind a specific vertex array object
  29659. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29660. * @param vertexArrayObject defines the vertex array object to bind
  29661. * @param indexBuffer defines the index buffer to bind
  29662. */
  29663. Engine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {
  29664. if (this._cachedVertexArrayObject !== vertexArrayObject) {
  29665. this._cachedVertexArrayObject = vertexArrayObject;
  29666. this._gl.bindVertexArray(vertexArrayObject);
  29667. this._cachedVertexBuffers = null;
  29668. this._cachedIndexBuffer = null;
  29669. this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
  29670. this._mustWipeVertexAttributes = true;
  29671. }
  29672. };
  29673. /**
  29674. * Bind webGl buffers directly to the webGL context
  29675. * @param vertexBuffer defines the vertex buffer to bind
  29676. * @param indexBuffer defines the index buffer to bind
  29677. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29678. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29679. * @param effect defines the effect associated with the vertex buffer
  29680. */
  29681. Engine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
  29682. if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
  29683. this._cachedVertexBuffers = vertexBuffer;
  29684. this._cachedEffectForVertexBuffers = effect;
  29685. var attributesCount = effect.getAttributesCount();
  29686. this._unbindVertexArrayObject();
  29687. this.unbindAllAttributes();
  29688. var offset = 0;
  29689. for (var index = 0; index < attributesCount; index++) {
  29690. if (index < vertexDeclaration.length) {
  29691. var order = effect.getAttributeLocation(index);
  29692. if (order >= 0) {
  29693. this._gl.enableVertexAttribArray(order);
  29694. this._vertexAttribArraysEnabled[order] = true;
  29695. this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
  29696. }
  29697. offset += vertexDeclaration[index] * 4;
  29698. }
  29699. }
  29700. }
  29701. this._bindIndexBufferWithCache(indexBuffer);
  29702. };
  29703. Engine.prototype._unbindVertexArrayObject = function () {
  29704. if (!this._cachedVertexArrayObject) {
  29705. return;
  29706. }
  29707. this._cachedVertexArrayObject = null;
  29708. this._gl.bindVertexArray(null);
  29709. };
  29710. /**
  29711. * Bind a list of vertex buffers to the webGL context
  29712. * @param vertexBuffers defines the list of vertex buffers to bind
  29713. * @param indexBuffer defines the index buffer to bind
  29714. * @param effect defines the effect associated with the vertex buffers
  29715. */
  29716. Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  29717. if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
  29718. this._cachedVertexBuffers = vertexBuffers;
  29719. this._cachedEffectForVertexBuffers = effect;
  29720. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  29721. }
  29722. this._bindIndexBufferWithCache(indexBuffer);
  29723. };
  29724. /**
  29725. * Unbind all instance attributes
  29726. */
  29727. Engine.prototype.unbindInstanceAttributes = function () {
  29728. var boundBuffer;
  29729. for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
  29730. var instancesBuffer = this._currentInstanceBuffers[i];
  29731. if (boundBuffer != instancesBuffer && instancesBuffer.references) {
  29732. boundBuffer = instancesBuffer;
  29733. this.bindArrayBuffer(instancesBuffer);
  29734. }
  29735. var offsetLocation = this._currentInstanceLocations[i];
  29736. this._gl.vertexAttribDivisor(offsetLocation, 0);
  29737. }
  29738. this._currentInstanceBuffers.length = 0;
  29739. this._currentInstanceLocations.length = 0;
  29740. };
  29741. /**
  29742. * Release and free the memory of a vertex array object
  29743. * @param vao defines the vertex array object to delete
  29744. */
  29745. Engine.prototype.releaseVertexArrayObject = function (vao) {
  29746. this._gl.deleteVertexArray(vao);
  29747. };
  29748. /** @hidden */
  29749. Engine.prototype._releaseBuffer = function (buffer) {
  29750. buffer.references--;
  29751. if (buffer.references === 0) {
  29752. this._gl.deleteBuffer(buffer);
  29753. return true;
  29754. }
  29755. return false;
  29756. };
  29757. /**
  29758. * Creates a webGL buffer to use with instanciation
  29759. * @param capacity defines the size of the buffer
  29760. * @returns the webGL buffer
  29761. */
  29762. Engine.prototype.createInstancesBuffer = function (capacity) {
  29763. var buffer = this._gl.createBuffer();
  29764. if (!buffer) {
  29765. throw new Error("Unable to create instance buffer");
  29766. }
  29767. buffer.capacity = capacity;
  29768. this.bindArrayBuffer(buffer);
  29769. this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
  29770. return buffer;
  29771. };
  29772. /**
  29773. * Delete a webGL buffer used with instanciation
  29774. * @param buffer defines the webGL buffer to delete
  29775. */
  29776. Engine.prototype.deleteInstancesBuffer = function (buffer) {
  29777. this._gl.deleteBuffer(buffer);
  29778. };
  29779. /**
  29780. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29781. * @param instancesBuffer defines the webGL buffer to update and bind
  29782. * @param data defines the data to store in the buffer
  29783. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29784. */
  29785. Engine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {
  29786. this.bindArrayBuffer(instancesBuffer);
  29787. if (data) {
  29788. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29789. }
  29790. if (offsetLocations[0].index !== undefined) {
  29791. var stride = 0;
  29792. for (var i = 0; i < offsetLocations.length; i++) {
  29793. var ai = offsetLocations[i];
  29794. stride += ai.attributeSize * 4;
  29795. }
  29796. for (var i = 0; i < offsetLocations.length; i++) {
  29797. var ai = offsetLocations[i];
  29798. if (!this._vertexAttribArraysEnabled[ai.index]) {
  29799. this._gl.enableVertexAttribArray(ai.index);
  29800. this._vertexAttribArraysEnabled[ai.index] = true;
  29801. }
  29802. this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
  29803. this._gl.vertexAttribDivisor(ai.index, 1);
  29804. this._currentInstanceLocations.push(ai.index);
  29805. this._currentInstanceBuffers.push(instancesBuffer);
  29806. }
  29807. }
  29808. else {
  29809. for (var index = 0; index < 4; index++) {
  29810. var offsetLocation = offsetLocations[index];
  29811. if (!this._vertexAttribArraysEnabled[offsetLocation]) {
  29812. this._gl.enableVertexAttribArray(offsetLocation);
  29813. this._vertexAttribArraysEnabled[offsetLocation] = true;
  29814. }
  29815. this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
  29816. this._gl.vertexAttribDivisor(offsetLocation, 1);
  29817. this._currentInstanceLocations.push(offsetLocation);
  29818. this._currentInstanceBuffers.push(instancesBuffer);
  29819. }
  29820. }
  29821. };
  29822. /**
  29823. * Apply all cached states (depth, culling, stencil and alpha)
  29824. */
  29825. Engine.prototype.applyStates = function () {
  29826. this._depthCullingState.apply(this._gl);
  29827. this._stencilState.apply(this._gl);
  29828. this._alphaState.apply(this._gl);
  29829. };
  29830. /**
  29831. * Send a draw order
  29832. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29833. * @param indexStart defines the starting index
  29834. * @param indexCount defines the number of index to draw
  29835. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29836. */
  29837. Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  29838. this.drawElementsType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, indexStart, indexCount, instancesCount);
  29839. };
  29840. /**
  29841. * Draw a list of points
  29842. * @param verticesStart defines the index of first vertex to draw
  29843. * @param verticesCount defines the count of vertices to draw
  29844. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29845. */
  29846. Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
  29847. this.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode, verticesStart, verticesCount, instancesCount);
  29848. };
  29849. /**
  29850. * Draw a list of unindexed primitives
  29851. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29852. * @param verticesStart defines the index of first vertex to draw
  29853. * @param verticesCount defines the count of vertices to draw
  29854. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29855. */
  29856. Engine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {
  29857. this.drawArraysType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, verticesStart, verticesCount, instancesCount);
  29858. };
  29859. /**
  29860. * Draw a list of indexed primitives
  29861. * @param fillMode defines the primitive to use
  29862. * @param indexStart defines the starting index
  29863. * @param indexCount defines the number of index to draw
  29864. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29865. */
  29866. Engine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  29867. // Apply states
  29868. this.applyStates();
  29869. this._drawCalls.addCount(1, false);
  29870. // Render
  29871. var drawMode = this._drawMode(fillMode);
  29872. var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
  29873. var mult = this._uintIndicesCurrentlySet ? 4 : 2;
  29874. if (instancesCount) {
  29875. this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
  29876. }
  29877. else {
  29878. this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
  29879. }
  29880. };
  29881. /**
  29882. * Draw a list of unindexed primitives
  29883. * @param fillMode defines the primitive to use
  29884. * @param verticesStart defines the index of first vertex to draw
  29885. * @param verticesCount defines the count of vertices to draw
  29886. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29887. */
  29888. Engine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  29889. // Apply states
  29890. this.applyStates();
  29891. this._drawCalls.addCount(1, false);
  29892. var drawMode = this._drawMode(fillMode);
  29893. if (instancesCount) {
  29894. this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
  29895. }
  29896. else {
  29897. this._gl.drawArrays(drawMode, verticesStart, verticesCount);
  29898. }
  29899. };
  29900. Engine.prototype._drawMode = function (fillMode) {
  29901. switch (fillMode) {
  29902. // Triangle views
  29903. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode:
  29904. return this._gl.TRIANGLES;
  29905. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode:
  29906. return this._gl.POINTS;
  29907. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode:
  29908. return this._gl.LINES;
  29909. // Draw modes
  29910. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointListDrawMode:
  29911. return this._gl.POINTS;
  29912. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineListDrawMode:
  29913. return this._gl.LINES;
  29914. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineLoopDrawMode:
  29915. return this._gl.LINE_LOOP;
  29916. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineStripDrawMode:
  29917. return this._gl.LINE_STRIP;
  29918. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleStripDrawMode:
  29919. return this._gl.TRIANGLE_STRIP;
  29920. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFanDrawMode:
  29921. return this._gl.TRIANGLE_FAN;
  29922. default:
  29923. return this._gl.TRIANGLES;
  29924. }
  29925. };
  29926. // Shaders
  29927. /** @hidden */
  29928. Engine.prototype._releaseEffect = function (effect) {
  29929. if (this._compiledEffects[effect._key]) {
  29930. delete this._compiledEffects[effect._key];
  29931. this._deleteProgram(effect.getProgram());
  29932. }
  29933. };
  29934. /** @hidden */
  29935. Engine.prototype._deleteProgram = function (program) {
  29936. if (program) {
  29937. program.__SPECTOR_rebuildProgram = null;
  29938. if (program.transformFeedback) {
  29939. this.deleteTransformFeedback(program.transformFeedback);
  29940. program.transformFeedback = null;
  29941. }
  29942. this._gl.deleteProgram(program);
  29943. }
  29944. };
  29945. /**
  29946. * Create a new effect (used to store vertex/fragment shaders)
  29947. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29948. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29949. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29950. * @param samplers defines an array of string used to represent textures
  29951. * @param defines defines the string containing the defines to use to compile the shaders
  29952. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29953. * @param onCompiled defines a function to call when the effect creation is successful
  29954. * @param onError defines a function to call when the effect creation has failed
  29955. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29956. * @returns the new Effect
  29957. */
  29958. Engine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {
  29959. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  29960. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  29961. var name = vertex + "+" + fragment + "@" + (defines ? defines : attributesNamesOrOptions.defines);
  29962. if (this._compiledEffects[name]) {
  29963. var compiledEffect = this._compiledEffects[name];
  29964. if (onCompiled && compiledEffect.isReady()) {
  29965. onCompiled(compiledEffect);
  29966. }
  29967. return compiledEffect;
  29968. }
  29969. var effect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"](baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
  29970. effect._key = name;
  29971. this._compiledEffects[name] = effect;
  29972. return effect;
  29973. };
  29974. Engine.prototype._compileShader = function (source, type, defines, shaderVersion) {
  29975. return this._compileRawShader(shaderVersion + (defines ? defines + "\n" : "") + source, type);
  29976. };
  29977. Engine.prototype._compileRawShader = function (source, type) {
  29978. var gl = this._gl;
  29979. var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
  29980. if (!shader) {
  29981. throw new Error("Something went wrong while compile the shader.");
  29982. }
  29983. gl.shaderSource(shader, source);
  29984. gl.compileShader(shader);
  29985. if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
  29986. var log = gl.getShaderInfoLog(shader);
  29987. if (log) {
  29988. throw new Error(log);
  29989. }
  29990. }
  29991. return shader;
  29992. };
  29993. /**
  29994. * Directly creates a webGL program
  29995. * @param vertexCode defines the vertex shader code to use
  29996. * @param fragmentCode defines the fragment shader code to use
  29997. * @param context defines the webGL context to use (if not set, the current one will be used)
  29998. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29999. * @returns the new webGL program
  30000. */
  30001. Engine.prototype.createRawShaderProgram = function (vertexCode, fragmentCode, context, transformFeedbackVaryings) {
  30002. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30003. context = context || this._gl;
  30004. var vertexShader = this._compileRawShader(vertexCode, "vertex");
  30005. var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
  30006. return this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30007. };
  30008. /**
  30009. * Creates a webGL program
  30010. * @param vertexCode defines the vertex shader code to use
  30011. * @param fragmentCode defines the fragment shader code to use
  30012. * @param defines defines the string containing the defines to use to compile the shaders
  30013. * @param context defines the webGL context to use (if not set, the current one will be used)
  30014. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30015. * @returns the new webGL program
  30016. */
  30017. Engine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {
  30018. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30019. context = context || this._gl;
  30020. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  30021. var shaderVersion = (this._webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  30022. var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
  30023. var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
  30024. var program = this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30025. this.onAfterShaderCompilationObservable.notifyObservers(this);
  30026. return program;
  30027. };
  30028. Engine.prototype._createShaderProgram = function (vertexShader, fragmentShader, context, transformFeedbackVaryings) {
  30029. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30030. var shaderProgram = context.createProgram();
  30031. if (!shaderProgram) {
  30032. throw new Error("Unable to create program");
  30033. }
  30034. context.attachShader(shaderProgram, vertexShader);
  30035. context.attachShader(shaderProgram, fragmentShader);
  30036. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30037. var transformFeedback = this.createTransformFeedback();
  30038. this.bindTransformFeedback(transformFeedback);
  30039. this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
  30040. shaderProgram.transformFeedback = transformFeedback;
  30041. }
  30042. context.linkProgram(shaderProgram);
  30043. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30044. this.bindTransformFeedback(null);
  30045. }
  30046. shaderProgram.context = context;
  30047. shaderProgram.vertexShader = vertexShader;
  30048. shaderProgram.fragmentShader = fragmentShader;
  30049. if (!this._caps.parallelShaderCompile) {
  30050. this._finalizeProgram(shaderProgram);
  30051. }
  30052. else {
  30053. shaderProgram.isParallelCompiled = true;
  30054. }
  30055. return shaderProgram;
  30056. };
  30057. Engine.prototype._finalizeProgram = function (shaderProgram) {
  30058. var context = shaderProgram.context;
  30059. var vertexShader = shaderProgram.vertexShader;
  30060. var fragmentShader = shaderProgram.fragmentShader;
  30061. var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
  30062. if (!linked) {
  30063. var error = context.getProgramInfoLog(shaderProgram);
  30064. if (error) {
  30065. throw new Error(error);
  30066. }
  30067. }
  30068. if (this.validateShaderPrograms) {
  30069. context.validateProgram(shaderProgram);
  30070. var validated = context.getProgramParameter(shaderProgram, context.VALIDATE_STATUS);
  30071. if (!validated) {
  30072. var error = context.getProgramInfoLog(shaderProgram);
  30073. if (error) {
  30074. throw new Error(error);
  30075. }
  30076. }
  30077. }
  30078. context.deleteShader(vertexShader);
  30079. context.deleteShader(fragmentShader);
  30080. shaderProgram.context = undefined;
  30081. shaderProgram.vertexShader = undefined;
  30082. shaderProgram.fragmentShader = undefined;
  30083. if (shaderProgram.onCompiled) {
  30084. shaderProgram.onCompiled();
  30085. shaderProgram.onCompiled = undefined;
  30086. }
  30087. };
  30088. /** @hidden */
  30089. Engine.prototype._isProgramCompiled = function (shaderProgram) {
  30090. if (!shaderProgram.isParallelCompiled) {
  30091. return true;
  30092. }
  30093. if (this._gl.getProgramParameter(shaderProgram, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
  30094. this._finalizeProgram(shaderProgram);
  30095. return true;
  30096. }
  30097. return false;
  30098. };
  30099. /** @hidden */
  30100. Engine.prototype._executeWhenProgramIsCompiled = function (shaderProgram, action) {
  30101. if (!shaderProgram.isParallelCompiled) {
  30102. action();
  30103. return;
  30104. }
  30105. shaderProgram.onCompiled = action;
  30106. };
  30107. /**
  30108. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30109. * @param shaderProgram defines the webGL program to use
  30110. * @param uniformsNames defines the list of uniform names
  30111. * @returns an array of webGL uniform locations
  30112. */
  30113. Engine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  30114. var results = new Array();
  30115. for (var index = 0; index < uniformsNames.length; index++) {
  30116. results.push(this._gl.getUniformLocation(shaderProgram, uniformsNames[index]));
  30117. }
  30118. return results;
  30119. };
  30120. /**
  30121. * Gets the lsit of active attributes for a given webGL program
  30122. * @param shaderProgram defines the webGL program to use
  30123. * @param attributesNames defines the list of attribute names to get
  30124. * @returns an array of indices indicating the offset of each attribute
  30125. */
  30126. Engine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  30127. var results = [];
  30128. for (var index = 0; index < attributesNames.length; index++) {
  30129. try {
  30130. results.push(this._gl.getAttribLocation(shaderProgram, attributesNames[index]));
  30131. }
  30132. catch (e) {
  30133. results.push(-1);
  30134. }
  30135. }
  30136. return results;
  30137. };
  30138. /**
  30139. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30140. * @param effect defines the effect to activate
  30141. */
  30142. Engine.prototype.enableEffect = function (effect) {
  30143. if (!effect || effect === this._currentEffect) {
  30144. return;
  30145. }
  30146. // Use program
  30147. this.bindSamplers(effect);
  30148. this._currentEffect = effect;
  30149. if (effect.onBind) {
  30150. effect.onBind(effect);
  30151. }
  30152. if (effect._onBindObservable) {
  30153. effect._onBindObservable.notifyObservers(effect);
  30154. }
  30155. };
  30156. /**
  30157. * Set the value of an uniform to an array of int32
  30158. * @param uniform defines the webGL uniform location where to store the value
  30159. * @param array defines the array of int32 to store
  30160. */
  30161. Engine.prototype.setIntArray = function (uniform, array) {
  30162. if (!uniform) {
  30163. return;
  30164. }
  30165. this._gl.uniform1iv(uniform, array);
  30166. };
  30167. /**
  30168. * Set the value of an uniform to an array of int32 (stored as vec2)
  30169. * @param uniform defines the webGL uniform location where to store the value
  30170. * @param array defines the array of int32 to store
  30171. */
  30172. Engine.prototype.setIntArray2 = function (uniform, array) {
  30173. if (!uniform || array.length % 2 !== 0) {
  30174. return;
  30175. }
  30176. this._gl.uniform2iv(uniform, array);
  30177. };
  30178. /**
  30179. * Set the value of an uniform to an array of int32 (stored as vec3)
  30180. * @param uniform defines the webGL uniform location where to store the value
  30181. * @param array defines the array of int32 to store
  30182. */
  30183. Engine.prototype.setIntArray3 = function (uniform, array) {
  30184. if (!uniform || array.length % 3 !== 0) {
  30185. return;
  30186. }
  30187. this._gl.uniform3iv(uniform, array);
  30188. };
  30189. /**
  30190. * Set the value of an uniform to an array of int32 (stored as vec4)
  30191. * @param uniform defines the webGL uniform location where to store the value
  30192. * @param array defines the array of int32 to store
  30193. */
  30194. Engine.prototype.setIntArray4 = function (uniform, array) {
  30195. if (!uniform || array.length % 4 !== 0) {
  30196. return;
  30197. }
  30198. this._gl.uniform4iv(uniform, array);
  30199. };
  30200. /**
  30201. * Set the value of an uniform to an array of float32
  30202. * @param uniform defines the webGL uniform location where to store the value
  30203. * @param array defines the array of float32 to store
  30204. */
  30205. Engine.prototype.setFloatArray = function (uniform, array) {
  30206. if (!uniform) {
  30207. return;
  30208. }
  30209. this._gl.uniform1fv(uniform, array);
  30210. };
  30211. /**
  30212. * Set the value of an uniform to an array of float32 (stored as vec2)
  30213. * @param uniform defines the webGL uniform location where to store the value
  30214. * @param array defines the array of float32 to store
  30215. */
  30216. Engine.prototype.setFloatArray2 = function (uniform, array) {
  30217. if (!uniform || array.length % 2 !== 0) {
  30218. return;
  30219. }
  30220. this._gl.uniform2fv(uniform, array);
  30221. };
  30222. /**
  30223. * Set the value of an uniform to an array of float32 (stored as vec3)
  30224. * @param uniform defines the webGL uniform location where to store the value
  30225. * @param array defines the array of float32 to store
  30226. */
  30227. Engine.prototype.setFloatArray3 = function (uniform, array) {
  30228. if (!uniform || array.length % 3 !== 0) {
  30229. return;
  30230. }
  30231. this._gl.uniform3fv(uniform, array);
  30232. };
  30233. /**
  30234. * Set the value of an uniform to an array of float32 (stored as vec4)
  30235. * @param uniform defines the webGL uniform location where to store the value
  30236. * @param array defines the array of float32 to store
  30237. */
  30238. Engine.prototype.setFloatArray4 = function (uniform, array) {
  30239. if (!uniform || array.length % 4 !== 0) {
  30240. return;
  30241. }
  30242. this._gl.uniform4fv(uniform, array);
  30243. };
  30244. /**
  30245. * Set the value of an uniform to an array of number
  30246. * @param uniform defines the webGL uniform location where to store the value
  30247. * @param array defines the array of number to store
  30248. */
  30249. Engine.prototype.setArray = function (uniform, array) {
  30250. if (!uniform) {
  30251. return;
  30252. }
  30253. this._gl.uniform1fv(uniform, array);
  30254. };
  30255. /**
  30256. * Set the value of an uniform to an array of number (stored as vec2)
  30257. * @param uniform defines the webGL uniform location where to store the value
  30258. * @param array defines the array of number to store
  30259. */
  30260. Engine.prototype.setArray2 = function (uniform, array) {
  30261. if (!uniform || array.length % 2 !== 0) {
  30262. return;
  30263. }
  30264. this._gl.uniform2fv(uniform, array);
  30265. };
  30266. /**
  30267. * Set the value of an uniform to an array of number (stored as vec3)
  30268. * @param uniform defines the webGL uniform location where to store the value
  30269. * @param array defines the array of number to store
  30270. */
  30271. Engine.prototype.setArray3 = function (uniform, array) {
  30272. if (!uniform || array.length % 3 !== 0) {
  30273. return;
  30274. }
  30275. this._gl.uniform3fv(uniform, array);
  30276. };
  30277. /**
  30278. * Set the value of an uniform to an array of number (stored as vec4)
  30279. * @param uniform defines the webGL uniform location where to store the value
  30280. * @param array defines the array of number to store
  30281. */
  30282. Engine.prototype.setArray4 = function (uniform, array) {
  30283. if (!uniform || array.length % 4 !== 0) {
  30284. return;
  30285. }
  30286. this._gl.uniform4fv(uniform, array);
  30287. };
  30288. /**
  30289. * Set the value of an uniform to an array of float32 (stored as matrices)
  30290. * @param uniform defines the webGL uniform location where to store the value
  30291. * @param matrices defines the array of float32 to store
  30292. */
  30293. Engine.prototype.setMatrices = function (uniform, matrices) {
  30294. if (!uniform) {
  30295. return;
  30296. }
  30297. this._gl.uniformMatrix4fv(uniform, false, matrices);
  30298. };
  30299. /**
  30300. * Set the value of an uniform to a matrix
  30301. * @param uniform defines the webGL uniform location where to store the value
  30302. * @param matrix defines the matrix to store
  30303. */
  30304. Engine.prototype.setMatrix = function (uniform, matrix) {
  30305. if (!uniform) {
  30306. return;
  30307. }
  30308. this._gl.uniformMatrix4fv(uniform, false, matrix.toArray());
  30309. };
  30310. /**
  30311. * Set the value of an uniform to a matrix (3x3)
  30312. * @param uniform defines the webGL uniform location where to store the value
  30313. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30314. */
  30315. Engine.prototype.setMatrix3x3 = function (uniform, matrix) {
  30316. if (!uniform) {
  30317. return;
  30318. }
  30319. this._gl.uniformMatrix3fv(uniform, false, matrix);
  30320. };
  30321. /**
  30322. * Set the value of an uniform to a matrix (2x2)
  30323. * @param uniform defines the webGL uniform location where to store the value
  30324. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30325. */
  30326. Engine.prototype.setMatrix2x2 = function (uniform, matrix) {
  30327. if (!uniform) {
  30328. return;
  30329. }
  30330. this._gl.uniformMatrix2fv(uniform, false, matrix);
  30331. };
  30332. /**
  30333. * Set the value of an uniform to a number (int)
  30334. * @param uniform defines the webGL uniform location where to store the value
  30335. * @param value defines the int number to store
  30336. */
  30337. Engine.prototype.setInt = function (uniform, value) {
  30338. if (!uniform) {
  30339. return;
  30340. }
  30341. this._gl.uniform1i(uniform, value);
  30342. };
  30343. /**
  30344. * Set the value of an uniform to a number (float)
  30345. * @param uniform defines the webGL uniform location where to store the value
  30346. * @param value defines the float number to store
  30347. */
  30348. Engine.prototype.setFloat = function (uniform, value) {
  30349. if (!uniform) {
  30350. return;
  30351. }
  30352. this._gl.uniform1f(uniform, value);
  30353. };
  30354. /**
  30355. * Set the value of an uniform to a vec2
  30356. * @param uniform defines the webGL uniform location where to store the value
  30357. * @param x defines the 1st component of the value
  30358. * @param y defines the 2nd component of the value
  30359. */
  30360. Engine.prototype.setFloat2 = function (uniform, x, y) {
  30361. if (!uniform) {
  30362. return;
  30363. }
  30364. this._gl.uniform2f(uniform, x, y);
  30365. };
  30366. /**
  30367. * Set the value of an uniform to a vec3
  30368. * @param uniform defines the webGL uniform location where to store the value
  30369. * @param x defines the 1st component of the value
  30370. * @param y defines the 2nd component of the value
  30371. * @param z defines the 3rd component of the value
  30372. */
  30373. Engine.prototype.setFloat3 = function (uniform, x, y, z) {
  30374. if (!uniform) {
  30375. return;
  30376. }
  30377. this._gl.uniform3f(uniform, x, y, z);
  30378. };
  30379. /**
  30380. * Set the value of an uniform to a boolean
  30381. * @param uniform defines the webGL uniform location where to store the value
  30382. * @param bool defines the boolean to store
  30383. */
  30384. Engine.prototype.setBool = function (uniform, bool) {
  30385. if (!uniform) {
  30386. return;
  30387. }
  30388. this._gl.uniform1i(uniform, bool);
  30389. };
  30390. /**
  30391. * Set the value of an uniform to a vec4
  30392. * @param uniform defines the webGL uniform location where to store the value
  30393. * @param x defines the 1st component of the value
  30394. * @param y defines the 2nd component of the value
  30395. * @param z defines the 3rd component of the value
  30396. * @param w defines the 4th component of the value
  30397. */
  30398. Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  30399. if (!uniform) {
  30400. return;
  30401. }
  30402. this._gl.uniform4f(uniform, x, y, z, w);
  30403. };
  30404. /**
  30405. * Set the value of an uniform to a Color3
  30406. * @param uniform defines the webGL uniform location where to store the value
  30407. * @param color3 defines the color to store
  30408. */
  30409. Engine.prototype.setColor3 = function (uniform, color3) {
  30410. if (!uniform) {
  30411. return;
  30412. }
  30413. this._gl.uniform3f(uniform, color3.r, color3.g, color3.b);
  30414. };
  30415. /**
  30416. * Set the value of an uniform to a Color3 and an alpha value
  30417. * @param uniform defines the webGL uniform location where to store the value
  30418. * @param color3 defines the color to store
  30419. * @param alpha defines the alpha component to store
  30420. */
  30421. Engine.prototype.setColor4 = function (uniform, color3, alpha) {
  30422. if (!uniform) {
  30423. return;
  30424. }
  30425. this._gl.uniform4f(uniform, color3.r, color3.g, color3.b, alpha);
  30426. };
  30427. /**
  30428. * Sets a Color4 on a uniform variable
  30429. * @param uniform defines the uniform location
  30430. * @param color4 defines the value to be set
  30431. */
  30432. Engine.prototype.setDirectColor4 = function (uniform, color4) {
  30433. if (!uniform) {
  30434. return;
  30435. }
  30436. this._gl.uniform4f(uniform, color4.r, color4.g, color4.b, color4.a);
  30437. };
  30438. // States
  30439. /**
  30440. * Set various states to the webGL context
  30441. * @param culling defines backface culling state
  30442. * @param zOffset defines the value to apply to zOffset (0 by default)
  30443. * @param force defines if states must be applied even if cache is up to date
  30444. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30445. */
  30446. Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  30447. if (zOffset === void 0) { zOffset = 0; }
  30448. if (reverseSide === void 0) { reverseSide = false; }
  30449. // Culling
  30450. if (this._depthCullingState.cull !== culling || force) {
  30451. this._depthCullingState.cull = culling;
  30452. }
  30453. // Cull face
  30454. var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
  30455. if (this._depthCullingState.cullFace !== cullFace || force) {
  30456. this._depthCullingState.cullFace = cullFace;
  30457. }
  30458. // Z offset
  30459. this.setZOffset(zOffset);
  30460. // Front face
  30461. var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
  30462. if (this._depthCullingState.frontFace !== frontFace || force) {
  30463. this._depthCullingState.frontFace = frontFace;
  30464. }
  30465. };
  30466. /**
  30467. * Set the z offset to apply to current rendering
  30468. * @param value defines the offset to apply
  30469. */
  30470. Engine.prototype.setZOffset = function (value) {
  30471. this._depthCullingState.zOffset = value;
  30472. };
  30473. /**
  30474. * Gets the current value of the zOffset
  30475. * @returns the current zOffset state
  30476. */
  30477. Engine.prototype.getZOffset = function () {
  30478. return this._depthCullingState.zOffset;
  30479. };
  30480. /**
  30481. * Enable or disable depth buffering
  30482. * @param enable defines the state to set
  30483. */
  30484. Engine.prototype.setDepthBuffer = function (enable) {
  30485. this._depthCullingState.depthTest = enable;
  30486. };
  30487. /**
  30488. * Gets a boolean indicating if depth writing is enabled
  30489. * @returns the current depth writing state
  30490. */
  30491. Engine.prototype.getDepthWrite = function () {
  30492. return this._depthCullingState.depthMask;
  30493. };
  30494. /**
  30495. * Enable or disable depth writing
  30496. * @param enable defines the state to set
  30497. */
  30498. Engine.prototype.setDepthWrite = function (enable) {
  30499. this._depthCullingState.depthMask = enable;
  30500. };
  30501. /**
  30502. * Enable or disable color writing
  30503. * @param enable defines the state to set
  30504. */
  30505. Engine.prototype.setColorWrite = function (enable) {
  30506. this._gl.colorMask(enable, enable, enable, enable);
  30507. this._colorWrite = enable;
  30508. };
  30509. /**
  30510. * Gets a boolean indicating if color writing is enabled
  30511. * @returns the current color writing state
  30512. */
  30513. Engine.prototype.getColorWrite = function () {
  30514. return this._colorWrite;
  30515. };
  30516. /**
  30517. * Sets alpha constants used by some alpha blending modes
  30518. * @param r defines the red component
  30519. * @param g defines the green component
  30520. * @param b defines the blue component
  30521. * @param a defines the alpha component
  30522. */
  30523. Engine.prototype.setAlphaConstants = function (r, g, b, a) {
  30524. this._alphaState.setAlphaBlendConstants(r, g, b, a);
  30525. };
  30526. /**
  30527. * Sets the current alpha mode
  30528. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  30529. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  30530. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30531. */
  30532. Engine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  30533. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  30534. if (this._alphaMode === mode) {
  30535. return;
  30536. }
  30537. switch (mode) {
  30538. case Engine.ALPHA_DISABLE:
  30539. this._alphaState.alphaBlend = false;
  30540. break;
  30541. case Engine.ALPHA_PREMULTIPLIED:
  30542. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  30543. this._alphaState.alphaBlend = true;
  30544. break;
  30545. case Engine.ALPHA_PREMULTIPLIED_PORTERDUFF:
  30546. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  30547. this._alphaState.alphaBlend = true;
  30548. break;
  30549. case Engine.ALPHA_COMBINE:
  30550. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  30551. this._alphaState.alphaBlend = true;
  30552. break;
  30553. case Engine.ALPHA_ONEONE:
  30554. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  30555. this._alphaState.alphaBlend = true;
  30556. break;
  30557. case Engine.ALPHA_ADD:
  30558. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  30559. this._alphaState.alphaBlend = true;
  30560. break;
  30561. case Engine.ALPHA_SUBTRACT:
  30562. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  30563. this._alphaState.alphaBlend = true;
  30564. break;
  30565. case Engine.ALPHA_MULTIPLY:
  30566. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
  30567. this._alphaState.alphaBlend = true;
  30568. break;
  30569. case Engine.ALPHA_MAXIMIZED:
  30570. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  30571. this._alphaState.alphaBlend = true;
  30572. break;
  30573. case Engine.ALPHA_INTERPOLATE:
  30574. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);
  30575. this._alphaState.alphaBlend = true;
  30576. break;
  30577. case Engine.ALPHA_SCREENMODE:
  30578. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  30579. this._alphaState.alphaBlend = true;
  30580. break;
  30581. }
  30582. if (!noDepthWriteChange) {
  30583. this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
  30584. }
  30585. this._alphaMode = mode;
  30586. };
  30587. /**
  30588. * Gets the current alpha mode
  30589. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30590. * @returns the current alpha mode
  30591. */
  30592. Engine.prototype.getAlphaMode = function () {
  30593. return this._alphaMode;
  30594. };
  30595. // Textures
  30596. /**
  30597. * Clears the list of texture accessible through engine.
  30598. * This can help preventing texture load conflict due to name collision.
  30599. */
  30600. Engine.prototype.clearInternalTexturesCache = function () {
  30601. this._internalTexturesCache = [];
  30602. };
  30603. /**
  30604. * Force the entire cache to be cleared
  30605. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30606. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30607. */
  30608. Engine.prototype.wipeCaches = function (bruteForce) {
  30609. if (this.preventCacheWipeBetweenFrames && !bruteForce) {
  30610. return;
  30611. }
  30612. this._currentEffect = null;
  30613. this._viewportCached.x = 0;
  30614. this._viewportCached.y = 0;
  30615. this._viewportCached.z = 0;
  30616. this._viewportCached.w = 0;
  30617. if (bruteForce) {
  30618. this.resetTextureCache();
  30619. this._currentProgram = null;
  30620. this._stencilState.reset();
  30621. this._depthCullingState.reset();
  30622. this.setDepthFunctionToLessOrEqual();
  30623. this._alphaState.reset();
  30624. this._unpackFlipYCached = null;
  30625. }
  30626. this._resetVertexBufferBinding();
  30627. this._cachedIndexBuffer = null;
  30628. this._cachedEffectForVertexBuffers = null;
  30629. this._unbindVertexArrayObject();
  30630. this.bindIndexBuffer(null);
  30631. };
  30632. /**
  30633. * Set the compressed texture format to use, based on the formats you have, and the formats
  30634. * supported by the hardware / browser.
  30635. *
  30636. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  30637. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  30638. * to API arguments needed to compressed textures. This puts the burden on the container
  30639. * generator to house the arcane code for determining these for current & future formats.
  30640. *
  30641. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30642. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30643. *
  30644. * Note: The result of this call is not taken into account when a texture is base64.
  30645. *
  30646. * @param formatsAvailable defines the list of those format families you have created
  30647. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  30648. *
  30649. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  30650. * @returns The extension selected.
  30651. */
  30652. Engine.prototype.setTextureFormatToUse = function (formatsAvailable) {
  30653. for (var i = 0, len1 = this.texturesSupported.length; i < len1; i++) {
  30654. for (var j = 0, len2 = formatsAvailable.length; j < len2; j++) {
  30655. if (this._texturesSupported[i] === formatsAvailable[j].toLowerCase()) {
  30656. return this._textureFormatInUse = this._texturesSupported[i];
  30657. }
  30658. }
  30659. }
  30660. // actively set format to nothing, to allow this to be called more than once
  30661. // and possibly fail the 2nd time
  30662. this._textureFormatInUse = null;
  30663. return null;
  30664. };
  30665. Engine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {
  30666. var gl = this._gl;
  30667. var magFilter = gl.NEAREST;
  30668. var minFilter = gl.NEAREST;
  30669. switch (samplingMode) {
  30670. case Engine.TEXTURE_BILINEAR_SAMPLINGMODE:
  30671. magFilter = gl.LINEAR;
  30672. if (generateMipMaps) {
  30673. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  30674. }
  30675. else {
  30676. minFilter = gl.LINEAR;
  30677. }
  30678. break;
  30679. case Engine.TEXTURE_TRILINEAR_SAMPLINGMODE:
  30680. magFilter = gl.LINEAR;
  30681. if (generateMipMaps) {
  30682. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  30683. }
  30684. else {
  30685. minFilter = gl.LINEAR;
  30686. }
  30687. break;
  30688. case Engine.TEXTURE_NEAREST_SAMPLINGMODE:
  30689. magFilter = gl.NEAREST;
  30690. if (generateMipMaps) {
  30691. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  30692. }
  30693. else {
  30694. minFilter = gl.NEAREST;
  30695. }
  30696. break;
  30697. case Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  30698. magFilter = gl.NEAREST;
  30699. if (generateMipMaps) {
  30700. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  30701. }
  30702. else {
  30703. minFilter = gl.NEAREST;
  30704. }
  30705. break;
  30706. case Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  30707. magFilter = gl.NEAREST;
  30708. if (generateMipMaps) {
  30709. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  30710. }
  30711. else {
  30712. minFilter = gl.LINEAR;
  30713. }
  30714. break;
  30715. case Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  30716. magFilter = gl.NEAREST;
  30717. if (generateMipMaps) {
  30718. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  30719. }
  30720. else {
  30721. minFilter = gl.LINEAR;
  30722. }
  30723. break;
  30724. case Engine.TEXTURE_NEAREST_LINEAR:
  30725. magFilter = gl.NEAREST;
  30726. minFilter = gl.LINEAR;
  30727. break;
  30728. case Engine.TEXTURE_NEAREST_NEAREST:
  30729. magFilter = gl.NEAREST;
  30730. minFilter = gl.NEAREST;
  30731. break;
  30732. case Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  30733. magFilter = gl.LINEAR;
  30734. if (generateMipMaps) {
  30735. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  30736. }
  30737. else {
  30738. minFilter = gl.NEAREST;
  30739. }
  30740. break;
  30741. case Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  30742. magFilter = gl.LINEAR;
  30743. if (generateMipMaps) {
  30744. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  30745. }
  30746. else {
  30747. minFilter = gl.NEAREST;
  30748. }
  30749. break;
  30750. case Engine.TEXTURE_LINEAR_LINEAR:
  30751. magFilter = gl.LINEAR;
  30752. minFilter = gl.LINEAR;
  30753. break;
  30754. case Engine.TEXTURE_LINEAR_NEAREST:
  30755. magFilter = gl.LINEAR;
  30756. minFilter = gl.NEAREST;
  30757. break;
  30758. }
  30759. return {
  30760. min: minFilter,
  30761. mag: magFilter
  30762. };
  30763. };
  30764. Engine.prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
  30765. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  30766. var img;
  30767. var onload = function () {
  30768. loadedImages[index] = img;
  30769. loadedImages._internalCount++;
  30770. if (scene) {
  30771. scene._removePendingData(img);
  30772. }
  30773. if (loadedImages._internalCount === 6) {
  30774. onfinish(loadedImages);
  30775. }
  30776. };
  30777. var onerror = function (message, exception) {
  30778. if (scene) {
  30779. scene._removePendingData(img);
  30780. }
  30781. if (onErrorCallBack) {
  30782. onErrorCallBack(message, exception);
  30783. }
  30784. };
  30785. img = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
  30786. if (scene) {
  30787. scene._addPendingData(img);
  30788. }
  30789. };
  30790. Engine.prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
  30791. if (onError === void 0) { onError = null; }
  30792. var loadedImages = [];
  30793. loadedImages._internalCount = 0;
  30794. for (var index = 0; index < 6; index++) {
  30795. this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
  30796. }
  30797. };
  30798. /** @hidden */
  30799. Engine.prototype._createTexture = function () {
  30800. var texture = this._gl.createTexture();
  30801. if (!texture) {
  30802. throw new Error("Unable to create texture");
  30803. }
  30804. return texture;
  30805. };
  30806. /**
  30807. * Usually called from Texture.ts.
  30808. * Passed information to create a WebGLTexture
  30809. * @param urlArg defines a value which contains one of the following:
  30810. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30811. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30812. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30813. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30814. * @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)
  30815. * @param scene needed for loading to the correct scene
  30816. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30817. * @param onLoad optional callback to be called upon successful completion
  30818. * @param onError optional callback to be called upon failure
  30819. * @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
  30820. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30821. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30822. * @param forcedExtension defines the extension to use to pick the right loader
  30823. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30824. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30825. */
  30826. Engine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
  30827. var _this = this;
  30828. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  30829. if (onLoad === void 0) { onLoad = null; }
  30830. if (onError === void 0) { onError = null; }
  30831. if (buffer === void 0) { buffer = null; }
  30832. if (fallback === void 0) { fallback = null; }
  30833. if (format === void 0) { format = null; }
  30834. if (forcedExtension === void 0) { forcedExtension = null; }
  30835. if (excludeLoaders === void 0) { excludeLoaders = []; }
  30836. var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
  30837. var fromData = url.substr(0, 5) === "data:";
  30838. var fromBlob = url.substr(0, 5) === "blob:";
  30839. var isBase64 = fromData && url.indexOf(";base64,") !== -1;
  30840. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_URL);
  30841. // establish the file extension, if possible
  30842. var lastDot = url.lastIndexOf('.');
  30843. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");
  30844. var loader = null;
  30845. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  30846. var availableLoader = _a[_i];
  30847. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, isBase64, buffer ? true : false)) {
  30848. loader = availableLoader;
  30849. break;
  30850. }
  30851. }
  30852. if (loader) {
  30853. url = loader.transformUrl(url, this._textureFormatInUse);
  30854. }
  30855. if (scene) {
  30856. scene._addPendingData(texture);
  30857. }
  30858. texture.url = url;
  30859. texture.generateMipMaps = !noMipmap;
  30860. texture.samplingMode = samplingMode;
  30861. texture.invertY = invertY;
  30862. if (!this._doNotHandleContextLost) {
  30863. // Keep a link to the buffer only if we plan to handle context lost
  30864. texture._buffer = buffer;
  30865. }
  30866. var onLoadObserver = null;
  30867. if (onLoad && !fallback) {
  30868. onLoadObserver = texture.onLoadedObservable.add(onLoad);
  30869. }
  30870. if (!fallback) {
  30871. this._internalTexturesCache.push(texture);
  30872. }
  30873. var onInternalError = function (message, exception) {
  30874. if (scene) {
  30875. scene._removePendingData(texture);
  30876. }
  30877. var customFallback = false;
  30878. if (loader) {
  30879. var fallbackUrl = loader.getFallbackTextureUrl(url, _this._textureFormatInUse);
  30880. if (fallbackUrl) {
  30881. // Add Back
  30882. customFallback = true;
  30883. excludeLoaders.push(loader);
  30884. _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");
  30885. _this.createTexture(urlArg, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture, undefined, undefined, excludeLoaders);
  30886. }
  30887. }
  30888. if (!customFallback) {
  30889. if (onLoadObserver) {
  30890. texture.onLoadedObservable.remove(onLoadObserver);
  30891. }
  30892. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].UseFallbackTexture) {
  30893. _this.createTexture(_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].fallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture);
  30894. }
  30895. }
  30896. if (onError) {
  30897. onError(message || "Unknown error", exception);
  30898. }
  30899. };
  30900. // processing for non-image formats
  30901. if (loader) {
  30902. var callback = function (data) {
  30903. loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {
  30904. if (loadFailed) {
  30905. onInternalError("TextureLoader failed to load data");
  30906. }
  30907. else {
  30908. _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {
  30909. done();
  30910. return false;
  30911. }, samplingMode);
  30912. }
  30913. });
  30914. };
  30915. if (!buffer) {
  30916. this._loadFile(url, callback, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
  30917. onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
  30918. });
  30919. }
  30920. else {
  30921. callback(buffer);
  30922. }
  30923. }
  30924. else {
  30925. var onload = function (img) {
  30926. if (fromBlob && !_this._doNotHandleContextLost) {
  30927. // We need to store the image if we need to rebuild the texture
  30928. // in case of a webgl context lost
  30929. texture._buffer = img;
  30930. }
  30931. _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {
  30932. var gl = _this._gl;
  30933. var isPot = (img.width === potWidth && img.height === potHeight);
  30934. var internalFormat = format ? _this._getInternalFormat(format) : ((extension === ".jpg") ? gl.RGB : gl.RGBA);
  30935. if (isPot) {
  30936. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  30937. return false;
  30938. }
  30939. var maxTextureSize = _this._caps.maxTextureSize;
  30940. if (img.width > maxTextureSize || img.height > maxTextureSize || Engine._RescalePostProcessFactory === null) {
  30941. _this._prepareWorkingCanvas();
  30942. if (!_this._workingCanvas || !_this._workingContext) {
  30943. return false;
  30944. }
  30945. _this._workingCanvas.width = potWidth;
  30946. _this._workingCanvas.height = potHeight;
  30947. _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
  30948. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  30949. texture.width = potWidth;
  30950. texture.height = potHeight;
  30951. return false;
  30952. }
  30953. else {
  30954. // Using shaders when possible to rescale because canvas.drawImage is lossy
  30955. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_TEMP);
  30956. _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
  30957. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  30958. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  30959. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  30960. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30961. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30962. _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
  30963. _this._releaseTexture(source_1);
  30964. _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  30965. continuationCallback();
  30966. });
  30967. }
  30968. return true;
  30969. }, samplingMode);
  30970. };
  30971. if (!fromData || isBase64) {
  30972. if (buffer instanceof HTMLImageElement) {
  30973. onload(buffer);
  30974. }
  30975. else {
  30976. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
  30977. }
  30978. }
  30979. else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
  30980. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
  30981. }
  30982. else {
  30983. onload(buffer);
  30984. }
  30985. }
  30986. return texture;
  30987. };
  30988. Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {
  30989. var _this = this;
  30990. var rtt = this.createRenderTargetTexture({
  30991. width: destination.width,
  30992. height: destination.height,
  30993. }, {
  30994. generateMipMaps: false,
  30995. type: Engine.TEXTURETYPE_UNSIGNED_INT,
  30996. samplingMode: Engine.TEXTURE_BILINEAR_SAMPLINGMODE,
  30997. generateDepthBuffer: false,
  30998. generateStencilBuffer: false
  30999. });
  31000. if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {
  31001. this._rescalePostProcess = Engine._RescalePostProcessFactory(this);
  31002. }
  31003. this._rescalePostProcess.getEffect().executeWhenCompiled(function () {
  31004. _this._rescalePostProcess.onApply = function (effect) {
  31005. effect._bindTexture("textureSampler", source);
  31006. };
  31007. var hostingScene = scene;
  31008. if (!hostingScene) {
  31009. hostingScene = _this.scenes[_this.scenes.length - 1];
  31010. }
  31011. hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);
  31012. _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);
  31013. _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);
  31014. _this.unBindFramebuffer(rtt);
  31015. _this._releaseTexture(rtt);
  31016. if (onComplete) {
  31017. onComplete();
  31018. }
  31019. });
  31020. };
  31021. /**
  31022. * Update a raw texture
  31023. * @param texture defines the texture to update
  31024. * @param data defines the data to store in the texture
  31025. * @param format defines the format of the data
  31026. * @param invertY defines if data must be stored with Y axis inverted
  31027. * @param compression defines the compression used (null by default)
  31028. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31029. */
  31030. Engine.prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
  31031. if (compression === void 0) { compression = null; }
  31032. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31033. if (!texture) {
  31034. return;
  31035. }
  31036. // babylon's internalSizedFomat but gl's texImage2D internalFormat
  31037. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format);
  31038. // babylon's internalFormat but gl's texImage2D format
  31039. var internalFormat = this._getInternalFormat(format);
  31040. var textureType = this._getWebGLTextureType(type);
  31041. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31042. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31043. if (!this._doNotHandleContextLost) {
  31044. texture._bufferView = data;
  31045. texture.format = format;
  31046. texture.type = type;
  31047. texture.invertY = invertY;
  31048. texture._compression = compression;
  31049. }
  31050. if (texture.width % 4 !== 0) {
  31051. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  31052. }
  31053. if (compression && data) {
  31054. this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
  31055. }
  31056. else {
  31057. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
  31058. }
  31059. if (texture.generateMipMaps) {
  31060. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31061. }
  31062. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31063. // this.resetTextureCache();
  31064. texture.isReady = true;
  31065. };
  31066. /**
  31067. * Creates a raw texture
  31068. * @param data defines the data to store in the texture
  31069. * @param width defines the width of the texture
  31070. * @param height defines the height of the texture
  31071. * @param format defines the format of the data
  31072. * @param generateMipMaps defines if the engine should generate the mip levels
  31073. * @param invertY defines if data must be stored with Y axis inverted
  31074. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31075. * @param compression defines the compression used (null by default)
  31076. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31077. * @returns the raw texture inside an InternalTexture
  31078. */
  31079. Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  31080. if (compression === void 0) { compression = null; }
  31081. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31082. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW);
  31083. texture.baseWidth = width;
  31084. texture.baseHeight = height;
  31085. texture.width = width;
  31086. texture.height = height;
  31087. texture.format = format;
  31088. texture.generateMipMaps = generateMipMaps;
  31089. texture.samplingMode = samplingMode;
  31090. texture.invertY = invertY;
  31091. texture._compression = compression;
  31092. texture.type = type;
  31093. if (!this._doNotHandleContextLost) {
  31094. texture._bufferView = data;
  31095. }
  31096. this.updateRawTexture(texture, data, format, invertY, compression, type);
  31097. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31098. // Filters
  31099. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31100. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  31101. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31102. if (generateMipMaps) {
  31103. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31104. }
  31105. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31106. this._internalTexturesCache.push(texture);
  31107. return texture;
  31108. };
  31109. /** @hidden */
  31110. Engine.prototype._unpackFlipY = function (value) {
  31111. if (this._unpackFlipYCached !== value) {
  31112. this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
  31113. if (this.enableUnpackFlipYCached) {
  31114. this._unpackFlipYCached = value;
  31115. }
  31116. }
  31117. };
  31118. /** @hidden */
  31119. Engine.prototype._getUnpackAlignement = function () {
  31120. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
  31121. };
  31122. /**
  31123. * Creates a dynamic texture
  31124. * @param width defines the width of the texture
  31125. * @param height defines the height of the texture
  31126. * @param generateMipMaps defines if the engine should generate the mip levels
  31127. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31128. * @returns the dynamic texture inside an InternalTexture
  31129. */
  31130. Engine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
  31131. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DYNAMIC);
  31132. texture.baseWidth = width;
  31133. texture.baseHeight = height;
  31134. if (generateMipMaps) {
  31135. width = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
  31136. height = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
  31137. }
  31138. // this.resetTextureCache();
  31139. texture.width = width;
  31140. texture.height = height;
  31141. texture.isReady = false;
  31142. texture.generateMipMaps = generateMipMaps;
  31143. texture.samplingMode = samplingMode;
  31144. this.updateTextureSamplingMode(samplingMode, texture);
  31145. this._internalTexturesCache.push(texture);
  31146. return texture;
  31147. };
  31148. /**
  31149. * Update the sampling mode of a given texture
  31150. * @param samplingMode defines the required sampling mode
  31151. * @param texture defines the texture to update
  31152. */
  31153. Engine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  31154. var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps);
  31155. if (texture.isCube) {
  31156. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31157. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31158. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31159. }
  31160. else if (texture.is3D) {
  31161. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31162. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31163. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31164. }
  31165. else {
  31166. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31167. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31168. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31169. }
  31170. texture.samplingMode = samplingMode;
  31171. };
  31172. /**
  31173. * Update the content of a dynamic texture
  31174. * @param texture defines the texture to update
  31175. * @param canvas defines the canvas containing the source
  31176. * @param invertY defines if data must be stored with Y axis inverted
  31177. * @param premulAlpha defines if alpha is stored as premultiplied
  31178. * @param format defines the format of the data
  31179. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31180. */
  31181. Engine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format, forceBindTexture) {
  31182. if (premulAlpha === void 0) { premulAlpha = false; }
  31183. if (forceBindTexture === void 0) { forceBindTexture = false; }
  31184. if (!texture) {
  31185. return;
  31186. }
  31187. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true, forceBindTexture);
  31188. this._unpackFlipY(invertY);
  31189. if (premulAlpha) {
  31190. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  31191. }
  31192. var internalFormat = format ? this._getInternalFormat(format) : this._gl.RGBA;
  31193. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, internalFormat, this._gl.UNSIGNED_BYTE, canvas);
  31194. if (texture.generateMipMaps) {
  31195. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31196. }
  31197. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31198. if (premulAlpha) {
  31199. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
  31200. }
  31201. texture.isReady = true;
  31202. };
  31203. /**
  31204. * Update a video texture
  31205. * @param texture defines the texture to update
  31206. * @param video defines the video element to use
  31207. * @param invertY defines if data must be stored with Y axis inverted
  31208. */
  31209. Engine.prototype.updateVideoTexture = function (texture, video, invertY) {
  31210. if (!texture || texture._isDisabled) {
  31211. return;
  31212. }
  31213. var wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31214. this._unpackFlipY(!invertY); // Video are upside down by default
  31215. try {
  31216. // Testing video texture support
  31217. if (this._videoTextureSupported === undefined) {
  31218. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31219. if (this._gl.getError() !== 0) {
  31220. this._videoTextureSupported = false;
  31221. }
  31222. else {
  31223. this._videoTextureSupported = true;
  31224. }
  31225. }
  31226. // Copy video through the current working canvas if video texture is not supported
  31227. if (!this._videoTextureSupported) {
  31228. if (!texture._workingCanvas) {
  31229. texture._workingCanvas = document.createElement("canvas");
  31230. var context = texture._workingCanvas.getContext("2d");
  31231. if (!context) {
  31232. throw new Error("Unable to get 2d context");
  31233. }
  31234. texture._workingContext = context;
  31235. texture._workingCanvas.width = texture.width;
  31236. texture._workingCanvas.height = texture.height;
  31237. }
  31238. texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
  31239. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
  31240. }
  31241. else {
  31242. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31243. }
  31244. if (texture.generateMipMaps) {
  31245. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31246. }
  31247. if (!wasPreviouslyBound) {
  31248. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31249. }
  31250. // this.resetTextureCache();
  31251. texture.isReady = true;
  31252. }
  31253. catch (ex) {
  31254. // Something unexpected
  31255. // Let's disable the texture
  31256. texture._isDisabled = true;
  31257. }
  31258. };
  31259. /**
  31260. * Updates a depth texture Comparison Mode and Function.
  31261. * If the comparison Function is equal to 0, the mode will be set to none.
  31262. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31263. * @param texture The texture to set the comparison function for
  31264. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31265. */
  31266. Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {
  31267. if (this.webGLVersion === 1) {
  31268. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("WebGL 1 does not support texture comparison.");
  31269. return;
  31270. }
  31271. var gl = this._gl;
  31272. if (texture.isCube) {
  31273. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  31274. if (comparisonFunction === 0) {
  31275. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31276. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31277. }
  31278. else {
  31279. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31280. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31281. }
  31282. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31283. }
  31284. else {
  31285. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31286. if (comparisonFunction === 0) {
  31287. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31288. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31289. }
  31290. else {
  31291. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31292. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31293. }
  31294. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31295. }
  31296. texture._comparisonFunction = comparisonFunction;
  31297. };
  31298. Engine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {
  31299. var width = size.width || size;
  31300. var height = size.height || size;
  31301. internalTexture.baseWidth = width;
  31302. internalTexture.baseHeight = height;
  31303. internalTexture.width = width;
  31304. internalTexture.height = height;
  31305. internalTexture.isReady = true;
  31306. internalTexture.samples = 1;
  31307. internalTexture.generateMipMaps = false;
  31308. internalTexture._generateDepthBuffer = true;
  31309. internalTexture._generateStencilBuffer = generateStencil;
  31310. internalTexture.samplingMode = bilinearFiltering ? Engine.TEXTURE_BILINEAR_SAMPLINGMODE : Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31311. internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31312. internalTexture._comparisonFunction = comparisonFunction;
  31313. var gl = this._gl;
  31314. var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31315. var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);
  31316. gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
  31317. gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
  31318. gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31319. gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31320. if (comparisonFunction === 0) {
  31321. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31322. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31323. }
  31324. else {
  31325. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31326. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31327. }
  31328. };
  31329. /**
  31330. * Creates a depth stencil texture.
  31331. * This is only available in WebGL 2 or with the depth texture extension available.
  31332. * @param size The size of face edge in the texture.
  31333. * @param options The options defining the texture.
  31334. * @returns The texture
  31335. */
  31336. Engine.prototype.createDepthStencilTexture = function (size, options) {
  31337. if (options.isCube) {
  31338. var width = size.width || size;
  31339. return this._createDepthStencilCubeTexture(width, options);
  31340. }
  31341. else {
  31342. return this._createDepthStencilTexture(size, options);
  31343. }
  31344. };
  31345. /**
  31346. * Creates a depth stencil texture.
  31347. * This is only available in WebGL 2 or with the depth texture extension available.
  31348. * @param size The size of face edge in the texture.
  31349. * @param options The options defining the texture.
  31350. * @returns The texture
  31351. */
  31352. Engine.prototype._createDepthStencilTexture = function (size, options) {
  31353. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DEPTHTEXTURE);
  31354. if (!this._caps.depthTextureExtension) {
  31355. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth texture is not supported by your browser or hardware.");
  31356. return internalTexture;
  31357. }
  31358. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  31359. var gl = this._gl;
  31360. this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
  31361. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  31362. if (this.webGLVersion > 1) {
  31363. if (internalOptions.generateStencil) {
  31364. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  31365. }
  31366. else {
  31367. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31368. }
  31369. }
  31370. else {
  31371. if (internalOptions.generateStencil) {
  31372. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  31373. }
  31374. else {
  31375. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31376. }
  31377. }
  31378. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31379. return internalTexture;
  31380. };
  31381. /**
  31382. * Creates a depth stencil cube texture.
  31383. * This is only available in WebGL 2.
  31384. * @param size The size of face edge in the cube texture.
  31385. * @param options The options defining the cube texture.
  31386. * @returns The cube texture
  31387. */
  31388. Engine.prototype._createDepthStencilCubeTexture = function (size, options) {
  31389. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_UNKNOWN);
  31390. internalTexture.isCube = true;
  31391. if (this.webGLVersion === 1) {
  31392. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth cube texture is not supported by WebGL 1.");
  31393. return internalTexture;
  31394. }
  31395. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  31396. var gl = this._gl;
  31397. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
  31398. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  31399. // Create the depth/stencil buffer
  31400. for (var face = 0; face < 6; face++) {
  31401. if (internalOptions.generateStencil) {
  31402. 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);
  31403. }
  31404. else {
  31405. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31406. }
  31407. }
  31408. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31409. return internalTexture;
  31410. };
  31411. /**
  31412. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31413. * @param renderTarget The render target to set the frame buffer for
  31414. */
  31415. Engine.prototype.setFrameBufferDepthStencilTexture = function (renderTarget) {
  31416. // Create the framebuffer
  31417. var internalTexture = renderTarget.getInternalTexture();
  31418. if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
  31419. return;
  31420. }
  31421. var gl = this._gl;
  31422. var depthStencilTexture = renderTarget.depthStencilTexture;
  31423. this.bindUnboundFramebuffer(internalTexture._framebuffer);
  31424. if (depthStencilTexture.isCube) {
  31425. if (depthStencilTexture._generateStencilBuffer) {
  31426. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  31427. }
  31428. else {
  31429. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  31430. }
  31431. }
  31432. else {
  31433. if (depthStencilTexture._generateStencilBuffer) {
  31434. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  31435. }
  31436. else {
  31437. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  31438. }
  31439. }
  31440. this.bindUnboundFramebuffer(null);
  31441. };
  31442. /**
  31443. * Creates a new render target texture
  31444. * @param size defines the size of the texture
  31445. * @param options defines the options used to create the texture
  31446. * @returns a new render target texture stored in an InternalTexture
  31447. */
  31448. Engine.prototype.createRenderTargetTexture = function (size, options) {
  31449. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__["RenderTargetCreationOptions"]();
  31450. if (options !== undefined && typeof options === "object") {
  31451. fullOptions.generateMipMaps = options.generateMipMaps;
  31452. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  31453. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  31454. fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
  31455. fullOptions.samplingMode = options.samplingMode === undefined ? Engine.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  31456. fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
  31457. }
  31458. else {
  31459. fullOptions.generateMipMaps = options;
  31460. fullOptions.generateDepthBuffer = true;
  31461. fullOptions.generateStencilBuffer = false;
  31462. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31463. fullOptions.samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  31464. fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
  31465. }
  31466. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31467. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31468. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31469. }
  31470. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31471. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31472. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31473. }
  31474. var gl = this._gl;
  31475. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  31476. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31477. var width = size.width || size;
  31478. var height = size.height || size;
  31479. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps ? true : false);
  31480. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31481. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31482. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  31483. }
  31484. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  31485. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  31486. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31487. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31488. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  31489. // Create the framebuffer
  31490. var currentFrameBuffer = this._currentFramebuffer;
  31491. var framebuffer = gl.createFramebuffer();
  31492. this.bindUnboundFramebuffer(framebuffer);
  31493. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
  31494. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, width, height);
  31495. if (fullOptions.generateMipMaps) {
  31496. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31497. }
  31498. // Unbind
  31499. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31500. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31501. this.bindUnboundFramebuffer(currentFrameBuffer);
  31502. texture._framebuffer = framebuffer;
  31503. texture.baseWidth = width;
  31504. texture.baseHeight = height;
  31505. texture.width = width;
  31506. texture.height = height;
  31507. texture.isReady = true;
  31508. texture.samples = 1;
  31509. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  31510. texture.samplingMode = fullOptions.samplingMode;
  31511. texture.type = fullOptions.type;
  31512. texture.format = fullOptions.format;
  31513. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  31514. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  31515. // this.resetTextureCache();
  31516. this._internalTexturesCache.push(texture);
  31517. return texture;
  31518. };
  31519. /**
  31520. * Create a multi render target texture
  31521. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  31522. * @param size defines the size of the texture
  31523. * @param options defines the creation options
  31524. * @returns the cube texture as an InternalTexture
  31525. */
  31526. Engine.prototype.createMultipleRenderTarget = function (size, options) {
  31527. var generateMipMaps = false;
  31528. var generateDepthBuffer = true;
  31529. var generateStencilBuffer = false;
  31530. var generateDepthTexture = false;
  31531. var textureCount = 1;
  31532. var defaultType = Engine.TEXTURETYPE_UNSIGNED_INT;
  31533. var defaultSamplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  31534. var types = new Array();
  31535. var samplingModes = new Array();
  31536. if (options !== undefined) {
  31537. generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
  31538. generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  31539. generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  31540. generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;
  31541. textureCount = options.textureCount || 1;
  31542. if (options.types) {
  31543. types = options.types;
  31544. }
  31545. if (options.samplingModes) {
  31546. samplingModes = options.samplingModes;
  31547. }
  31548. }
  31549. var gl = this._gl;
  31550. // Create the framebuffer
  31551. var framebuffer = gl.createFramebuffer();
  31552. this.bindUnboundFramebuffer(framebuffer);
  31553. var width = size.width || size;
  31554. var height = size.height || size;
  31555. var textures = [];
  31556. var attachments = [];
  31557. var depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
  31558. for (var i = 0; i < textureCount; i++) {
  31559. var samplingMode = samplingModes[i] || defaultSamplingMode;
  31560. var type = types[i] || defaultType;
  31561. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31562. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31563. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31564. }
  31565. else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31566. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31567. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31568. }
  31569. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31570. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31571. type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31572. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  31573. }
  31574. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  31575. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  31576. textures.push(texture);
  31577. attachments.push(attachment);
  31578. gl.activeTexture(gl["TEXTURE" + i]);
  31579. gl.bindTexture(gl.TEXTURE_2D, texture._webGLTexture);
  31580. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  31581. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  31582. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31583. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31584. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  31585. gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._webGLTexture, 0);
  31586. if (generateMipMaps) {
  31587. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31588. }
  31589. // Unbind
  31590. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31591. texture._framebuffer = framebuffer;
  31592. texture._depthStencilBuffer = depthStencilBuffer;
  31593. texture.baseWidth = width;
  31594. texture.baseHeight = height;
  31595. texture.width = width;
  31596. texture.height = height;
  31597. texture.isReady = true;
  31598. texture.samples = 1;
  31599. texture.generateMipMaps = generateMipMaps;
  31600. texture.samplingMode = samplingMode;
  31601. texture.type = type;
  31602. texture._generateDepthBuffer = generateDepthBuffer;
  31603. texture._generateStencilBuffer = generateStencilBuffer;
  31604. texture._attachments = attachments;
  31605. this._internalTexturesCache.push(texture);
  31606. }
  31607. if (generateDepthTexture && this._caps.depthTextureExtension) {
  31608. // Depth texture
  31609. var depthTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  31610. gl.activeTexture(gl.TEXTURE0);
  31611. gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);
  31612. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  31613. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  31614. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31615. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31616. 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);
  31617. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._webGLTexture, 0);
  31618. depthTexture._framebuffer = framebuffer;
  31619. depthTexture.baseWidth = width;
  31620. depthTexture.baseHeight = height;
  31621. depthTexture.width = width;
  31622. depthTexture.height = height;
  31623. depthTexture.isReady = true;
  31624. depthTexture.samples = 1;
  31625. depthTexture.generateMipMaps = generateMipMaps;
  31626. depthTexture.samplingMode = gl.NEAREST;
  31627. depthTexture._generateDepthBuffer = generateDepthBuffer;
  31628. depthTexture._generateStencilBuffer = generateStencilBuffer;
  31629. textures.push(depthTexture);
  31630. this._internalTexturesCache.push(depthTexture);
  31631. }
  31632. gl.drawBuffers(attachments);
  31633. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31634. this.bindUnboundFramebuffer(null);
  31635. this.resetTextureCache();
  31636. return textures;
  31637. };
  31638. Engine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {
  31639. if (samples === void 0) { samples = 1; }
  31640. var depthStencilBuffer = null;
  31641. var gl = this._gl;
  31642. // Create the depth/stencil buffer
  31643. if (generateStencilBuffer) {
  31644. depthStencilBuffer = gl.createRenderbuffer();
  31645. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  31646. if (samples > 1) {
  31647. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
  31648. }
  31649. else {
  31650. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
  31651. }
  31652. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  31653. }
  31654. else if (generateDepthBuffer) {
  31655. depthStencilBuffer = gl.createRenderbuffer();
  31656. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  31657. if (samples > 1) {
  31658. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
  31659. }
  31660. else {
  31661. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
  31662. }
  31663. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  31664. }
  31665. return depthStencilBuffer;
  31666. };
  31667. /**
  31668. * Updates the sample count of a render target texture
  31669. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31670. * @param texture defines the texture to update
  31671. * @param samples defines the sample count to set
  31672. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31673. */
  31674. Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {
  31675. if (this.webGLVersion < 2 || !texture) {
  31676. return 1;
  31677. }
  31678. if (texture.samples === samples) {
  31679. return samples;
  31680. }
  31681. var gl = this._gl;
  31682. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  31683. // Dispose previous render buffers
  31684. if (texture._depthStencilBuffer) {
  31685. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  31686. texture._depthStencilBuffer = null;
  31687. }
  31688. if (texture._MSAAFramebuffer) {
  31689. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  31690. texture._MSAAFramebuffer = null;
  31691. }
  31692. if (texture._MSAARenderBuffer) {
  31693. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  31694. texture._MSAARenderBuffer = null;
  31695. }
  31696. if (samples > 1) {
  31697. var framebuffer = gl.createFramebuffer();
  31698. if (!framebuffer) {
  31699. throw new Error("Unable to create multi sampled framebuffer");
  31700. }
  31701. texture._MSAAFramebuffer = framebuffer;
  31702. this.bindUnboundFramebuffer(texture._MSAAFramebuffer);
  31703. var colorRenderbuffer = gl.createRenderbuffer();
  31704. if (!colorRenderbuffer) {
  31705. throw new Error("Unable to create multi sampled framebuffer");
  31706. }
  31707. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  31708. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  31709. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);
  31710. texture._MSAARenderBuffer = colorRenderbuffer;
  31711. }
  31712. else {
  31713. this.bindUnboundFramebuffer(texture._framebuffer);
  31714. }
  31715. texture.samples = samples;
  31716. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);
  31717. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31718. this.bindUnboundFramebuffer(null);
  31719. return samples;
  31720. };
  31721. /**
  31722. * Update the sample count for a given multiple render target texture
  31723. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31724. * @param textures defines the textures to update
  31725. * @param samples defines the sample count to set
  31726. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31727. */
  31728. Engine.prototype.updateMultipleRenderTargetTextureSampleCount = function (textures, samples) {
  31729. if (this.webGLVersion < 2 || !textures || textures.length == 0) {
  31730. return 1;
  31731. }
  31732. if (textures[0].samples === samples) {
  31733. return samples;
  31734. }
  31735. var gl = this._gl;
  31736. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  31737. // Dispose previous render buffers
  31738. if (textures[0]._depthStencilBuffer) {
  31739. gl.deleteRenderbuffer(textures[0]._depthStencilBuffer);
  31740. textures[0]._depthStencilBuffer = null;
  31741. }
  31742. if (textures[0]._MSAAFramebuffer) {
  31743. gl.deleteFramebuffer(textures[0]._MSAAFramebuffer);
  31744. textures[0]._MSAAFramebuffer = null;
  31745. }
  31746. for (var i = 0; i < textures.length; i++) {
  31747. if (textures[i]._MSAARenderBuffer) {
  31748. gl.deleteRenderbuffer(textures[i]._MSAARenderBuffer);
  31749. textures[i]._MSAARenderBuffer = null;
  31750. }
  31751. }
  31752. if (samples > 1) {
  31753. var framebuffer = gl.createFramebuffer();
  31754. if (!framebuffer) {
  31755. throw new Error("Unable to create multi sampled framebuffer");
  31756. }
  31757. this.bindUnboundFramebuffer(framebuffer);
  31758. var depthStencilBuffer = this._setupFramebufferDepthAttachments(textures[0]._generateStencilBuffer, textures[0]._generateDepthBuffer, textures[0].width, textures[0].height, samples);
  31759. var attachments = [];
  31760. for (var i = 0; i < textures.length; i++) {
  31761. var texture = textures[i];
  31762. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  31763. var colorRenderbuffer = gl.createRenderbuffer();
  31764. if (!colorRenderbuffer) {
  31765. throw new Error("Unable to create multi sampled framebuffer");
  31766. }
  31767. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  31768. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  31769. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, colorRenderbuffer);
  31770. texture._MSAAFramebuffer = framebuffer;
  31771. texture._MSAARenderBuffer = colorRenderbuffer;
  31772. texture.samples = samples;
  31773. texture._depthStencilBuffer = depthStencilBuffer;
  31774. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31775. attachments.push(attachment);
  31776. }
  31777. gl.drawBuffers(attachments);
  31778. }
  31779. else {
  31780. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  31781. }
  31782. this.bindUnboundFramebuffer(null);
  31783. return samples;
  31784. };
  31785. /** @hidden */
  31786. Engine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  31787. if (faceIndex === void 0) { faceIndex = 0; }
  31788. if (lod === void 0) { lod = 0; }
  31789. var gl = this._gl;
  31790. var target = gl.TEXTURE_2D;
  31791. if (texture.isCube) {
  31792. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31793. }
  31794. this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
  31795. };
  31796. /** @hidden */
  31797. Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  31798. if (faceIndex === void 0) { faceIndex = 0; }
  31799. if (lod === void 0) { lod = 0; }
  31800. var gl = this._gl;
  31801. var textureType = this._getWebGLTextureType(texture.type);
  31802. var format = this._getInternalFormat(texture.format);
  31803. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  31804. this._unpackFlipY(texture.invertY);
  31805. var target = gl.TEXTURE_2D;
  31806. if (texture.isCube) {
  31807. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31808. }
  31809. var lodMaxWidth = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.width));
  31810. var lodMaxHeight = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.height));
  31811. var width = Math.pow(2, Math.max(lodMaxWidth - lod, 0));
  31812. var height = Math.pow(2, Math.max(lodMaxHeight - lod, 0));
  31813. gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
  31814. };
  31815. /** @hidden */
  31816. Engine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  31817. if (faceIndex === void 0) { faceIndex = 0; }
  31818. if (lod === void 0) { lod = 0; }
  31819. var gl = this._gl;
  31820. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31821. this._bindTextureDirectly(bindTarget, texture, true);
  31822. this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
  31823. this._bindTextureDirectly(bindTarget, null, true);
  31824. };
  31825. /** @hidden */
  31826. Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  31827. if (faceIndex === void 0) { faceIndex = 0; }
  31828. if (lod === void 0) { lod = 0; }
  31829. var gl = this._gl;
  31830. var textureType = this._getWebGLTextureType(texture.type);
  31831. var format = this._getInternalFormat(texture.format);
  31832. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  31833. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31834. this._bindTextureDirectly(bindTarget, texture, true);
  31835. this._unpackFlipY(texture.invertY);
  31836. var target = gl.TEXTURE_2D;
  31837. if (texture.isCube) {
  31838. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31839. }
  31840. gl.texImage2D(target, lod, internalFormat, format, textureType, image);
  31841. this._bindTextureDirectly(bindTarget, null, true);
  31842. };
  31843. /**
  31844. * Creates a new render target cube texture
  31845. * @param size defines the size of the texture
  31846. * @param options defines the options used to create the texture
  31847. * @returns a new render target cube texture stored in an InternalTexture
  31848. */
  31849. Engine.prototype.createRenderTargetCubeTexture = function (size, options) {
  31850. 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);
  31851. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
  31852. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31853. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31854. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31855. }
  31856. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31857. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31858. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31859. }
  31860. var gl = this._gl;
  31861. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  31862. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31863. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);
  31864. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31865. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31866. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
  31867. }
  31868. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  31869. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  31870. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31871. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31872. for (var face = 0; face < 6; face++) {
  31873. 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);
  31874. }
  31875. // Create the framebuffer
  31876. var framebuffer = gl.createFramebuffer();
  31877. this.bindUnboundFramebuffer(framebuffer);
  31878. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, size, size);
  31879. // MipMaps
  31880. if (fullOptions.generateMipMaps) {
  31881. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  31882. }
  31883. // Unbind
  31884. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31885. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31886. this.bindUnboundFramebuffer(null);
  31887. texture._framebuffer = framebuffer;
  31888. texture.width = size;
  31889. texture.height = size;
  31890. texture.isReady = true;
  31891. texture.isCube = true;
  31892. texture.samples = 1;
  31893. texture.generateMipMaps = fullOptions.generateMipMaps;
  31894. texture.samplingMode = fullOptions.samplingMode;
  31895. texture.type = fullOptions.type;
  31896. texture.format = fullOptions.format;
  31897. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  31898. texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
  31899. this._internalTexturesCache.push(texture);
  31900. return texture;
  31901. };
  31902. /**
  31903. * Creates a cube texture
  31904. * @param rootUrl defines the url where the files to load is located
  31905. * @param scene defines the current scene
  31906. * @param files defines the list of files to load (1 per face)
  31907. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  31908. * @param onLoad defines an optional callback raised when the texture is loaded
  31909. * @param onError defines an optional callback raised if there is an issue to load the texture
  31910. * @param format defines the format of the data
  31911. * @param forcedExtension defines the extension to use to pick the right loader
  31912. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  31913. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  31914. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  31915. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  31916. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  31917. * @returns the cube texture as an InternalTexture
  31918. */
  31919. Engine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders) {
  31920. var _this = this;
  31921. if (onLoad === void 0) { onLoad = null; }
  31922. if (onError === void 0) { onError = null; }
  31923. if (forcedExtension === void 0) { forcedExtension = null; }
  31924. if (createPolynomials === void 0) { createPolynomials = false; }
  31925. if (lodScale === void 0) { lodScale = 0; }
  31926. if (lodOffset === void 0) { lodOffset = 0; }
  31927. if (fallback === void 0) { fallback = null; }
  31928. if (excludeLoaders === void 0) { excludeLoaders = []; }
  31929. var gl = this._gl;
  31930. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBE);
  31931. texture.isCube = true;
  31932. texture.url = rootUrl;
  31933. texture.generateMipMaps = !noMipmap;
  31934. texture._lodGenerationScale = lodScale;
  31935. texture._lodGenerationOffset = lodOffset;
  31936. if (!this._doNotHandleContextLost) {
  31937. texture._extension = forcedExtension;
  31938. texture._files = files;
  31939. }
  31940. var lastDot = rootUrl.lastIndexOf('.');
  31941. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  31942. var loader = null;
  31943. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  31944. var availableLoader = _a[_i];
  31945. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, false, false)) {
  31946. loader = availableLoader;
  31947. break;
  31948. }
  31949. }
  31950. var onInternalError = function (request, exception) {
  31951. if (loader) {
  31952. var fallbackUrl = loader.getFallbackTextureUrl(texture.url, _this._textureFormatInUse);
  31953. _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");
  31954. if (fallbackUrl) {
  31955. excludeLoaders.push(loader);
  31956. _this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
  31957. return;
  31958. }
  31959. }
  31960. if (onError && request) {
  31961. onError(request.status + " " + request.statusText, exception);
  31962. }
  31963. };
  31964. if (loader) {
  31965. rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
  31966. var onloaddata = function (data) {
  31967. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31968. loader.loadCubeData(data, texture, createPolynomials, onLoad, onError);
  31969. };
  31970. if (files && files.length === 6) {
  31971. if (loader.supportCascades) {
  31972. this._cascadeLoadFiles(scene, onloaddata, files, onError);
  31973. }
  31974. else if (onError) {
  31975. onError("Textures type does not support cascades.");
  31976. }
  31977. }
  31978. else {
  31979. this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
  31980. }
  31981. }
  31982. else {
  31983. if (!files) {
  31984. throw new Error("Cannot load cubemap because files were not defined");
  31985. }
  31986. this._cascadeLoadImgs(scene, function (imgs) {
  31987. var width = _this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(imgs[0].width, _this._caps.maxCubemapTextureSize) : imgs[0].width;
  31988. var height = width;
  31989. _this._prepareWorkingCanvas();
  31990. if (!_this._workingCanvas || !_this._workingContext) {
  31991. return;
  31992. }
  31993. _this._workingCanvas.width = width;
  31994. _this._workingCanvas.height = height;
  31995. var faces = [
  31996. gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
  31997. gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
  31998. ];
  31999. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32000. _this._unpackFlipY(false);
  32001. var internalFormat = format ? _this._getInternalFormat(format) : _this._gl.RGBA;
  32002. for (var index = 0; index < faces.length; index++) {
  32003. _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
  32004. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  32005. }
  32006. if (!noMipmap) {
  32007. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32008. }
  32009. _this._setCubeMapTextureParams(!noMipmap);
  32010. texture.width = width;
  32011. texture.height = height;
  32012. texture.isReady = true;
  32013. if (format) {
  32014. texture.format = format;
  32015. }
  32016. texture.onLoadedObservable.notifyObservers(texture);
  32017. texture.onLoadedObservable.clear();
  32018. if (onLoad) {
  32019. onLoad();
  32020. }
  32021. }, files, onError);
  32022. }
  32023. this._internalTexturesCache.push(texture);
  32024. return texture;
  32025. };
  32026. /**
  32027. * @hidden
  32028. */
  32029. Engine.prototype._setCubeMapTextureParams = function (loadMipmap) {
  32030. var gl = this._gl;
  32031. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  32032. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  32033. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32034. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32035. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32036. // this.resetTextureCache();
  32037. };
  32038. /**
  32039. * Update a raw cube texture
  32040. * @param texture defines the texture to udpdate
  32041. * @param data defines the data to store
  32042. * @param format defines the data format
  32043. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32044. * @param invertY defines if data must be stored with Y axis inverted
  32045. * @param compression defines the compression used (null by default)
  32046. * @param level defines which level of the texture to update
  32047. */
  32048. Engine.prototype.updateRawCubeTexture = function (texture, data, format, type, invertY, compression, level) {
  32049. if (compression === void 0) { compression = null; }
  32050. if (level === void 0) { level = 0; }
  32051. texture._bufferViewArray = data;
  32052. texture.format = format;
  32053. texture.type = type;
  32054. texture.invertY = invertY;
  32055. texture._compression = compression;
  32056. var gl = this._gl;
  32057. var textureType = this._getWebGLTextureType(type);
  32058. var internalFormat = this._getInternalFormat(format);
  32059. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
  32060. var needConversion = false;
  32061. if (internalFormat === gl.RGB) {
  32062. internalFormat = gl.RGBA;
  32063. needConversion = true;
  32064. }
  32065. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32066. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32067. if (texture.width % 4 !== 0) {
  32068. gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
  32069. }
  32070. // Data are known to be in +X +Y +Z -X -Y -Z
  32071. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32072. var faceData = data[faceIndex];
  32073. if (compression) {
  32074. gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, (this.getCaps().s3tc)[compression], texture.width, texture.height, 0, faceData);
  32075. }
  32076. else {
  32077. if (needConversion) {
  32078. faceData = this._convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);
  32079. }
  32080. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);
  32081. }
  32082. }
  32083. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  32084. if (isPot && texture.generateMipMaps && level === 0) {
  32085. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  32086. }
  32087. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32088. // this.resetTextureCache();
  32089. texture.isReady = true;
  32090. };
  32091. /**
  32092. * Creates a new raw cube texture
  32093. * @param data defines the array of data to use to create each face
  32094. * @param size defines the size of the textures
  32095. * @param format defines the format of the data
  32096. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32097. * @param generateMipMaps defines if the engine should generate the mip levels
  32098. * @param invertY defines if data must be stored with Y axis inverted
  32099. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32100. * @param compression defines the compression used (null by default)
  32101. * @returns the cube texture as an InternalTexture
  32102. */
  32103. Engine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  32104. if (compression === void 0) { compression = null; }
  32105. var gl = this._gl;
  32106. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBERAW);
  32107. texture.isCube = true;
  32108. texture.format = format;
  32109. texture.type = type;
  32110. if (!this._doNotHandleContextLost) {
  32111. texture._bufferViewArray = data;
  32112. }
  32113. var textureType = this._getWebGLTextureType(type);
  32114. var internalFormat = this._getInternalFormat(format);
  32115. if (internalFormat === gl.RGB) {
  32116. internalFormat = gl.RGBA;
  32117. }
  32118. // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable
  32119. if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
  32120. generateMipMaps = false;
  32121. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32122. _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.");
  32123. }
  32124. else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
  32125. generateMipMaps = false;
  32126. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32127. _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.");
  32128. }
  32129. else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
  32130. generateMipMaps = false;
  32131. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to float textures is not supported. Mipmap generation forced to false.");
  32132. }
  32133. else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
  32134. generateMipMaps = false;
  32135. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
  32136. }
  32137. var width = size;
  32138. var height = width;
  32139. texture.width = width;
  32140. texture.height = height;
  32141. // Double check on POT to generate Mips.
  32142. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  32143. if (!isPot) {
  32144. generateMipMaps = false;
  32145. }
  32146. // Upload data if needed. The texture won't be ready until then.
  32147. if (data) {
  32148. this.updateRawCubeTexture(texture, data, format, type, invertY, compression);
  32149. }
  32150. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  32151. // Filters
  32152. if (data && generateMipMaps) {
  32153. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  32154. }
  32155. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32156. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  32157. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  32158. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32159. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32160. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32161. texture.generateMipMaps = generateMipMaps;
  32162. return texture;
  32163. };
  32164. /**
  32165. * Creates a new raw cube texture from a specified url
  32166. * @param url defines the url where the data is located
  32167. * @param scene defines the current scene
  32168. * @param size defines the size of the textures
  32169. * @param format defines the format of the data
  32170. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32171. * @param noMipmap defines if the engine should avoid generating the mip levels
  32172. * @param callback defines a callback used to extract texture data from loaded data
  32173. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  32174. * @param onLoad defines a callback called when texture is loaded
  32175. * @param onError defines a callback called if there is an error
  32176. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32177. * @param invertY defines if data must be stored with Y axis inverted
  32178. * @returns the cube texture as an InternalTexture
  32179. */
  32180. Engine.prototype.createRawCubeTextureFromUrl = function (url, scene, size, format, type, noMipmap, callback, mipmapGenerator, onLoad, onError, samplingMode, invertY) {
  32181. var _this = this;
  32182. if (onLoad === void 0) { onLoad = null; }
  32183. if (onError === void 0) { onError = null; }
  32184. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  32185. if (invertY === void 0) { invertY = false; }
  32186. var gl = this._gl;
  32187. var texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode);
  32188. scene._addPendingData(texture);
  32189. texture.url = url;
  32190. this._internalTexturesCache.push(texture);
  32191. var onerror = function (request, exception) {
  32192. scene._removePendingData(texture);
  32193. if (onError && request) {
  32194. onError(request.status + " " + request.statusText, exception);
  32195. }
  32196. };
  32197. var internalCallback = function (data) {
  32198. var width = texture.width;
  32199. var faceDataArrays = callback(data);
  32200. if (!faceDataArrays) {
  32201. return;
  32202. }
  32203. if (mipmapGenerator) {
  32204. var textureType = _this._getWebGLTextureType(type);
  32205. var internalFormat = _this._getInternalFormat(format);
  32206. var internalSizedFomat = _this._getRGBABufferInternalSizedFormat(type);
  32207. var needConversion = false;
  32208. if (internalFormat === gl.RGB) {
  32209. internalFormat = gl.RGBA;
  32210. needConversion = true;
  32211. }
  32212. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32213. _this._unpackFlipY(false);
  32214. var mipData = mipmapGenerator(faceDataArrays);
  32215. for (var level = 0; level < mipData.length; level++) {
  32216. var mipSize = width >> level;
  32217. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32218. var mipFaceData = mipData[level][faceIndex];
  32219. if (needConversion) {
  32220. mipFaceData = _this._convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);
  32221. }
  32222. gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);
  32223. }
  32224. }
  32225. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32226. }
  32227. else {
  32228. _this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);
  32229. }
  32230. texture.isReady = true;
  32231. // this.resetTextureCache();
  32232. scene._removePendingData(texture);
  32233. if (onLoad) {
  32234. onLoad();
  32235. }
  32236. };
  32237. this._loadFile(url, function (data) {
  32238. internalCallback(data);
  32239. }, undefined, scene.offlineProvider, true, onerror);
  32240. return texture;
  32241. };
  32242. /**
  32243. * Update a raw 3D texture
  32244. * @param texture defines the texture to update
  32245. * @param data defines the data to store
  32246. * @param format defines the data format
  32247. * @param invertY defines if data must be stored with Y axis inverted
  32248. * @param compression defines the used compression (can be null)
  32249. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  32250. */
  32251. Engine.prototype.updateRawTexture3D = function (texture, data, format, invertY, compression, textureType) {
  32252. if (compression === void 0) { compression = null; }
  32253. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32254. var internalType = this._getWebGLTextureType(textureType);
  32255. var internalFormat = this._getInternalFormat(format);
  32256. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);
  32257. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  32258. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32259. if (!this._doNotHandleContextLost) {
  32260. texture._bufferView = data;
  32261. texture.format = format;
  32262. texture.invertY = invertY;
  32263. texture._compression = compression;
  32264. }
  32265. if (texture.width % 4 !== 0) {
  32266. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  32267. }
  32268. if (compression && data) {
  32269. this._gl.compressedTexImage3D(this._gl.TEXTURE_3D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, texture.depth, 0, data);
  32270. }
  32271. else {
  32272. this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);
  32273. }
  32274. if (texture.generateMipMaps) {
  32275. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  32276. }
  32277. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32278. // this.resetTextureCache();
  32279. texture.isReady = true;
  32280. };
  32281. /**
  32282. * Creates a new raw 3D texture
  32283. * @param data defines the data used to create the texture
  32284. * @param width defines the width of the texture
  32285. * @param height defines the height of the texture
  32286. * @param depth defines the depth of the texture
  32287. * @param format defines the format of the texture
  32288. * @param generateMipMaps defines if the engine must generate mip levels
  32289. * @param invertY defines if data must be stored with Y axis inverted
  32290. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32291. * @param compression defines the compressed used (can be null)
  32292. * @param textureType defines the compressed used (can be null)
  32293. * @returns a new raw 3D texture (stored in an InternalTexture)
  32294. */
  32295. Engine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  32296. if (compression === void 0) { compression = null; }
  32297. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32298. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW3D);
  32299. texture.baseWidth = width;
  32300. texture.baseHeight = height;
  32301. texture.baseDepth = depth;
  32302. texture.width = width;
  32303. texture.height = height;
  32304. texture.depth = depth;
  32305. texture.format = format;
  32306. texture.type = textureType;
  32307. texture.generateMipMaps = generateMipMaps;
  32308. texture.samplingMode = samplingMode;
  32309. texture.is3D = true;
  32310. if (!this._doNotHandleContextLost) {
  32311. texture._bufferView = data;
  32312. }
  32313. this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);
  32314. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  32315. // Filters
  32316. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32317. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  32318. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32319. if (generateMipMaps) {
  32320. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  32321. }
  32322. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32323. this._internalTexturesCache.push(texture);
  32324. return texture;
  32325. };
  32326. Engine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {
  32327. var gl = this._gl;
  32328. if (!gl) {
  32329. return;
  32330. }
  32331. var filters = this._getSamplingParameters(samplingMode, !noMipmap);
  32332. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32333. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32334. if (!noMipmap && !isCompressed) {
  32335. gl.generateMipmap(gl.TEXTURE_2D);
  32336. }
  32337. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32338. // this.resetTextureCache();
  32339. if (scene) {
  32340. scene._removePendingData(texture);
  32341. }
  32342. texture.onLoadedObservable.notifyObservers(texture);
  32343. texture.onLoadedObservable.clear();
  32344. };
  32345. Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
  32346. var _this = this;
  32347. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  32348. var maxTextureSize = this.getCaps().maxTextureSize;
  32349. var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, maxTextureSize) : width);
  32350. var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, maxTextureSize) : height);
  32351. var gl = this._gl;
  32352. if (!gl) {
  32353. return;
  32354. }
  32355. if (!texture._webGLTexture) {
  32356. // this.resetTextureCache();
  32357. if (scene) {
  32358. scene._removePendingData(texture);
  32359. }
  32360. return;
  32361. }
  32362. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  32363. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32364. texture.baseWidth = width;
  32365. texture.baseHeight = height;
  32366. texture.width = potWidth;
  32367. texture.height = potHeight;
  32368. texture.isReady = true;
  32369. if (processFunction(potWidth, potHeight, function () {
  32370. _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  32371. })) {
  32372. // Returning as texture needs extra async steps
  32373. return;
  32374. }
  32375. this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  32376. };
  32377. Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {
  32378. // Create new RGBA data container.
  32379. var rgbaData;
  32380. if (textureType === Engine.TEXTURETYPE_FLOAT) {
  32381. rgbaData = new Float32Array(width * height * 4);
  32382. }
  32383. else {
  32384. rgbaData = new Uint32Array(width * height * 4);
  32385. }
  32386. // Convert each pixel.
  32387. for (var x = 0; x < width; x++) {
  32388. for (var y = 0; y < height; y++) {
  32389. var index = (y * width + x) * 3;
  32390. var newIndex = (y * width + x) * 4;
  32391. // Map Old Value to new value.
  32392. rgbaData[newIndex + 0] = rgbData[index + 0];
  32393. rgbaData[newIndex + 1] = rgbData[index + 1];
  32394. rgbaData[newIndex + 2] = rgbData[index + 2];
  32395. // Add fully opaque alpha channel.
  32396. rgbaData[newIndex + 3] = 1;
  32397. }
  32398. }
  32399. return rgbaData;
  32400. };
  32401. /** @hidden */
  32402. Engine.prototype._releaseFramebufferObjects = function (texture) {
  32403. var gl = this._gl;
  32404. if (texture._framebuffer) {
  32405. gl.deleteFramebuffer(texture._framebuffer);
  32406. texture._framebuffer = null;
  32407. }
  32408. if (texture._depthStencilBuffer) {
  32409. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  32410. texture._depthStencilBuffer = null;
  32411. }
  32412. if (texture._MSAAFramebuffer) {
  32413. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  32414. texture._MSAAFramebuffer = null;
  32415. }
  32416. if (texture._MSAARenderBuffer) {
  32417. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  32418. texture._MSAARenderBuffer = null;
  32419. }
  32420. };
  32421. /** @hidden */
  32422. Engine.prototype._releaseTexture = function (texture) {
  32423. var gl = this._gl;
  32424. this._releaseFramebufferObjects(texture);
  32425. gl.deleteTexture(texture._webGLTexture);
  32426. // Unbind channels
  32427. this.unbindAllTextures();
  32428. var index = this._internalTexturesCache.indexOf(texture);
  32429. if (index !== -1) {
  32430. this._internalTexturesCache.splice(index, 1);
  32431. }
  32432. // Integrated fixed lod samplers.
  32433. if (texture._lodTextureHigh) {
  32434. texture._lodTextureHigh.dispose();
  32435. }
  32436. if (texture._lodTextureMid) {
  32437. texture._lodTextureMid.dispose();
  32438. }
  32439. if (texture._lodTextureLow) {
  32440. texture._lodTextureLow.dispose();
  32441. }
  32442. // Set output texture of post process to null if the texture has been released/disposed
  32443. this.scenes.forEach(function (scene) {
  32444. scene.postProcesses.forEach(function (postProcess) {
  32445. if (postProcess._outputTexture == texture) {
  32446. postProcess._outputTexture = null;
  32447. }
  32448. });
  32449. scene.cameras.forEach(function (camera) {
  32450. camera._postProcesses.forEach(function (postProcess) {
  32451. if (postProcess) {
  32452. if (postProcess._outputTexture == texture) {
  32453. postProcess._outputTexture = null;
  32454. }
  32455. }
  32456. });
  32457. });
  32458. });
  32459. };
  32460. Engine.prototype.setProgram = function (program) {
  32461. if (this._currentProgram !== program) {
  32462. this._gl.useProgram(program);
  32463. this._currentProgram = program;
  32464. }
  32465. };
  32466. /**
  32467. * Binds an effect to the webGL context
  32468. * @param effect defines the effect to bind
  32469. */
  32470. Engine.prototype.bindSamplers = function (effect) {
  32471. this.setProgram(effect.getProgram());
  32472. var samplers = effect.getSamplers();
  32473. for (var index = 0; index < samplers.length; index++) {
  32474. var uniform = effect.getUniform(samplers[index]);
  32475. if (uniform) {
  32476. this._boundUniforms[index] = uniform;
  32477. }
  32478. }
  32479. this._currentEffect = null;
  32480. };
  32481. Engine.prototype._moveBoundTextureOnTop = function (internalTexture) {
  32482. if (this.disableTextureBindingOptimization || this._lastBoundInternalTextureTracker.previous === internalTexture) {
  32483. return;
  32484. }
  32485. // Remove
  32486. this._linkTrackers(internalTexture.previous, internalTexture.next);
  32487. // Bind last to it
  32488. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, internalTexture);
  32489. // Bind to dummy
  32490. this._linkTrackers(internalTexture, this._lastBoundInternalTextureTracker);
  32491. };
  32492. Engine.prototype._getCorrectTextureChannel = function (channel, internalTexture) {
  32493. if (!internalTexture) {
  32494. return -1;
  32495. }
  32496. internalTexture._initialSlot = channel;
  32497. if (this.disableTextureBindingOptimization) { // We want texture sampler ID === texture channel
  32498. if (channel !== internalTexture._designatedSlot) {
  32499. this._textureCollisions.addCount(1, false);
  32500. }
  32501. }
  32502. else {
  32503. if (channel !== internalTexture._designatedSlot) {
  32504. if (internalTexture._designatedSlot > -1) { // Texture is already assigned to a slot
  32505. return internalTexture._designatedSlot;
  32506. }
  32507. else {
  32508. // No slot for this texture, let's pick a new one (if we find a free slot)
  32509. if (this._nextFreeTextureSlots.length) {
  32510. return this._nextFreeTextureSlots[0];
  32511. }
  32512. // We need to recycle the oldest bound texture, sorry.
  32513. this._textureCollisions.addCount(1, false);
  32514. return this._removeDesignatedSlot(this._firstBoundInternalTextureTracker.next);
  32515. }
  32516. }
  32517. }
  32518. return channel;
  32519. };
  32520. Engine.prototype._linkTrackers = function (previous, next) {
  32521. previous.next = next;
  32522. next.previous = previous;
  32523. };
  32524. Engine.prototype._removeDesignatedSlot = function (internalTexture) {
  32525. var currentSlot = internalTexture._designatedSlot;
  32526. if (currentSlot === -1) {
  32527. return -1;
  32528. }
  32529. internalTexture._designatedSlot = -1;
  32530. if (this.disableTextureBindingOptimization) {
  32531. return -1;
  32532. }
  32533. // Remove from bound list
  32534. this._linkTrackers(internalTexture.previous, internalTexture.next);
  32535. // Free the slot
  32536. this._boundTexturesCache[currentSlot] = null;
  32537. this._nextFreeTextureSlots.push(currentSlot);
  32538. return currentSlot;
  32539. };
  32540. Engine.prototype._activateCurrentTexture = function () {
  32541. if (this._currentTextureChannel !== this._activeChannel) {
  32542. this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
  32543. this._currentTextureChannel = this._activeChannel;
  32544. }
  32545. };
  32546. /** @hidden */
  32547. Engine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {
  32548. if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }
  32549. if (force === void 0) { force = false; }
  32550. var wasPreviouslyBound = false;
  32551. if (forTextureDataUpdate && texture && texture._designatedSlot > -1) {
  32552. this._activeChannel = texture._designatedSlot;
  32553. }
  32554. var currentTextureBound = this._boundTexturesCache[this._activeChannel];
  32555. var isTextureForRendering = texture && texture._initialSlot > -1;
  32556. if (currentTextureBound !== texture || force) {
  32557. if (currentTextureBound) {
  32558. this._removeDesignatedSlot(currentTextureBound);
  32559. }
  32560. this._activateCurrentTexture();
  32561. this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
  32562. this._boundTexturesCache[this._activeChannel] = texture;
  32563. if (texture) {
  32564. if (!this.disableTextureBindingOptimization) {
  32565. var slotIndex = this._nextFreeTextureSlots.indexOf(this._activeChannel);
  32566. if (slotIndex > -1) {
  32567. this._nextFreeTextureSlots.splice(slotIndex, 1);
  32568. }
  32569. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, texture);
  32570. this._linkTrackers(texture, this._lastBoundInternalTextureTracker);
  32571. }
  32572. texture._designatedSlot = this._activeChannel;
  32573. }
  32574. }
  32575. else if (forTextureDataUpdate) {
  32576. wasPreviouslyBound = true;
  32577. this._activateCurrentTexture();
  32578. }
  32579. if (isTextureForRendering && !forTextureDataUpdate) {
  32580. this._bindSamplerUniformToChannel(texture._initialSlot, this._activeChannel);
  32581. }
  32582. return wasPreviouslyBound;
  32583. };
  32584. /** @hidden */
  32585. Engine.prototype._bindTexture = function (channel, texture) {
  32586. if (channel < 0) {
  32587. return;
  32588. }
  32589. if (texture) {
  32590. channel = this._getCorrectTextureChannel(channel, texture);
  32591. }
  32592. this._activeChannel = channel;
  32593. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
  32594. };
  32595. /**
  32596. * Sets a texture to the webGL context from a postprocess
  32597. * @param channel defines the channel to use
  32598. * @param postProcess defines the source postprocess
  32599. */
  32600. Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  32601. this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
  32602. };
  32603. /**
  32604. * Binds the output of the passed in post process to the texture channel specified
  32605. * @param channel The channel the texture should be bound to
  32606. * @param postProcess The post process which's output should be bound
  32607. */
  32608. Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  32609. this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);
  32610. };
  32611. /**
  32612. * Unbind all textures from the webGL context
  32613. */
  32614. Engine.prototype.unbindAllTextures = function () {
  32615. for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {
  32616. this._activeChannel = channel;
  32617. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32618. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32619. if (this.webGLVersion > 1) {
  32620. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32621. }
  32622. }
  32623. };
  32624. /**
  32625. * Sets a texture to the according uniform.
  32626. * @param channel The texture channel
  32627. * @param uniform The uniform to set
  32628. * @param texture The texture to apply
  32629. */
  32630. Engine.prototype.setTexture = function (channel, uniform, texture) {
  32631. if (channel < 0) {
  32632. return;
  32633. }
  32634. if (uniform) {
  32635. this._boundUniforms[channel] = uniform;
  32636. }
  32637. this._setTexture(channel, texture);
  32638. };
  32639. /**
  32640. * Sets a depth stencil texture from a render target to the according uniform.
  32641. * @param channel The texture channel
  32642. * @param uniform The uniform to set
  32643. * @param texture The render target texture containing the depth stencil texture to apply
  32644. */
  32645. Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {
  32646. if (channel < 0) {
  32647. return;
  32648. }
  32649. if (uniform) {
  32650. this._boundUniforms[channel] = uniform;
  32651. }
  32652. if (!texture || !texture.depthStencilTexture) {
  32653. this._setTexture(channel, null);
  32654. }
  32655. else {
  32656. this._setTexture(channel, texture, false, true);
  32657. }
  32658. };
  32659. Engine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {
  32660. var uniform = this._boundUniforms[sourceSlot];
  32661. if (uniform._currentState === destination) {
  32662. return;
  32663. }
  32664. this._gl.uniform1i(uniform, destination);
  32665. uniform._currentState = destination;
  32666. };
  32667. Engine.prototype._getTextureWrapMode = function (mode) {
  32668. switch (mode) {
  32669. case Engine.TEXTURE_WRAP_ADDRESSMODE:
  32670. return this._gl.REPEAT;
  32671. case Engine.TEXTURE_CLAMP_ADDRESSMODE:
  32672. return this._gl.CLAMP_TO_EDGE;
  32673. case Engine.TEXTURE_MIRROR_ADDRESSMODE:
  32674. return this._gl.MIRRORED_REPEAT;
  32675. }
  32676. return this._gl.REPEAT;
  32677. };
  32678. Engine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {
  32679. if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }
  32680. if (depthStencilTexture === void 0) { depthStencilTexture = false; }
  32681. // Not ready?
  32682. if (!texture) {
  32683. if (this._boundTexturesCache[channel] != null) {
  32684. this._activeChannel = channel;
  32685. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32686. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32687. if (this.webGLVersion > 1) {
  32688. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32689. }
  32690. }
  32691. return false;
  32692. }
  32693. // Video
  32694. if (texture.video) {
  32695. this._activeChannel = channel;
  32696. texture.update();
  32697. }
  32698. else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
  32699. texture.delayLoad();
  32700. return false;
  32701. }
  32702. var internalTexture;
  32703. if (depthStencilTexture) {
  32704. internalTexture = texture.depthStencilTexture;
  32705. }
  32706. else if (texture.isReady()) {
  32707. internalTexture = texture.getInternalTexture();
  32708. }
  32709. else if (texture.isCube) {
  32710. internalTexture = this.emptyCubeTexture;
  32711. }
  32712. else if (texture.is3D) {
  32713. internalTexture = this.emptyTexture3D;
  32714. }
  32715. else {
  32716. internalTexture = this.emptyTexture;
  32717. }
  32718. if (!isPartOfTextureArray) {
  32719. channel = this._getCorrectTextureChannel(channel, internalTexture);
  32720. }
  32721. var needToBind = true;
  32722. if (this._boundTexturesCache[channel] === internalTexture) {
  32723. this._moveBoundTextureOnTop(internalTexture);
  32724. if (!isPartOfTextureArray) {
  32725. this._bindSamplerUniformToChannel(internalTexture._initialSlot, channel);
  32726. }
  32727. needToBind = false;
  32728. }
  32729. this._activeChannel = channel;
  32730. if (internalTexture && internalTexture.is3D) {
  32731. if (needToBind) {
  32732. this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture, isPartOfTextureArray);
  32733. }
  32734. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  32735. internalTexture._cachedWrapU = texture.wrapU;
  32736. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  32737. }
  32738. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  32739. internalTexture._cachedWrapV = texture.wrapV;
  32740. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  32741. }
  32742. if (internalTexture && internalTexture._cachedWrapR !== texture.wrapR) {
  32743. internalTexture._cachedWrapR = texture.wrapR;
  32744. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
  32745. }
  32746. this._setAnisotropicLevel(this._gl.TEXTURE_3D, texture);
  32747. }
  32748. else if (internalTexture && internalTexture.isCube) {
  32749. if (needToBind) {
  32750. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, internalTexture, isPartOfTextureArray);
  32751. }
  32752. if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
  32753. internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
  32754. // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
  32755. var textureWrapMode = (texture.coordinatesMode !== Engine.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Engine.TEXTURE_SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
  32756. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode, internalTexture);
  32757. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
  32758. }
  32759. this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP, texture);
  32760. }
  32761. else {
  32762. if (needToBind) {
  32763. this._bindTextureDirectly(this._gl.TEXTURE_2D, internalTexture, isPartOfTextureArray);
  32764. }
  32765. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  32766. internalTexture._cachedWrapU = texture.wrapU;
  32767. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  32768. }
  32769. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  32770. internalTexture._cachedWrapV = texture.wrapV;
  32771. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  32772. }
  32773. this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
  32774. }
  32775. return true;
  32776. };
  32777. /**
  32778. * Sets an array of texture to the webGL context
  32779. * @param channel defines the channel where the texture array must be set
  32780. * @param uniform defines the associated uniform location
  32781. * @param textures defines the array of textures to bind
  32782. */
  32783. Engine.prototype.setTextureArray = function (channel, uniform, textures) {
  32784. if (channel < 0 || !uniform) {
  32785. return;
  32786. }
  32787. if (!this._textureUnits || this._textureUnits.length !== textures.length) {
  32788. this._textureUnits = new Int32Array(textures.length);
  32789. }
  32790. for (var i = 0; i < textures.length; i++) {
  32791. this._textureUnits[i] = this._getCorrectTextureChannel(channel + i, textures[i].getInternalTexture());
  32792. }
  32793. this._gl.uniform1iv(uniform, this._textureUnits);
  32794. for (var index = 0; index < textures.length; index++) {
  32795. this._setTexture(this._textureUnits[index], textures[index], true);
  32796. }
  32797. };
  32798. /** @hidden */
  32799. Engine.prototype._setAnisotropicLevel = function (target, texture) {
  32800. var internalTexture = texture.getInternalTexture();
  32801. if (!internalTexture) {
  32802. return;
  32803. }
  32804. var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
  32805. var value = texture.anisotropicFilteringLevel;
  32806. if (internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST
  32807. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR
  32808. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR) {
  32809. value = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
  32810. }
  32811. if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== value) {
  32812. this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(value, this._caps.maxAnisotropy), internalTexture);
  32813. internalTexture._cachedAnisotropicFilteringLevel = value;
  32814. }
  32815. };
  32816. Engine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {
  32817. this._bindTextureDirectly(target, texture, true, true);
  32818. this._gl.texParameterf(target, parameter, value);
  32819. };
  32820. Engine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {
  32821. if (texture) {
  32822. this._bindTextureDirectly(target, texture, true, true);
  32823. }
  32824. this._gl.texParameteri(target, parameter, value);
  32825. };
  32826. /**
  32827. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32828. * @param x defines the x coordinate of the rectangle where pixels must be read
  32829. * @param y defines the y coordinate of the rectangle where pixels must be read
  32830. * @param width defines the width of the rectangle where pixels must be read
  32831. * @param height defines the height of the rectangle where pixels must be read
  32832. * @returns a Uint8Array containing RGBA colors
  32833. */
  32834. Engine.prototype.readPixels = function (x, y, width, height) {
  32835. var data = new Uint8Array(height * width * 4);
  32836. this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
  32837. return data;
  32838. };
  32839. /**
  32840. * Add an externaly attached data from its key.
  32841. * This method call will fail and return false, if such key already exists.
  32842. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32843. * @param key the unique key that identifies the data
  32844. * @param data the data object to associate to the key for this Engine instance
  32845. * @return true if no such key were already present and the data was added successfully, false otherwise
  32846. */
  32847. Engine.prototype.addExternalData = function (key, data) {
  32848. if (!this._externalData) {
  32849. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32850. }
  32851. return this._externalData.add(key, data);
  32852. };
  32853. /**
  32854. * Get an externaly attached data from its key
  32855. * @param key the unique key that identifies the data
  32856. * @return the associated data, if present (can be null), or undefined if not present
  32857. */
  32858. Engine.prototype.getExternalData = function (key) {
  32859. if (!this._externalData) {
  32860. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32861. }
  32862. return this._externalData.get(key);
  32863. };
  32864. /**
  32865. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32866. * @param key the unique key that identifies the data
  32867. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32868. * @return the associated data, can be null if the factory returned null.
  32869. */
  32870. Engine.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  32871. if (!this._externalData) {
  32872. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32873. }
  32874. return this._externalData.getOrAddWithFactory(key, factory);
  32875. };
  32876. /**
  32877. * Remove an externaly attached data from the Engine instance
  32878. * @param key the unique key that identifies the data
  32879. * @return true if the data was successfully removed, false if it doesn't exist
  32880. */
  32881. Engine.prototype.removeExternalData = function (key) {
  32882. if (!this._externalData) {
  32883. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32884. }
  32885. return this._externalData.remove(key);
  32886. };
  32887. /**
  32888. * Unbind all vertex attributes from the webGL context
  32889. */
  32890. Engine.prototype.unbindAllAttributes = function () {
  32891. if (this._mustWipeVertexAttributes) {
  32892. this._mustWipeVertexAttributes = false;
  32893. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  32894. this._gl.disableVertexAttribArray(i);
  32895. this._vertexAttribArraysEnabled[i] = false;
  32896. this._currentBufferPointers[i].active = false;
  32897. }
  32898. return;
  32899. }
  32900. for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
  32901. if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
  32902. continue;
  32903. }
  32904. this._gl.disableVertexAttribArray(i);
  32905. this._vertexAttribArraysEnabled[i] = false;
  32906. this._currentBufferPointers[i].active = false;
  32907. }
  32908. };
  32909. /**
  32910. * 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
  32911. */
  32912. Engine.prototype.releaseEffects = function () {
  32913. for (var name in this._compiledEffects) {
  32914. this._deleteProgram(this._compiledEffects[name]._program);
  32915. }
  32916. this._compiledEffects = {};
  32917. };
  32918. /**
  32919. * Dispose and release all associated resources
  32920. */
  32921. Engine.prototype.dispose = function () {
  32922. this.hideLoadingUI();
  32923. this.stopRenderLoop();
  32924. this.onNewSceneAddedObservable.clear();
  32925. // Release postProcesses
  32926. while (this.postProcesses.length) {
  32927. this.postProcesses[0].dispose();
  32928. }
  32929. // Empty texture
  32930. if (this._emptyTexture) {
  32931. this._releaseTexture(this._emptyTexture);
  32932. this._emptyTexture = null;
  32933. }
  32934. if (this._emptyCubeTexture) {
  32935. this._releaseTexture(this._emptyCubeTexture);
  32936. this._emptyCubeTexture = null;
  32937. }
  32938. // Rescale PP
  32939. if (this._rescalePostProcess) {
  32940. this._rescalePostProcess.dispose();
  32941. }
  32942. // Release scenes
  32943. while (this.scenes.length) {
  32944. this.scenes[0].dispose();
  32945. }
  32946. // Release audio engine
  32947. if (Engine.Instances.length === 1 && Engine.audioEngine) {
  32948. Engine.audioEngine.dispose();
  32949. }
  32950. // Release effects
  32951. this.releaseEffects();
  32952. // Unbind
  32953. this.unbindAllAttributes();
  32954. this._boundUniforms = [];
  32955. if (this._dummyFramebuffer) {
  32956. this._gl.deleteFramebuffer(this._dummyFramebuffer);
  32957. }
  32958. //WebVR
  32959. this.disableVR();
  32960. // Events
  32961. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  32962. window.removeEventListener("blur", this._onBlur);
  32963. window.removeEventListener("focus", this._onFocus);
  32964. window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
  32965. window.removeEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted);
  32966. if (this._renderingCanvas) {
  32967. this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus);
  32968. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
  32969. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut);
  32970. if (!this._doNotHandleContextLost) {
  32971. this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
  32972. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
  32973. }
  32974. }
  32975. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  32976. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  32977. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  32978. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  32979. document.removeEventListener("pointerlockchange", this._onPointerLockChange);
  32980. document.removeEventListener("mspointerlockchange", this._onPointerLockChange);
  32981. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange);
  32982. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange);
  32983. if (this._onVrDisplayConnect) {
  32984. window.removeEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  32985. if (this._onVrDisplayDisconnect) {
  32986. window.removeEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  32987. }
  32988. if (this._onVrDisplayPresentChange) {
  32989. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  32990. }
  32991. this._onVrDisplayConnect = null;
  32992. this._onVrDisplayDisconnect = null;
  32993. }
  32994. }
  32995. // Remove from Instances
  32996. var index = Engine.Instances.indexOf(this);
  32997. if (index >= 0) {
  32998. Engine.Instances.splice(index, 1);
  32999. }
  33000. this._workingCanvas = null;
  33001. this._workingContext = null;
  33002. this._currentBufferPointers = [];
  33003. this._renderingCanvas = null;
  33004. this._currentProgram = null;
  33005. this._bindedRenderFunction = null;
  33006. this.onResizeObservable.clear();
  33007. this.onCanvasBlurObservable.clear();
  33008. this.onCanvasFocusObservable.clear();
  33009. this.onCanvasPointerOutObservable.clear();
  33010. this.onBeginFrameObservable.clear();
  33011. this.onEndFrameObservable.clear();
  33012. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  33013. // Abort active requests
  33014. for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {
  33015. var request = _a[_i];
  33016. request.abort();
  33017. }
  33018. };
  33019. // Loading screen
  33020. /**
  33021. * Display the loading screen
  33022. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33023. */
  33024. Engine.prototype.displayLoadingUI = function () {
  33025. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33026. return;
  33027. }
  33028. var loadingScreen = this.loadingScreen;
  33029. if (loadingScreen) {
  33030. loadingScreen.displayLoadingUI();
  33031. }
  33032. };
  33033. /**
  33034. * Hide the loading screen
  33035. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33036. */
  33037. Engine.prototype.hideLoadingUI = function () {
  33038. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33039. return;
  33040. }
  33041. var loadingScreen = this.loadingScreen;
  33042. if (loadingScreen) {
  33043. loadingScreen.hideLoadingUI();
  33044. }
  33045. };
  33046. Object.defineProperty(Engine.prototype, "loadingScreen", {
  33047. /**
  33048. * Gets the current loading screen object
  33049. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33050. */
  33051. get: function () {
  33052. if (!this._loadingScreen && this._renderingCanvas) {
  33053. this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
  33054. }
  33055. return this._loadingScreen;
  33056. },
  33057. /**
  33058. * Sets the current loading screen object
  33059. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33060. */
  33061. set: function (loadingScreen) {
  33062. this._loadingScreen = loadingScreen;
  33063. },
  33064. enumerable: true,
  33065. configurable: true
  33066. });
  33067. Object.defineProperty(Engine.prototype, "loadingUIText", {
  33068. /**
  33069. * Sets the current loading screen text
  33070. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33071. */
  33072. set: function (text) {
  33073. this.loadingScreen.loadingUIText = text;
  33074. },
  33075. enumerable: true,
  33076. configurable: true
  33077. });
  33078. Object.defineProperty(Engine.prototype, "loadingUIBackgroundColor", {
  33079. /**
  33080. * Sets the current loading screen background color
  33081. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33082. */
  33083. set: function (color) {
  33084. this.loadingScreen.loadingUIBackgroundColor = color;
  33085. },
  33086. enumerable: true,
  33087. configurable: true
  33088. });
  33089. /**
  33090. * Attach a new callback raised when context lost event is fired
  33091. * @param callback defines the callback to call
  33092. */
  33093. Engine.prototype.attachContextLostEvent = function (callback) {
  33094. if (this._renderingCanvas) {
  33095. this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
  33096. }
  33097. };
  33098. /**
  33099. * Attach a new callback raised when context restored event is fired
  33100. * @param callback defines the callback to call
  33101. */
  33102. Engine.prototype.attachContextRestoredEvent = function (callback) {
  33103. if (this._renderingCanvas) {
  33104. this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
  33105. }
  33106. };
  33107. /**
  33108. * Gets the source code of the vertex shader associated with a specific webGL program
  33109. * @param program defines the program to use
  33110. * @returns a string containing the source code of the vertex shader associated with the program
  33111. */
  33112. Engine.prototype.getVertexShaderSource = function (program) {
  33113. var shaders = this._gl.getAttachedShaders(program);
  33114. if (!shaders) {
  33115. return null;
  33116. }
  33117. return this._gl.getShaderSource(shaders[0]);
  33118. };
  33119. /**
  33120. * Gets the source code of the fragment shader associated with a specific webGL program
  33121. * @param program defines the program to use
  33122. * @returns a string containing the source code of the fragment shader associated with the program
  33123. */
  33124. Engine.prototype.getFragmentShaderSource = function (program) {
  33125. var shaders = this._gl.getAttachedShaders(program);
  33126. if (!shaders) {
  33127. return null;
  33128. }
  33129. return this._gl.getShaderSource(shaders[1]);
  33130. };
  33131. /**
  33132. * Get the current error code of the webGL context
  33133. * @returns the error code
  33134. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33135. */
  33136. Engine.prototype.getError = function () {
  33137. return this._gl.getError();
  33138. };
  33139. // FPS
  33140. /**
  33141. * Gets the current framerate
  33142. * @returns a number representing the framerate
  33143. */
  33144. Engine.prototype.getFps = function () {
  33145. return this._fps;
  33146. };
  33147. /**
  33148. * Gets the time spent between current and previous frame
  33149. * @returns a number representing the delta time in ms
  33150. */
  33151. Engine.prototype.getDeltaTime = function () {
  33152. return this._deltaTime;
  33153. };
  33154. Engine.prototype._measureFps = function () {
  33155. this._performanceMonitor.sampleFrame();
  33156. this._fps = this._performanceMonitor.averageFPS;
  33157. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
  33158. };
  33159. /** @hidden */
  33160. Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {
  33161. if (faceIndex === void 0) { faceIndex = -1; }
  33162. if (level === void 0) { level = 0; }
  33163. if (buffer === void 0) { buffer = null; }
  33164. var gl = this._gl;
  33165. if (!this._dummyFramebuffer) {
  33166. var dummy = gl.createFramebuffer();
  33167. if (!dummy) {
  33168. throw new Error("Unable to create dummy framebuffer");
  33169. }
  33170. this._dummyFramebuffer = dummy;
  33171. }
  33172. gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
  33173. if (faceIndex > -1) {
  33174. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);
  33175. }
  33176. else {
  33177. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);
  33178. }
  33179. var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;
  33180. switch (readType) {
  33181. case gl.UNSIGNED_BYTE:
  33182. if (!buffer) {
  33183. buffer = new Uint8Array(4 * width * height);
  33184. }
  33185. readType = gl.UNSIGNED_BYTE;
  33186. break;
  33187. default:
  33188. if (!buffer) {
  33189. buffer = new Float32Array(4 * width * height);
  33190. }
  33191. readType = gl.FLOAT;
  33192. break;
  33193. }
  33194. gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);
  33195. gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);
  33196. return buffer;
  33197. };
  33198. Engine.prototype._canRenderToFloatFramebuffer = function () {
  33199. if (this._webGLVersion > 1) {
  33200. return this._caps.colorBufferFloat;
  33201. }
  33202. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
  33203. };
  33204. Engine.prototype._canRenderToHalfFloatFramebuffer = function () {
  33205. if (this._webGLVersion > 1) {
  33206. return this._caps.colorBufferFloat;
  33207. }
  33208. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
  33209. };
  33210. // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
  33211. Engine.prototype._canRenderToFramebuffer = function (type) {
  33212. var gl = this._gl;
  33213. //clear existing errors
  33214. while (gl.getError() !== gl.NO_ERROR) { }
  33215. var successful = true;
  33216. var texture = gl.createTexture();
  33217. gl.bindTexture(gl.TEXTURE_2D, texture);
  33218. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  33219. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  33220. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  33221. var fb = gl.createFramebuffer();
  33222. gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
  33223. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
  33224. var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
  33225. successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);
  33226. successful = successful && (gl.getError() === gl.NO_ERROR);
  33227. //try render by clearing frame buffer's color buffer
  33228. if (successful) {
  33229. gl.clear(gl.COLOR_BUFFER_BIT);
  33230. successful = successful && (gl.getError() === gl.NO_ERROR);
  33231. }
  33232. //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
  33233. if (successful) {
  33234. //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
  33235. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33236. var readFormat = gl.RGBA;
  33237. var readType = gl.UNSIGNED_BYTE;
  33238. var buffer = new Uint8Array(4);
  33239. gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
  33240. successful = successful && (gl.getError() === gl.NO_ERROR);
  33241. }
  33242. //clean up
  33243. gl.deleteTexture(texture);
  33244. gl.deleteFramebuffer(fb);
  33245. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33246. //clear accumulated errors
  33247. while (!successful && (gl.getError() !== gl.NO_ERROR)) { }
  33248. return successful;
  33249. };
  33250. /** @hidden */
  33251. Engine.prototype._getWebGLTextureType = function (type) {
  33252. if (this._webGLVersion === 1) {
  33253. switch (type) {
  33254. case Engine.TEXTURETYPE_FLOAT:
  33255. return this._gl.FLOAT;
  33256. case Engine.TEXTURETYPE_HALF_FLOAT:
  33257. return this._gl.HALF_FLOAT_OES;
  33258. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33259. return this._gl.UNSIGNED_BYTE;
  33260. }
  33261. return this._gl.UNSIGNED_BYTE;
  33262. }
  33263. switch (type) {
  33264. case Engine.TEXTURETYPE_BYTE:
  33265. return this._gl.BYTE;
  33266. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33267. return this._gl.UNSIGNED_BYTE;
  33268. case Engine.TEXTURETYPE_SHORT:
  33269. return this._gl.SHORT;
  33270. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  33271. return this._gl.UNSIGNED_SHORT;
  33272. case Engine.TEXTURETYPE_INT:
  33273. return this._gl.INT;
  33274. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  33275. return this._gl.UNSIGNED_INT;
  33276. case Engine.TEXTURETYPE_FLOAT:
  33277. return this._gl.FLOAT;
  33278. case Engine.TEXTURETYPE_HALF_FLOAT:
  33279. return this._gl.HALF_FLOAT;
  33280. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  33281. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  33282. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  33283. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  33284. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  33285. return this._gl.UNSIGNED_SHORT_5_6_5;
  33286. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  33287. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  33288. case Engine.TEXTURETYPE_UNSIGNED_INT_24_8:
  33289. return this._gl.UNSIGNED_INT_24_8;
  33290. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  33291. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  33292. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  33293. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  33294. case Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  33295. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
  33296. }
  33297. return this._gl.UNSIGNED_BYTE;
  33298. };
  33299. Engine.prototype._getInternalFormat = function (format) {
  33300. var internalFormat = this._gl.RGBA;
  33301. switch (format) {
  33302. case Engine.TEXTUREFORMAT_ALPHA:
  33303. internalFormat = this._gl.ALPHA;
  33304. break;
  33305. case Engine.TEXTUREFORMAT_LUMINANCE:
  33306. internalFormat = this._gl.LUMINANCE;
  33307. break;
  33308. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  33309. internalFormat = this._gl.LUMINANCE_ALPHA;
  33310. break;
  33311. case Engine.TEXTUREFORMAT_RED:
  33312. internalFormat = this._gl.RED;
  33313. break;
  33314. case Engine.TEXTUREFORMAT_RG:
  33315. internalFormat = this._gl.RG;
  33316. break;
  33317. case Engine.TEXTUREFORMAT_RGB:
  33318. internalFormat = this._gl.RGB;
  33319. break;
  33320. case Engine.TEXTUREFORMAT_RGBA:
  33321. internalFormat = this._gl.RGBA;
  33322. break;
  33323. }
  33324. if (this._webGLVersion > 1) {
  33325. switch (format) {
  33326. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33327. internalFormat = this._gl.RED_INTEGER;
  33328. break;
  33329. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33330. internalFormat = this._gl.RG_INTEGER;
  33331. break;
  33332. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33333. internalFormat = this._gl.RGB_INTEGER;
  33334. break;
  33335. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33336. internalFormat = this._gl.RGBA_INTEGER;
  33337. break;
  33338. }
  33339. }
  33340. return internalFormat;
  33341. };
  33342. /** @hidden */
  33343. Engine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {
  33344. if (this._webGLVersion === 1) {
  33345. if (format !== undefined) {
  33346. switch (format) {
  33347. case Engine.TEXTUREFORMAT_ALPHA:
  33348. return this._gl.ALPHA;
  33349. case Engine.TEXTUREFORMAT_LUMINANCE:
  33350. return this._gl.LUMINANCE;
  33351. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  33352. return this._gl.LUMINANCE_ALPHA;
  33353. }
  33354. }
  33355. return this._gl.RGBA;
  33356. }
  33357. switch (type) {
  33358. case Engine.TEXTURETYPE_BYTE:
  33359. switch (format) {
  33360. case Engine.TEXTUREFORMAT_RED:
  33361. return this._gl.R8_SNORM;
  33362. case Engine.TEXTUREFORMAT_RG:
  33363. return this._gl.RG8_SNORM;
  33364. case Engine.TEXTUREFORMAT_RGB:
  33365. return this._gl.RGB8_SNORM;
  33366. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33367. return this._gl.R8I;
  33368. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33369. return this._gl.RG8I;
  33370. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33371. return this._gl.RGB8I;
  33372. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33373. return this._gl.RGBA8I;
  33374. default:
  33375. return this._gl.RGBA8_SNORM;
  33376. }
  33377. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33378. switch (format) {
  33379. case Engine.TEXTUREFORMAT_RED:
  33380. return this._gl.R8;
  33381. case Engine.TEXTUREFORMAT_RG:
  33382. return this._gl.RG8;
  33383. case Engine.TEXTUREFORMAT_RGB:
  33384. return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
  33385. case Engine.TEXTUREFORMAT_RGBA:
  33386. return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
  33387. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33388. return this._gl.R8UI;
  33389. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33390. return this._gl.RG8UI;
  33391. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33392. return this._gl.RGB8UI;
  33393. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33394. return this._gl.RGBA8UI;
  33395. default:
  33396. return this._gl.RGBA8;
  33397. }
  33398. case Engine.TEXTURETYPE_SHORT:
  33399. switch (format) {
  33400. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33401. return this._gl.R16I;
  33402. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33403. return this._gl.RG16I;
  33404. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33405. return this._gl.RGB16I;
  33406. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33407. return this._gl.RGBA16I;
  33408. default:
  33409. return this._gl.RGBA16I;
  33410. }
  33411. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  33412. switch (format) {
  33413. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33414. return this._gl.R16UI;
  33415. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33416. return this._gl.RG16UI;
  33417. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33418. return this._gl.RGB16UI;
  33419. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33420. return this._gl.RGBA16UI;
  33421. default:
  33422. return this._gl.RGBA16UI;
  33423. }
  33424. case Engine.TEXTURETYPE_INT:
  33425. switch (format) {
  33426. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33427. return this._gl.R32I;
  33428. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33429. return this._gl.RG32I;
  33430. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33431. return this._gl.RGB32I;
  33432. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33433. return this._gl.RGBA32I;
  33434. default:
  33435. return this._gl.RGBA32I;
  33436. }
  33437. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  33438. switch (format) {
  33439. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33440. return this._gl.R32UI;
  33441. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33442. return this._gl.RG32UI;
  33443. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33444. return this._gl.RGB32UI;
  33445. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33446. return this._gl.RGBA32UI;
  33447. default:
  33448. return this._gl.RGBA32UI;
  33449. }
  33450. case Engine.TEXTURETYPE_FLOAT:
  33451. switch (format) {
  33452. case Engine.TEXTUREFORMAT_RED:
  33453. return this._gl.R32F; // By default. Other possibility is R16F.
  33454. case Engine.TEXTUREFORMAT_RG:
  33455. return this._gl.RG32F; // By default. Other possibility is RG16F.
  33456. case Engine.TEXTUREFORMAT_RGB:
  33457. return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
  33458. case Engine.TEXTUREFORMAT_RGBA:
  33459. return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
  33460. default:
  33461. return this._gl.RGBA32F;
  33462. }
  33463. case Engine.TEXTURETYPE_HALF_FLOAT:
  33464. switch (format) {
  33465. case Engine.TEXTUREFORMAT_RED:
  33466. return this._gl.R16F;
  33467. case Engine.TEXTUREFORMAT_RG:
  33468. return this._gl.RG16F;
  33469. case Engine.TEXTUREFORMAT_RGB:
  33470. return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
  33471. case Engine.TEXTUREFORMAT_RGBA:
  33472. return this._gl.RGBA16F;
  33473. default:
  33474. return this._gl.RGBA16F;
  33475. }
  33476. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  33477. return this._gl.RGB565;
  33478. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  33479. return this._gl.R11F_G11F_B10F;
  33480. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  33481. return this._gl.RGB9_E5;
  33482. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  33483. return this._gl.RGBA4;
  33484. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  33485. return this._gl.RGB5_A1;
  33486. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  33487. switch (format) {
  33488. case Engine.TEXTUREFORMAT_RGBA:
  33489. return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
  33490. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33491. return this._gl.RGB10_A2UI;
  33492. default:
  33493. return this._gl.RGB10_A2;
  33494. }
  33495. }
  33496. return this._gl.RGBA8;
  33497. };
  33498. /** @hidden */
  33499. Engine.prototype._getRGBAMultiSampleBufferFormat = function (type) {
  33500. if (type === Engine.TEXTURETYPE_FLOAT) {
  33501. return this._gl.RGBA32F;
  33502. }
  33503. else if (type === Engine.TEXTURETYPE_HALF_FLOAT) {
  33504. return this._gl.RGBA16F;
  33505. }
  33506. return this._gl.RGBA8;
  33507. };
  33508. /** @hidden */
  33509. Engine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  33510. var _this = this;
  33511. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  33512. this._activeRequests.push(request);
  33513. request.onCompleteObservable.add(function (request) {
  33514. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  33515. });
  33516. return request;
  33517. };
  33518. /** @hidden */
  33519. Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {
  33520. var _this = this;
  33521. return new Promise(function (resolve, reject) {
  33522. _this._loadFile(url, function (data) {
  33523. resolve(data);
  33524. }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  33525. reject(exception);
  33526. });
  33527. });
  33528. };
  33529. Engine.prototype._partialLoadFile = function (url, index, loadedFiles, onfinish, onErrorCallBack) {
  33530. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  33531. var onload = function (data) {
  33532. loadedFiles[index] = data;
  33533. loadedFiles._internalCount++;
  33534. if (loadedFiles._internalCount === 6) {
  33535. onfinish(loadedFiles);
  33536. }
  33537. };
  33538. var onerror = function (request, exception) {
  33539. if (onErrorCallBack && request) {
  33540. onErrorCallBack(request.status + " " + request.statusText, exception);
  33541. }
  33542. };
  33543. this._loadFile(url, onload, undefined, undefined, true, onerror);
  33544. };
  33545. Engine.prototype._cascadeLoadFiles = function (scene, onfinish, files, onError) {
  33546. if (onError === void 0) { onError = null; }
  33547. var loadedFiles = [];
  33548. loadedFiles._internalCount = 0;
  33549. for (var index = 0; index < 6; index++) {
  33550. this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
  33551. }
  33552. };
  33553. // Statics
  33554. /**
  33555. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33556. * @returns true if the engine can be created
  33557. * @ignorenaming
  33558. */
  33559. Engine.isSupported = function () {
  33560. try {
  33561. var tempcanvas = document.createElement("canvas");
  33562. var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
  33563. return gl != null && !!window.WebGLRenderingContext;
  33564. }
  33565. catch (e) {
  33566. return false;
  33567. }
  33568. };
  33569. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  33570. Engine.ExceptionList = [
  33571. { key: "Chrome/63.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
  33572. { key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  33573. { key: "Firefox/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  33574. { key: "Macintosh", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  33575. { key: "iPhone", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  33576. { key: "iPad", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] }
  33577. ];
  33578. /**
  33579. * Hidden
  33580. */
  33581. Engine._TextureLoaders = [];
  33582. // Const statics
  33583. /** Defines that alpha blending is disabled */
  33584. Engine.ALPHA_DISABLE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_DISABLE;
  33585. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33586. Engine.ALPHA_ADD = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ADD;
  33587. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33588. Engine.ALPHA_COMBINE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_COMBINE;
  33589. /** Defines that alpha blending to DEST - SRC * DEST */
  33590. Engine.ALPHA_SUBTRACT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SUBTRACT;
  33591. /** Defines that alpha blending to SRC * DEST */
  33592. Engine.ALPHA_MULTIPLY = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MULTIPLY;
  33593. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33594. Engine.ALPHA_MAXIMIZED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MAXIMIZED;
  33595. /** Defines that alpha blending to SRC + DEST */
  33596. Engine.ALPHA_ONEONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ONEONE;
  33597. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33598. Engine.ALPHA_PREMULTIPLIED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED;
  33599. /**
  33600. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33601. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33602. */
  33603. Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  33604. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33605. Engine.ALPHA_INTERPOLATE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_INTERPOLATE;
  33606. /**
  33607. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33608. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33609. */
  33610. Engine.ALPHA_SCREENMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SCREENMODE;
  33611. /** Defines that the ressource is not delayed*/
  33612. Engine.DELAYLOADSTATE_NONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NONE;
  33613. /** Defines that the ressource was successfully delay loaded */
  33614. Engine.DELAYLOADSTATE_LOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADED;
  33615. /** Defines that the ressource is currently delay loading */
  33616. Engine.DELAYLOADSTATE_LOADING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADING;
  33617. /** Defines that the ressource is delayed and has not started loading */
  33618. Engine.DELAYLOADSTATE_NOTLOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NOTLOADED;
  33619. // Depht or Stencil test Constants.
  33620. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33621. Engine.NEVER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NEVER;
  33622. /** 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 */
  33623. Engine.ALWAYS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALWAYS;
  33624. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33625. Engine.LESS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LESS;
  33626. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33627. Engine.EQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].EQUAL;
  33628. /** 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 */
  33629. Engine.LEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LEQUAL;
  33630. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33631. Engine.GREATER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GREATER;
  33632. /** 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 */
  33633. Engine.GEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GEQUAL;
  33634. /** 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 */
  33635. Engine.NOTEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NOTEQUAL;
  33636. // Stencil Actions Constants.
  33637. /** Passed to stencilOperation to specify that stencil value must be kept */
  33638. Engine.KEEP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].KEEP;
  33639. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33640. Engine.REPLACE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].REPLACE;
  33641. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33642. Engine.INCR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR;
  33643. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33644. Engine.DECR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR;
  33645. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33646. Engine.INVERT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INVERT;
  33647. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33648. Engine.INCR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR_WRAP;
  33649. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33650. Engine.DECR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR_WRAP;
  33651. /** Texture is not repeating outside of 0..1 UVs */
  33652. Engine.TEXTURE_CLAMP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  33653. /** Texture is repeating outside of 0..1 UVs */
  33654. Engine.TEXTURE_WRAP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  33655. /** Texture is repeating and mirrored */
  33656. Engine.TEXTURE_MIRROR_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  33657. /** ALPHA */
  33658. Engine.TEXTUREFORMAT_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_ALPHA;
  33659. /** LUMINANCE */
  33660. Engine.TEXTUREFORMAT_LUMINANCE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE;
  33661. /** LUMINANCE_ALPHA */
  33662. Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA;
  33663. /** RGB */
  33664. Engine.TEXTUREFORMAT_RGB = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB;
  33665. /** RGBA */
  33666. Engine.TEXTUREFORMAT_RGBA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA;
  33667. /** RED */
  33668. Engine.TEXTUREFORMAT_RED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED;
  33669. /** RED (2nd reference) */
  33670. Engine.TEXTUREFORMAT_R = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R;
  33671. /** RG */
  33672. Engine.TEXTUREFORMAT_RG = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG;
  33673. /** RED_INTEGER */
  33674. Engine.TEXTUREFORMAT_RED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED_INTEGER;
  33675. /** RED_INTEGER (2nd reference) */
  33676. Engine.TEXTUREFORMAT_R_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R_INTEGER;
  33677. /** RG_INTEGER */
  33678. Engine.TEXTUREFORMAT_RG_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG_INTEGER;
  33679. /** RGB_INTEGER */
  33680. Engine.TEXTUREFORMAT_RGB_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB_INTEGER;
  33681. /** RGBA_INTEGER */
  33682. Engine.TEXTUREFORMAT_RGBA_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA_INTEGER;
  33683. /** UNSIGNED_BYTE */
  33684. Engine.TEXTURETYPE_UNSIGNED_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  33685. /** UNSIGNED_BYTE (2nd reference) */
  33686. Engine.TEXTURETYPE_UNSIGNED_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  33687. /** FLOAT */
  33688. Engine.TEXTURETYPE_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT;
  33689. /** HALF_FLOAT */
  33690. Engine.TEXTURETYPE_HALF_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_HALF_FLOAT;
  33691. /** BYTE */
  33692. Engine.TEXTURETYPE_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_BYTE;
  33693. /** SHORT */
  33694. Engine.TEXTURETYPE_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_SHORT;
  33695. /** UNSIGNED_SHORT */
  33696. Engine.TEXTURETYPE_UNSIGNED_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT;
  33697. /** INT */
  33698. Engine.TEXTURETYPE_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_INT;
  33699. /** UNSIGNED_INT */
  33700. Engine.TEXTURETYPE_UNSIGNED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INTEGER;
  33701. /** UNSIGNED_SHORT_4_4_4_4 */
  33702. Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4;
  33703. /** UNSIGNED_SHORT_5_5_5_1 */
  33704. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1;
  33705. /** UNSIGNED_SHORT_5_6_5 */
  33706. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  33707. /** UNSIGNED_INT_2_10_10_10_REV */
  33708. Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV;
  33709. /** UNSIGNED_INT_24_8 */
  33710. Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_24_8;
  33711. /** UNSIGNED_INT_10F_11F_11F_REV */
  33712. Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV;
  33713. /** UNSIGNED_INT_5_9_9_9_REV */
  33714. Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV;
  33715. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33716. Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV;
  33717. /** nearest is mag = nearest and min = nearest and mip = linear */
  33718. Engine.TEXTURE_NEAREST_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  33719. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33720. Engine.TEXTURE_BILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  33721. /** Trilinear is mag = linear and min = linear and mip = linear */
  33722. Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  33723. /** nearest is mag = nearest and min = nearest and mip = linear */
  33724. Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  33725. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33726. Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  33727. /** Trilinear is mag = linear and min = linear and mip = linear */
  33728. Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  33729. /** mag = nearest and min = nearest and mip = nearest */
  33730. Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  33731. /** mag = nearest and min = linear and mip = nearest */
  33732. Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  33733. /** mag = nearest and min = linear and mip = linear */
  33734. Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  33735. /** mag = nearest and min = linear and mip = none */
  33736. Engine.TEXTURE_NEAREST_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR;
  33737. /** mag = nearest and min = nearest and mip = none */
  33738. Engine.TEXTURE_NEAREST_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST;
  33739. /** mag = linear and min = nearest and mip = nearest */
  33740. Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  33741. /** mag = linear and min = nearest and mip = linear */
  33742. Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  33743. /** mag = linear and min = linear and mip = none */
  33744. Engine.TEXTURE_LINEAR_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR;
  33745. /** mag = linear and min = nearest and mip = none */
  33746. Engine.TEXTURE_LINEAR_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST;
  33747. /** Explicit coordinates mode */
  33748. Engine.TEXTURE_EXPLICIT_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EXPLICIT_MODE;
  33749. /** Spherical coordinates mode */
  33750. Engine.TEXTURE_SPHERICAL_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SPHERICAL_MODE;
  33751. /** Planar coordinates mode */
  33752. Engine.TEXTURE_PLANAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PLANAR_MODE;
  33753. /** Cubic coordinates mode */
  33754. Engine.TEXTURE_CUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CUBIC_MODE;
  33755. /** Projection coordinates mode */
  33756. Engine.TEXTURE_PROJECTION_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PROJECTION_MODE;
  33757. /** Skybox coordinates mode */
  33758. Engine.TEXTURE_SKYBOX_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SKYBOX_MODE;
  33759. /** Inverse Cubic coordinates mode */
  33760. Engine.TEXTURE_INVCUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_INVCUBIC_MODE;
  33761. /** Equirectangular coordinates mode */
  33762. Engine.TEXTURE_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  33763. /** Equirectangular Fixed coordinates mode */
  33764. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  33765. /** Equirectangular Fixed Mirrored coordinates mode */
  33766. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  33767. // Texture rescaling mode
  33768. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33769. Engine.SCALEMODE_FLOOR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_FLOOR;
  33770. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33771. Engine.SCALEMODE_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_NEAREST;
  33772. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33773. Engine.SCALEMODE_CEILING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_CEILING;
  33774. // Updatable statics so stick with vars here
  33775. /**
  33776. * Gets or sets the epsilon value used by collision engine
  33777. */
  33778. Engine.CollisionsEpsilon = 0.001;
  33779. /**
  33780. * Method called to create the default rescale post process on each engine.
  33781. */
  33782. Engine._RescalePostProcessFactory = null;
  33783. return Engine;
  33784. }());
  33785. /***/ }),
  33786. /***/ "./Engines/engineStore.ts":
  33787. /*!********************************!*\
  33788. !*** ./Engines/engineStore.ts ***!
  33789. \********************************/
  33790. /*! exports provided: EngineStore */
  33791. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33792. "use strict";
  33793. __webpack_require__.r(__webpack_exports__);
  33794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return EngineStore; });
  33795. /**
  33796. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33797. * during the life time of the application.
  33798. */
  33799. var EngineStore = /** @class */ (function () {
  33800. function EngineStore() {
  33801. }
  33802. Object.defineProperty(EngineStore, "LastCreatedEngine", {
  33803. /**
  33804. * Gets the latest created engine
  33805. */
  33806. get: function () {
  33807. if (this.Instances.length === 0) {
  33808. return null;
  33809. }
  33810. return this.Instances[this.Instances.length - 1];
  33811. },
  33812. enumerable: true,
  33813. configurable: true
  33814. });
  33815. Object.defineProperty(EngineStore, "LastCreatedScene", {
  33816. /**
  33817. * Gets the latest created scene
  33818. */
  33819. get: function () {
  33820. var lastCreatedEngine = this.LastCreatedEngine;
  33821. if (!lastCreatedEngine) {
  33822. return null;
  33823. }
  33824. if (lastCreatedEngine.scenes.length === 0) {
  33825. return null;
  33826. }
  33827. return lastCreatedEngine.scenes[lastCreatedEngine.scenes.length - 1];
  33828. },
  33829. enumerable: true,
  33830. configurable: true
  33831. });
  33832. /** Gets the list of created engines */
  33833. EngineStore.Instances = new Array();
  33834. return EngineStore;
  33835. }());
  33836. /***/ }),
  33837. /***/ "./Engines/index.ts":
  33838. /*!**************************!*\
  33839. !*** ./Engines/index.ts ***!
  33840. \**************************/
  33841. /*! exports provided: Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  33842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33843. "use strict";
  33844. __webpack_require__.r(__webpack_exports__);
  33845. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  33846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _constants__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  33847. /* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ "./Engines/engine.ts");
  33848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["InstancingAttributeInfo"]; });
  33849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["DepthTextureCreationOptions"]; });
  33850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["EngineCapabilities"]; });
  33851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]; });
  33852. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  33853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"]; });
  33854. /* harmony import */ var _nullEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nullEngine */ "./Engines/nullEngine.ts");
  33855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngineOptions"]; });
  33856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngine"]; });
  33857. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Extensions/index */ "./Engines/Extensions/index.ts");
  33858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_OcclusionDataStorage"]; });
  33859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_forceTransformFeedbackToBundle"]; });
  33860. /***/ }),
  33861. /***/ "./Engines/nullEngine.ts":
  33862. /*!*******************************!*\
  33863. !*** ./Engines/nullEngine.ts ***!
  33864. \*******************************/
  33865. /*! exports provided: NullEngineOptions, NullEngine */
  33866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33867. "use strict";
  33868. __webpack_require__.r(__webpack_exports__);
  33869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return NullEngineOptions; });
  33870. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return NullEngine; });
  33871. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33872. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  33873. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  33874. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  33875. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  33876. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  33877. /**
  33878. * Options to create the null engine
  33879. */
  33880. var NullEngineOptions = /** @class */ (function () {
  33881. function NullEngineOptions() {
  33882. /**
  33883. * Render width (Default: 512)
  33884. */
  33885. this.renderWidth = 512;
  33886. /**
  33887. * Render height (Default: 256)
  33888. */
  33889. this.renderHeight = 256;
  33890. /**
  33891. * Texture size (Default: 512)
  33892. */
  33893. this.textureSize = 512;
  33894. /**
  33895. * If delta time between frames should be constant
  33896. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33897. */
  33898. this.deterministicLockstep = false;
  33899. /**
  33900. * Maximum about of steps between frames (Default: 4)
  33901. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33902. */
  33903. this.lockstepMaxSteps = 4;
  33904. }
  33905. return NullEngineOptions;
  33906. }());
  33907. /**
  33908. * The null engine class provides support for headless version of babylon.js.
  33909. * This can be used in server side scenario or for testing purposes
  33910. */
  33911. var NullEngine = /** @class */ (function (_super) {
  33912. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NullEngine, _super);
  33913. function NullEngine(options) {
  33914. if (options === void 0) { options = new NullEngineOptions(); }
  33915. var _this = _super.call(this, null) || this;
  33916. if (options.deterministicLockstep === undefined) {
  33917. options.deterministicLockstep = false;
  33918. }
  33919. if (options.lockstepMaxSteps === undefined) {
  33920. options.lockstepMaxSteps = 4;
  33921. }
  33922. _this._options = options;
  33923. // Init caps
  33924. // We consider we are on a webgl1 capable device
  33925. _this._caps = new _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["EngineCapabilities"]();
  33926. _this._caps.maxTexturesImageUnits = 16;
  33927. _this._caps.maxVertexTextureImageUnits = 16;
  33928. _this._caps.maxTextureSize = 512;
  33929. _this._caps.maxCubemapTextureSize = 512;
  33930. _this._caps.maxRenderTextureSize = 512;
  33931. _this._caps.maxVertexAttribs = 16;
  33932. _this._caps.maxVaryingVectors = 16;
  33933. _this._caps.maxFragmentUniformVectors = 16;
  33934. _this._caps.maxVertexUniformVectors = 16;
  33935. // Extensions
  33936. _this._caps.standardDerivatives = false;
  33937. _this._caps.astc = null;
  33938. _this._caps.s3tc = null;
  33939. _this._caps.pvrtc = null;
  33940. _this._caps.etc1 = null;
  33941. _this._caps.etc2 = null;
  33942. _this._caps.textureAnisotropicFilterExtension = null;
  33943. _this._caps.maxAnisotropy = 0;
  33944. _this._caps.uintIndices = false;
  33945. _this._caps.fragmentDepthSupported = false;
  33946. _this._caps.highPrecisionShaderSupported = true;
  33947. _this._caps.colorBufferFloat = false;
  33948. _this._caps.textureFloat = false;
  33949. _this._caps.textureFloatLinearFiltering = false;
  33950. _this._caps.textureFloatRender = false;
  33951. _this._caps.textureHalfFloat = false;
  33952. _this._caps.textureHalfFloatLinearFiltering = false;
  33953. _this._caps.textureHalfFloatRender = false;
  33954. _this._caps.textureLOD = false;
  33955. _this._caps.drawBuffersExtension = false;
  33956. _this._caps.depthTextureExtension = false;
  33957. _this._caps.vertexArrayObject = false;
  33958. _this._caps.instancedArrays = false;
  33959. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("Babylon.js v" + _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].Version + " - Null engine");
  33960. // Wrappers
  33961. if (typeof URL === "undefined") {
  33962. URL = {
  33963. createObjectURL: function () { },
  33964. revokeObjectURL: function () { }
  33965. };
  33966. }
  33967. if (typeof Blob === "undefined") {
  33968. Blob = function () { };
  33969. }
  33970. return _this;
  33971. }
  33972. /**
  33973. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33974. */
  33975. NullEngine.prototype.isDeterministicLockStep = function () {
  33976. return this._options.deterministicLockstep;
  33977. };
  33978. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  33979. NullEngine.prototype.getLockstepMaxSteps = function () {
  33980. return this._options.lockstepMaxSteps;
  33981. };
  33982. /**
  33983. * Sets hardware scaling, used to save performance if needed
  33984. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33985. */
  33986. NullEngine.prototype.getHardwareScalingLevel = function () {
  33987. return 1.0;
  33988. };
  33989. NullEngine.prototype.createVertexBuffer = function (vertices) {
  33990. return {
  33991. capacity: 0,
  33992. references: 1,
  33993. is32Bits: false
  33994. };
  33995. };
  33996. NullEngine.prototype.createIndexBuffer = function (indices) {
  33997. return {
  33998. capacity: 0,
  33999. references: 1,
  34000. is32Bits: false
  34001. };
  34002. };
  34003. NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {
  34004. if (stencil === void 0) { stencil = false; }
  34005. };
  34006. NullEngine.prototype.getRenderWidth = function (useScreen) {
  34007. if (useScreen === void 0) { useScreen = false; }
  34008. if (!useScreen && this._currentRenderTarget) {
  34009. return this._currentRenderTarget.width;
  34010. }
  34011. return this._options.renderWidth;
  34012. };
  34013. NullEngine.prototype.getRenderHeight = function (useScreen) {
  34014. if (useScreen === void 0) { useScreen = false; }
  34015. if (!useScreen && this._currentRenderTarget) {
  34016. return this._currentRenderTarget.height;
  34017. }
  34018. return this._options.renderHeight;
  34019. };
  34020. NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  34021. this._cachedViewport = viewport;
  34022. };
  34023. NullEngine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context) {
  34024. return {
  34025. transformFeedback: null,
  34026. __SPECTOR_rebuildProgram: null,
  34027. isParallelCompiled: false
  34028. };
  34029. };
  34030. NullEngine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  34031. return [];
  34032. };
  34033. NullEngine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  34034. return [];
  34035. };
  34036. NullEngine.prototype.bindSamplers = function (effect) {
  34037. this._currentEffect = null;
  34038. };
  34039. NullEngine.prototype.enableEffect = function (effect) {
  34040. this._currentEffect = effect;
  34041. if (effect.onBind) {
  34042. effect.onBind(effect);
  34043. }
  34044. if (effect._onBindObservable) {
  34045. effect._onBindObservable.notifyObservers(effect);
  34046. }
  34047. };
  34048. NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  34049. if (zOffset === void 0) { zOffset = 0; }
  34050. if (reverseSide === void 0) { reverseSide = false; }
  34051. };
  34052. NullEngine.prototype.setIntArray = function (uniform, array) {
  34053. };
  34054. NullEngine.prototype.setIntArray2 = function (uniform, array) {
  34055. };
  34056. NullEngine.prototype.setIntArray3 = function (uniform, array) {
  34057. };
  34058. NullEngine.prototype.setIntArray4 = function (uniform, array) {
  34059. };
  34060. NullEngine.prototype.setFloatArray = function (uniform, array) {
  34061. };
  34062. NullEngine.prototype.setFloatArray2 = function (uniform, array) {
  34063. };
  34064. NullEngine.prototype.setFloatArray3 = function (uniform, array) {
  34065. };
  34066. NullEngine.prototype.setFloatArray4 = function (uniform, array) {
  34067. };
  34068. NullEngine.prototype.setArray = function (uniform, array) {
  34069. };
  34070. NullEngine.prototype.setArray2 = function (uniform, array) {
  34071. };
  34072. NullEngine.prototype.setArray3 = function (uniform, array) {
  34073. };
  34074. NullEngine.prototype.setArray4 = function (uniform, array) {
  34075. };
  34076. NullEngine.prototype.setMatrices = function (uniform, matrices) {
  34077. };
  34078. NullEngine.prototype.setMatrix = function (uniform, matrix) {
  34079. };
  34080. NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {
  34081. };
  34082. NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {
  34083. };
  34084. NullEngine.prototype.setFloat = function (uniform, value) {
  34085. };
  34086. NullEngine.prototype.setFloat2 = function (uniform, x, y) {
  34087. };
  34088. NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {
  34089. };
  34090. NullEngine.prototype.setBool = function (uniform, bool) {
  34091. };
  34092. NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  34093. };
  34094. NullEngine.prototype.setColor3 = function (uniform, color3) {
  34095. };
  34096. NullEngine.prototype.setColor4 = function (uniform, color3, alpha) {
  34097. };
  34098. NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  34099. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  34100. if (this._alphaMode === mode) {
  34101. return;
  34102. }
  34103. this._alphaState.alphaBlend = (mode !== _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34104. if (!noDepthWriteChange) {
  34105. this.setDepthWrite(mode === _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34106. }
  34107. this._alphaMode = mode;
  34108. };
  34109. NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  34110. };
  34111. NullEngine.prototype.wipeCaches = function (bruteForce) {
  34112. if (this.preventCacheWipeBetweenFrames) {
  34113. return;
  34114. }
  34115. this.resetTextureCache();
  34116. this._currentEffect = null;
  34117. if (bruteForce) {
  34118. this._currentProgram = null;
  34119. this._stencilState.reset();
  34120. this._depthCullingState.reset();
  34121. this._alphaState.reset();
  34122. }
  34123. this._cachedVertexBuffers = null;
  34124. this._cachedIndexBuffer = null;
  34125. this._cachedEffectForVertexBuffers = null;
  34126. };
  34127. NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  34128. };
  34129. NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  34130. };
  34131. NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  34132. };
  34133. /** @hidden */
  34134. NullEngine.prototype._createTexture = function () {
  34135. return {};
  34136. };
  34137. /** @hidden */
  34138. NullEngine.prototype._releaseTexture = function (texture) {
  34139. };
  34140. NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallBack, format) {
  34141. if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  34142. if (onLoad === void 0) { onLoad = null; }
  34143. if (onError === void 0) { onError = null; }
  34144. if (buffer === void 0) { buffer = null; }
  34145. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_URL);
  34146. var url = String(urlArg);
  34147. texture.url = url;
  34148. texture.generateMipMaps = !noMipmap;
  34149. texture.samplingMode = samplingMode;
  34150. texture.invertY = invertY;
  34151. texture.baseWidth = this._options.textureSize;
  34152. texture.baseHeight = this._options.textureSize;
  34153. texture.width = this._options.textureSize;
  34154. texture.height = this._options.textureSize;
  34155. if (format) {
  34156. texture.format = format;
  34157. }
  34158. texture.isReady = true;
  34159. if (onLoad) {
  34160. onLoad();
  34161. }
  34162. this._internalTexturesCache.push(texture);
  34163. return texture;
  34164. };
  34165. NullEngine.prototype.createRenderTargetTexture = function (size, options) {
  34166. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__["RenderTargetCreationOptions"]();
  34167. if (options !== undefined && typeof options === "object") {
  34168. fullOptions.generateMipMaps = options.generateMipMaps;
  34169. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  34170. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  34171. fullOptions.type = options.type === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT : options.type;
  34172. fullOptions.samplingMode = options.samplingMode === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  34173. }
  34174. else {
  34175. fullOptions.generateMipMaps = options;
  34176. fullOptions.generateDepthBuffer = true;
  34177. fullOptions.generateStencilBuffer = false;
  34178. fullOptions.type = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  34179. fullOptions.samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  34180. }
  34181. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_RENDERTARGET);
  34182. var width = size.width || size;
  34183. var height = size.height || size;
  34184. texture._depthStencilBuffer = {};
  34185. texture._framebuffer = {};
  34186. texture.baseWidth = width;
  34187. texture.baseHeight = height;
  34188. texture.width = width;
  34189. texture.height = height;
  34190. texture.isReady = true;
  34191. texture.samples = 1;
  34192. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  34193. texture.samplingMode = fullOptions.samplingMode;
  34194. texture.type = fullOptions.type;
  34195. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  34196. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  34197. this._internalTexturesCache.push(texture);
  34198. return texture;
  34199. };
  34200. NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  34201. texture.samplingMode = samplingMode;
  34202. };
  34203. NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
  34204. if (this._currentRenderTarget) {
  34205. this.unBindFramebuffer(this._currentRenderTarget);
  34206. }
  34207. this._currentRenderTarget = texture;
  34208. this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
  34209. if (this._cachedViewport && !forceFullscreenViewport) {
  34210. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  34211. }
  34212. };
  34213. NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  34214. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  34215. this._currentRenderTarget = null;
  34216. if (onBeforeUnbind) {
  34217. if (texture._MSAAFramebuffer) {
  34218. this._currentFramebuffer = texture._framebuffer;
  34219. }
  34220. onBeforeUnbind();
  34221. }
  34222. this._currentFramebuffer = null;
  34223. };
  34224. NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
  34225. var vbo = {
  34226. capacity: 1,
  34227. references: 1,
  34228. is32Bits: false
  34229. };
  34230. return vbo;
  34231. };
  34232. NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {
  34233. if (premulAlpha === void 0) { premulAlpha = false; }
  34234. };
  34235. NullEngine.prototype.areAllEffectsReady = function () {
  34236. return true;
  34237. };
  34238. /**
  34239. * @hidden
  34240. * Get the current error code of the webGL context
  34241. * @returns the error code
  34242. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34243. */
  34244. NullEngine.prototype.getError = function () {
  34245. return 0;
  34246. };
  34247. /** @hidden */
  34248. NullEngine.prototype._getUnpackAlignement = function () {
  34249. return 1;
  34250. };
  34251. /** @hidden */
  34252. NullEngine.prototype._unpackFlipY = function (value) {
  34253. };
  34254. NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  34255. if (offset === void 0) { offset = 0; }
  34256. };
  34257. /**
  34258. * Updates a dynamic vertex buffer.
  34259. * @param vertexBuffer the vertex buffer to update
  34260. * @param data the data used to update the vertex buffer
  34261. * @param byteOffset the byte offset of the data (optional)
  34262. * @param byteLength the byte length of the data (optional)
  34263. */
  34264. NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {
  34265. };
  34266. NullEngine.prototype._bindTextureDirectly = function (target, texture) {
  34267. if (this._boundTexturesCache[this._activeChannel] !== texture) {
  34268. this._boundTexturesCache[this._activeChannel] = texture;
  34269. return true;
  34270. }
  34271. return false;
  34272. };
  34273. /** @hidden */
  34274. NullEngine.prototype._bindTexture = function (channel, texture) {
  34275. if (channel < 0) {
  34276. return;
  34277. }
  34278. this._bindTextureDirectly(0, texture);
  34279. };
  34280. /** @hidden */
  34281. NullEngine.prototype._releaseBuffer = function (buffer) {
  34282. buffer.references--;
  34283. if (buffer.references === 0) {
  34284. return true;
  34285. }
  34286. return false;
  34287. };
  34288. NullEngine.prototype.releaseEffects = function () {
  34289. };
  34290. NullEngine.prototype.displayLoadingUI = function () {
  34291. };
  34292. NullEngine.prototype.hideLoadingUI = function () {
  34293. };
  34294. /** @hidden */
  34295. NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  34296. if (faceIndex === void 0) { faceIndex = 0; }
  34297. if (lod === void 0) { lod = 0; }
  34298. };
  34299. /** @hidden */
  34300. NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  34301. if (faceIndex === void 0) { faceIndex = 0; }
  34302. if (lod === void 0) { lod = 0; }
  34303. };
  34304. /** @hidden */
  34305. NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  34306. if (faceIndex === void 0) { faceIndex = 0; }
  34307. if (lod === void 0) { lod = 0; }
  34308. };
  34309. /** @hidden */
  34310. NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  34311. if (faceIndex === void 0) { faceIndex = 0; }
  34312. if (lod === void 0) { lod = 0; }
  34313. };
  34314. return NullEngine;
  34315. }(_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]));
  34316. /***/ }),
  34317. /***/ "./Events/clipboardEvents.ts":
  34318. /*!***********************************!*\
  34319. !*** ./Events/clipboardEvents.ts ***!
  34320. \***********************************/
  34321. /*! exports provided: ClipboardEventTypes, ClipboardInfo */
  34322. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34323. "use strict";
  34324. __webpack_require__.r(__webpack_exports__);
  34325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return ClipboardEventTypes; });
  34326. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return ClipboardInfo; });
  34327. /**
  34328. * Gather the list of clipboard event types as constants.
  34329. */
  34330. var ClipboardEventTypes = /** @class */ (function () {
  34331. function ClipboardEventTypes() {
  34332. }
  34333. /**
  34334. * The clipboard event is fired when a copy command is active (pressed).
  34335. */
  34336. ClipboardEventTypes.COPY = 0x01; //
  34337. /**
  34338. * The clipboard event is fired when a cut command is active (pressed).
  34339. */
  34340. ClipboardEventTypes.CUT = 0x02;
  34341. /**
  34342. * The clipboard event is fired when a paste command is active (pressed).
  34343. */
  34344. ClipboardEventTypes.PASTE = 0x03;
  34345. return ClipboardEventTypes;
  34346. }());
  34347. /**
  34348. * This class is used to store clipboard related info for the onClipboardObservable event.
  34349. */
  34350. var ClipboardInfo = /** @class */ (function () {
  34351. /**
  34352. *Creates an instance of ClipboardInfo.
  34353. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  34354. * @param event Defines the related dom event
  34355. */
  34356. function ClipboardInfo(
  34357. /**
  34358. * Defines the type of event (BABYLON.ClipboardEventTypes)
  34359. */
  34360. type,
  34361. /**
  34362. * Defines the related dom event
  34363. */
  34364. event) {
  34365. this.type = type;
  34366. this.event = event;
  34367. }
  34368. /**
  34369. * Get the clipboard event's type from the keycode.
  34370. * @param keyCode Defines the keyCode for the current keyboard event.
  34371. * @return {number}
  34372. */
  34373. ClipboardInfo.GetTypeFromCharacter = function (keyCode) {
  34374. var charCode = keyCode;
  34375. //TODO: add codes for extended ASCII
  34376. switch (charCode) {
  34377. case 67: return ClipboardEventTypes.COPY;
  34378. case 86: return ClipboardEventTypes.PASTE;
  34379. case 88: return ClipboardEventTypes.CUT;
  34380. default: return -1;
  34381. }
  34382. };
  34383. return ClipboardInfo;
  34384. }());
  34385. /***/ }),
  34386. /***/ "./Events/index.ts":
  34387. /*!*************************!*\
  34388. !*** ./Events/index.ts ***!
  34389. \*************************/
  34390. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo */
  34391. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34392. "use strict";
  34393. __webpack_require__.r(__webpack_exports__);
  34394. /* harmony import */ var _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardEvents */ "./Events/keyboardEvents.ts");
  34395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  34396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  34397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  34398. /* harmony import */ var _pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pointerEvents */ "./Events/pointerEvents.ts");
  34399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"]; });
  34400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoBase"]; });
  34401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoPre"]; });
  34402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfo"]; });
  34403. /* harmony import */ var _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clipboardEvents */ "./Events/clipboardEvents.ts");
  34404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardEventTypes"]; });
  34405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardInfo"]; });
  34406. /***/ }),
  34407. /***/ "./Events/keyboardEvents.ts":
  34408. /*!**********************************!*\
  34409. !*** ./Events/keyboardEvents.ts ***!
  34410. \**********************************/
  34411. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre */
  34412. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34413. "use strict";
  34414. __webpack_require__.r(__webpack_exports__);
  34415. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return KeyboardEventTypes; });
  34416. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return KeyboardInfo; });
  34417. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return KeyboardInfoPre; });
  34418. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34419. /**
  34420. * Gather the list of keyboard event types as constants.
  34421. */
  34422. var KeyboardEventTypes = /** @class */ (function () {
  34423. function KeyboardEventTypes() {
  34424. }
  34425. /**
  34426. * The keydown event is fired when a key becomes active (pressed).
  34427. */
  34428. KeyboardEventTypes.KEYDOWN = 0x01;
  34429. /**
  34430. * The keyup event is fired when a key has been released.
  34431. */
  34432. KeyboardEventTypes.KEYUP = 0x02;
  34433. return KeyboardEventTypes;
  34434. }());
  34435. /**
  34436. * This class is used to store keyboard related info for the onKeyboardObservable event.
  34437. */
  34438. var KeyboardInfo = /** @class */ (function () {
  34439. /**
  34440. * Instantiates a new keyboard info.
  34441. * This class is used to store keyboard related info for the onKeyboardObservable event.
  34442. * @param type Defines the type of event (KeyboardEventTypes)
  34443. * @param event Defines the related dom event
  34444. */
  34445. function KeyboardInfo(
  34446. /**
  34447. * Defines the type of event (KeyboardEventTypes)
  34448. */
  34449. type,
  34450. /**
  34451. * Defines the related dom event
  34452. */
  34453. event) {
  34454. this.type = type;
  34455. this.event = event;
  34456. }
  34457. return KeyboardInfo;
  34458. }());
  34459. /**
  34460. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  34461. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  34462. */
  34463. var KeyboardInfoPre = /** @class */ (function (_super) {
  34464. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeyboardInfoPre, _super);
  34465. /**
  34466. * Instantiates a new keyboard pre info.
  34467. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  34468. * @param type Defines the type of event (KeyboardEventTypes)
  34469. * @param event Defines the related dom event
  34470. */
  34471. function KeyboardInfoPre(
  34472. /**
  34473. * Defines the type of event (KeyboardEventTypes)
  34474. */
  34475. type,
  34476. /**
  34477. * Defines the related dom event
  34478. */
  34479. event) {
  34480. var _this = _super.call(this, type, event) || this;
  34481. _this.type = type;
  34482. _this.event = event;
  34483. _this.skipOnPointerObservable = false;
  34484. return _this;
  34485. }
  34486. return KeyboardInfoPre;
  34487. }(KeyboardInfo));
  34488. /***/ }),
  34489. /***/ "./Events/pointerEvents.ts":
  34490. /*!*********************************!*\
  34491. !*** ./Events/pointerEvents.ts ***!
  34492. \*********************************/
  34493. /*! exports provided: PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo */
  34494. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34495. "use strict";
  34496. __webpack_require__.r(__webpack_exports__);
  34497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return PointerEventTypes; });
  34498. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return PointerInfoBase; });
  34499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return PointerInfoPre; });
  34500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return PointerInfo; });
  34501. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34502. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  34503. /**
  34504. * Gather the list of pointer event types as constants.
  34505. */
  34506. var PointerEventTypes = /** @class */ (function () {
  34507. function PointerEventTypes() {
  34508. }
  34509. /**
  34510. * 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.
  34511. */
  34512. PointerEventTypes.POINTERDOWN = 0x01;
  34513. /**
  34514. * The pointerup event is fired when a pointer is no longer active.
  34515. */
  34516. PointerEventTypes.POINTERUP = 0x02;
  34517. /**
  34518. * The pointermove event is fired when a pointer changes coordinates.
  34519. */
  34520. PointerEventTypes.POINTERMOVE = 0x04;
  34521. /**
  34522. * The pointerwheel event is fired when a mouse wheel has been rotated.
  34523. */
  34524. PointerEventTypes.POINTERWHEEL = 0x08;
  34525. /**
  34526. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  34527. */
  34528. PointerEventTypes.POINTERPICK = 0x10;
  34529. /**
  34530. * The pointertap event is fired when a the object has been touched and released without drag.
  34531. */
  34532. PointerEventTypes.POINTERTAP = 0x20;
  34533. /**
  34534. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  34535. */
  34536. PointerEventTypes.POINTERDOUBLETAP = 0x40;
  34537. return PointerEventTypes;
  34538. }());
  34539. /**
  34540. * Base class of pointer info types.
  34541. */
  34542. var PointerInfoBase = /** @class */ (function () {
  34543. /**
  34544. * Instantiates the base class of pointers info.
  34545. * @param type Defines the type of event (PointerEventTypes)
  34546. * @param event Defines the related dom event
  34547. */
  34548. function PointerInfoBase(
  34549. /**
  34550. * Defines the type of event (PointerEventTypes)
  34551. */
  34552. type,
  34553. /**
  34554. * Defines the related dom event
  34555. */
  34556. event) {
  34557. this.type = type;
  34558. this.event = event;
  34559. }
  34560. return PointerInfoBase;
  34561. }());
  34562. /**
  34563. * This class is used to store pointer related info for the onPrePointerObservable event.
  34564. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  34565. */
  34566. var PointerInfoPre = /** @class */ (function (_super) {
  34567. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfoPre, _super);
  34568. /**
  34569. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  34570. * @param type Defines the type of event (PointerEventTypes)
  34571. * @param event Defines the related dom event
  34572. * @param localX Defines the local x coordinates of the pointer when the event occured
  34573. * @param localY Defines the local y coordinates of the pointer when the event occured
  34574. */
  34575. function PointerInfoPre(type, event, localX, localY) {
  34576. var _this = _super.call(this, type, event) || this;
  34577. /**
  34578. * Ray from a pointer if availible (eg. 6dof controller)
  34579. */
  34580. _this.ray = null;
  34581. _this.skipOnPointerObservable = false;
  34582. _this.localPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](localX, localY);
  34583. return _this;
  34584. }
  34585. return PointerInfoPre;
  34586. }(PointerInfoBase));
  34587. /**
  34588. * This type contains all the data related to a pointer event in Babylon.js.
  34589. * 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.
  34590. */
  34591. var PointerInfo = /** @class */ (function (_super) {
  34592. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfo, _super);
  34593. /**
  34594. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  34595. * @param type Defines the type of event (PointerEventTypes)
  34596. * @param event Defines the related dom event
  34597. * @param pickInfo Defines the picking info associated to the info (if any)\
  34598. */
  34599. function PointerInfo(type, event,
  34600. /**
  34601. * Defines the picking info associated to the info (if any)\
  34602. */
  34603. pickInfo) {
  34604. var _this = _super.call(this, type, event) || this;
  34605. _this.pickInfo = pickInfo;
  34606. return _this;
  34607. }
  34608. return PointerInfo;
  34609. }(PointerInfoBase));
  34610. /***/ }),
  34611. /***/ "./Gamepads/Controllers/daydreamController.ts":
  34612. /*!****************************************************!*\
  34613. !*** ./Gamepads/Controllers/daydreamController.ts ***!
  34614. \****************************************************/
  34615. /*! exports provided: DaydreamController */
  34616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34617. "use strict";
  34618. __webpack_require__.r(__webpack_exports__);
  34619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return DaydreamController; });
  34620. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34621. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  34622. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34623. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34624. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34625. /**
  34626. * Google Daydream controller
  34627. */
  34628. var DaydreamController = /** @class */ (function (_super) {
  34629. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DaydreamController, _super);
  34630. /**
  34631. * Creates a new DaydreamController from a gamepad
  34632. * @param vrGamepad the gamepad that the controller should be created from
  34633. */
  34634. function DaydreamController(vrGamepad) {
  34635. var _this = _super.call(this, vrGamepad) || this;
  34636. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].DAYDREAM;
  34637. return _this;
  34638. }
  34639. /**
  34640. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34641. * @param scene scene in which to add meshes
  34642. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34643. */
  34644. DaydreamController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34645. var _this = this;
  34646. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, function (newMeshes) {
  34647. _this._defaultModel = newMeshes[1];
  34648. _this.attachToMesh(_this._defaultModel);
  34649. if (meshLoaded) {
  34650. meshLoaded(_this._defaultModel);
  34651. }
  34652. });
  34653. };
  34654. /**
  34655. * Called once for each button that changed state since the last frame
  34656. * @param buttonIdx Which button index changed
  34657. * @param state New state of the button
  34658. * @param changes Which properties on the state changed since last frame
  34659. */
  34660. DaydreamController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34661. // Daydream controller only has 1 GamepadButton (on the trackpad).
  34662. if (buttonIdx === 0) {
  34663. var observable = this.onTriggerStateChangedObservable;
  34664. if (observable) {
  34665. observable.notifyObservers(state);
  34666. }
  34667. }
  34668. else {
  34669. // If the app or home buttons are ever made available
  34670. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Unrecognized Daydream button index: " + buttonIdx);
  34671. }
  34672. };
  34673. /**
  34674. * Base Url for the controller model.
  34675. */
  34676. DaydreamController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34677. /**
  34678. * File name for the controller model.
  34679. */
  34680. DaydreamController.MODEL_FILENAME = 'generic.babylon';
  34681. /**
  34682. * Gamepad Id prefix used to identify Daydream Controller.
  34683. */
  34684. DaydreamController.GAMEPAD_ID_PREFIX = 'Daydream'; // id is 'Daydream Controller'
  34685. return DaydreamController;
  34686. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  34687. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34688. canCreate: function (gamepadInfo) {
  34689. return gamepadInfo.id.indexOf(DaydreamController.GAMEPAD_ID_PREFIX) === 0;
  34690. },
  34691. create: function (gamepadInfo) {
  34692. return new DaydreamController(gamepadInfo);
  34693. }
  34694. });
  34695. /***/ }),
  34696. /***/ "./Gamepads/Controllers/gearVRController.ts":
  34697. /*!**************************************************!*\
  34698. !*** ./Gamepads/Controllers/gearVRController.ts ***!
  34699. \**************************************************/
  34700. /*! exports provided: GearVRController */
  34701. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34702. "use strict";
  34703. __webpack_require__.r(__webpack_exports__);
  34704. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return GearVRController; });
  34705. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34706. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  34707. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  34708. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34709. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34710. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34711. /**
  34712. * Gear VR Controller
  34713. */
  34714. var GearVRController = /** @class */ (function (_super) {
  34715. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GearVRController, _super);
  34716. /**
  34717. * Creates a new GearVRController from a gamepad
  34718. * @param vrGamepad the gamepad that the controller should be created from
  34719. */
  34720. function GearVRController(vrGamepad) {
  34721. var _this = _super.call(this, vrGamepad) || this;
  34722. _this._buttonIndexToObservableNameMap = [
  34723. 'onTrackpadChangedObservable',
  34724. 'onTriggerStateChangedObservable' // Trigger
  34725. ];
  34726. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerType"].GEAR_VR;
  34727. // Initial starting position defaults to where hand would be (incase of only 3dof controller)
  34728. _this._calculatedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](_this.hand == "left" ? -0.15 : 0.15, -0.5, 0.25);
  34729. _this._disableTrackPosition(_this._calculatedPosition);
  34730. return _this;
  34731. }
  34732. /**
  34733. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34734. * @param scene scene in which to add meshes
  34735. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34736. */
  34737. GearVRController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34738. var _this = this;
  34739. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__["SceneLoader"].ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, function (newMeshes) {
  34740. // Offset the controller so it will rotate around the users wrist
  34741. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", scene);
  34742. newMeshes[1].parent = mesh;
  34743. newMeshes[1].position.z = -0.15;
  34744. _this._defaultModel = mesh;
  34745. _this.attachToMesh(_this._defaultModel);
  34746. if (meshLoaded) {
  34747. meshLoaded(_this._defaultModel);
  34748. }
  34749. });
  34750. };
  34751. /**
  34752. * Called once for each button that changed state since the last frame
  34753. * @param buttonIdx Which button index changed
  34754. * @param state New state of the button
  34755. * @param changes Which properties on the state changed since last frame
  34756. */
  34757. GearVRController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34758. if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
  34759. var observableName = this._buttonIndexToObservableNameMap[buttonIdx];
  34760. // Only emit events for buttons that we know how to map from index to observable
  34761. var observable = this[observableName];
  34762. if (observable) {
  34763. observable.notifyObservers(state);
  34764. }
  34765. }
  34766. };
  34767. /**
  34768. * Base Url for the controller model.
  34769. */
  34770. GearVRController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34771. /**
  34772. * File name for the controller model.
  34773. */
  34774. GearVRController.MODEL_FILENAME = 'generic.babylon';
  34775. /**
  34776. * Gamepad Id prefix used to identify this controller.
  34777. */
  34778. GearVRController.GAMEPAD_ID_PREFIX = 'Gear VR'; // id is 'Gear VR Controller'
  34779. return GearVRController;
  34780. }(_webVRController__WEBPACK_IMPORTED_MODULE_4__["WebVRController"]));
  34781. _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34782. canCreate: function (gamepadInfo) {
  34783. return gamepadInfo.id.indexOf(GearVRController.GAMEPAD_ID_PREFIX) === 0 ||
  34784. gamepadInfo.id.indexOf('Oculus Go') !== -1;
  34785. },
  34786. create: function (gamepadInfo) {
  34787. return new GearVRController(gamepadInfo);
  34788. }
  34789. });
  34790. /***/ }),
  34791. /***/ "./Gamepads/Controllers/genericController.ts":
  34792. /*!***************************************************!*\
  34793. !*** ./Gamepads/Controllers/genericController.ts ***!
  34794. \***************************************************/
  34795. /*! exports provided: GenericController */
  34796. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34797. "use strict";
  34798. __webpack_require__.r(__webpack_exports__);
  34799. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return GenericController; });
  34800. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34801. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34802. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34803. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34804. /**
  34805. * Generic Controller
  34806. */
  34807. var GenericController = /** @class */ (function (_super) {
  34808. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericController, _super);
  34809. /**
  34810. * Creates a new GenericController from a gamepad
  34811. * @param vrGamepad the gamepad that the controller should be created from
  34812. */
  34813. function GenericController(vrGamepad) {
  34814. return _super.call(this, vrGamepad) || this;
  34815. }
  34816. /**
  34817. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34818. * @param scene scene in which to add meshes
  34819. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34820. */
  34821. GenericController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34822. var _this = this;
  34823. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, function (newMeshes) {
  34824. _this._defaultModel = newMeshes[1];
  34825. _this.attachToMesh(_this._defaultModel);
  34826. if (meshLoaded) {
  34827. meshLoaded(_this._defaultModel);
  34828. }
  34829. });
  34830. };
  34831. /**
  34832. * Called once for each button that changed state since the last frame
  34833. * @param buttonIdx Which button index changed
  34834. * @param state New state of the button
  34835. * @param changes Which properties on the state changed since last frame
  34836. */
  34837. GenericController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34838. console.log("Button id: " + buttonIdx + "state: ");
  34839. console.dir(state);
  34840. };
  34841. /**
  34842. * Base Url for the controller model.
  34843. */
  34844. GenericController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34845. /**
  34846. * File name for the controller model.
  34847. */
  34848. GenericController.MODEL_FILENAME = 'generic.babylon';
  34849. return GenericController;
  34850. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  34851. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._DefaultControllerFactory = function (gamepadInfo) { return new GenericController(gamepadInfo); };
  34852. /***/ }),
  34853. /***/ "./Gamepads/Controllers/index.ts":
  34854. /*!***************************************!*\
  34855. !*** ./Gamepads/Controllers/index.ts ***!
  34856. \***************************************/
  34857. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  34858. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34859. "use strict";
  34860. __webpack_require__.r(__webpack_exports__);
  34861. /* harmony import */ var _daydreamController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./daydreamController */ "./Gamepads/Controllers/daydreamController.ts");
  34862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _daydreamController__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  34863. /* harmony import */ var _gearVRController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gearVRController */ "./Gamepads/Controllers/gearVRController.ts");
  34864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _gearVRController__WEBPACK_IMPORTED_MODULE_1__["GearVRController"]; });
  34865. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  34866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _genericController__WEBPACK_IMPORTED_MODULE_2__["GenericController"]; });
  34867. /* harmony import */ var _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  34868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__["OculusTouchController"]; });
  34869. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"]; });
  34871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]; });
  34872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledController"]; });
  34873. /* harmony import */ var _viveController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viveController */ "./Gamepads/Controllers/viveController.ts");
  34874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _viveController__WEBPACK_IMPORTED_MODULE_5__["ViveController"]; });
  34875. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _webVRController__WEBPACK_IMPORTED_MODULE_6__["WebVRController"]; });
  34877. /* harmony import */ var _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  34878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__["WindowsMotionController"]; });
  34879. /***/ }),
  34880. /***/ "./Gamepads/Controllers/oculusTouchController.ts":
  34881. /*!*******************************************************!*\
  34882. !*** ./Gamepads/Controllers/oculusTouchController.ts ***!
  34883. \*******************************************************/
  34884. /*! exports provided: OculusTouchController */
  34885. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34886. "use strict";
  34887. __webpack_require__.r(__webpack_exports__);
  34888. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return OculusTouchController; });
  34889. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34890. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  34891. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34892. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34893. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34894. /**
  34895. * Oculus Touch Controller
  34896. */
  34897. var OculusTouchController = /** @class */ (function (_super) {
  34898. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OculusTouchController, _super);
  34899. /**
  34900. * Creates a new OculusTouchController from a gamepad
  34901. * @param vrGamepad the gamepad that the controller should be created from
  34902. */
  34903. function OculusTouchController(vrGamepad) {
  34904. var _this = _super.call(this, vrGamepad) || this;
  34905. /**
  34906. * Fired when the secondary trigger on this controller is modified
  34907. */
  34908. _this.onSecondaryTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34909. /**
  34910. * Fired when the thumb rest on this controller is modified
  34911. */
  34912. _this.onThumbRestChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34913. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].OCULUS;
  34914. return _this;
  34915. }
  34916. /**
  34917. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34918. * @param scene scene in which to add meshes
  34919. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34920. */
  34921. OculusTouchController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34922. var _this = this;
  34923. var meshName;
  34924. // Hand
  34925. if (this.hand === 'left') {
  34926. meshName = OculusTouchController.MODEL_LEFT_FILENAME;
  34927. }
  34928. else { // Right is the default if no hand is specified
  34929. meshName = OculusTouchController.MODEL_RIGHT_FILENAME;
  34930. }
  34931. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", OculusTouchController.MODEL_BASE_URL, meshName, scene, function (newMeshes) {
  34932. /*
  34933. Parent Mesh name: oculus_touch_left
  34934. - body
  34935. - trigger
  34936. - thumbstick
  34937. - grip
  34938. - button_y
  34939. - button_x
  34940. - button_enter
  34941. */
  34942. _this._defaultModel = newMeshes[1];
  34943. _this.attachToMesh(_this._defaultModel);
  34944. if (meshLoaded) {
  34945. meshLoaded(_this._defaultModel);
  34946. }
  34947. });
  34948. };
  34949. Object.defineProperty(OculusTouchController.prototype, "onAButtonStateChangedObservable", {
  34950. /**
  34951. * Fired when the A button on this controller is modified
  34952. */
  34953. get: function () {
  34954. if (this.hand === 'right') {
  34955. return this.onMainButtonStateChangedObservable;
  34956. }
  34957. else {
  34958. throw new Error('No A button on left hand');
  34959. }
  34960. },
  34961. enumerable: true,
  34962. configurable: true
  34963. });
  34964. Object.defineProperty(OculusTouchController.prototype, "onBButtonStateChangedObservable", {
  34965. /**
  34966. * Fired when the B button on this controller is modified
  34967. */
  34968. get: function () {
  34969. if (this.hand === 'right') {
  34970. return this.onSecondaryButtonStateChangedObservable;
  34971. }
  34972. else {
  34973. throw new Error('No B button on left hand');
  34974. }
  34975. },
  34976. enumerable: true,
  34977. configurable: true
  34978. });
  34979. Object.defineProperty(OculusTouchController.prototype, "onXButtonStateChangedObservable", {
  34980. /**
  34981. * Fired when the X button on this controller is modified
  34982. */
  34983. get: function () {
  34984. if (this.hand === 'left') {
  34985. return this.onMainButtonStateChangedObservable;
  34986. }
  34987. else {
  34988. throw new Error('No X button on right hand');
  34989. }
  34990. },
  34991. enumerable: true,
  34992. configurable: true
  34993. });
  34994. Object.defineProperty(OculusTouchController.prototype, "onYButtonStateChangedObservable", {
  34995. /**
  34996. * Fired when the Y button on this controller is modified
  34997. */
  34998. get: function () {
  34999. if (this.hand === 'left') {
  35000. return this.onSecondaryButtonStateChangedObservable;
  35001. }
  35002. else {
  35003. throw new Error('No Y button on right hand');
  35004. }
  35005. },
  35006. enumerable: true,
  35007. configurable: true
  35008. });
  35009. /**
  35010. * Called once for each button that changed state since the last frame
  35011. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  35012. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  35013. * 2) secondary trigger (same)
  35014. * 3) A (right) X (left), touch, pressed = value
  35015. * 4) B / Y
  35016. * 5) thumb rest
  35017. * @param buttonIdx Which button index changed
  35018. * @param state New state of the button
  35019. * @param changes Which properties on the state changed since last frame
  35020. */
  35021. OculusTouchController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35022. var notifyObject = state; //{ state: state, changes: changes };
  35023. var triggerDirection = this.hand === 'right' ? -1 : 1;
  35024. switch (buttonIdx) {
  35025. case 0:
  35026. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  35027. return;
  35028. case 1: // index trigger
  35029. if (this._defaultModel) {
  35030. (this._defaultModel.getChildren()[3]).rotation.x = -notifyObject.value * 0.20;
  35031. (this._defaultModel.getChildren()[3]).position.y = -notifyObject.value * 0.005;
  35032. (this._defaultModel.getChildren()[3]).position.z = -notifyObject.value * 0.005;
  35033. }
  35034. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35035. return;
  35036. case 2: // secondary trigger
  35037. if (this._defaultModel) {
  35038. (this._defaultModel.getChildren()[4]).position.x = triggerDirection * notifyObject.value * 0.0035;
  35039. }
  35040. this.onSecondaryTriggerStateChangedObservable.notifyObservers(notifyObject);
  35041. return;
  35042. case 3:
  35043. if (this._defaultModel) {
  35044. if (notifyObject.pressed) {
  35045. (this._defaultModel.getChildren()[1]).position.y = -0.001;
  35046. }
  35047. else {
  35048. (this._defaultModel.getChildren()[1]).position.y = 0;
  35049. }
  35050. }
  35051. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35052. return;
  35053. case 4:
  35054. if (this._defaultModel) {
  35055. if (notifyObject.pressed) {
  35056. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  35057. }
  35058. else {
  35059. (this._defaultModel.getChildren()[2]).position.y = 0;
  35060. }
  35061. }
  35062. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  35063. return;
  35064. case 5:
  35065. this.onThumbRestChangedObservable.notifyObservers(notifyObject);
  35066. return;
  35067. }
  35068. };
  35069. /**
  35070. * Base Url for the controller model.
  35071. */
  35072. OculusTouchController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculus/';
  35073. /**
  35074. * File name for the left controller model.
  35075. */
  35076. OculusTouchController.MODEL_LEFT_FILENAME = 'left.babylon';
  35077. /**
  35078. * File name for the right controller model.
  35079. */
  35080. OculusTouchController.MODEL_RIGHT_FILENAME = 'right.babylon';
  35081. return OculusTouchController;
  35082. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35083. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35084. canCreate: function (gamepadInfo) {
  35085. return gamepadInfo.id.indexOf('Oculus Touch') !== -1;
  35086. },
  35087. create: function (gamepadInfo) {
  35088. return new OculusTouchController(gamepadInfo);
  35089. }
  35090. });
  35091. /***/ }),
  35092. /***/ "./Gamepads/Controllers/poseEnabledController.ts":
  35093. /*!*******************************************************!*\
  35094. !*** ./Gamepads/Controllers/poseEnabledController.ts ***!
  35095. \*******************************************************/
  35096. /*! exports provided: PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController */
  35097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35098. "use strict";
  35099. __webpack_require__.r(__webpack_exports__);
  35100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return PoseEnabledControllerType; });
  35101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return PoseEnabledControllerHelper; });
  35102. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return PoseEnabledController; });
  35103. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35104. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35105. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35106. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  35107. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  35108. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  35109. /**
  35110. * Defines the types of pose enabled controllers that are supported
  35111. */
  35112. var PoseEnabledControllerType;
  35113. (function (PoseEnabledControllerType) {
  35114. /**
  35115. * HTC Vive
  35116. */
  35117. PoseEnabledControllerType[PoseEnabledControllerType["VIVE"] = 0] = "VIVE";
  35118. /**
  35119. * Oculus Rift
  35120. */
  35121. PoseEnabledControllerType[PoseEnabledControllerType["OCULUS"] = 1] = "OCULUS";
  35122. /**
  35123. * Windows mixed reality
  35124. */
  35125. PoseEnabledControllerType[PoseEnabledControllerType["WINDOWS"] = 2] = "WINDOWS";
  35126. /**
  35127. * Samsung gear VR
  35128. */
  35129. PoseEnabledControllerType[PoseEnabledControllerType["GEAR_VR"] = 3] = "GEAR_VR";
  35130. /**
  35131. * Google Daydream
  35132. */
  35133. PoseEnabledControllerType[PoseEnabledControllerType["DAYDREAM"] = 4] = "DAYDREAM";
  35134. /**
  35135. * Generic
  35136. */
  35137. PoseEnabledControllerType[PoseEnabledControllerType["GENERIC"] = 5] = "GENERIC";
  35138. })(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  35139. /**
  35140. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35141. */
  35142. var PoseEnabledControllerHelper = /** @class */ (function () {
  35143. function PoseEnabledControllerHelper() {
  35144. }
  35145. /**
  35146. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35147. * @param vrGamepad the gamepad to initialized
  35148. * @returns a vr controller of the type the gamepad identified as
  35149. */
  35150. PoseEnabledControllerHelper.InitiateController = function (vrGamepad) {
  35151. for (var _i = 0, _a = this._ControllerFactories; _i < _a.length; _i++) {
  35152. var factory = _a[_i];
  35153. if (factory.canCreate(vrGamepad)) {
  35154. return factory.create(vrGamepad);
  35155. }
  35156. }
  35157. if (this._DefaultControllerFactory) {
  35158. return this._DefaultControllerFactory(vrGamepad);
  35159. }
  35160. throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
  35161. };
  35162. /** @hidden */
  35163. PoseEnabledControllerHelper._ControllerFactories = [];
  35164. /** @hidden */
  35165. PoseEnabledControllerHelper._DefaultControllerFactory = null;
  35166. return PoseEnabledControllerHelper;
  35167. }());
  35168. /**
  35169. * Defines the PoseEnabledController object that contains state of a vr capable controller
  35170. */
  35171. var PoseEnabledController = /** @class */ (function (_super) {
  35172. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PoseEnabledController, _super);
  35173. /**
  35174. * Creates a new PoseEnabledController from a gamepad
  35175. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  35176. */
  35177. function PoseEnabledController(browserGamepad) {
  35178. var _this = _super.call(this, browserGamepad.id, browserGamepad.index, browserGamepad) || this;
  35179. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  35180. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35181. _this._deviceRoomRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35182. /**
  35183. * The device position in babylon space
  35184. */
  35185. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35186. /**
  35187. * The device rotation in babylon space
  35188. */
  35189. _this.deviceRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35190. /**
  35191. * The scale factor of the device in babylon space
  35192. */
  35193. _this.deviceScaleFactor = 1;
  35194. // Used to convert 6dof controllers to 3dof
  35195. _this._trackPosition = true;
  35196. _this._maxRotationDistFromHeadset = Math.PI / 5;
  35197. _this._draggedRoomRotation = 0;
  35198. _this._leftHandSystemQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35199. /**
  35200. * Internal, matrix used to convert room space to babylon space
  35201. * @hidden
  35202. */
  35203. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35204. /**
  35205. * Node to be used when casting a ray from the controller
  35206. * @hidden
  35207. */
  35208. _this._pointingPoseNode = null;
  35209. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35210. /**
  35211. * @hidden
  35212. */
  35213. _this._meshAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35214. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED;
  35215. _this.controllerType = PoseEnabledControllerType.GENERIC;
  35216. _this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35217. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35218. _this._calculatedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35219. _this._calculatedRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35220. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(Math.PI, 0, 0, _this._leftHandSystemQuaternion);
  35221. return _this;
  35222. }
  35223. /**
  35224. * @hidden
  35225. */
  35226. PoseEnabledController.prototype._disableTrackPosition = function (fixedPosition) {
  35227. if (this._trackPosition) {
  35228. this._calculatedPosition.copyFrom(fixedPosition);
  35229. this._trackPosition = false;
  35230. }
  35231. };
  35232. /**
  35233. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  35234. */
  35235. PoseEnabledController.prototype.update = function () {
  35236. _super.prototype.update.call(this);
  35237. this._updatePoseAndMesh();
  35238. };
  35239. /**
  35240. * Updates only the pose device and mesh without doing any button event checking
  35241. */
  35242. PoseEnabledController.prototype._updatePoseAndMesh = function () {
  35243. var pose = this.browserGamepad.pose;
  35244. this.updateFromDevice(pose);
  35245. 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) {
  35246. var camera = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera;
  35247. camera._computeDevicePosition();
  35248. this._deviceToWorld.setTranslation(camera.devicePosition);
  35249. if (camera.deviceRotationQuaternion) {
  35250. var camera = camera;
  35251. camera._deviceRoomRotationQuaternion.toEulerAnglesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0]);
  35252. // Find the radian distance away that the headset is from the controllers rotation
  35253. 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));
  35254. if (Math.abs(distanceAway) > this._maxRotationDistFromHeadset) {
  35255. // Only rotate enouph to be within the _maxRotationDistFromHeadset
  35256. var rotationAmount = distanceAway - (distanceAway < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  35257. this._draggedRoomRotation += rotationAmount;
  35258. // Rotate controller around headset
  35259. var sin = Math.sin(-rotationAmount);
  35260. var cos = Math.cos(-rotationAmount);
  35261. this._calculatedPosition.x = this._calculatedPosition.x * cos - this._calculatedPosition.z * sin;
  35262. this._calculatedPosition.z = this._calculatedPosition.x * sin + this._calculatedPosition.z * cos;
  35263. }
  35264. }
  35265. }
  35266. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition);
  35267. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
  35268. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  35269. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation);
  35270. if (this._mesh) {
  35271. this._mesh.position.copyFrom(this.devicePosition);
  35272. if (this._mesh.rotationQuaternion) {
  35273. this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion);
  35274. }
  35275. }
  35276. };
  35277. /**
  35278. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  35279. * @param poseData raw pose fromthe device
  35280. */
  35281. PoseEnabledController.prototype.updateFromDevice = function (poseData) {
  35282. if (poseData) {
  35283. this.rawPose = poseData;
  35284. if (poseData.position) {
  35285. this._deviceRoomPosition.copyFromFloats(poseData.position[0], poseData.position[1], -poseData.position[2]);
  35286. if (this._mesh && this._mesh.getScene().useRightHandedSystem) {
  35287. this._deviceRoomPosition.z *= -1;
  35288. }
  35289. if (this._trackPosition) {
  35290. this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
  35291. }
  35292. this._calculatedPosition.addInPlace(this.position);
  35293. }
  35294. var pose = this.rawPose;
  35295. if (poseData.orientation && pose.orientation) {
  35296. this._deviceRoomRotationQuaternion.copyFromFloats(pose.orientation[0], pose.orientation[1], -pose.orientation[2], -pose.orientation[3]);
  35297. if (this._mesh) {
  35298. if (this._mesh.getScene().useRightHandedSystem) {
  35299. this._deviceRoomRotationQuaternion.z *= -1;
  35300. this._deviceRoomRotationQuaternion.w *= -1;
  35301. }
  35302. else {
  35303. this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion);
  35304. }
  35305. }
  35306. // if the camera is set, rotate to the camera's rotation
  35307. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation);
  35308. }
  35309. }
  35310. };
  35311. /**
  35312. * Attaches a mesh to the controller
  35313. * @param mesh the mesh to be attached
  35314. */
  35315. PoseEnabledController.prototype.attachToMesh = function (mesh) {
  35316. if (this._mesh) {
  35317. this._mesh.parent = null;
  35318. }
  35319. this._mesh = mesh;
  35320. if (this._poseControlledCamera) {
  35321. this._mesh.parent = this._poseControlledCamera;
  35322. }
  35323. if (!this._mesh.rotationQuaternion) {
  35324. this._mesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35325. }
  35326. // 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
  35327. this._updatePoseAndMesh();
  35328. if (this._pointingPoseNode) {
  35329. var parents = [];
  35330. var obj = this._pointingPoseNode;
  35331. while (obj.parent) {
  35332. parents.push(obj.parent);
  35333. obj = obj.parent;
  35334. }
  35335. parents.reverse().forEach(function (p) { p.computeWorldMatrix(true); });
  35336. }
  35337. this._meshAttachedObservable.notifyObservers(mesh);
  35338. };
  35339. /**
  35340. * Attaches the controllers mesh to a camera
  35341. * @param camera the camera the mesh should be attached to
  35342. */
  35343. PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
  35344. this._poseControlledCamera = camera;
  35345. if (this._mesh) {
  35346. this._mesh.parent = this._poseControlledCamera;
  35347. }
  35348. };
  35349. /**
  35350. * Disposes of the controller
  35351. */
  35352. PoseEnabledController.prototype.dispose = function () {
  35353. if (this._mesh) {
  35354. this._mesh.dispose();
  35355. }
  35356. this._mesh = null;
  35357. _super.prototype.dispose.call(this);
  35358. };
  35359. Object.defineProperty(PoseEnabledController.prototype, "mesh", {
  35360. /**
  35361. * The mesh that is attached to the controller
  35362. */
  35363. get: function () {
  35364. return this._mesh;
  35365. },
  35366. enumerable: true,
  35367. configurable: true
  35368. });
  35369. /**
  35370. * Gets the ray of the controller in the direction the controller is pointing
  35371. * @param length the length the resulting ray should be
  35372. * @returns a ray in the direction the controller is pointing
  35373. */
  35374. PoseEnabledController.prototype.getForwardRay = function (length) {
  35375. if (length === void 0) { length = 100; }
  35376. if (!this.mesh) {
  35377. 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);
  35378. }
  35379. var m = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix();
  35380. var origin = m.getTranslation();
  35381. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1);
  35382. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(forward, m);
  35383. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(forwardWorld);
  35384. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, length);
  35385. };
  35386. /**
  35387. * Name of the child mesh that can be used to cast a ray from the controller
  35388. */
  35389. PoseEnabledController.POINTING_POSE = "POINTING_POSE";
  35390. return PoseEnabledController;
  35391. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"]));
  35392. /***/ }),
  35393. /***/ "./Gamepads/Controllers/viveController.ts":
  35394. /*!************************************************!*\
  35395. !*** ./Gamepads/Controllers/viveController.ts ***!
  35396. \************************************************/
  35397. /*! exports provided: ViveController */
  35398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35399. "use strict";
  35400. __webpack_require__.r(__webpack_exports__);
  35401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return ViveController; });
  35402. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35403. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35404. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35405. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35406. /**
  35407. * Vive Controller
  35408. */
  35409. var ViveController = /** @class */ (function (_super) {
  35410. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ViveController, _super);
  35411. /**
  35412. * Creates a new ViveController from a gamepad
  35413. * @param vrGamepad the gamepad that the controller should be created from
  35414. */
  35415. function ViveController(vrGamepad) {
  35416. var _this = _super.call(this, vrGamepad) || this;
  35417. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerType"].VIVE;
  35418. _this._invertLeftStickY = true;
  35419. return _this;
  35420. }
  35421. /**
  35422. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35423. * @param scene scene in which to add meshes
  35424. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35425. */
  35426. ViveController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35427. var _this = this;
  35428. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, function (newMeshes) {
  35429. /*
  35430. Parent Mesh name: ViveWand
  35431. - body
  35432. - r_gripper
  35433. - l_gripper
  35434. - menu_button
  35435. - system_button
  35436. - trackpad
  35437. - trigger
  35438. - LED
  35439. */
  35440. _this._defaultModel = newMeshes[1];
  35441. _this.attachToMesh(_this._defaultModel);
  35442. if (meshLoaded) {
  35443. meshLoaded(_this._defaultModel);
  35444. }
  35445. });
  35446. };
  35447. Object.defineProperty(ViveController.prototype, "onLeftButtonStateChangedObservable", {
  35448. /**
  35449. * Fired when the left button on this controller is modified
  35450. */
  35451. get: function () {
  35452. return this.onMainButtonStateChangedObservable;
  35453. },
  35454. enumerable: true,
  35455. configurable: true
  35456. });
  35457. Object.defineProperty(ViveController.prototype, "onRightButtonStateChangedObservable", {
  35458. /**
  35459. * Fired when the right button on this controller is modified
  35460. */
  35461. get: function () {
  35462. return this.onMainButtonStateChangedObservable;
  35463. },
  35464. enumerable: true,
  35465. configurable: true
  35466. });
  35467. Object.defineProperty(ViveController.prototype, "onMenuButtonStateChangedObservable", {
  35468. /**
  35469. * Fired when the menu button on this controller is modified
  35470. */
  35471. get: function () {
  35472. return this.onSecondaryButtonStateChangedObservable;
  35473. },
  35474. enumerable: true,
  35475. configurable: true
  35476. });
  35477. /**
  35478. * Called once for each button that changed state since the last frame
  35479. * Vive mapping:
  35480. * 0: touchpad
  35481. * 1: trigger
  35482. * 2: left AND right buttons
  35483. * 3: menu button
  35484. * @param buttonIdx Which button index changed
  35485. * @param state New state of the button
  35486. * @param changes Which properties on the state changed since last frame
  35487. */
  35488. ViveController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35489. var notifyObject = state; //{ state: state, changes: changes };
  35490. switch (buttonIdx) {
  35491. case 0:
  35492. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  35493. return;
  35494. case 1: // index trigger
  35495. if (this._defaultModel) {
  35496. (this._defaultModel.getChildren()[6]).rotation.x = -notifyObject.value * 0.15;
  35497. }
  35498. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35499. return;
  35500. case 2: // left AND right button
  35501. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35502. return;
  35503. case 3:
  35504. if (this._defaultModel) {
  35505. if (notifyObject.pressed) {
  35506. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  35507. }
  35508. else {
  35509. (this._defaultModel.getChildren()[2]).position.y = 0;
  35510. }
  35511. }
  35512. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  35513. return;
  35514. }
  35515. };
  35516. /**
  35517. * Base Url for the controller model.
  35518. */
  35519. ViveController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/vive/';
  35520. /**
  35521. * File name for the controller model.
  35522. */
  35523. ViveController.MODEL_FILENAME = 'wand.babylon';
  35524. return ViveController;
  35525. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  35526. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35527. canCreate: function (gamepadInfo) {
  35528. return gamepadInfo.id.toLowerCase().indexOf('openvr') !== -1;
  35529. },
  35530. create: function (gamepadInfo) {
  35531. return new ViveController(gamepadInfo);
  35532. }
  35533. });
  35534. /***/ }),
  35535. /***/ "./Gamepads/Controllers/webVRController.ts":
  35536. /*!*************************************************!*\
  35537. !*** ./Gamepads/Controllers/webVRController.ts ***!
  35538. \*************************************************/
  35539. /*! exports provided: WebVRController */
  35540. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35541. "use strict";
  35542. __webpack_require__.r(__webpack_exports__);
  35543. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return WebVRController; });
  35544. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35545. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35546. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35547. /**
  35548. * Defines the WebVRController object that represents controllers tracked in 3D space
  35549. */
  35550. var WebVRController = /** @class */ (function (_super) {
  35551. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRController, _super);
  35552. /**
  35553. * Creates a new WebVRController from a gamepad
  35554. * @param vrGamepad the gamepad that the WebVRController should be created from
  35555. */
  35556. function WebVRController(vrGamepad) {
  35557. var _this = _super.call(this, vrGamepad) || this;
  35558. // Observables
  35559. /**
  35560. * Fired when the trigger state has changed
  35561. */
  35562. _this.onTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35563. /**
  35564. * Fired when the main button state has changed
  35565. */
  35566. _this.onMainButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35567. /**
  35568. * Fired when the secondary button state has changed
  35569. */
  35570. _this.onSecondaryButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35571. /**
  35572. * Fired when the pad state has changed
  35573. */
  35574. _this.onPadStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35575. /**
  35576. * Fired when controllers stick values have changed
  35577. */
  35578. _this.onPadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35579. /**
  35580. * X and Y axis corrisponding to the controllers joystick
  35581. */
  35582. _this.pad = { x: 0, y: 0 };
  35583. // avoid GC, store state in a tmp object
  35584. _this._changes = {
  35585. pressChanged: false,
  35586. touchChanged: false,
  35587. valueChanged: false,
  35588. changed: false
  35589. };
  35590. _this._buttons = new Array(vrGamepad.buttons.length);
  35591. _this.hand = vrGamepad.hand;
  35592. return _this;
  35593. }
  35594. /**
  35595. * Fired when a controller button's state has changed
  35596. * @param callback the callback containing the button that was modified
  35597. */
  35598. WebVRController.prototype.onButtonStateChange = function (callback) {
  35599. this._onButtonStateChange = callback;
  35600. };
  35601. Object.defineProperty(WebVRController.prototype, "defaultModel", {
  35602. /**
  35603. * The default controller model for the controller
  35604. */
  35605. get: function () {
  35606. return this._defaultModel;
  35607. },
  35608. enumerable: true,
  35609. configurable: true
  35610. });
  35611. /**
  35612. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  35613. */
  35614. WebVRController.prototype.update = function () {
  35615. _super.prototype.update.call(this);
  35616. for (var index = 0; index < this._buttons.length; index++) {
  35617. this._setButtonValue(this.browserGamepad.buttons[index], this._buttons[index], index);
  35618. }
  35619. if (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) {
  35620. this.pad.x = this.leftStick.x;
  35621. this.pad.y = this.leftStick.y;
  35622. this.onPadValuesChangedObservable.notifyObservers(this.pad);
  35623. }
  35624. };
  35625. WebVRController.prototype._setButtonValue = function (newState, currentState, buttonIndex) {
  35626. if (!newState) {
  35627. newState = {
  35628. pressed: false,
  35629. touched: false,
  35630. value: 0
  35631. };
  35632. }
  35633. if (!currentState) {
  35634. this._buttons[buttonIndex] = {
  35635. pressed: newState.pressed,
  35636. touched: newState.touched,
  35637. value: newState.value
  35638. };
  35639. return;
  35640. }
  35641. this._checkChanges(newState, currentState);
  35642. if (this._changes.changed) {
  35643. this._onButtonStateChange && this._onButtonStateChange(this.index, buttonIndex, newState);
  35644. this._handleButtonChange(buttonIndex, newState, this._changes);
  35645. }
  35646. this._buttons[buttonIndex].pressed = newState.pressed;
  35647. this._buttons[buttonIndex].touched = newState.touched;
  35648. // oculus triggers are never 0, thou not touched.
  35649. this._buttons[buttonIndex].value = newState.value < 0.00000001 ? 0 : newState.value;
  35650. };
  35651. WebVRController.prototype._checkChanges = function (newState, currentState) {
  35652. this._changes.pressChanged = newState.pressed !== currentState.pressed;
  35653. this._changes.touchChanged = newState.touched !== currentState.touched;
  35654. this._changes.valueChanged = newState.value !== currentState.value;
  35655. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
  35656. return this._changes;
  35657. };
  35658. /**
  35659. * Disposes of th webVRCOntroller
  35660. */
  35661. WebVRController.prototype.dispose = function () {
  35662. _super.prototype.dispose.call(this);
  35663. this.onTriggerStateChangedObservable.clear();
  35664. this.onMainButtonStateChangedObservable.clear();
  35665. this.onSecondaryButtonStateChangedObservable.clear();
  35666. this.onPadStateChangedObservable.clear();
  35667. this.onPadValuesChangedObservable.clear();
  35668. };
  35669. return WebVRController;
  35670. }(_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledController"]));
  35671. /***/ }),
  35672. /***/ "./Gamepads/Controllers/windowsMotionController.ts":
  35673. /*!*********************************************************!*\
  35674. !*** ./Gamepads/Controllers/windowsMotionController.ts ***!
  35675. \*********************************************************/
  35676. /*! exports provided: WindowsMotionController */
  35677. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35678. "use strict";
  35679. __webpack_require__.r(__webpack_exports__);
  35680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return WindowsMotionController; });
  35681. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35682. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  35683. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35684. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35685. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  35686. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  35687. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35688. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35689. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  35690. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35691. /**
  35692. * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
  35693. */
  35694. var LoadedMeshInfo = /** @class */ (function () {
  35695. function LoadedMeshInfo() {
  35696. /**
  35697. * Map of the button meshes contained in the controller
  35698. */
  35699. this.buttonMeshes = {};
  35700. /**
  35701. * Map of the axis meshes contained in the controller
  35702. */
  35703. this.axisMeshes = {};
  35704. }
  35705. return LoadedMeshInfo;
  35706. }());
  35707. /**
  35708. * Defines the WindowsMotionController object that the state of the windows motion controller
  35709. */
  35710. var WindowsMotionController = /** @class */ (function (_super) {
  35711. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WindowsMotionController, _super);
  35712. /**
  35713. * Creates a new WindowsMotionController from a gamepad
  35714. * @param vrGamepad the gamepad that the controller should be created from
  35715. */
  35716. function WindowsMotionController(vrGamepad) {
  35717. var _this = _super.call(this, vrGamepad) || this;
  35718. _this._mapping = {
  35719. // Semantic button names
  35720. buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
  35721. // A mapping of the button name to glTF model node name
  35722. // that should be transformed by button value.
  35723. buttonMeshNames: {
  35724. 'trigger': 'SELECT',
  35725. 'menu': 'MENU',
  35726. 'grip': 'GRASP',
  35727. 'thumbstick': 'THUMBSTICK_PRESS',
  35728. 'trackpad': 'TOUCHPAD_PRESS'
  35729. },
  35730. // This mapping is used to translate from the Motion Controller to Babylon semantics
  35731. buttonObservableNames: {
  35732. 'trigger': 'onTriggerStateChangedObservable',
  35733. 'menu': 'onSecondaryButtonStateChangedObservable',
  35734. 'grip': 'onMainButtonStateChangedObservable',
  35735. 'thumbstick': 'onPadStateChangedObservable',
  35736. 'trackpad': 'onTrackpadChangedObservable'
  35737. },
  35738. // A mapping of the axis name to glTF model node name
  35739. // that should be transformed by axis value.
  35740. // This array mirrors the browserGamepad.axes array, such that
  35741. // the mesh corresponding to axis 0 is in this array index 0.
  35742. axisMeshNames: [
  35743. 'THUMBSTICK_X',
  35744. 'THUMBSTICK_Y',
  35745. 'TOUCHPAD_TOUCH_X',
  35746. 'TOUCHPAD_TOUCH_Y'
  35747. ],
  35748. pointingPoseMeshName: _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledController"].POINTING_POSE
  35749. };
  35750. /**
  35751. * Fired when the trackpad on this controller is clicked
  35752. */
  35753. _this.onTrackpadChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  35754. /**
  35755. * Fired when the trackpad on this controller is modified
  35756. */
  35757. _this.onTrackpadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  35758. /**
  35759. * The current x and y values of this controller's trackpad
  35760. */
  35761. _this.trackpad = { x: 0, y: 0 };
  35762. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerType"].WINDOWS;
  35763. _this._loadedMeshInfo = null;
  35764. return _this;
  35765. }
  35766. Object.defineProperty(WindowsMotionController.prototype, "onTriggerButtonStateChangedObservable", {
  35767. /**
  35768. * Fired when the trigger on this controller is modified
  35769. */
  35770. get: function () {
  35771. return this.onTriggerStateChangedObservable;
  35772. },
  35773. enumerable: true,
  35774. configurable: true
  35775. });
  35776. Object.defineProperty(WindowsMotionController.prototype, "onMenuButtonStateChangedObservable", {
  35777. /**
  35778. * Fired when the menu button on this controller is modified
  35779. */
  35780. get: function () {
  35781. return this.onSecondaryButtonStateChangedObservable;
  35782. },
  35783. enumerable: true,
  35784. configurable: true
  35785. });
  35786. Object.defineProperty(WindowsMotionController.prototype, "onGripButtonStateChangedObservable", {
  35787. /**
  35788. * Fired when the grip button on this controller is modified
  35789. */
  35790. get: function () {
  35791. return this.onMainButtonStateChangedObservable;
  35792. },
  35793. enumerable: true,
  35794. configurable: true
  35795. });
  35796. Object.defineProperty(WindowsMotionController.prototype, "onThumbstickButtonStateChangedObservable", {
  35797. /**
  35798. * Fired when the thumbstick button on this controller is modified
  35799. */
  35800. get: function () {
  35801. return this.onPadStateChangedObservable;
  35802. },
  35803. enumerable: true,
  35804. configurable: true
  35805. });
  35806. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadButtonStateChangedObservable", {
  35807. /**
  35808. * Fired when the touchpad button on this controller is modified
  35809. */
  35810. get: function () {
  35811. return this.onTrackpadChangedObservable;
  35812. },
  35813. enumerable: true,
  35814. configurable: true
  35815. });
  35816. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadValuesChangedObservable", {
  35817. /**
  35818. * Fired when the touchpad values on this controller are modified
  35819. */
  35820. get: function () {
  35821. return this.onTrackpadValuesChangedObservable;
  35822. },
  35823. enumerable: true,
  35824. configurable: true
  35825. });
  35826. WindowsMotionController.prototype._updateTrackpad = function () {
  35827. if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
  35828. this.trackpad.x = this.browserGamepad["axes"][2];
  35829. this.trackpad.y = this.browserGamepad["axes"][3];
  35830. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
  35831. }
  35832. };
  35833. /**
  35834. * Called once per frame by the engine.
  35835. */
  35836. WindowsMotionController.prototype.update = function () {
  35837. _super.prototype.update.call(this);
  35838. if (this.browserGamepad.axes) {
  35839. this._updateTrackpad();
  35840. // Only need to animate axes if there is a loaded mesh
  35841. if (this._loadedMeshInfo) {
  35842. for (var axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
  35843. this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
  35844. }
  35845. }
  35846. }
  35847. };
  35848. /**
  35849. * Called once for each button that changed state since the last frame
  35850. * @param buttonIdx Which button index changed
  35851. * @param state New state of the button
  35852. * @param changes Which properties on the state changed since last frame
  35853. */
  35854. WindowsMotionController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35855. var buttonName = this._mapping.buttons[buttonIdx];
  35856. if (!buttonName) {
  35857. return;
  35858. }
  35859. // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
  35860. this._updateTrackpad();
  35861. // Only emit events for buttons that we know how to map from index to name
  35862. var observable = this[(this._mapping.buttonObservableNames)[buttonName]];
  35863. if (observable) {
  35864. observable.notifyObservers(state);
  35865. }
  35866. this._lerpButtonTransform(buttonName, state.value);
  35867. };
  35868. /**
  35869. * Moves the buttons on the controller mesh based on their current state
  35870. * @param buttonName the name of the button to move
  35871. * @param buttonValue the value of the button which determines the buttons new position
  35872. */
  35873. WindowsMotionController.prototype._lerpButtonTransform = function (buttonName, buttonValue) {
  35874. // If there is no loaded mesh, there is nothing to transform.
  35875. if (!this._loadedMeshInfo) {
  35876. return;
  35877. }
  35878. var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
  35879. if (!meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  35880. return;
  35881. }
  35882. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
  35883. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
  35884. };
  35885. /**
  35886. * Moves the axis on the controller mesh based on its current state
  35887. * @param axis the index of the axis
  35888. * @param axisValue the value of the axis which determines the meshes new position
  35889. * @hidden
  35890. */
  35891. WindowsMotionController.prototype._lerpAxisTransform = function (axis, axisValue) {
  35892. if (!this._loadedMeshInfo) {
  35893. return;
  35894. }
  35895. var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
  35896. if (!meshInfo) {
  35897. return;
  35898. }
  35899. if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  35900. return;
  35901. }
  35902. // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
  35903. var lerpValue = axisValue * 0.5 + 0.5;
  35904. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
  35905. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
  35906. };
  35907. /**
  35908. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35909. * @param scene scene in which to add meshes
  35910. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35911. */
  35912. WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded, forceDefault) {
  35913. var _this = this;
  35914. if (forceDefault === void 0) { forceDefault = false; }
  35915. var path;
  35916. var filename;
  35917. // Checking if GLB loader is present
  35918. if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].IsPluginForExtensionAvailable(".glb")) {
  35919. // Determine the device specific folder based on the ID suffix
  35920. var device = 'default';
  35921. if (this.id && !forceDefault) {
  35922. var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
  35923. device = ((match && match[0]) || device);
  35924. }
  35925. // Hand
  35926. if (this.hand === 'left') {
  35927. filename = WindowsMotionController.MODEL_LEFT_FILENAME;
  35928. }
  35929. else { // Right is the default if no hand is specified
  35930. filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
  35931. }
  35932. path = WindowsMotionController.MODEL_BASE_URL + device + '/';
  35933. }
  35934. else {
  35935. _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");
  35936. path = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_BASE_URL;
  35937. filename = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_FILENAME;
  35938. }
  35939. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].ImportMesh("", path, filename, scene, function (meshes) {
  35940. // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
  35941. _this._loadedMeshInfo = _this.processModel(scene, meshes);
  35942. if (!_this._loadedMeshInfo) {
  35943. return;
  35944. }
  35945. _this._defaultModel = _this._loadedMeshInfo.rootNode;
  35946. _this.attachToMesh(_this._defaultModel);
  35947. if (meshLoaded) {
  35948. meshLoaded(_this._defaultModel);
  35949. }
  35950. }, null, function (scene, message) {
  35951. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log(message);
  35952. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
  35953. if (!forceDefault) {
  35954. _this.initControllerMesh(scene, meshLoaded, true);
  35955. }
  35956. });
  35957. };
  35958. /**
  35959. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  35960. * can be transformed by button presses and axes values, based on this._mapping.
  35961. *
  35962. * @param scene scene in which the meshes exist
  35963. * @param meshes list of meshes that make up the controller model to process
  35964. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  35965. */
  35966. WindowsMotionController.prototype.processModel = function (scene, meshes) {
  35967. var loadedMeshInfo = null;
  35968. // Create a new mesh to contain the glTF hierarchy
  35969. var parentMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.id + " " + this.hand, scene);
  35970. // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
  35971. var childMesh = null;
  35972. for (var i = 0; i < meshes.length; i++) {
  35973. var mesh = meshes[i];
  35974. if (!mesh.parent) {
  35975. // Exclude controller meshes from picking results
  35976. mesh.isPickable = false;
  35977. // Handle root node, attach to the new parentMesh
  35978. childMesh = mesh;
  35979. break;
  35980. }
  35981. }
  35982. if (childMesh) {
  35983. childMesh.setParent(parentMesh);
  35984. // Create our mesh info. Note that this method will always return non-null.
  35985. loadedMeshInfo = this.createMeshInfo(parentMesh);
  35986. }
  35987. else {
  35988. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Could not find root node in model file.');
  35989. }
  35990. return loadedMeshInfo;
  35991. };
  35992. WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
  35993. var loadedMeshInfo = new LoadedMeshInfo();
  35994. var i;
  35995. loadedMeshInfo.rootNode = rootNode;
  35996. // Reset the caches
  35997. loadedMeshInfo.buttonMeshes = {};
  35998. loadedMeshInfo.axisMeshes = {};
  35999. // Button Meshes
  36000. for (i = 0; i < this._mapping.buttons.length; i++) {
  36001. var buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
  36002. if (!buttonMeshName) {
  36003. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
  36004. continue;
  36005. }
  36006. var buttonMesh = getChildByName(rootNode, buttonMeshName);
  36007. if (!buttonMesh) {
  36008. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button mesh with name: ' + buttonMeshName);
  36009. continue;
  36010. }
  36011. var buttonMeshInfo = {
  36012. index: i,
  36013. value: getImmediateChildByName(buttonMesh, 'VALUE'),
  36014. pressed: getImmediateChildByName(buttonMesh, 'PRESSED'),
  36015. unpressed: getImmediateChildByName(buttonMesh, 'UNPRESSED')
  36016. };
  36017. if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
  36018. loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
  36019. }
  36020. else {
  36021. // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
  36022. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
  36023. '(VALUE: ' + !!buttonMeshInfo.value +
  36024. ', PRESSED: ' + !!buttonMeshInfo.pressed +
  36025. ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
  36026. ')');
  36027. }
  36028. }
  36029. // Axis Meshes
  36030. for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
  36031. var axisMeshName = this._mapping.axisMeshNames[i];
  36032. if (!axisMeshName) {
  36033. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown axis at index: ' + i);
  36034. continue;
  36035. }
  36036. var axisMesh = getChildByName(rootNode, axisMeshName);
  36037. if (!axisMesh) {
  36038. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis mesh with name: ' + axisMeshName);
  36039. continue;
  36040. }
  36041. var axisMeshInfo = {
  36042. index: i,
  36043. value: getImmediateChildByName(axisMesh, 'VALUE'),
  36044. min: getImmediateChildByName(axisMesh, 'MIN'),
  36045. max: getImmediateChildByName(axisMesh, 'MAX')
  36046. };
  36047. if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
  36048. loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
  36049. }
  36050. else {
  36051. // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
  36052. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
  36053. '(VALUE: ' + !!axisMeshInfo.value +
  36054. ', MIN: ' + !!axisMeshInfo.min +
  36055. ', MAX:' + !!axisMeshInfo.max +
  36056. ')');
  36057. }
  36058. }
  36059. // Pointing Ray
  36060. loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
  36061. if (!loadedMeshInfo.pointingPoseNode) {
  36062. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
  36063. }
  36064. else {
  36065. this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
  36066. }
  36067. return loadedMeshInfo;
  36068. // Look through all children recursively. This will return null if no mesh exists with the given name.
  36069. function getChildByName(node, name) {
  36070. return node.getChildren(function (n) { return n.name === name; }, false)[0];
  36071. }
  36072. // Look through only immediate children. This will return null if no mesh exists with the given name.
  36073. function getImmediateChildByName(node, name) {
  36074. return node.getChildren(function (n) { return n.name == name; }, true)[0];
  36075. }
  36076. };
  36077. /**
  36078. * Gets the ray of the controller in the direction the controller is pointing
  36079. * @param length the length the resulting ray should be
  36080. * @returns a ray in the direction the controller is pointing
  36081. */
  36082. WindowsMotionController.prototype.getForwardRay = function (length) {
  36083. if (length === void 0) { length = 100; }
  36084. if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
  36085. return _super.prototype.getForwardRay.call(this, length);
  36086. }
  36087. var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
  36088. var origin = m.getTranslation();
  36089. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  36090. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(forward, m);
  36091. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(forwardWorld);
  36092. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, length);
  36093. };
  36094. /**
  36095. * Disposes of the controller
  36096. */
  36097. WindowsMotionController.prototype.dispose = function () {
  36098. _super.prototype.dispose.call(this);
  36099. this.onTrackpadChangedObservable.clear();
  36100. };
  36101. /**
  36102. * The base url used to load the left and right controller models
  36103. */
  36104. WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/microsoft/';
  36105. /**
  36106. * The name of the left controller model file
  36107. */
  36108. WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
  36109. /**
  36110. * The name of the right controller model file
  36111. */
  36112. WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
  36113. /**
  36114. * The controller name prefix for this controller type
  36115. */
  36116. WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
  36117. /**
  36118. * The controller id pattern for this controller type
  36119. */
  36120. WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
  36121. return WindowsMotionController;
  36122. }(_webVRController__WEBPACK_IMPORTED_MODULE_7__["WebVRController"]));
  36123. _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36124. canCreate: function (gamepadInfo) {
  36125. return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
  36126. },
  36127. create: function (gamepadInfo) {
  36128. return new WindowsMotionController(gamepadInfo);
  36129. }
  36130. });
  36131. /***/ }),
  36132. /***/ "./Gamepads/gamepad.ts":
  36133. /*!*****************************!*\
  36134. !*** ./Gamepads/gamepad.ts ***!
  36135. \*****************************/
  36136. /*! exports provided: StickValues, Gamepad, GenericPad */
  36137. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36138. "use strict";
  36139. __webpack_require__.r(__webpack_exports__);
  36140. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return StickValues; });
  36141. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return Gamepad; });
  36142. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return GenericPad; });
  36143. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36144. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36145. /**
  36146. * Represents a gamepad control stick position
  36147. */
  36148. var StickValues = /** @class */ (function () {
  36149. /**
  36150. * Initializes the gamepad x and y control stick values
  36151. * @param x The x component of the gamepad control stick value
  36152. * @param y The y component of the gamepad control stick value
  36153. */
  36154. function StickValues(
  36155. /**
  36156. * The x component of the control stick
  36157. */
  36158. x,
  36159. /**
  36160. * The y component of the control stick
  36161. */
  36162. y) {
  36163. this.x = x;
  36164. this.y = y;
  36165. }
  36166. return StickValues;
  36167. }());
  36168. /**
  36169. * Represents a gamepad
  36170. */
  36171. var Gamepad = /** @class */ (function () {
  36172. /**
  36173. * Initializes the gamepad
  36174. * @param id The id of the gamepad
  36175. * @param index The index of the gamepad
  36176. * @param browserGamepad The browser gamepad
  36177. * @param leftStickX The x component of the left joystick
  36178. * @param leftStickY The y component of the left joystick
  36179. * @param rightStickX The x component of the right joystick
  36180. * @param rightStickY The y component of the right joystick
  36181. */
  36182. function Gamepad(
  36183. /**
  36184. * The id of the gamepad
  36185. */
  36186. id,
  36187. /**
  36188. * The index of the gamepad
  36189. */
  36190. index,
  36191. /**
  36192. * The browser gamepad
  36193. */
  36194. browserGamepad, leftStickX, leftStickY, rightStickX, rightStickY) {
  36195. if (leftStickX === void 0) { leftStickX = 0; }
  36196. if (leftStickY === void 0) { leftStickY = 1; }
  36197. if (rightStickX === void 0) { rightStickX = 2; }
  36198. if (rightStickY === void 0) { rightStickY = 3; }
  36199. this.id = id;
  36200. this.index = index;
  36201. this.browserGamepad = browserGamepad;
  36202. this._leftStick = { x: 0, y: 0 };
  36203. this._rightStick = { x: 0, y: 0 };
  36204. /** @hidden */
  36205. this._isConnected = true;
  36206. /**
  36207. * Specifies whether the left control stick should be Y-inverted
  36208. */
  36209. this._invertLeftStickY = false;
  36210. this.type = Gamepad.GAMEPAD;
  36211. this._leftStickAxisX = leftStickX;
  36212. this._leftStickAxisY = leftStickY;
  36213. this._rightStickAxisX = rightStickX;
  36214. this._rightStickAxisY = rightStickY;
  36215. if (this.browserGamepad.axes.length >= 2) {
  36216. this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  36217. }
  36218. if (this.browserGamepad.axes.length >= 4) {
  36219. this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  36220. }
  36221. }
  36222. Object.defineProperty(Gamepad.prototype, "isConnected", {
  36223. /**
  36224. * Specifies if the gamepad has been connected
  36225. */
  36226. get: function () {
  36227. return this._isConnected;
  36228. },
  36229. enumerable: true,
  36230. configurable: true
  36231. });
  36232. /**
  36233. * Callback triggered when the left joystick has changed
  36234. * @param callback
  36235. */
  36236. Gamepad.prototype.onleftstickchanged = function (callback) {
  36237. this._onleftstickchanged = callback;
  36238. };
  36239. /**
  36240. * Callback triggered when the right joystick has changed
  36241. * @param callback
  36242. */
  36243. Gamepad.prototype.onrightstickchanged = function (callback) {
  36244. this._onrightstickchanged = callback;
  36245. };
  36246. Object.defineProperty(Gamepad.prototype, "leftStick", {
  36247. /**
  36248. * Gets the left joystick
  36249. */
  36250. get: function () {
  36251. return this._leftStick;
  36252. },
  36253. /**
  36254. * Sets the left joystick values
  36255. */
  36256. set: function (newValues) {
  36257. if (this._onleftstickchanged && (this._leftStick.x !== newValues.x || this._leftStick.y !== newValues.y)) {
  36258. this._onleftstickchanged(newValues);
  36259. }
  36260. this._leftStick = newValues;
  36261. },
  36262. enumerable: true,
  36263. configurable: true
  36264. });
  36265. Object.defineProperty(Gamepad.prototype, "rightStick", {
  36266. /**
  36267. * Gets the right joystick
  36268. */
  36269. get: function () {
  36270. return this._rightStick;
  36271. },
  36272. /**
  36273. * Sets the right joystick value
  36274. */
  36275. set: function (newValues) {
  36276. if (this._onrightstickchanged && (this._rightStick.x !== newValues.x || this._rightStick.y !== newValues.y)) {
  36277. this._onrightstickchanged(newValues);
  36278. }
  36279. this._rightStick = newValues;
  36280. },
  36281. enumerable: true,
  36282. configurable: true
  36283. });
  36284. /**
  36285. * Updates the gamepad joystick positions
  36286. */
  36287. Gamepad.prototype.update = function () {
  36288. if (this._leftStick) {
  36289. this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  36290. if (this._invertLeftStickY) {
  36291. this.leftStick.y *= -1;
  36292. }
  36293. }
  36294. if (this._rightStick) {
  36295. this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  36296. }
  36297. };
  36298. /**
  36299. * Disposes the gamepad
  36300. */
  36301. Gamepad.prototype.dispose = function () {
  36302. };
  36303. /**
  36304. * Represents a gamepad controller
  36305. */
  36306. Gamepad.GAMEPAD = 0;
  36307. /**
  36308. * Represents a generic controller
  36309. */
  36310. Gamepad.GENERIC = 1;
  36311. /**
  36312. * Represents an XBox controller
  36313. */
  36314. Gamepad.XBOX = 2;
  36315. /**
  36316. * Represents a pose-enabled controller
  36317. */
  36318. Gamepad.POSE_ENABLED = 3;
  36319. return Gamepad;
  36320. }());
  36321. /**
  36322. * Represents a generic gamepad
  36323. */
  36324. var GenericPad = /** @class */ (function (_super) {
  36325. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericPad, _super);
  36326. /**
  36327. * Initializes the generic gamepad
  36328. * @param id The id of the generic gamepad
  36329. * @param index The index of the generic gamepad
  36330. * @param browserGamepad The browser gamepad
  36331. */
  36332. function GenericPad(id, index, browserGamepad) {
  36333. var _this = _super.call(this, id, index, browserGamepad) || this;
  36334. /**
  36335. * Observable triggered when a button has been pressed
  36336. */
  36337. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36338. /**
  36339. * Observable triggered when a button has been released
  36340. */
  36341. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36342. _this.type = Gamepad.GENERIC;
  36343. _this._buttons = new Array(browserGamepad.buttons.length);
  36344. return _this;
  36345. }
  36346. /**
  36347. * Callback triggered when a button has been pressed
  36348. * @param callback Called when a button has been pressed
  36349. */
  36350. GenericPad.prototype.onbuttondown = function (callback) {
  36351. this._onbuttondown = callback;
  36352. };
  36353. /**
  36354. * Callback triggered when a button has been released
  36355. * @param callback Called when a button has been released
  36356. */
  36357. GenericPad.prototype.onbuttonup = function (callback) {
  36358. this._onbuttonup = callback;
  36359. };
  36360. GenericPad.prototype._setButtonValue = function (newValue, currentValue, buttonIndex) {
  36361. if (newValue !== currentValue) {
  36362. if (newValue === 1) {
  36363. if (this._onbuttondown) {
  36364. this._onbuttondown(buttonIndex);
  36365. }
  36366. this.onButtonDownObservable.notifyObservers(buttonIndex);
  36367. }
  36368. if (newValue === 0) {
  36369. if (this._onbuttonup) {
  36370. this._onbuttonup(buttonIndex);
  36371. }
  36372. this.onButtonUpObservable.notifyObservers(buttonIndex);
  36373. }
  36374. }
  36375. return newValue;
  36376. };
  36377. /**
  36378. * Updates the generic gamepad
  36379. */
  36380. GenericPad.prototype.update = function () {
  36381. _super.prototype.update.call(this);
  36382. for (var index = 0; index < this._buttons.length; index++) {
  36383. this._buttons[index] = this._setButtonValue(this.browserGamepad.buttons[index].value, this._buttons[index], index);
  36384. }
  36385. };
  36386. /**
  36387. * Disposes the generic gamepad
  36388. */
  36389. GenericPad.prototype.dispose = function () {
  36390. _super.prototype.dispose.call(this);
  36391. this.onButtonDownObservable.clear();
  36392. this.onButtonUpObservable.clear();
  36393. };
  36394. return GenericPad;
  36395. }(Gamepad));
  36396. /***/ }),
  36397. /***/ "./Gamepads/gamepadManager.ts":
  36398. /*!************************************!*\
  36399. !*** ./Gamepads/gamepadManager.ts ***!
  36400. \************************************/
  36401. /*! exports provided: GamepadManager */
  36402. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36403. "use strict";
  36404. __webpack_require__.r(__webpack_exports__);
  36405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return GamepadManager; });
  36406. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  36407. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36408. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  36409. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36410. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  36411. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  36412. /**
  36413. * Manager for handling gamepads
  36414. */
  36415. var GamepadManager = /** @class */ (function () {
  36416. /**
  36417. * Initializes the gamepad manager
  36418. * @param _scene BabylonJS scene
  36419. */
  36420. function GamepadManager(_scene) {
  36421. var _this = this;
  36422. this._scene = _scene;
  36423. this._babylonGamepads = [];
  36424. this._oneGamepadConnected = false;
  36425. /** @hidden */
  36426. this._isMonitoring = false;
  36427. /**
  36428. * observable to be triggered when the gamepad controller has been disconnected
  36429. */
  36430. this.onGamepadDisconnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36431. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  36432. this._gamepadEventSupported = false;
  36433. }
  36434. else {
  36435. this._gamepadEventSupported = 'GamepadEvent' in window;
  36436. this._gamepadSupport = (navigator.getGamepads ||
  36437. navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
  36438. }
  36439. this.onGamepadConnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"](function (observer) {
  36440. // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
  36441. for (var i in _this._babylonGamepads) {
  36442. var gamepad = _this._babylonGamepads[i];
  36443. if (gamepad && gamepad._isConnected) {
  36444. _this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
  36445. }
  36446. }
  36447. });
  36448. this._onGamepadConnectedEvent = function (evt) {
  36449. var gamepad = evt.gamepad;
  36450. if (gamepad.index in _this._babylonGamepads) {
  36451. if (_this._babylonGamepads[gamepad.index].isConnected) {
  36452. return;
  36453. }
  36454. }
  36455. var newGamepad;
  36456. if (_this._babylonGamepads[gamepad.index]) {
  36457. newGamepad = _this._babylonGamepads[gamepad.index];
  36458. newGamepad.browserGamepad = gamepad;
  36459. newGamepad._isConnected = true;
  36460. }
  36461. else {
  36462. newGamepad = _this._addNewGamepad(gamepad);
  36463. }
  36464. _this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  36465. _this._startMonitoringGamepads();
  36466. };
  36467. this._onGamepadDisconnectedEvent = function (evt) {
  36468. var gamepad = evt.gamepad;
  36469. // Remove the gamepad from the list of gamepads to monitor.
  36470. for (var i in _this._babylonGamepads) {
  36471. if (_this._babylonGamepads[i].index === gamepad.index) {
  36472. var disconnectedGamepad = _this._babylonGamepads[i];
  36473. disconnectedGamepad._isConnected = false;
  36474. _this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
  36475. break;
  36476. }
  36477. }
  36478. };
  36479. if (this._gamepadSupport) {
  36480. //first add already-connected gamepads
  36481. this._updateGamepadObjects();
  36482. if (this._babylonGamepads.length) {
  36483. this._startMonitoringGamepads();
  36484. }
  36485. // Checking if the gamepad connected event is supported (like in Firefox)
  36486. if (this._gamepadEventSupported) {
  36487. window.addEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
  36488. window.addEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent, false);
  36489. }
  36490. else {
  36491. this._startMonitoringGamepads();
  36492. }
  36493. }
  36494. }
  36495. Object.defineProperty(GamepadManager.prototype, "gamepads", {
  36496. /**
  36497. * The gamepads in the game pad manager
  36498. */
  36499. get: function () {
  36500. return this._babylonGamepads;
  36501. },
  36502. enumerable: true,
  36503. configurable: true
  36504. });
  36505. /**
  36506. * Get the gamepad controllers based on type
  36507. * @param type The type of gamepad controller
  36508. * @returns Nullable gamepad
  36509. */
  36510. GamepadManager.prototype.getGamepadByType = function (type) {
  36511. if (type === void 0) { type = _gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].XBOX; }
  36512. for (var _i = 0, _a = this._babylonGamepads; _i < _a.length; _i++) {
  36513. var gamepad = _a[_i];
  36514. if (gamepad && gamepad.type === type) {
  36515. return gamepad;
  36516. }
  36517. }
  36518. return null;
  36519. };
  36520. /**
  36521. * Disposes the gamepad manager
  36522. */
  36523. GamepadManager.prototype.dispose = function () {
  36524. if (this._gamepadEventSupported) {
  36525. if (this._onGamepadConnectedEvent) {
  36526. window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent);
  36527. }
  36528. if (this._onGamepadDisconnectedEvent) {
  36529. window.removeEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent);
  36530. }
  36531. this._onGamepadConnectedEvent = null;
  36532. this._onGamepadDisconnectedEvent = null;
  36533. }
  36534. this._babylonGamepads.forEach(function (gamepad) {
  36535. gamepad.dispose();
  36536. });
  36537. this.onGamepadConnectedObservable.clear();
  36538. this.onGamepadDisconnectedObservable.clear();
  36539. this._oneGamepadConnected = false;
  36540. this._stopMonitoringGamepads();
  36541. this._babylonGamepads = [];
  36542. };
  36543. GamepadManager.prototype._addNewGamepad = function (gamepad) {
  36544. if (!this._oneGamepadConnected) {
  36545. this._oneGamepadConnected = true;
  36546. }
  36547. var newGamepad;
  36548. var xboxOne = (gamepad.id.search("Xbox One") !== -1);
  36549. if (xboxOne || gamepad.id.search("Xbox 360") !== -1 || gamepad.id.search("xinput") !== -1) {
  36550. newGamepad = new _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"](gamepad.id, gamepad.index, gamepad, xboxOne);
  36551. }
  36552. // if pose is supported, use the (WebVR) pose enabled controller
  36553. else if (gamepad.pose) {
  36554. newGamepad = _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"].InitiateController(gamepad);
  36555. }
  36556. else {
  36557. newGamepad = new _gamepad__WEBPACK_IMPORTED_MODULE_5__["GenericPad"](gamepad.id, gamepad.index, gamepad);
  36558. }
  36559. this._babylonGamepads[newGamepad.index] = newGamepad;
  36560. return newGamepad;
  36561. };
  36562. GamepadManager.prototype._startMonitoringGamepads = function () {
  36563. if (!this._isMonitoring) {
  36564. this._isMonitoring = true;
  36565. //back-comp
  36566. if (!this._scene) {
  36567. this._checkGamepadsStatus();
  36568. }
  36569. }
  36570. };
  36571. GamepadManager.prototype._stopMonitoringGamepads = function () {
  36572. this._isMonitoring = false;
  36573. };
  36574. /** @hidden */
  36575. GamepadManager.prototype._checkGamepadsStatus = function () {
  36576. var _this = this;
  36577. // Hack to be compatible Chrome
  36578. this._updateGamepadObjects();
  36579. for (var i in this._babylonGamepads) {
  36580. var gamepad = this._babylonGamepads[i];
  36581. if (!gamepad || !gamepad.isConnected) {
  36582. continue;
  36583. }
  36584. gamepad.update();
  36585. }
  36586. if (this._isMonitoring && !this._scene) {
  36587. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].QueueNewFrame(function () { _this._checkGamepadsStatus(); });
  36588. }
  36589. };
  36590. // This function is called only on Chrome, which does not properly support
  36591. // connection/disconnection events and forces you to recopy again the gamepad object
  36592. GamepadManager.prototype._updateGamepadObjects = function () {
  36593. var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
  36594. for (var i = 0; i < gamepads.length; i++) {
  36595. var gamepad = gamepads[i];
  36596. if (gamepad) {
  36597. if (!this._babylonGamepads[gamepad.index]) {
  36598. var newGamepad = this._addNewGamepad(gamepad);
  36599. this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  36600. }
  36601. else {
  36602. // Forced to copy again this object for Chrome for unknown reason
  36603. this._babylonGamepads[i].browserGamepad = gamepad;
  36604. if (!this._babylonGamepads[i].isConnected) {
  36605. this._babylonGamepads[i]._isConnected = true;
  36606. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
  36607. }
  36608. }
  36609. }
  36610. }
  36611. };
  36612. return GamepadManager;
  36613. }());
  36614. /***/ }),
  36615. /***/ "./Gamepads/gamepadSceneComponent.ts":
  36616. /*!*******************************************!*\
  36617. !*** ./Gamepads/gamepadSceneComponent.ts ***!
  36618. \*******************************************/
  36619. /*! exports provided: GamepadSystemSceneComponent */
  36620. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36621. "use strict";
  36622. __webpack_require__.r(__webpack_exports__);
  36623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return GamepadSystemSceneComponent; });
  36624. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  36625. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  36626. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  36627. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  36628. /* harmony import */ var _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  36629. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  36630. /* harmony import */ var _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  36631. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "gamepadManager", {
  36632. get: function () {
  36633. if (!this._gamepadManager) {
  36634. this._gamepadManager = new _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"](this);
  36635. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD);
  36636. if (!component) {
  36637. component = new GamepadSystemSceneComponent(this);
  36638. this._addComponent(component);
  36639. }
  36640. }
  36641. return this._gamepadManager;
  36642. },
  36643. enumerable: true,
  36644. configurable: true
  36645. });
  36646. /**
  36647. * Adds a gamepad to the free camera inputs manager
  36648. */
  36649. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addGamepad = function () {
  36650. this.add(new _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraGamepadInput"]());
  36651. return this;
  36652. };
  36653. /**
  36654. * Adds a gamepad to the arc rotate camera inputs manager
  36655. */
  36656. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["ArcRotateCameraInputsManager"].prototype.addGamepad = function () {
  36657. this.add(new _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__["ArcRotateCameraGamepadInput"]());
  36658. return this;
  36659. };
  36660. /**
  36661. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  36662. */
  36663. var GamepadSystemSceneComponent = /** @class */ (function () {
  36664. /**
  36665. * Creates a new instance of the component for the given scene
  36666. * @param scene Defines the scene to register the component in
  36667. */
  36668. function GamepadSystemSceneComponent(scene) {
  36669. /**
  36670. * The component name helpfull to identify the component in the list of scene components.
  36671. */
  36672. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD;
  36673. this.scene = scene;
  36674. }
  36675. /**
  36676. * Registers the component in a given scene
  36677. */
  36678. GamepadSystemSceneComponent.prototype.register = function () {
  36679. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
  36680. };
  36681. /**
  36682. * Rebuilds the elements related to this component in case of
  36683. * context lost for instance.
  36684. */
  36685. GamepadSystemSceneComponent.prototype.rebuild = function () {
  36686. // Nothing to do for gamepads
  36687. };
  36688. /**
  36689. * Disposes the component and the associated ressources
  36690. */
  36691. GamepadSystemSceneComponent.prototype.dispose = function () {
  36692. var gamepadManager = this.scene._gamepadManager;
  36693. if (gamepadManager) {
  36694. gamepadManager.dispose();
  36695. this.scene._gamepadManager = null;
  36696. }
  36697. };
  36698. GamepadSystemSceneComponent.prototype._beforeCameraUpdate = function () {
  36699. var gamepadManager = this.scene._gamepadManager;
  36700. if (gamepadManager && gamepadManager._isMonitoring) {
  36701. gamepadManager._checkGamepadsStatus();
  36702. }
  36703. };
  36704. return GamepadSystemSceneComponent;
  36705. }());
  36706. /***/ }),
  36707. /***/ "./Gamepads/index.ts":
  36708. /*!***************************!*\
  36709. !*** ./Gamepads/index.ts ***!
  36710. \***************************/
  36711. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad */
  36712. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36713. "use strict";
  36714. __webpack_require__.r(__webpack_exports__);
  36715. /* harmony import */ var _Controllers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Controllers/index */ "./Gamepads/Controllers/index.ts");
  36716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  36717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  36718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  36719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  36720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  36721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  36722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  36723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  36724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  36725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  36726. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  36727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["StickValues"]; });
  36728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["Gamepad"]; });
  36729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["GenericPad"]; });
  36730. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  36731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"]; });
  36732. /* harmony import */ var _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  36733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__["GamepadSystemSceneComponent"]; });
  36734. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  36735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Button"]; });
  36736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Dpad"]; });
  36737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"]; });
  36738. /***/ }),
  36739. /***/ "./Gamepads/xboxGamepad.ts":
  36740. /*!*********************************!*\
  36741. !*** ./Gamepads/xboxGamepad.ts ***!
  36742. \*********************************/
  36743. /*! exports provided: Xbox360Button, Xbox360Dpad, Xbox360Pad */
  36744. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36745. "use strict";
  36746. __webpack_require__.r(__webpack_exports__);
  36747. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return Xbox360Button; });
  36748. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return Xbox360Dpad; });
  36749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return Xbox360Pad; });
  36750. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36751. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36752. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  36753. /**
  36754. * Defines supported buttons for XBox360 compatible gamepads
  36755. */
  36756. var Xbox360Button;
  36757. (function (Xbox360Button) {
  36758. /** A */
  36759. Xbox360Button[Xbox360Button["A"] = 0] = "A";
  36760. /** B */
  36761. Xbox360Button[Xbox360Button["B"] = 1] = "B";
  36762. /** X */
  36763. Xbox360Button[Xbox360Button["X"] = 2] = "X";
  36764. /** Y */
  36765. Xbox360Button[Xbox360Button["Y"] = 3] = "Y";
  36766. /** Start */
  36767. Xbox360Button[Xbox360Button["Start"] = 4] = "Start";
  36768. /** Back */
  36769. Xbox360Button[Xbox360Button["Back"] = 5] = "Back";
  36770. /** Left button */
  36771. Xbox360Button[Xbox360Button["LB"] = 6] = "LB";
  36772. /** Right button */
  36773. Xbox360Button[Xbox360Button["RB"] = 7] = "RB";
  36774. /** Left stick */
  36775. Xbox360Button[Xbox360Button["LeftStick"] = 8] = "LeftStick";
  36776. /** Right stick */
  36777. Xbox360Button[Xbox360Button["RightStick"] = 9] = "RightStick";
  36778. })(Xbox360Button || (Xbox360Button = {}));
  36779. /** Defines values for XBox360 DPad */
  36780. var Xbox360Dpad;
  36781. (function (Xbox360Dpad) {
  36782. /** Up */
  36783. Xbox360Dpad[Xbox360Dpad["Up"] = 0] = "Up";
  36784. /** Down */
  36785. Xbox360Dpad[Xbox360Dpad["Down"] = 1] = "Down";
  36786. /** Left */
  36787. Xbox360Dpad[Xbox360Dpad["Left"] = 2] = "Left";
  36788. /** Right */
  36789. Xbox360Dpad[Xbox360Dpad["Right"] = 3] = "Right";
  36790. })(Xbox360Dpad || (Xbox360Dpad = {}));
  36791. /**
  36792. * Defines a XBox360 gamepad
  36793. */
  36794. var Xbox360Pad = /** @class */ (function (_super) {
  36795. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Xbox360Pad, _super);
  36796. /**
  36797. * Creates a new XBox360 gamepad object
  36798. * @param id defines the id of this gamepad
  36799. * @param index defines its index
  36800. * @param gamepad defines the internal HTML gamepad object
  36801. * @param xboxOne defines if it is a XBox One gamepad
  36802. */
  36803. function Xbox360Pad(id, index, gamepad, xboxOne) {
  36804. if (xboxOne === void 0) { xboxOne = false; }
  36805. var _this = _super.call(this, id, index, gamepad, 0, 1, 2, 3) || this;
  36806. _this._leftTrigger = 0;
  36807. _this._rightTrigger = 0;
  36808. /** Observable raised when a button is pressed */
  36809. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36810. /** Observable raised when a button is released */
  36811. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36812. /** Observable raised when a pad is pressed */
  36813. _this.onPadDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36814. /** Observable raised when a pad is released */
  36815. _this.onPadUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36816. _this._buttonA = 0;
  36817. _this._buttonB = 0;
  36818. _this._buttonX = 0;
  36819. _this._buttonY = 0;
  36820. _this._buttonBack = 0;
  36821. _this._buttonStart = 0;
  36822. _this._buttonLB = 0;
  36823. _this._buttonRB = 0;
  36824. _this._buttonLeftStick = 0;
  36825. _this._buttonRightStick = 0;
  36826. _this._dPadUp = 0;
  36827. _this._dPadDown = 0;
  36828. _this._dPadLeft = 0;
  36829. _this._dPadRight = 0;
  36830. _this._isXboxOnePad = false;
  36831. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"].XBOX;
  36832. _this._isXboxOnePad = xboxOne;
  36833. return _this;
  36834. }
  36835. /**
  36836. * Defines the callback to call when left trigger is pressed
  36837. * @param callback defines the callback to use
  36838. */
  36839. Xbox360Pad.prototype.onlefttriggerchanged = function (callback) {
  36840. this._onlefttriggerchanged = callback;
  36841. };
  36842. /**
  36843. * Defines the callback to call when right trigger is pressed
  36844. * @param callback defines the callback to use
  36845. */
  36846. Xbox360Pad.prototype.onrighttriggerchanged = function (callback) {
  36847. this._onrighttriggerchanged = callback;
  36848. };
  36849. Object.defineProperty(Xbox360Pad.prototype, "leftTrigger", {
  36850. /**
  36851. * Gets the left trigger value
  36852. */
  36853. get: function () {
  36854. return this._leftTrigger;
  36855. },
  36856. /**
  36857. * Sets the left trigger value
  36858. */
  36859. set: function (newValue) {
  36860. if (this._onlefttriggerchanged && this._leftTrigger !== newValue) {
  36861. this._onlefttriggerchanged(newValue);
  36862. }
  36863. this._leftTrigger = newValue;
  36864. },
  36865. enumerable: true,
  36866. configurable: true
  36867. });
  36868. Object.defineProperty(Xbox360Pad.prototype, "rightTrigger", {
  36869. /**
  36870. * Gets the right trigger value
  36871. */
  36872. get: function () {
  36873. return this._rightTrigger;
  36874. },
  36875. /**
  36876. * Sets the right trigger value
  36877. */
  36878. set: function (newValue) {
  36879. if (this._onrighttriggerchanged && this._rightTrigger !== newValue) {
  36880. this._onrighttriggerchanged(newValue);
  36881. }
  36882. this._rightTrigger = newValue;
  36883. },
  36884. enumerable: true,
  36885. configurable: true
  36886. });
  36887. /**
  36888. * Defines the callback to call when a button is pressed
  36889. * @param callback defines the callback to use
  36890. */
  36891. Xbox360Pad.prototype.onbuttondown = function (callback) {
  36892. this._onbuttondown = callback;
  36893. };
  36894. /**
  36895. * Defines the callback to call when a button is released
  36896. * @param callback defines the callback to use
  36897. */
  36898. Xbox360Pad.prototype.onbuttonup = function (callback) {
  36899. this._onbuttonup = callback;
  36900. };
  36901. /**
  36902. * Defines the callback to call when a pad is pressed
  36903. * @param callback defines the callback to use
  36904. */
  36905. Xbox360Pad.prototype.ondpaddown = function (callback) {
  36906. this._ondpaddown = callback;
  36907. };
  36908. /**
  36909. * Defines the callback to call when a pad is released
  36910. * @param callback defines the callback to use
  36911. */
  36912. Xbox360Pad.prototype.ondpadup = function (callback) {
  36913. this._ondpadup = callback;
  36914. };
  36915. Xbox360Pad.prototype._setButtonValue = function (newValue, currentValue, buttonType) {
  36916. if (newValue !== currentValue) {
  36917. if (newValue === 1) {
  36918. if (this._onbuttondown) {
  36919. this._onbuttondown(buttonType);
  36920. }
  36921. this.onButtonDownObservable.notifyObservers(buttonType);
  36922. }
  36923. if (newValue === 0) {
  36924. if (this._onbuttonup) {
  36925. this._onbuttonup(buttonType);
  36926. }
  36927. this.onButtonUpObservable.notifyObservers(buttonType);
  36928. }
  36929. }
  36930. return newValue;
  36931. };
  36932. Xbox360Pad.prototype._setDPadValue = function (newValue, currentValue, buttonType) {
  36933. if (newValue !== currentValue) {
  36934. if (newValue === 1) {
  36935. if (this._ondpaddown) {
  36936. this._ondpaddown(buttonType);
  36937. }
  36938. this.onPadDownObservable.notifyObservers(buttonType);
  36939. }
  36940. if (newValue === 0) {
  36941. if (this._ondpadup) {
  36942. this._ondpadup(buttonType);
  36943. }
  36944. this.onPadUpObservable.notifyObservers(buttonType);
  36945. }
  36946. }
  36947. return newValue;
  36948. };
  36949. Object.defineProperty(Xbox360Pad.prototype, "buttonA", {
  36950. /**
  36951. * Gets the value of the `A` button
  36952. */
  36953. get: function () {
  36954. return this._buttonA;
  36955. },
  36956. /**
  36957. * Sets the value of the `A` button
  36958. */
  36959. set: function (value) {
  36960. this._buttonA = this._setButtonValue(value, this._buttonA, Xbox360Button.A);
  36961. },
  36962. enumerable: true,
  36963. configurable: true
  36964. });
  36965. Object.defineProperty(Xbox360Pad.prototype, "buttonB", {
  36966. /**
  36967. * Gets the value of the `B` button
  36968. */
  36969. get: function () {
  36970. return this._buttonB;
  36971. },
  36972. /**
  36973. * Sets the value of the `B` button
  36974. */
  36975. set: function (value) {
  36976. this._buttonB = this._setButtonValue(value, this._buttonB, Xbox360Button.B);
  36977. },
  36978. enumerable: true,
  36979. configurable: true
  36980. });
  36981. Object.defineProperty(Xbox360Pad.prototype, "buttonX", {
  36982. /**
  36983. * Gets the value of the `X` button
  36984. */
  36985. get: function () {
  36986. return this._buttonX;
  36987. },
  36988. /**
  36989. * Sets the value of the `X` button
  36990. */
  36991. set: function (value) {
  36992. this._buttonX = this._setButtonValue(value, this._buttonX, Xbox360Button.X);
  36993. },
  36994. enumerable: true,
  36995. configurable: true
  36996. });
  36997. Object.defineProperty(Xbox360Pad.prototype, "buttonY", {
  36998. /**
  36999. * Gets the value of the `Y` button
  37000. */
  37001. get: function () {
  37002. return this._buttonY;
  37003. },
  37004. /**
  37005. * Sets the value of the `Y` button
  37006. */
  37007. set: function (value) {
  37008. this._buttonY = this._setButtonValue(value, this._buttonY, Xbox360Button.Y);
  37009. },
  37010. enumerable: true,
  37011. configurable: true
  37012. });
  37013. Object.defineProperty(Xbox360Pad.prototype, "buttonStart", {
  37014. /**
  37015. * Gets the value of the `Start` button
  37016. */
  37017. get: function () {
  37018. return this._buttonStart;
  37019. },
  37020. /**
  37021. * Sets the value of the `Start` button
  37022. */
  37023. set: function (value) {
  37024. this._buttonStart = this._setButtonValue(value, this._buttonStart, Xbox360Button.Start);
  37025. },
  37026. enumerable: true,
  37027. configurable: true
  37028. });
  37029. Object.defineProperty(Xbox360Pad.prototype, "buttonBack", {
  37030. /**
  37031. * Gets the value of the `Back` button
  37032. */
  37033. get: function () {
  37034. return this._buttonBack;
  37035. },
  37036. /**
  37037. * Sets the value of the `Back` button
  37038. */
  37039. set: function (value) {
  37040. this._buttonBack = this._setButtonValue(value, this._buttonBack, Xbox360Button.Back);
  37041. },
  37042. enumerable: true,
  37043. configurable: true
  37044. });
  37045. Object.defineProperty(Xbox360Pad.prototype, "buttonLB", {
  37046. /**
  37047. * Gets the value of the `Left` button
  37048. */
  37049. get: function () {
  37050. return this._buttonLB;
  37051. },
  37052. /**
  37053. * Sets the value of the `Left` button
  37054. */
  37055. set: function (value) {
  37056. this._buttonLB = this._setButtonValue(value, this._buttonLB, Xbox360Button.LB);
  37057. },
  37058. enumerable: true,
  37059. configurable: true
  37060. });
  37061. Object.defineProperty(Xbox360Pad.prototype, "buttonRB", {
  37062. /**
  37063. * Gets the value of the `Right` button
  37064. */
  37065. get: function () {
  37066. return this._buttonRB;
  37067. },
  37068. /**
  37069. * Sets the value of the `Right` button
  37070. */
  37071. set: function (value) {
  37072. this._buttonRB = this._setButtonValue(value, this._buttonRB, Xbox360Button.RB);
  37073. },
  37074. enumerable: true,
  37075. configurable: true
  37076. });
  37077. Object.defineProperty(Xbox360Pad.prototype, "buttonLeftStick", {
  37078. /**
  37079. * Gets the value of the Left joystick
  37080. */
  37081. get: function () {
  37082. return this._buttonLeftStick;
  37083. },
  37084. /**
  37085. * Sets the value of the Left joystick
  37086. */
  37087. set: function (value) {
  37088. this._buttonLeftStick = this._setButtonValue(value, this._buttonLeftStick, Xbox360Button.LeftStick);
  37089. },
  37090. enumerable: true,
  37091. configurable: true
  37092. });
  37093. Object.defineProperty(Xbox360Pad.prototype, "buttonRightStick", {
  37094. /**
  37095. * Gets the value of the Right joystick
  37096. */
  37097. get: function () {
  37098. return this._buttonRightStick;
  37099. },
  37100. /**
  37101. * Sets the value of the Right joystick
  37102. */
  37103. set: function (value) {
  37104. this._buttonRightStick = this._setButtonValue(value, this._buttonRightStick, Xbox360Button.RightStick);
  37105. },
  37106. enumerable: true,
  37107. configurable: true
  37108. });
  37109. Object.defineProperty(Xbox360Pad.prototype, "dPadUp", {
  37110. /**
  37111. * Gets the value of D-pad up
  37112. */
  37113. get: function () {
  37114. return this._dPadUp;
  37115. },
  37116. /**
  37117. * Sets the value of D-pad up
  37118. */
  37119. set: function (value) {
  37120. this._dPadUp = this._setDPadValue(value, this._dPadUp, Xbox360Dpad.Up);
  37121. },
  37122. enumerable: true,
  37123. configurable: true
  37124. });
  37125. Object.defineProperty(Xbox360Pad.prototype, "dPadDown", {
  37126. /**
  37127. * Gets the value of D-pad down
  37128. */
  37129. get: function () {
  37130. return this._dPadDown;
  37131. },
  37132. /**
  37133. * Sets the value of D-pad down
  37134. */
  37135. set: function (value) {
  37136. this._dPadDown = this._setDPadValue(value, this._dPadDown, Xbox360Dpad.Down);
  37137. },
  37138. enumerable: true,
  37139. configurable: true
  37140. });
  37141. Object.defineProperty(Xbox360Pad.prototype, "dPadLeft", {
  37142. /**
  37143. * Gets the value of D-pad left
  37144. */
  37145. get: function () {
  37146. return this._dPadLeft;
  37147. },
  37148. /**
  37149. * Sets the value of D-pad left
  37150. */
  37151. set: function (value) {
  37152. this._dPadLeft = this._setDPadValue(value, this._dPadLeft, Xbox360Dpad.Left);
  37153. },
  37154. enumerable: true,
  37155. configurable: true
  37156. });
  37157. Object.defineProperty(Xbox360Pad.prototype, "dPadRight", {
  37158. /**
  37159. * Gets the value of D-pad right
  37160. */
  37161. get: function () {
  37162. return this._dPadRight;
  37163. },
  37164. /**
  37165. * Sets the value of D-pad right
  37166. */
  37167. set: function (value) {
  37168. this._dPadRight = this._setDPadValue(value, this._dPadRight, Xbox360Dpad.Right);
  37169. },
  37170. enumerable: true,
  37171. configurable: true
  37172. });
  37173. /**
  37174. * Force the gamepad to synchronize with device values
  37175. */
  37176. Xbox360Pad.prototype.update = function () {
  37177. _super.prototype.update.call(this);
  37178. if (this._isXboxOnePad) {
  37179. this.buttonA = this.browserGamepad.buttons[0].value;
  37180. this.buttonB = this.browserGamepad.buttons[1].value;
  37181. this.buttonX = this.browserGamepad.buttons[2].value;
  37182. this.buttonY = this.browserGamepad.buttons[3].value;
  37183. this.buttonLB = this.browserGamepad.buttons[4].value;
  37184. this.buttonRB = this.browserGamepad.buttons[5].value;
  37185. this.leftTrigger = this.browserGamepad.axes[2];
  37186. this.rightTrigger = this.browserGamepad.axes[5];
  37187. this.buttonBack = this.browserGamepad.buttons[9].value;
  37188. this.buttonStart = this.browserGamepad.buttons[8].value;
  37189. this.buttonLeftStick = this.browserGamepad.buttons[6].value;
  37190. this.buttonRightStick = this.browserGamepad.buttons[7].value;
  37191. this.dPadUp = this.browserGamepad.buttons[11].value;
  37192. this.dPadDown = this.browserGamepad.buttons[12].value;
  37193. this.dPadLeft = this.browserGamepad.buttons[13].value;
  37194. this.dPadRight = this.browserGamepad.buttons[14].value;
  37195. }
  37196. else {
  37197. this.buttonA = this.browserGamepad.buttons[0].value;
  37198. this.buttonB = this.browserGamepad.buttons[1].value;
  37199. this.buttonX = this.browserGamepad.buttons[2].value;
  37200. this.buttonY = this.browserGamepad.buttons[3].value;
  37201. this.buttonLB = this.browserGamepad.buttons[4].value;
  37202. this.buttonRB = this.browserGamepad.buttons[5].value;
  37203. this.leftTrigger = this.browserGamepad.buttons[6].value;
  37204. this.rightTrigger = this.browserGamepad.buttons[7].value;
  37205. this.buttonBack = this.browserGamepad.buttons[8].value;
  37206. this.buttonStart = this.browserGamepad.buttons[9].value;
  37207. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  37208. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  37209. this.dPadUp = this.browserGamepad.buttons[12].value;
  37210. this.dPadDown = this.browserGamepad.buttons[13].value;
  37211. this.dPadLeft = this.browserGamepad.buttons[14].value;
  37212. this.dPadRight = this.browserGamepad.buttons[15].value;
  37213. }
  37214. };
  37215. /**
  37216. * Disposes the gamepad
  37217. */
  37218. Xbox360Pad.prototype.dispose = function () {
  37219. _super.prototype.dispose.call(this);
  37220. this.onButtonDownObservable.clear();
  37221. this.onButtonUpObservable.clear();
  37222. this.onPadDownObservable.clear();
  37223. this.onPadUpObservable.clear();
  37224. };
  37225. return Xbox360Pad;
  37226. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"]));
  37227. /***/ }),
  37228. /***/ "./Gizmos/axisDragGizmo.ts":
  37229. /*!*********************************!*\
  37230. !*** ./Gizmos/axisDragGizmo.ts ***!
  37231. \*********************************/
  37232. /*! exports provided: AxisDragGizmo */
  37233. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37234. "use strict";
  37235. __webpack_require__.r(__webpack_exports__);
  37236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return AxisDragGizmo; });
  37237. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37238. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37239. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37240. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  37241. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  37242. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37243. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37244. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37245. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37246. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37247. /**
  37248. * Single axis drag gizmo
  37249. */
  37250. var AxisDragGizmo = /** @class */ (function (_super) {
  37251. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisDragGizmo, _super);
  37252. /**
  37253. * Creates an AxisDragGizmo
  37254. * @param gizmoLayer The utility layer the gizmo will be added to
  37255. * @param dragAxis The axis which the gizmo will be able to drag on
  37256. * @param color The color of the gizmo
  37257. */
  37258. function AxisDragGizmo(dragAxis, color, gizmoLayer) {
  37259. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37260. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37261. var _this = _super.call(this, gizmoLayer) || this;
  37262. _this._pointerObserver = null;
  37263. /**
  37264. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37265. */
  37266. _this.snapDistance = 0;
  37267. /**
  37268. * Event that fires each time the gizmo snaps to a new location.
  37269. * * snapDistance is the the change in distance
  37270. */
  37271. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37272. // Create Material
  37273. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37274. coloredMaterial.disableLighting = true;
  37275. coloredMaterial.emissiveColor = color;
  37276. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37277. hoverMaterial.disableLighting = true;
  37278. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37279. // Build mesh on root node
  37280. var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
  37281. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  37282. arrow.scaling.scaleInPlace(1 / 3);
  37283. arrow.parent = _this._rootMesh;
  37284. var currentSnapDragDistance = 0;
  37285. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37286. var tmpSnapEvent = { snapDistance: 0 };
  37287. // Add drag behavior to handle events when the gizmo is dragged
  37288. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37289. _this.dragBehavior.moveAttached = false;
  37290. _this._rootMesh.addBehavior(_this.dragBehavior);
  37291. var localDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37292. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  37293. _this.dragBehavior.onDragObservable.add(function (event) {
  37294. if (_this.attachedMesh) {
  37295. // Convert delta to local translation if it has a parent
  37296. if (_this.attachedMesh.parent) {
  37297. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  37298. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  37299. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  37300. }
  37301. else {
  37302. localDelta.copyFrom(event.delta);
  37303. }
  37304. // Snapping logic
  37305. if (_this.snapDistance == 0) {
  37306. _this.attachedMesh.position.addInPlace(localDelta);
  37307. }
  37308. else {
  37309. currentSnapDragDistance += event.dragDistance;
  37310. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37311. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37312. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  37313. localDelta.normalizeToRef(tmpVector);
  37314. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  37315. _this.attachedMesh.position.addInPlace(tmpVector);
  37316. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  37317. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  37318. }
  37319. }
  37320. }
  37321. });
  37322. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37323. if (_this._customMeshSet) {
  37324. return;
  37325. }
  37326. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  37327. var material = isHovered ? hoverMaterial : coloredMaterial;
  37328. _this._rootMesh.getChildMeshes().forEach(function (m) {
  37329. m.material = material;
  37330. if (m.color) {
  37331. m.color = material.emissiveColor;
  37332. }
  37333. });
  37334. });
  37335. return _this;
  37336. }
  37337. /** @hidden */
  37338. AxisDragGizmo._CreateArrow = function (scene, material) {
  37339. var arrow = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  37340. var cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0, height: 1.5, diameterBottom: 0.75, tessellation: 96 }, scene);
  37341. 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);
  37342. line.color = material.emissiveColor;
  37343. cylinder.parent = arrow;
  37344. line.parent = arrow;
  37345. // Position arrow pointing in its drag axis
  37346. cylinder.scaling.scaleInPlace(0.05);
  37347. cylinder.material = material;
  37348. cylinder.rotation.x = Math.PI / 2;
  37349. cylinder.position.z += 0.3;
  37350. line.scaling.scaleInPlace(0.26);
  37351. line.rotation.x = Math.PI / 2;
  37352. line.material = material;
  37353. return arrow;
  37354. };
  37355. /** @hidden */
  37356. AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
  37357. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  37358. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  37359. var mesh = _a[_i];
  37360. var childInstance = mesh.createInstance(mesh.name);
  37361. childInstance.parent = instance;
  37362. }
  37363. return instance;
  37364. };
  37365. AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
  37366. if (this.dragBehavior) {
  37367. this.dragBehavior.enabled = value ? true : false;
  37368. }
  37369. };
  37370. /**
  37371. * Disposes of the gizmo
  37372. */
  37373. AxisDragGizmo.prototype.dispose = function () {
  37374. this.onSnapObservable.clear();
  37375. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37376. this.dragBehavior.detach();
  37377. _super.prototype.dispose.call(this);
  37378. };
  37379. return AxisDragGizmo;
  37380. }(_gizmo__WEBPACK_IMPORTED_MODULE_7__["Gizmo"]));
  37381. /***/ }),
  37382. /***/ "./Gizmos/axisScaleGizmo.ts":
  37383. /*!**********************************!*\
  37384. !*** ./Gizmos/axisScaleGizmo.ts ***!
  37385. \**********************************/
  37386. /*! exports provided: AxisScaleGizmo */
  37387. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37388. "use strict";
  37389. __webpack_require__.r(__webpack_exports__);
  37390. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return AxisScaleGizmo; });
  37391. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37392. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37393. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37394. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37395. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  37396. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37397. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37398. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37399. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37400. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37401. /**
  37402. * Single axis scale gizmo
  37403. */
  37404. var AxisScaleGizmo = /** @class */ (function (_super) {
  37405. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisScaleGizmo, _super);
  37406. /**
  37407. * Creates an AxisScaleGizmo
  37408. * @param gizmoLayer The utility layer the gizmo will be added to
  37409. * @param dragAxis The axis which the gizmo will be able to scale on
  37410. * @param color The color of the gizmo
  37411. */
  37412. function AxisScaleGizmo(dragAxis, color, gizmoLayer) {
  37413. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37414. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37415. var _this = _super.call(this, gizmoLayer) || this;
  37416. _this._pointerObserver = null;
  37417. /**
  37418. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37419. */
  37420. _this.snapDistance = 0;
  37421. /**
  37422. * Event that fires each time the gizmo snaps to a new location.
  37423. * * snapDistance is the the change in distance
  37424. */
  37425. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37426. /**
  37427. * If the scaling operation should be done on all axis (default: false)
  37428. */
  37429. _this.uniformScaling = false;
  37430. // Create Material
  37431. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37432. _this._coloredMaterial.disableLighting = true;
  37433. _this._coloredMaterial.emissiveColor = color;
  37434. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37435. hoverMaterial.disableLighting = true;
  37436. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37437. // Build mesh on root node
  37438. var arrow = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37439. var arrowMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__["BoxBuilder"].CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
  37440. 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);
  37441. arrowTail.color = _this._coloredMaterial.emissiveColor;
  37442. arrow.addChild(arrowMesh);
  37443. arrow.addChild(arrowTail);
  37444. // Position arrow pointing in its drag axis
  37445. arrowMesh.scaling.scaleInPlace(0.1);
  37446. arrowMesh.material = _this._coloredMaterial;
  37447. arrowMesh.rotation.x = Math.PI / 2;
  37448. arrowMesh.position.z += 0.3;
  37449. arrowTail.scaling.scaleInPlace(0.26);
  37450. arrowTail.rotation.x = Math.PI / 2;
  37451. arrowTail.material = _this._coloredMaterial;
  37452. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  37453. _this._rootMesh.addChild(arrow);
  37454. arrow.scaling.scaleInPlace(1 / 3);
  37455. // Add drag behavior to handle events when the gizmo is dragged
  37456. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37457. _this.dragBehavior.moveAttached = false;
  37458. _this._rootMesh.addBehavior(_this.dragBehavior);
  37459. var currentSnapDragDistance = 0;
  37460. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37461. var tmpSnapEvent = { snapDistance: 0 };
  37462. _this.dragBehavior.onDragObservable.add(function (event) {
  37463. if (_this.attachedMesh) {
  37464. // Snapping logic
  37465. var snapped = false;
  37466. var dragSteps = 0;
  37467. if (_this.uniformScaling) {
  37468. _this.attachedMesh.scaling.normalizeToRef(tmpVector);
  37469. if (tmpVector.y < 0) {
  37470. tmpVector.scaleInPlace(-1);
  37471. }
  37472. }
  37473. else {
  37474. tmpVector.copyFrom(dragAxis);
  37475. }
  37476. if (_this.snapDistance == 0) {
  37477. tmpVector.scaleToRef(event.dragDistance, tmpVector);
  37478. }
  37479. else {
  37480. currentSnapDragDistance += event.dragDistance;
  37481. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37482. dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37483. if (currentSnapDragDistance < 0) {
  37484. dragSteps *= -1;
  37485. }
  37486. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  37487. tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
  37488. snapped = true;
  37489. }
  37490. else {
  37491. tmpVector.scaleInPlace(0);
  37492. }
  37493. }
  37494. _this.attachedMesh.scaling.addInPlace(tmpVector);
  37495. if (snapped) {
  37496. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  37497. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  37498. }
  37499. }
  37500. });
  37501. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37502. if (_this._customMeshSet) {
  37503. return;
  37504. }
  37505. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  37506. var material = isHovered ? hoverMaterial : _this._coloredMaterial;
  37507. _this._rootMesh.getChildMeshes().forEach(function (m) {
  37508. m.material = material;
  37509. if (m.color) {
  37510. m.color = material.emissiveColor;
  37511. }
  37512. });
  37513. });
  37514. return _this;
  37515. }
  37516. AxisScaleGizmo.prototype._attachedMeshChanged = function (value) {
  37517. if (this.dragBehavior) {
  37518. this.dragBehavior.enabled = value ? true : false;
  37519. }
  37520. };
  37521. /**
  37522. * Disposes of the gizmo
  37523. */
  37524. AxisScaleGizmo.prototype.dispose = function () {
  37525. this.onSnapObservable.clear();
  37526. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37527. this.dragBehavior.detach();
  37528. _super.prototype.dispose.call(this);
  37529. };
  37530. /**
  37531. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  37532. * @param mesh The mesh to replace the default mesh of the gizmo
  37533. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  37534. */
  37535. AxisScaleGizmo.prototype.setCustomMesh = function (mesh, useGizmoMaterial) {
  37536. var _this = this;
  37537. if (useGizmoMaterial === void 0) { useGizmoMaterial = false; }
  37538. _super.prototype.setCustomMesh.call(this, mesh);
  37539. if (useGizmoMaterial) {
  37540. this._rootMesh.getChildMeshes().forEach(function (m) {
  37541. m.material = _this._coloredMaterial;
  37542. if (m.color) {
  37543. m.color = _this._coloredMaterial.emissiveColor;
  37544. }
  37545. });
  37546. this._customMeshSet = false;
  37547. }
  37548. };
  37549. return AxisScaleGizmo;
  37550. }(_gizmo__WEBPACK_IMPORTED_MODULE_8__["Gizmo"]));
  37551. /***/ }),
  37552. /***/ "./Gizmos/boundingBoxGizmo.ts":
  37553. /*!************************************!*\
  37554. !*** ./Gizmos/boundingBoxGizmo.ts ***!
  37555. \************************************/
  37556. /*! exports provided: BoundingBoxGizmo */
  37557. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37558. "use strict";
  37559. __webpack_require__.r(__webpack_exports__);
  37560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return BoundingBoxGizmo; });
  37561. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37562. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37563. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  37564. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37565. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37566. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  37567. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  37568. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  37569. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37570. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37571. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37572. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37573. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37574. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/pivotTools */ "./Misc/pivotTools.ts");
  37575. /**
  37576. * Bounding box gizmo
  37577. */
  37578. var BoundingBoxGizmo = /** @class */ (function (_super) {
  37579. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoundingBoxGizmo, _super);
  37580. /**
  37581. * Creates an BoundingBoxGizmo
  37582. * @param gizmoLayer The utility layer the gizmo will be added to
  37583. * @param color The color of the gizmo
  37584. */
  37585. function BoundingBoxGizmo(color, gizmoLayer) {
  37586. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  37587. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__["UtilityLayerRenderer"].DefaultKeepDepthUtilityLayer; }
  37588. var _this = _super.call(this, gizmoLayer) || this;
  37589. _this._boundingDimensions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 1);
  37590. _this._renderObserver = null;
  37591. _this._pointerObserver = null;
  37592. _this._scaleDragSpeed = 0.2;
  37593. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37594. _this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  37595. _this._tmpRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  37596. /**
  37597. * 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)
  37598. */
  37599. _this.ignoreChildren = false;
  37600. /**
  37601. * 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)
  37602. */
  37603. _this.includeChildPredicate = null;
  37604. /**
  37605. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  37606. */
  37607. _this.rotationSphereSize = 0.1;
  37608. /**
  37609. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  37610. */
  37611. _this.scaleBoxSize = 0.1;
  37612. /**
  37613. * 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)
  37614. */
  37615. _this.fixedDragMeshScreenSize = false;
  37616. /**
  37617. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  37618. */
  37619. _this.fixedDragMeshScreenSizeDistanceFactor = 10;
  37620. /**
  37621. * Fired when a rotation sphere or scale box is dragged
  37622. */
  37623. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37624. /**
  37625. * Fired when a scale box is dragged
  37626. */
  37627. _this.onScaleBoxDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37628. /**
  37629. * Fired when a scale box drag is ended
  37630. */
  37631. _this.onScaleBoxDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37632. /**
  37633. * Fired when a rotation sphere is dragged
  37634. */
  37635. _this.onRotationSphereDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37636. /**
  37637. * Fired when a rotation sphere drag is ended
  37638. */
  37639. _this.onRotationSphereDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37640. /**
  37641. * 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)
  37642. */
  37643. _this.scalePivot = null;
  37644. _this._existingMeshScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  37645. // Dragging
  37646. _this._dragMesh = null;
  37647. _this.pointerDragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]();
  37648. // Do not update the gizmo's scale so it has a fixed size to the object its attached to
  37649. _this._updateScale = false;
  37650. _this._anchorMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("anchor", gizmoLayer.utilityLayerScene);
  37651. // Create Materials
  37652. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37653. coloredMaterial.disableLighting = true;
  37654. coloredMaterial.emissiveColor = color;
  37655. var hoverColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37656. hoverColoredMaterial.disableLighting = true;
  37657. hoverColoredMaterial.emissiveColor = color.clone().add(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  37658. // Build bounding box out of lines
  37659. _this._lineBoundingBox = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37660. _this._lineBoundingBox.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37661. var lines = [];
  37662. 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));
  37663. 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));
  37664. 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));
  37665. 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));
  37666. 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));
  37667. 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));
  37668. 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));
  37669. 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));
  37670. 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));
  37671. 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));
  37672. 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));
  37673. 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));
  37674. lines.forEach(function (l) {
  37675. l.color = color;
  37676. l.position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-_this._boundingDimensions.x / 2, -_this._boundingDimensions.y / 2, -_this._boundingDimensions.z / 2));
  37677. l.isPickable = false;
  37678. _this._lineBoundingBox.addChild(l);
  37679. });
  37680. _this._rootMesh.addChild(_this._lineBoundingBox);
  37681. // Create rotation spheres
  37682. _this._rotateSpheresParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37683. _this._rotateSpheresParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37684. var _loop_1 = function (i_1) {
  37685. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__["SphereBuilder"].CreateSphere("", { diameter: 1 }, gizmoLayer.utilityLayerScene);
  37686. sphere.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37687. sphere.material = coloredMaterial;
  37688. // Drag behavior
  37689. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({});
  37690. _dragBehavior.moveAttached = false;
  37691. _dragBehavior.updateDragPlane = false;
  37692. sphere.addBehavior(_dragBehavior);
  37693. var startingTurnDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  37694. var totalTurnAmountOfDrag = 0;
  37695. _dragBehavior.onDragStartObservable.add(function () {
  37696. startingTurnDirection.copyFrom(sphere.forward);
  37697. totalTurnAmountOfDrag = 0;
  37698. });
  37699. _dragBehavior.onDragObservable.add(function (event) {
  37700. _this.onRotationSphereDragObservable.notifyObservers({});
  37701. if (_this.attachedMesh) {
  37702. var originalParent = _this.attachedMesh.parent;
  37703. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  37704. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  37705. return;
  37706. }
  37707. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  37708. var worldDragDirection = startingTurnDirection;
  37709. // Project the world right on to the drag plane
  37710. var toSub = event.dragPlaneNormal.scale(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(event.dragPlaneNormal, worldDragDirection));
  37711. var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
  37712. // project drag delta on to the resulting drag axis and rotate based on that
  37713. var projectDist = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
  37714. // Make rotation relative to size of mesh.
  37715. projectDist = (projectDist / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  37716. // Rotate based on axis
  37717. if (!_this.attachedMesh.rotationQuaternion) {
  37718. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  37719. }
  37720. if (!_this._anchorMesh.rotationQuaternion) {
  37721. _this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this._anchorMesh.rotation.y, _this._anchorMesh.rotation.x, _this._anchorMesh.rotation.z);
  37722. }
  37723. // Do not allow the object to turn more than a full circle
  37724. totalTurnAmountOfDrag += projectDist;
  37725. if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {
  37726. if (i_1 >= 8) {
  37727. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, 0, projectDist, _this._tmpQuaternion);
  37728. }
  37729. else if (i_1 >= 4) {
  37730. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(projectDist, 0, 0, _this._tmpQuaternion);
  37731. }
  37732. else {
  37733. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, projectDist, 0, _this._tmpQuaternion);
  37734. }
  37735. // Rotate around center of bounding box
  37736. _this._anchorMesh.addChild(_this.attachedMesh);
  37737. _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
  37738. _this._anchorMesh.removeChild(_this.attachedMesh);
  37739. _this.attachedMesh.setParent(originalParent);
  37740. }
  37741. _this.updateBoundingBox();
  37742. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  37743. }
  37744. _this._updateDummy();
  37745. });
  37746. // Selection/deselection
  37747. _dragBehavior.onDragStartObservable.add(function () {
  37748. _this.onDragStartObservable.notifyObservers({});
  37749. _this._selectNode(sphere);
  37750. });
  37751. _dragBehavior.onDragEndObservable.add(function () {
  37752. _this.onRotationSphereDragEndObservable.notifyObservers({});
  37753. _this._selectNode(null);
  37754. _this._updateDummy();
  37755. });
  37756. this_1._rotateSpheresParent.addChild(sphere);
  37757. };
  37758. var this_1 = this, _dragBehavior;
  37759. for (var i_1 = 0; i_1 < 12; i_1++) {
  37760. _loop_1(i_1);
  37761. }
  37762. _this._rootMesh.addChild(_this._rotateSpheresParent);
  37763. // Create scale cubes
  37764. _this._scaleBoxesParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37765. _this._scaleBoxesParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37766. for (var i = 0; i < 2; i++) {
  37767. for (var j = 0; j < 2; j++) {
  37768. var _loop_2 = function () {
  37769. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("", { size: 1 }, gizmoLayer.utilityLayerScene);
  37770. box.material = coloredMaterial;
  37771. // Dragging logic
  37772. var dragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](i == 0 ? -1 : 1, j == 0 ? -1 : 1, k == 0 ? -1 : 1);
  37773. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37774. _dragBehavior.moveAttached = false;
  37775. box.addBehavior(_dragBehavior);
  37776. _dragBehavior.onDragObservable.add(function (event) {
  37777. _this.onScaleBoxDragObservable.notifyObservers({});
  37778. if (_this.attachedMesh) {
  37779. var originalParent = _this.attachedMesh.parent;
  37780. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  37781. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  37782. return;
  37783. }
  37784. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  37785. var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  37786. var deltaScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](relativeDragDistance, relativeDragDistance, relativeDragDistance);
  37787. deltaScale.scaleInPlace(_this._scaleDragSpeed);
  37788. _this.updateBoundingBox();
  37789. if (_this.scalePivot) {
  37790. _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
  37791. // Move anchor to desired pivot point (Bottom left corner + dimension/2)
  37792. _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
  37793. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  37794. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  37795. _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
  37796. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  37797. _this._anchorMesh.position.addInPlace(_this._tmpVector);
  37798. }
  37799. else {
  37800. // Scale from the position of the opposite corner
  37801. box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
  37802. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  37803. }
  37804. _this._anchorMesh.addChild(_this.attachedMesh);
  37805. _this._anchorMesh.scaling.addInPlace(deltaScale);
  37806. if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
  37807. _this._anchorMesh.scaling.subtractInPlace(deltaScale);
  37808. }
  37809. _this._anchorMesh.removeChild(_this.attachedMesh);
  37810. _this.attachedMesh.setParent(originalParent);
  37811. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  37812. }
  37813. _this._updateDummy();
  37814. });
  37815. // Selection/deselection
  37816. _dragBehavior.onDragStartObservable.add(function () {
  37817. _this.onDragStartObservable.notifyObservers({});
  37818. _this._selectNode(box);
  37819. });
  37820. _dragBehavior.onDragEndObservable.add(function () {
  37821. _this.onScaleBoxDragEndObservable.notifyObservers({});
  37822. _this._selectNode(null);
  37823. _this._updateDummy();
  37824. });
  37825. this_2._scaleBoxesParent.addChild(box);
  37826. };
  37827. var this_2 = this, _dragBehavior;
  37828. for (var k = 0; k < 2; k++) {
  37829. _loop_2();
  37830. }
  37831. }
  37832. }
  37833. _this._rootMesh.addChild(_this._scaleBoxesParent);
  37834. // Hover color change
  37835. var pointerIds = new Array();
  37836. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37837. if (!pointerIds[pointerInfo.event.pointerId]) {
  37838. _this._rotateSpheresParent.getChildMeshes().concat(_this._scaleBoxesParent.getChildMeshes()).forEach(function (mesh) {
  37839. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
  37840. pointerIds[pointerInfo.event.pointerId] = mesh;
  37841. mesh.material = hoverColoredMaterial;
  37842. }
  37843. });
  37844. }
  37845. else {
  37846. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
  37847. pointerIds[pointerInfo.event.pointerId].material = coloredMaterial;
  37848. delete pointerIds[pointerInfo.event.pointerId];
  37849. }
  37850. }
  37851. });
  37852. // Update bounding box positions
  37853. _this._renderObserver = _this.gizmoLayer.originalScene.onBeforeRenderObservable.add(function () {
  37854. // Only update the bouding box if scaling has changed
  37855. if (_this.attachedMesh && !_this._existingMeshScale.equals(_this.attachedMesh.scaling)) {
  37856. _this.updateBoundingBox();
  37857. }
  37858. else if (_this.fixedDragMeshScreenSize) {
  37859. _this._updateRotationSpheres();
  37860. _this._updateScaleBoxes();
  37861. }
  37862. // If dragg mesh is enabled and dragging, update the attached mesh pose to match the drag mesh
  37863. if (_this._dragMesh && _this.attachedMesh && _this.pointerDragBehavior.dragging) {
  37864. _this._lineBoundingBox.position.rotateByQuaternionToRef(_this._rootMesh.rotationQuaternion, _this._tmpVector);
  37865. _this.attachedMesh.setAbsolutePosition(_this._dragMesh.position.add(_this._tmpVector.scale(-1)));
  37866. }
  37867. });
  37868. _this.updateBoundingBox();
  37869. return _this;
  37870. }
  37871. BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
  37872. var _this = this;
  37873. if (value) {
  37874. // Reset anchor mesh to match attached mesh's scale
  37875. // This is needed to avoid invalid box/sphere position on first drag
  37876. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(value);
  37877. var originalParent = value.parent;
  37878. this._anchorMesh.addChild(value);
  37879. this._anchorMesh.removeChild(value);
  37880. value.setParent(originalParent);
  37881. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(value);
  37882. this.updateBoundingBox();
  37883. value.getChildMeshes(false).forEach(function (m) {
  37884. m.markAsDirty("scaling");
  37885. });
  37886. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
  37887. _this._updateDummy();
  37888. });
  37889. }
  37890. };
  37891. BoundingBoxGizmo.prototype._selectNode = function (selectedMesh) {
  37892. this._rotateSpheresParent.getChildMeshes()
  37893. .concat(this._scaleBoxesParent.getChildMeshes()).forEach(function (m) {
  37894. m.isVisible = (!selectedMesh || m == selectedMesh);
  37895. });
  37896. };
  37897. /**
  37898. * Updates the bounding box information for the Gizmo
  37899. */
  37900. BoundingBoxGizmo.prototype.updateBoundingBox = function () {
  37901. if (this.attachedMesh) {
  37902. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedMesh);
  37903. var originalParent = this.attachedMesh.parent;
  37904. this.attachedMesh.setParent(null);
  37905. this._update();
  37906. // Rotate based on axis
  37907. if (!this.attachedMesh.rotationQuaternion) {
  37908. this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
  37909. }
  37910. if (!this._anchorMesh.rotationQuaternion) {
  37911. this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);
  37912. }
  37913. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  37914. // Store original position and reset mesh to origin before computing the bounding box
  37915. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  37916. this._tmpVector.copyFrom(this.attachedMesh.position);
  37917. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);
  37918. this.attachedMesh.position.set(0, 0, 0);
  37919. // Update bounding dimensions/positions
  37920. var boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  37921. boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);
  37922. // Update gizmo to match bounding box scaling and rotation
  37923. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
  37924. 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);
  37925. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);
  37926. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);
  37927. this._lineBoundingBox.computeWorldMatrix();
  37928. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);
  37929. // restore position/rotation values
  37930. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
  37931. this.attachedMesh.position.copyFrom(this._tmpVector);
  37932. this.attachedMesh.setParent(originalParent);
  37933. }
  37934. this._updateRotationSpheres();
  37935. this._updateScaleBoxes();
  37936. if (this.attachedMesh) {
  37937. this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
  37938. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(this.attachedMesh);
  37939. }
  37940. };
  37941. BoundingBoxGizmo.prototype._updateRotationSpheres = function () {
  37942. var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
  37943. for (var i = 0; i < 3; i++) {
  37944. for (var j = 0; j < 2; j++) {
  37945. for (var k = 0; k < 2; k++) {
  37946. var index = ((i * 4) + (j * 2)) + k;
  37947. if (i == 0) {
  37948. rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  37949. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37950. 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));
  37951. }
  37952. if (i == 1) {
  37953. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
  37954. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37955. 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));
  37956. }
  37957. if (i == 2) {
  37958. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
  37959. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37960. 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));
  37961. }
  37962. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  37963. rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  37964. var distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  37965. rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  37966. }
  37967. else {
  37968. rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
  37969. }
  37970. }
  37971. }
  37972. }
  37973. };
  37974. BoundingBoxGizmo.prototype._updateScaleBoxes = function () {
  37975. var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
  37976. for (var i = 0; i < 2; i++) {
  37977. for (var j = 0; j < 2; j++) {
  37978. for (var k = 0; k < 2; k++) {
  37979. var index = ((i * 4) + (j * 2)) + k;
  37980. if (scaleBoxes[index]) {
  37981. scaleBoxes[index].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  37982. scaleBoxes[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37983. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  37984. scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  37985. var distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  37986. scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  37987. }
  37988. else {
  37989. scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  37990. }
  37991. }
  37992. }
  37993. }
  37994. }
  37995. };
  37996. /**
  37997. * Enables rotation on the specified axis and disables rotation on the others
  37998. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  37999. */
  38000. BoundingBoxGizmo.prototype.setEnabledRotationAxis = function (axis) {
  38001. this._rotateSpheresParent.getChildMeshes().forEach(function (m, i) {
  38002. if (i < 4) {
  38003. m.setEnabled(axis.indexOf("x") != -1);
  38004. }
  38005. else if (i < 8) {
  38006. m.setEnabled(axis.indexOf("y") != -1);
  38007. }
  38008. else {
  38009. m.setEnabled(axis.indexOf("z") != -1);
  38010. }
  38011. });
  38012. };
  38013. /**
  38014. * Enables/disables scaling
  38015. * @param enable if scaling should be enabled
  38016. */
  38017. BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
  38018. this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
  38019. m.setEnabled(enable);
  38020. });
  38021. };
  38022. BoundingBoxGizmo.prototype._updateDummy = function () {
  38023. if (this._dragMesh) {
  38024. this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
  38025. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);
  38026. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);
  38027. }
  38028. };
  38029. /**
  38030. * Enables a pointer drag behavior on the bounding box of the gizmo
  38031. */
  38032. BoundingBoxGizmo.prototype.enableDragBehavior = function () {
  38033. this._dragMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene);
  38034. this._dragMesh.visibility = 0;
  38035. this._dragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38036. this.pointerDragBehavior.useObjectOrienationForDragging = false;
  38037. this._dragMesh.addBehavior(this.pointerDragBehavior);
  38038. };
  38039. /**
  38040. * Disposes of the gizmo
  38041. */
  38042. BoundingBoxGizmo.prototype.dispose = function () {
  38043. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38044. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);
  38045. this._lineBoundingBox.dispose();
  38046. this._rotateSpheresParent.dispose();
  38047. this._scaleBoxesParent.dispose();
  38048. if (this._dragMesh) {
  38049. this._dragMesh.dispose();
  38050. }
  38051. _super.prototype.dispose.call(this);
  38052. };
  38053. /**
  38054. * 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)
  38055. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  38056. * @returns the bounding box mesh with the passed in mesh as a child
  38057. */
  38058. BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox = function (mesh) {
  38059. var makeNotPickable = function (root) {
  38060. root.isPickable = false;
  38061. root.getChildMeshes().forEach(function (c) {
  38062. makeNotPickable(c);
  38063. });
  38064. };
  38065. makeNotPickable(mesh);
  38066. // Reset position to get boudning box from origin with no rotation
  38067. if (!mesh.rotationQuaternion) {
  38068. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
  38069. }
  38070. var oldPos = mesh.position.clone();
  38071. var oldRot = mesh.rotationQuaternion.clone();
  38072. mesh.rotationQuaternion.set(0, 0, 0, 1);
  38073. mesh.position.set(0, 0, 0);
  38074. // Update bounding dimensions/positions
  38075. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("box", { size: 1 }, mesh.getScene());
  38076. var boundingMinMax = mesh.getHierarchyBoundingVectors();
  38077. boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);
  38078. // Adjust scale to avoid undefined behavior when adding child
  38079. if (box.scaling.y === 0) {
  38080. box.scaling.y = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38081. }
  38082. if (box.scaling.x === 0) {
  38083. box.scaling.x = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38084. }
  38085. if (box.scaling.z === 0) {
  38086. box.scaling.z = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38087. }
  38088. box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  38089. // Restore original positions
  38090. mesh.addChild(box);
  38091. mesh.rotationQuaternion.copyFrom(oldRot);
  38092. mesh.position.copyFrom(oldPos);
  38093. // Reverse parenting
  38094. mesh.removeChild(box);
  38095. box.addChild(mesh);
  38096. box.visibility = 0;
  38097. return box;
  38098. };
  38099. /**
  38100. * CustomMeshes are not supported by this gizmo
  38101. * @param mesh The mesh to replace the default mesh of the gizmo
  38102. */
  38103. BoundingBoxGizmo.prototype.setCustomMesh = function (mesh) {
  38104. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("Custom meshes are not supported on this gizmo");
  38105. };
  38106. return BoundingBoxGizmo;
  38107. }(_gizmo__WEBPACK_IMPORTED_MODULE_10__["Gizmo"]));
  38108. /***/ }),
  38109. /***/ "./Gizmos/gizmo.ts":
  38110. /*!*************************!*\
  38111. !*** ./Gizmos/gizmo.ts ***!
  38112. \*************************/
  38113. /*! exports provided: Gizmo */
  38114. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38115. "use strict";
  38116. __webpack_require__.r(__webpack_exports__);
  38117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return Gizmo; });
  38118. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38119. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38120. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38121. /**
  38122. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  38123. */
  38124. var Gizmo = /** @class */ (function () {
  38125. /**
  38126. * Creates a gizmo
  38127. * @param gizmoLayer The utility layer the gizmo will be added to
  38128. */
  38129. function Gizmo(
  38130. /** The utility layer the gizmo will be added to */
  38131. gizmoLayer) {
  38132. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38133. var _this = this;
  38134. this.gizmoLayer = gizmoLayer;
  38135. /**
  38136. * Ratio for the scale of the gizmo (Default: 1)
  38137. */
  38138. this.scaleRatio = 1;
  38139. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  38140. /**
  38141. * If a custom mesh has been set (Default: false)
  38142. */
  38143. this._customMeshSet = false;
  38144. /**
  38145. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  38146. */
  38147. this.updateGizmoRotationToMatchAttachedMesh = true;
  38148. /**
  38149. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  38150. */
  38151. this.updateGizmoPositionToMatchAttachedMesh = true;
  38152. /**
  38153. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  38154. */
  38155. this._updateScale = true;
  38156. this._interactionsEnabled = true;
  38157. this._tempVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  38158. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
  38159. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
  38160. _this._update();
  38161. });
  38162. this.attachedMesh = null;
  38163. }
  38164. Object.defineProperty(Gizmo.prototype, "attachedMesh", {
  38165. /**
  38166. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  38167. * * When set, interactions will be enabled
  38168. */
  38169. get: function () {
  38170. return this._attachedMesh;
  38171. },
  38172. set: function (value) {
  38173. this._attachedMesh = value;
  38174. this._rootMesh.setEnabled(value ? true : false);
  38175. this._attachedMeshChanged(value);
  38176. },
  38177. enumerable: true,
  38178. configurable: true
  38179. });
  38180. /**
  38181. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38182. * @param mesh The mesh to replace the default mesh of the gizmo
  38183. */
  38184. Gizmo.prototype.setCustomMesh = function (mesh) {
  38185. if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {
  38186. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  38187. }
  38188. this._rootMesh.getChildMeshes().forEach(function (c) {
  38189. c.dispose();
  38190. });
  38191. mesh.parent = this._rootMesh;
  38192. this._customMeshSet = true;
  38193. };
  38194. Gizmo.prototype._attachedMeshChanged = function (value) {
  38195. };
  38196. /**
  38197. * @hidden
  38198. * Updates the gizmo to match the attached mesh's position/rotation
  38199. */
  38200. Gizmo.prototype._update = function () {
  38201. if (this.attachedMesh) {
  38202. if (this.updateGizmoRotationToMatchAttachedMesh) {
  38203. if (!this._rootMesh.rotationQuaternion) {
  38204. this._rootMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(this._rootMesh.rotation.y, this._rootMesh.rotation.x, this._rootMesh.rotation.z);
  38205. }
  38206. // Remove scaling before getting rotation matrix to get rotation matrix unmodified by scale
  38207. this._tempVector.copyFrom(this.attachedMesh.scaling);
  38208. if (this.attachedMesh.scaling.x < 0) {
  38209. this.attachedMesh.scaling.x *= -1;
  38210. }
  38211. if (this.attachedMesh.scaling.y < 0) {
  38212. this.attachedMesh.scaling.y *= -1;
  38213. }
  38214. if (this.attachedMesh.scaling.z < 0) {
  38215. this.attachedMesh.scaling.z *= -1;
  38216. }
  38217. this.attachedMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);
  38218. this.attachedMesh.scaling.copyFrom(this._tempVector);
  38219. this.attachedMesh.computeWorldMatrix();
  38220. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._tmpMatrix, this._rootMesh.rotationQuaternion);
  38221. }
  38222. else if (this._rootMesh.rotationQuaternion) {
  38223. this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
  38224. }
  38225. if (this.updateGizmoPositionToMatchAttachedMesh) {
  38226. this._rootMesh.position.copyFrom(this.attachedMesh.absolutePosition);
  38227. }
  38228. if (this._updateScale && this.gizmoLayer.utilityLayerScene.activeCamera && this.attachedMesh) {
  38229. var cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition;
  38230. if (this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition) {
  38231. cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition;
  38232. }
  38233. this._rootMesh.position.subtractToRef(cameraPosition, this._tempVector);
  38234. var dist = this._tempVector.length() * this.scaleRatio;
  38235. this._rootMesh.scaling.set(dist, dist, dist);
  38236. }
  38237. }
  38238. };
  38239. /**
  38240. * Disposes of the gizmo
  38241. */
  38242. Gizmo.prototype.dispose = function () {
  38243. this._rootMesh.dispose();
  38244. if (this._beforeRenderObserver) {
  38245. this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  38246. }
  38247. };
  38248. return Gizmo;
  38249. }());
  38250. /***/ }),
  38251. /***/ "./Gizmos/gizmoManager.ts":
  38252. /*!********************************!*\
  38253. !*** ./Gizmos/gizmoManager.ts ***!
  38254. \********************************/
  38255. /*! exports provided: GizmoManager */
  38256. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38257. "use strict";
  38258. __webpack_require__.r(__webpack_exports__);
  38259. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return GizmoManager; });
  38260. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38261. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  38262. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38263. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38264. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38265. /* harmony import */ var _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  38266. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  38267. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  38268. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  38269. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  38270. /**
  38271. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  38272. */
  38273. var GizmoManager = /** @class */ (function () {
  38274. /**
  38275. * Instatiates a gizmo manager
  38276. * @param scene the scene to overlay the gizmos on top of
  38277. */
  38278. function GizmoManager(scene) {
  38279. var _this = this;
  38280. this.scene = scene;
  38281. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  38282. this.clearGizmoOnEmptyPointerEvent = false;
  38283. /** Fires an event when the manager is attached to a mesh */
  38284. this.onAttachedToMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  38285. this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
  38286. this._pointerObserver = null;
  38287. this._attachedMesh = null;
  38288. this._boundingBoxColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromHexString("#0984e3");
  38289. /**
  38290. * When bounding box gizmo is enabled, this can be used to track drag/end events
  38291. */
  38292. this.boundingBoxDragBehavior = new _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]();
  38293. /**
  38294. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  38295. */
  38296. this.attachableMeshes = null;
  38297. /**
  38298. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  38299. */
  38300. this.usePointerToAttachGizmos = true;
  38301. this._defaultKeepDepthUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  38302. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  38303. this._defaultUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  38304. this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
  38305. // Instatiate/dispose gizmos based on pointer actions
  38306. this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo) {
  38307. if (!_this.usePointerToAttachGizmos) {
  38308. return;
  38309. }
  38310. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  38311. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {
  38312. var node = pointerInfo.pickInfo.pickedMesh;
  38313. if (_this.attachableMeshes == null) {
  38314. // Attach to the most parent node
  38315. while (node && node.parent != null) {
  38316. node = node.parent;
  38317. }
  38318. }
  38319. else {
  38320. // Attach to the parent node that is an attachableMesh
  38321. var found = false;
  38322. _this.attachableMeshes.forEach(function (mesh) {
  38323. if (node && (node == mesh || node.isDescendantOf(mesh))) {
  38324. node = mesh;
  38325. found = true;
  38326. }
  38327. });
  38328. if (!found) {
  38329. node = null;
  38330. }
  38331. }
  38332. if (node instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]) {
  38333. if (_this._attachedMesh != node) {
  38334. _this.attachToMesh(node);
  38335. }
  38336. }
  38337. else {
  38338. if (_this.clearGizmoOnEmptyPointerEvent) {
  38339. _this.attachToMesh(null);
  38340. }
  38341. }
  38342. }
  38343. else {
  38344. if (_this.clearGizmoOnEmptyPointerEvent) {
  38345. _this.attachToMesh(null);
  38346. }
  38347. }
  38348. }
  38349. });
  38350. }
  38351. /**
  38352. * Attaches a set of gizmos to the specified mesh
  38353. * @param mesh The mesh the gizmo's should be attached to
  38354. */
  38355. GizmoManager.prototype.attachToMesh = function (mesh) {
  38356. if (this._attachedMesh) {
  38357. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  38358. }
  38359. this._attachedMesh = mesh;
  38360. for (var key in this.gizmos) {
  38361. var gizmo = (this.gizmos[key]);
  38362. if (gizmo && this._gizmosEnabled[key]) {
  38363. gizmo.attachedMesh = mesh;
  38364. }
  38365. }
  38366. if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
  38367. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  38368. }
  38369. this.onAttachedToMeshObservable.notifyObservers(mesh);
  38370. };
  38371. Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
  38372. get: function () {
  38373. return this._gizmosEnabled.positionGizmo;
  38374. },
  38375. /**
  38376. * If the position gizmo is enabled
  38377. */
  38378. set: function (value) {
  38379. if (value) {
  38380. if (!this.gizmos.positionGizmo) {
  38381. this.gizmos.positionGizmo = new _positionGizmo__WEBPACK_IMPORTED_MODULE_7__["PositionGizmo"](this._defaultUtilityLayer);
  38382. }
  38383. this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
  38384. }
  38385. else if (this.gizmos.positionGizmo) {
  38386. this.gizmos.positionGizmo.attachedMesh = null;
  38387. }
  38388. this._gizmosEnabled.positionGizmo = value;
  38389. },
  38390. enumerable: true,
  38391. configurable: true
  38392. });
  38393. Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
  38394. get: function () {
  38395. return this._gizmosEnabled.rotationGizmo;
  38396. },
  38397. /**
  38398. * If the rotation gizmo is enabled
  38399. */
  38400. set: function (value) {
  38401. if (value) {
  38402. if (!this.gizmos.rotationGizmo) {
  38403. this.gizmos.rotationGizmo = new _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__["RotationGizmo"](this._defaultUtilityLayer);
  38404. }
  38405. this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
  38406. }
  38407. else if (this.gizmos.rotationGizmo) {
  38408. this.gizmos.rotationGizmo.attachedMesh = null;
  38409. }
  38410. this._gizmosEnabled.rotationGizmo = value;
  38411. },
  38412. enumerable: true,
  38413. configurable: true
  38414. });
  38415. Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
  38416. get: function () {
  38417. return this._gizmosEnabled.scaleGizmo;
  38418. },
  38419. /**
  38420. * If the scale gizmo is enabled
  38421. */
  38422. set: function (value) {
  38423. if (value) {
  38424. this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"](this._defaultUtilityLayer);
  38425. this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
  38426. }
  38427. else if (this.gizmos.scaleGizmo) {
  38428. this.gizmos.scaleGizmo.attachedMesh = null;
  38429. }
  38430. this._gizmosEnabled.scaleGizmo = value;
  38431. },
  38432. enumerable: true,
  38433. configurable: true
  38434. });
  38435. Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
  38436. get: function () {
  38437. return this._gizmosEnabled.boundingBoxGizmo;
  38438. },
  38439. /**
  38440. * If the boundingBox gizmo is enabled
  38441. */
  38442. set: function (value) {
  38443. if (value) {
  38444. this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__["BoundingBoxGizmo"](this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
  38445. this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
  38446. if (this._attachedMesh) {
  38447. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  38448. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  38449. }
  38450. }
  38451. else if (this.gizmos.boundingBoxGizmo) {
  38452. this.gizmos.boundingBoxGizmo.attachedMesh = null;
  38453. }
  38454. this._gizmosEnabled.boundingBoxGizmo = value;
  38455. },
  38456. enumerable: true,
  38457. configurable: true
  38458. });
  38459. /**
  38460. * Disposes of the gizmo manager
  38461. */
  38462. GizmoManager.prototype.dispose = function () {
  38463. this.scene.onPointerObservable.remove(this._pointerObserver);
  38464. for (var key in this.gizmos) {
  38465. var gizmo = (this.gizmos[key]);
  38466. if (gizmo) {
  38467. gizmo.dispose();
  38468. }
  38469. }
  38470. this._defaultKeepDepthUtilityLayer.dispose();
  38471. this._defaultUtilityLayer.dispose();
  38472. this.boundingBoxDragBehavior.detach();
  38473. this.onAttachedToMeshObservable.clear();
  38474. };
  38475. return GizmoManager;
  38476. }());
  38477. /***/ }),
  38478. /***/ "./Gizmos/index.ts":
  38479. /*!*************************!*\
  38480. !*** ./Gizmos/index.ts ***!
  38481. \*************************/
  38482. /*! exports provided: AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo */
  38483. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38484. "use strict";
  38485. __webpack_require__.r(__webpack_exports__);
  38486. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  38487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  38488. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  38489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__["AxisScaleGizmo"]; });
  38490. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  38491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__["BoundingBoxGizmo"]; });
  38492. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _gizmo__WEBPACK_IMPORTED_MODULE_3__["Gizmo"]; });
  38494. /* harmony import */ var _gizmoManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmoManager */ "./Gizmos/gizmoManager.ts");
  38495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _gizmoManager__WEBPACK_IMPORTED_MODULE_4__["GizmoManager"]; });
  38496. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  38497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"]; });
  38498. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  38499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _positionGizmo__WEBPACK_IMPORTED_MODULE_6__["PositionGizmo"]; });
  38500. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  38501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__["RotationGizmo"]; });
  38502. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  38503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"]; });
  38504. /* harmony import */ var _lightGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lightGizmo */ "./Gizmos/lightGizmo.ts");
  38505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _lightGizmo__WEBPACK_IMPORTED_MODULE_9__["LightGizmo"]; });
  38506. /***/ }),
  38507. /***/ "./Gizmos/lightGizmo.ts":
  38508. /*!******************************!*\
  38509. !*** ./Gizmos/lightGizmo.ts ***!
  38510. \******************************/
  38511. /*! exports provided: LightGizmo */
  38512. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38513. "use strict";
  38514. __webpack_require__.r(__webpack_exports__);
  38515. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return LightGizmo; });
  38516. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38517. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38518. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38519. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38520. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38521. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38522. /**
  38523. * Gizmo that enables viewing a light
  38524. */
  38525. var LightGizmo = /** @class */ (function (_super) {
  38526. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LightGizmo, _super);
  38527. /**
  38528. * Creates a LightGizmo
  38529. * @param gizmoLayer The utility layer the gizmo will be added to
  38530. */
  38531. function LightGizmo(gizmoLayer) {
  38532. var _this = _super.call(this, gizmoLayer) || this;
  38533. _this._light = null;
  38534. _this._box = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder("light", 0.02, 0, 0.02, 16, 1, _this.gizmoLayer.utilityLayerScene);
  38535. _this._box.rotation.x = -Math.PI / 2;
  38536. _this._box.bakeCurrentTransformIntoVertices();
  38537. _this._box.material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("", _this.gizmoLayer.utilityLayerScene);
  38538. _this._box.material.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Yellow();
  38539. _this._rootMesh.addChild(_this._box);
  38540. _this.attachedMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", _this.gizmoLayer.utilityLayerScene);
  38541. return _this;
  38542. }
  38543. Object.defineProperty(LightGizmo.prototype, "light", {
  38544. get: function () {
  38545. return this._light;
  38546. },
  38547. /**
  38548. * The light that the gizmo is attached to
  38549. */
  38550. set: function (light) {
  38551. this._light = light;
  38552. if (light.position) {
  38553. this.attachedMesh.position.copyFrom(light.position);
  38554. }
  38555. if (light.direction) {
  38556. this._box.setDirection(light.direction);
  38557. }
  38558. },
  38559. enumerable: true,
  38560. configurable: true
  38561. });
  38562. /**
  38563. * @hidden
  38564. * Updates the gizmo to match the attached mesh's position/rotation
  38565. */
  38566. LightGizmo.prototype._update = function () {
  38567. _super.prototype._update.call(this);
  38568. if (!this._light) {
  38569. return;
  38570. }
  38571. if (this._light.position) {
  38572. this._light.position.copyFrom(this.attachedMesh.position);
  38573. }
  38574. if (this._light.direction) {
  38575. this._light.direction.copyFrom(this._box.forward);
  38576. }
  38577. if (!this._light.isEnabled()) {
  38578. this._box.material.emissiveColor.set(0, 0, 0);
  38579. }
  38580. else {
  38581. this._box.material.emissiveColor.set(1, 1, 1);
  38582. }
  38583. };
  38584. return LightGizmo;
  38585. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  38586. /***/ }),
  38587. /***/ "./Gizmos/planeRotationGizmo.ts":
  38588. /*!**************************************!*\
  38589. !*** ./Gizmos/planeRotationGizmo.ts ***!
  38590. \**************************************/
  38591. /*! exports provided: PlaneRotationGizmo */
  38592. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38593. "use strict";
  38594. __webpack_require__.r(__webpack_exports__);
  38595. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return PlaneRotationGizmo; });
  38596. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38597. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38598. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38599. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38600. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38601. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38602. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38603. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38604. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38605. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  38606. /**
  38607. * Single plane rotation gizmo
  38608. */
  38609. var PlaneRotationGizmo = /** @class */ (function (_super) {
  38610. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneRotationGizmo, _super);
  38611. /**
  38612. * Creates a PlaneRotationGizmo
  38613. * @param gizmoLayer The utility layer the gizmo will be added to
  38614. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  38615. * @param color The color of the gizmo
  38616. * @param tessellation Amount of tessellation to be used when creating rotation circles
  38617. */
  38618. function PlaneRotationGizmo(planeNormal, color, gizmoLayer, tessellation) {
  38619. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  38620. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38621. if (tessellation === void 0) { tessellation = 32; }
  38622. var _this = _super.call(this, gizmoLayer) || this;
  38623. _this._pointerObserver = null;
  38624. /**
  38625. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  38626. */
  38627. _this.snapDistance = 0;
  38628. /**
  38629. * Event that fires each time the gizmo snaps to a new location.
  38630. * * snapDistance is the the change in distance
  38631. */
  38632. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38633. // Create Material
  38634. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38635. coloredMaterial.disableLighting = true;
  38636. coloredMaterial.emissiveColor = color;
  38637. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38638. hoverMaterial.disableLighting = true;
  38639. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  38640. // Build mesh on root node
  38641. var parentMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38642. // Create circle out of lines
  38643. var radius = 0.8;
  38644. var points = new Array();
  38645. for (var i = 0; i < tessellation; i++) {
  38646. var radian = (2 * Math.PI) * (i / (tessellation - 1));
  38647. points.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * Math.sin(radian), 0, radius * Math.cos(radian)));
  38648. }
  38649. var rotationMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateLines("", points, gizmoLayer.utilityLayerScene);
  38650. rotationMesh.color = coloredMaterial.emissiveColor;
  38651. // Position arrow pointing in its drag axis
  38652. rotationMesh.scaling.scaleInPlace(0.26);
  38653. rotationMesh.material = coloredMaterial;
  38654. rotationMesh.rotation.x = Math.PI / 2;
  38655. parentMesh.addChild(rotationMesh);
  38656. parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
  38657. _this._rootMesh.addChild(parentMesh);
  38658. parentMesh.scaling.scaleInPlace(1 / 3);
  38659. // Add drag behavior to handle events when the gizmo is dragged
  38660. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragPlaneNormal: planeNormal });
  38661. _this.dragBehavior.moveAttached = false;
  38662. _this.dragBehavior.maxDragAngle = Math.PI * 9 / 20;
  38663. _this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
  38664. _this._rootMesh.addBehavior(_this.dragBehavior);
  38665. var lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38666. _this.dragBehavior.onDragStartObservable.add(function (e) {
  38667. if (_this.attachedMesh) {
  38668. lastDragPosition.copyFrom(e.dragPlanePoint);
  38669. }
  38670. });
  38671. var rotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  38672. var planeNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38673. var localPlaneNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38674. var tmpSnapEvent = { snapDistance: 0 };
  38675. var currentSnapDragDistance = 0;
  38676. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  38677. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38678. var amountToRotate = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  38679. _this.dragBehavior.onDragObservable.add(function (event) {
  38680. if (_this.attachedMesh) {
  38681. if (!_this.attachedMesh.rotationQuaternion) {
  38682. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  38683. }
  38684. // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
  38685. var newVector = event.dragPlanePoint.subtract(_this.attachedMesh.absolutePosition).normalize();
  38686. var originalVector = lastDragPosition.subtract(_this.attachedMesh.absolutePosition).normalize();
  38687. var cross = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(newVector, originalVector);
  38688. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(newVector, originalVector);
  38689. var angle = Math.atan2(cross.length(), dot);
  38690. planeNormalTowardsCamera.copyFrom(planeNormal);
  38691. localPlaneNormalTowardsCamera.copyFrom(planeNormal);
  38692. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  38693. _this.attachedMesh.rotationQuaternion.toRotationMatrix(rotationMatrix);
  38694. localPlaneNormalTowardsCamera = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);
  38695. }
  38696. // Flip up vector depending on which side the camera is on
  38697. if (gizmoLayer.utilityLayerScene.activeCamera) {
  38698. var camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(_this.attachedMesh.position);
  38699. if (_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(camVec, localPlaneNormalTowardsCamera) > 0) {
  38700. planeNormalTowardsCamera.scaleInPlace(-1);
  38701. localPlaneNormalTowardsCamera.scaleInPlace(-1);
  38702. }
  38703. }
  38704. var halfCircleSide = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(localPlaneNormalTowardsCamera, cross) > 0.0;
  38705. if (halfCircleSide) {
  38706. angle = -angle;
  38707. }
  38708. // Snapping logic
  38709. var snapped = false;
  38710. if (_this.snapDistance != 0) {
  38711. currentSnapDragDistance += angle;
  38712. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  38713. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  38714. if (currentSnapDragDistance < 0) {
  38715. dragSteps *= -1;
  38716. }
  38717. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38718. angle = _this.snapDistance * dragSteps;
  38719. snapped = true;
  38720. }
  38721. else {
  38722. angle = 0;
  38723. }
  38724. }
  38725. // If the mesh has a parent, convert needed world rotation to local rotation
  38726. tmpMatrix.reset();
  38727. if (_this.attachedMesh.parent) {
  38728. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  38729. tmpMatrix.getRotationMatrixToRef(tmpMatrix);
  38730. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planeNormalTowardsCamera, tmpMatrix, planeNormalTowardsCamera);
  38731. }
  38732. // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)
  38733. var quaternionCoefficient = Math.sin(angle / 2);
  38734. amountToRotate.set(planeNormalTowardsCamera.x * quaternionCoefficient, planeNormalTowardsCamera.y * quaternionCoefficient, planeNormalTowardsCamera.z * quaternionCoefficient, Math.cos(angle / 2));
  38735. // 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
  38736. if (tmpMatrix.determinant() > 0) {
  38737. amountToRotate.toEulerAnglesToRef(tmpVector);
  38738. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);
  38739. }
  38740. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  38741. // Rotate selected mesh quaternion over fixed axis
  38742. _this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate, _this.attachedMesh.rotationQuaternion);
  38743. }
  38744. else {
  38745. // Rotate selected mesh quaternion over rotated axis
  38746. amountToRotate.multiplyToRef(_this.attachedMesh.rotationQuaternion, _this.attachedMesh.rotationQuaternion);
  38747. }
  38748. lastDragPosition.copyFrom(event.dragPlanePoint);
  38749. if (snapped) {
  38750. tmpSnapEvent.snapDistance = angle;
  38751. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38752. }
  38753. }
  38754. });
  38755. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38756. if (_this._customMeshSet) {
  38757. return;
  38758. }
  38759. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38760. var material = isHovered ? hoverMaterial : coloredMaterial;
  38761. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38762. m.material = material;
  38763. if (m.color) {
  38764. m.color = material.emissiveColor;
  38765. }
  38766. });
  38767. });
  38768. return _this;
  38769. }
  38770. PlaneRotationGizmo.prototype._attachedMeshChanged = function (value) {
  38771. if (this.dragBehavior) {
  38772. this.dragBehavior.enabled = value ? true : false;
  38773. }
  38774. };
  38775. /**
  38776. * Disposes of the gizmo
  38777. */
  38778. PlaneRotationGizmo.prototype.dispose = function () {
  38779. this.onSnapObservable.clear();
  38780. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38781. this.dragBehavior.detach();
  38782. _super.prototype.dispose.call(this);
  38783. };
  38784. return PlaneRotationGizmo;
  38785. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  38786. /***/ }),
  38787. /***/ "./Gizmos/positionGizmo.ts":
  38788. /*!*********************************!*\
  38789. !*** ./Gizmos/positionGizmo.ts ***!
  38790. \*********************************/
  38791. /*! exports provided: PositionGizmo */
  38792. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38793. "use strict";
  38794. __webpack_require__.r(__webpack_exports__);
  38795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return PositionGizmo; });
  38796. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38797. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38798. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38799. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38800. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38801. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  38802. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38803. /**
  38804. * Gizmo that enables dragging a mesh along 3 axis
  38805. */
  38806. var PositionGizmo = /** @class */ (function (_super) {
  38807. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PositionGizmo, _super);
  38808. /**
  38809. * Creates a PositionGizmo
  38810. * @param gizmoLayer The utility layer the gizmo will be added to
  38811. */
  38812. function PositionGizmo(gizmoLayer) {
  38813. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38814. var _this = _super.call(this, gizmoLayer) || this;
  38815. /** Fires an event when any of it's sub gizmos are dragged */
  38816. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38817. /** Fires an event when any of it's sub gizmos are released from dragging */
  38818. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38819. _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);
  38820. _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);
  38821. _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);
  38822. // Relay drag events
  38823. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  38824. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38825. _this.onDragStartObservable.notifyObservers({});
  38826. });
  38827. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38828. _this.onDragEndObservable.notifyObservers({});
  38829. });
  38830. });
  38831. _this.attachedMesh = null;
  38832. return _this;
  38833. }
  38834. Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
  38835. set: function (mesh) {
  38836. if (this.xGizmo) {
  38837. this.xGizmo.attachedMesh = mesh;
  38838. this.yGizmo.attachedMesh = mesh;
  38839. this.zGizmo.attachedMesh = mesh;
  38840. }
  38841. },
  38842. enumerable: true,
  38843. configurable: true
  38844. });
  38845. Object.defineProperty(PositionGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38846. get: function () {
  38847. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  38848. },
  38849. set: function (value) {
  38850. if (this.xGizmo) {
  38851. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38852. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38853. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38854. }
  38855. },
  38856. enumerable: true,
  38857. configurable: true
  38858. });
  38859. Object.defineProperty(PositionGizmo.prototype, "snapDistance", {
  38860. get: function () {
  38861. return this.xGizmo.snapDistance;
  38862. },
  38863. /**
  38864. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38865. */
  38866. set: function (value) {
  38867. if (this.xGizmo) {
  38868. this.xGizmo.snapDistance = value;
  38869. this.yGizmo.snapDistance = value;
  38870. this.zGizmo.snapDistance = value;
  38871. }
  38872. },
  38873. enumerable: true,
  38874. configurable: true
  38875. });
  38876. Object.defineProperty(PositionGizmo.prototype, "scaleRatio", {
  38877. get: function () {
  38878. return this.xGizmo.scaleRatio;
  38879. },
  38880. /**
  38881. * Ratio for the scale of the gizmo (Default: 1)
  38882. */
  38883. set: function (value) {
  38884. if (this.xGizmo) {
  38885. this.xGizmo.scaleRatio = value;
  38886. this.yGizmo.scaleRatio = value;
  38887. this.zGizmo.scaleRatio = value;
  38888. }
  38889. },
  38890. enumerable: true,
  38891. configurable: true
  38892. });
  38893. /**
  38894. * Disposes of the gizmo
  38895. */
  38896. PositionGizmo.prototype.dispose = function () {
  38897. this.xGizmo.dispose();
  38898. this.yGizmo.dispose();
  38899. this.zGizmo.dispose();
  38900. this.onDragStartObservable.clear();
  38901. this.onDragEndObservable.clear();
  38902. };
  38903. /**
  38904. * CustomMeshes are not supported by this gizmo
  38905. * @param mesh The mesh to replace the default mesh of the gizmo
  38906. */
  38907. PositionGizmo.prototype.setCustomMesh = function (mesh) {
  38908. _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)");
  38909. };
  38910. return PositionGizmo;
  38911. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  38912. /***/ }),
  38913. /***/ "./Gizmos/rotationGizmo.ts":
  38914. /*!*********************************!*\
  38915. !*** ./Gizmos/rotationGizmo.ts ***!
  38916. \*********************************/
  38917. /*! exports provided: RotationGizmo */
  38918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38919. "use strict";
  38920. __webpack_require__.r(__webpack_exports__);
  38921. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return RotationGizmo; });
  38922. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38923. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38924. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38925. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38926. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38927. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  38928. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38929. /**
  38930. * Gizmo that enables rotating a mesh along 3 axis
  38931. */
  38932. var RotationGizmo = /** @class */ (function (_super) {
  38933. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RotationGizmo, _super);
  38934. /**
  38935. * Creates a RotationGizmo
  38936. * @param gizmoLayer The utility layer the gizmo will be added to
  38937. * @param tessellation Amount of tessellation to be used when creating rotation circles
  38938. */
  38939. function RotationGizmo(gizmoLayer, tessellation) {
  38940. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38941. if (tessellation === void 0) { tessellation = 32; }
  38942. var _this = _super.call(this, gizmoLayer) || this;
  38943. /** Fires an event when any of it's sub gizmos are dragged */
  38944. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38945. /** Fires an event when any of it's sub gizmos are released from dragging */
  38946. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38947. _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);
  38948. _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);
  38949. _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);
  38950. // Relay drag events
  38951. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  38952. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38953. _this.onDragStartObservable.notifyObservers({});
  38954. });
  38955. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38956. _this.onDragEndObservable.notifyObservers({});
  38957. });
  38958. });
  38959. _this.attachedMesh = null;
  38960. return _this;
  38961. }
  38962. Object.defineProperty(RotationGizmo.prototype, "attachedMesh", {
  38963. set: function (mesh) {
  38964. if (this.xGizmo) {
  38965. this.xGizmo.attachedMesh = mesh;
  38966. this.yGizmo.attachedMesh = mesh;
  38967. this.zGizmo.attachedMesh = mesh;
  38968. }
  38969. },
  38970. enumerable: true,
  38971. configurable: true
  38972. });
  38973. Object.defineProperty(RotationGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38974. get: function () {
  38975. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  38976. },
  38977. set: function (value) {
  38978. if (this.xGizmo) {
  38979. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38980. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38981. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38982. }
  38983. },
  38984. enumerable: true,
  38985. configurable: true
  38986. });
  38987. Object.defineProperty(RotationGizmo.prototype, "snapDistance", {
  38988. get: function () {
  38989. return this.xGizmo.snapDistance;
  38990. },
  38991. /**
  38992. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38993. */
  38994. set: function (value) {
  38995. if (this.xGizmo) {
  38996. this.xGizmo.snapDistance = value;
  38997. this.yGizmo.snapDistance = value;
  38998. this.zGizmo.snapDistance = value;
  38999. }
  39000. },
  39001. enumerable: true,
  39002. configurable: true
  39003. });
  39004. Object.defineProperty(RotationGizmo.prototype, "scaleRatio", {
  39005. get: function () {
  39006. return this.xGizmo.scaleRatio;
  39007. },
  39008. /**
  39009. * Ratio for the scale of the gizmo (Default: 1)
  39010. */
  39011. set: function (value) {
  39012. if (this.xGizmo) {
  39013. this.xGizmo.scaleRatio = value;
  39014. this.yGizmo.scaleRatio = value;
  39015. this.zGizmo.scaleRatio = value;
  39016. }
  39017. },
  39018. enumerable: true,
  39019. configurable: true
  39020. });
  39021. /**
  39022. * Disposes of the gizmo
  39023. */
  39024. RotationGizmo.prototype.dispose = function () {
  39025. this.xGizmo.dispose();
  39026. this.yGizmo.dispose();
  39027. this.zGizmo.dispose();
  39028. this.onDragStartObservable.clear();
  39029. this.onDragEndObservable.clear();
  39030. };
  39031. /**
  39032. * CustomMeshes are not supported by this gizmo
  39033. * @param mesh The mesh to replace the default mesh of the gizmo
  39034. */
  39035. RotationGizmo.prototype.setCustomMesh = function (mesh) {
  39036. _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)");
  39037. };
  39038. return RotationGizmo;
  39039. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39040. /***/ }),
  39041. /***/ "./Gizmos/scaleGizmo.ts":
  39042. /*!******************************!*\
  39043. !*** ./Gizmos/scaleGizmo.ts ***!
  39044. \******************************/
  39045. /*! exports provided: ScaleGizmo */
  39046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39047. "use strict";
  39048. __webpack_require__.r(__webpack_exports__);
  39049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return ScaleGizmo; });
  39050. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39051. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39052. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39053. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39054. /* harmony import */ var _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  39055. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39056. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  39057. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39058. /**
  39059. * Gizmo that enables scaling a mesh along 3 axis
  39060. */
  39061. var ScaleGizmo = /** @class */ (function (_super) {
  39062. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScaleGizmo, _super);
  39063. /**
  39064. * Creates a ScaleGizmo
  39065. * @param gizmoLayer The utility layer the gizmo will be added to
  39066. */
  39067. function ScaleGizmo(gizmoLayer) {
  39068. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39069. var _this = _super.call(this, gizmoLayer) || this;
  39070. /** Fires an event when any of it's sub gizmos are dragged */
  39071. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39072. /** Fires an event when any of it's sub gizmos are released from dragging */
  39073. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39074. _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);
  39075. _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);
  39076. _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);
  39077. // Create uniform scale gizmo
  39078. _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);
  39079. _this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
  39080. _this.uniformScaleGizmo.uniformScaling = true;
  39081. var uniformScalingMesh = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  39082. uniformScalingMesh.scaling.scaleInPlace(0.02);
  39083. uniformScalingMesh.visibility = 0;
  39084. var octahedron = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  39085. octahedron.scaling.scaleInPlace(0.007);
  39086. uniformScalingMesh.addChild(octahedron);
  39087. _this.uniformScaleGizmo.setCustomMesh(uniformScalingMesh, true);
  39088. // Relay drag events
  39089. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.uniformScaleGizmo].forEach(function (gizmo) {
  39090. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39091. _this.onDragStartObservable.notifyObservers({});
  39092. });
  39093. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39094. _this.onDragEndObservable.notifyObservers({});
  39095. });
  39096. });
  39097. _this.attachedMesh = null;
  39098. return _this;
  39099. }
  39100. Object.defineProperty(ScaleGizmo.prototype, "attachedMesh", {
  39101. set: function (mesh) {
  39102. if (this.xGizmo) {
  39103. this.xGizmo.attachedMesh = mesh;
  39104. this.yGizmo.attachedMesh = mesh;
  39105. this.zGizmo.attachedMesh = mesh;
  39106. this.uniformScaleGizmo.attachedMesh = mesh;
  39107. }
  39108. },
  39109. enumerable: true,
  39110. configurable: true
  39111. });
  39112. Object.defineProperty(ScaleGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39113. get: function () {
  39114. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39115. },
  39116. set: function (value) {
  39117. if (!value) {
  39118. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
  39119. }
  39120. if (this.xGizmo) {
  39121. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39122. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39123. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39124. }
  39125. },
  39126. enumerable: true,
  39127. configurable: true
  39128. });
  39129. Object.defineProperty(ScaleGizmo.prototype, "snapDistance", {
  39130. get: function () {
  39131. return this.xGizmo.snapDistance;
  39132. },
  39133. /**
  39134. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39135. */
  39136. set: function (value) {
  39137. if (this.xGizmo) {
  39138. this.xGizmo.snapDistance = value;
  39139. this.yGizmo.snapDistance = value;
  39140. this.zGizmo.snapDistance = value;
  39141. this.uniformScaleGizmo.snapDistance = value;
  39142. }
  39143. },
  39144. enumerable: true,
  39145. configurable: true
  39146. });
  39147. Object.defineProperty(ScaleGizmo.prototype, "scaleRatio", {
  39148. get: function () {
  39149. return this.xGizmo.scaleRatio;
  39150. },
  39151. /**
  39152. * Ratio for the scale of the gizmo (Default: 1)
  39153. */
  39154. set: function (value) {
  39155. if (this.xGizmo) {
  39156. this.xGizmo.scaleRatio = value;
  39157. this.yGizmo.scaleRatio = value;
  39158. this.zGizmo.scaleRatio = value;
  39159. this.uniformScaleGizmo.scaleRatio = value;
  39160. }
  39161. },
  39162. enumerable: true,
  39163. configurable: true
  39164. });
  39165. /**
  39166. * Disposes of the gizmo
  39167. */
  39168. ScaleGizmo.prototype.dispose = function () {
  39169. this.xGizmo.dispose();
  39170. this.yGizmo.dispose();
  39171. this.zGizmo.dispose();
  39172. this.uniformScaleGizmo.dispose();
  39173. this.onDragStartObservable.clear();
  39174. this.onDragEndObservable.clear();
  39175. };
  39176. return ScaleGizmo;
  39177. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  39178. /***/ }),
  39179. /***/ "./Helpers/environmentHelper.ts":
  39180. /*!**************************************!*\
  39181. !*** ./Helpers/environmentHelper.ts ***!
  39182. \**************************************/
  39183. /*! exports provided: EnvironmentHelper */
  39184. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39185. "use strict";
  39186. __webpack_require__.r(__webpack_exports__);
  39187. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return EnvironmentHelper; });
  39188. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39189. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39190. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  39191. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39192. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39193. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  39194. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39195. /* harmony import */ var _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  39196. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  39197. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39198. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  39199. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  39200. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  39201. /**
  39202. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  39203. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  39204. * It also helps with the default setup of your imageProcessing configuration.
  39205. */
  39206. var EnvironmentHelper = /** @class */ (function () {
  39207. /**
  39208. * constructor
  39209. * @param options Defines the options we want to customize the helper
  39210. * @param scene The scene to add the material to
  39211. */
  39212. function EnvironmentHelper(options, scene) {
  39213. var _this = this;
  39214. this._errorHandler = function (message, exception) {
  39215. _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
  39216. };
  39217. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EnvironmentHelper._getDefaultOptions(), options);
  39218. this._scene = scene;
  39219. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39220. this._setupBackground();
  39221. this._setupImageProcessing();
  39222. }
  39223. /**
  39224. * Creates the default options for the helper.
  39225. */
  39226. EnvironmentHelper._getDefaultOptions = function () {
  39227. return {
  39228. createGround: true,
  39229. groundSize: 15,
  39230. groundTexture: this._groundTextureCDNUrl,
  39231. groundColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  39232. groundOpacity: 0.9,
  39233. enableGroundShadow: true,
  39234. groundShadowLevel: 0.5,
  39235. enableGroundMirror: false,
  39236. groundMirrorSizeRatio: 0.3,
  39237. groundMirrorBlurKernel: 64,
  39238. groundMirrorAmount: 1,
  39239. groundMirrorFresnelWeight: 1,
  39240. groundMirrorFallOffDistance: 0,
  39241. groundMirrorTextureType: _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT,
  39242. groundYBias: 0.00001,
  39243. createSkybox: true,
  39244. skyboxSize: 20,
  39245. skyboxTexture: this._skyboxTextureCDNUrl,
  39246. skyboxColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  39247. backgroundYRotation: 0,
  39248. sizeAuto: true,
  39249. rootPosition: _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(),
  39250. setupImageProcessing: true,
  39251. environmentTexture: this._environmentTextureCDNUrl,
  39252. cameraExposure: 0.8,
  39253. cameraContrast: 1.2,
  39254. toneMappingEnabled: true,
  39255. };
  39256. };
  39257. Object.defineProperty(EnvironmentHelper.prototype, "rootMesh", {
  39258. /**
  39259. * Gets the root mesh created by the helper.
  39260. */
  39261. get: function () {
  39262. return this._rootMesh;
  39263. },
  39264. enumerable: true,
  39265. configurable: true
  39266. });
  39267. Object.defineProperty(EnvironmentHelper.prototype, "skybox", {
  39268. /**
  39269. * Gets the skybox created by the helper.
  39270. */
  39271. get: function () {
  39272. return this._skybox;
  39273. },
  39274. enumerable: true,
  39275. configurable: true
  39276. });
  39277. Object.defineProperty(EnvironmentHelper.prototype, "skyboxTexture", {
  39278. /**
  39279. * Gets the skybox texture created by the helper.
  39280. */
  39281. get: function () {
  39282. return this._skyboxTexture;
  39283. },
  39284. enumerable: true,
  39285. configurable: true
  39286. });
  39287. Object.defineProperty(EnvironmentHelper.prototype, "skyboxMaterial", {
  39288. /**
  39289. * Gets the skybox material created by the helper.
  39290. */
  39291. get: function () {
  39292. return this._skyboxMaterial;
  39293. },
  39294. enumerable: true,
  39295. configurable: true
  39296. });
  39297. Object.defineProperty(EnvironmentHelper.prototype, "ground", {
  39298. /**
  39299. * Gets the ground mesh created by the helper.
  39300. */
  39301. get: function () {
  39302. return this._ground;
  39303. },
  39304. enumerable: true,
  39305. configurable: true
  39306. });
  39307. Object.defineProperty(EnvironmentHelper.prototype, "groundTexture", {
  39308. /**
  39309. * Gets the ground texture created by the helper.
  39310. */
  39311. get: function () {
  39312. return this._groundTexture;
  39313. },
  39314. enumerable: true,
  39315. configurable: true
  39316. });
  39317. Object.defineProperty(EnvironmentHelper.prototype, "groundMirror", {
  39318. /**
  39319. * Gets the ground mirror created by the helper.
  39320. */
  39321. get: function () {
  39322. return this._groundMirror;
  39323. },
  39324. enumerable: true,
  39325. configurable: true
  39326. });
  39327. Object.defineProperty(EnvironmentHelper.prototype, "groundMirrorRenderList", {
  39328. /**
  39329. * Gets the ground mirror render list to helps pushing the meshes
  39330. * you wish in the ground reflection.
  39331. */
  39332. get: function () {
  39333. if (this._groundMirror) {
  39334. return this._groundMirror.renderList;
  39335. }
  39336. return null;
  39337. },
  39338. enumerable: true,
  39339. configurable: true
  39340. });
  39341. Object.defineProperty(EnvironmentHelper.prototype, "groundMaterial", {
  39342. /**
  39343. * Gets the ground material created by the helper.
  39344. */
  39345. get: function () {
  39346. return this._groundMaterial;
  39347. },
  39348. enumerable: true,
  39349. configurable: true
  39350. });
  39351. /**
  39352. * Updates the background according to the new options
  39353. * @param options
  39354. */
  39355. EnvironmentHelper.prototype.updateOptions = function (options) {
  39356. var newOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, this._options, options);
  39357. if (this._ground && !newOptions.createGround) {
  39358. this._ground.dispose();
  39359. this._ground = null;
  39360. }
  39361. if (this._groundMaterial && !newOptions.createGround) {
  39362. this._groundMaterial.dispose();
  39363. this._groundMaterial = null;
  39364. }
  39365. if (this._groundTexture) {
  39366. if (this._options.groundTexture != newOptions.groundTexture) {
  39367. this._groundTexture.dispose();
  39368. this._groundTexture = null;
  39369. }
  39370. }
  39371. if (this._skybox && !newOptions.createSkybox) {
  39372. this._skybox.dispose();
  39373. this._skybox = null;
  39374. }
  39375. if (this._skyboxMaterial && !newOptions.createSkybox) {
  39376. this._skyboxMaterial.dispose();
  39377. this._skyboxMaterial = null;
  39378. }
  39379. if (this._skyboxTexture) {
  39380. if (this._options.skyboxTexture != newOptions.skyboxTexture) {
  39381. this._skyboxTexture.dispose();
  39382. this._skyboxTexture = null;
  39383. }
  39384. }
  39385. if (this._groundMirror && !newOptions.enableGroundMirror) {
  39386. this._groundMirror.dispose();
  39387. this._groundMirror = null;
  39388. }
  39389. if (this._scene.environmentTexture) {
  39390. if (this._options.environmentTexture != newOptions.environmentTexture) {
  39391. this._scene.environmentTexture.dispose();
  39392. }
  39393. }
  39394. this._options = newOptions;
  39395. this._setupBackground();
  39396. this._setupImageProcessing();
  39397. };
  39398. /**
  39399. * Sets the primary color of all the available elements.
  39400. * @param color the main color to affect to the ground and the background
  39401. */
  39402. EnvironmentHelper.prototype.setMainColor = function (color) {
  39403. if (this.groundMaterial) {
  39404. this.groundMaterial.primaryColor = color;
  39405. }
  39406. if (this.skyboxMaterial) {
  39407. this.skyboxMaterial.primaryColor = color;
  39408. }
  39409. if (this.groundMirror) {
  39410. this.groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](color.r, color.g, color.b, 1.0);
  39411. }
  39412. };
  39413. /**
  39414. * Setup the image processing according to the specified options.
  39415. */
  39416. EnvironmentHelper.prototype._setupImageProcessing = function () {
  39417. if (this._options.setupImageProcessing) {
  39418. this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
  39419. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
  39420. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
  39421. this._setupEnvironmentTexture();
  39422. }
  39423. };
  39424. /**
  39425. * Setup the environment texture according to the specified options.
  39426. */
  39427. EnvironmentHelper.prototype._setupEnvironmentTexture = function () {
  39428. if (this._scene.environmentTexture) {
  39429. return;
  39430. }
  39431. if (this._options.environmentTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39432. this._scene.environmentTexture = this._options.environmentTexture;
  39433. return;
  39434. }
  39435. var environmentTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  39436. this._scene.environmentTexture = environmentTexture;
  39437. };
  39438. /**
  39439. * Setup the background according to the specified options.
  39440. */
  39441. EnvironmentHelper.prototype._setupBackground = function () {
  39442. if (!this._rootMesh) {
  39443. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("BackgroundHelper", this._scene);
  39444. }
  39445. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  39446. var sceneSize = this._getSceneSize();
  39447. if (this._options.createGround) {
  39448. this._setupGround(sceneSize);
  39449. this._setupGroundMaterial();
  39450. this._setupGroundDiffuseTexture();
  39451. if (this._options.enableGroundMirror) {
  39452. this._setupGroundMirrorTexture(sceneSize);
  39453. }
  39454. this._setupMirrorInGroundMaterial();
  39455. }
  39456. if (this._options.createSkybox) {
  39457. this._setupSkybox(sceneSize);
  39458. this._setupSkyboxMaterial();
  39459. this._setupSkyboxReflectionTexture();
  39460. }
  39461. this._rootMesh.position.x = sceneSize.rootPosition.x;
  39462. this._rootMesh.position.z = sceneSize.rootPosition.z;
  39463. this._rootMesh.position.y = sceneSize.rootPosition.y;
  39464. };
  39465. /**
  39466. * Get the scene sizes according to the setup.
  39467. */
  39468. EnvironmentHelper.prototype._getSceneSize = function () {
  39469. var _this = this;
  39470. var groundSize = this._options.groundSize;
  39471. var skyboxSize = this._options.skyboxSize;
  39472. var rootPosition = this._options.rootPosition;
  39473. if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
  39474. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  39475. }
  39476. var sceneExtends = this._scene.getWorldExtends(function (mesh) {
  39477. return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
  39478. });
  39479. var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
  39480. if (this._options.sizeAuto) {
  39481. if (this._scene.activeCamera instanceof _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"] &&
  39482. this._scene.activeCamera.upperRadiusLimit) {
  39483. groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
  39484. skyboxSize = groundSize;
  39485. }
  39486. var sceneDiagonalLenght = sceneDiagonal.length();
  39487. if (sceneDiagonalLenght > groundSize) {
  39488. groundSize = sceneDiagonalLenght * 2;
  39489. skyboxSize = groundSize;
  39490. }
  39491. // 10 % bigger.
  39492. groundSize *= 1.1;
  39493. skyboxSize *= 1.5;
  39494. rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
  39495. rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
  39496. }
  39497. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  39498. };
  39499. /**
  39500. * Setup the ground according to the specified options.
  39501. */
  39502. EnvironmentHelper.prototype._setupGround = function (sceneSize) {
  39503. var _this = this;
  39504. if (!this._ground || this._ground.isDisposed()) {
  39505. this._ground = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
  39506. this._ground.rotation.x = Math.PI / 2; // Face up by default.
  39507. this._ground.parent = this._rootMesh;
  39508. this._ground.onDisposeObservable.add(function () { _this._ground = null; });
  39509. }
  39510. this._ground.receiveShadows = this._options.enableGroundShadow;
  39511. };
  39512. /**
  39513. * Setup the ground material according to the specified options.
  39514. */
  39515. EnvironmentHelper.prototype._setupGroundMaterial = function () {
  39516. if (!this._groundMaterial) {
  39517. this._groundMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundPlaneMaterial", this._scene);
  39518. }
  39519. this._groundMaterial.alpha = this._options.groundOpacity;
  39520. this._groundMaterial.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  39521. this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
  39522. this._groundMaterial.primaryColor = this._options.groundColor;
  39523. this._groundMaterial.useRGBColor = false;
  39524. this._groundMaterial.enableNoise = true;
  39525. if (this._ground) {
  39526. this._ground.material = this._groundMaterial;
  39527. }
  39528. };
  39529. /**
  39530. * Setup the ground diffuse texture according to the specified options.
  39531. */
  39532. EnvironmentHelper.prototype._setupGroundDiffuseTexture = function () {
  39533. if (!this._groundMaterial) {
  39534. return;
  39535. }
  39536. if (this._groundTexture) {
  39537. return;
  39538. }
  39539. if (this._options.groundTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39540. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  39541. return;
  39542. }
  39543. var diffuseTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  39544. diffuseTexture.gammaSpace = false;
  39545. diffuseTexture.hasAlpha = true;
  39546. this._groundMaterial.diffuseTexture = diffuseTexture;
  39547. };
  39548. /**
  39549. * Setup the ground mirror texture according to the specified options.
  39550. */
  39551. EnvironmentHelper.prototype._setupGroundMirrorTexture = function (sceneSize) {
  39552. var wrapping = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  39553. if (!this._groundMirror) {
  39554. 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);
  39555. this._groundMirror.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Plane"](0, -1, 0, sceneSize.rootPosition.y);
  39556. this._groundMirror.anisotropicFilteringLevel = 1;
  39557. this._groundMirror.wrapU = wrapping;
  39558. this._groundMirror.wrapV = wrapping;
  39559. this._groundMirror.gammaSpace = false;
  39560. if (this._groundMirror.renderList) {
  39561. for (var i = 0; i < this._scene.meshes.length; i++) {
  39562. var mesh = this._scene.meshes[i];
  39563. if (mesh !== this._ground &&
  39564. mesh !== this._skybox &&
  39565. mesh !== this._rootMesh) {
  39566. this._groundMirror.renderList.push(mesh);
  39567. }
  39568. }
  39569. }
  39570. }
  39571. this._groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1);
  39572. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
  39573. };
  39574. /**
  39575. * Setup the ground to receive the mirror texture.
  39576. */
  39577. EnvironmentHelper.prototype._setupMirrorInGroundMaterial = function () {
  39578. if (this._groundMaterial) {
  39579. this._groundMaterial.reflectionTexture = this._groundMirror;
  39580. this._groundMaterial.reflectionFresnel = true;
  39581. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount;
  39582. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight;
  39583. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance;
  39584. }
  39585. };
  39586. /**
  39587. * Setup the skybox according to the specified options.
  39588. */
  39589. EnvironmentHelper.prototype._setupSkybox = function (sceneSize) {
  39590. var _this = this;
  39591. if (!this._skybox || this._skybox.isDisposed()) {
  39592. this._skybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].BACKSIDE);
  39593. this._skybox.onDisposeObservable.add(function () { _this._skybox = null; });
  39594. }
  39595. this._skybox.parent = this._rootMesh;
  39596. };
  39597. /**
  39598. * Setup the skybox material according to the specified options.
  39599. */
  39600. EnvironmentHelper.prototype._setupSkyboxMaterial = function () {
  39601. if (!this._skybox) {
  39602. return;
  39603. }
  39604. if (!this._skyboxMaterial) {
  39605. this._skyboxMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundSkyboxMaterial", this._scene);
  39606. }
  39607. this._skyboxMaterial.useRGBColor = false;
  39608. this._skyboxMaterial.primaryColor = this._options.skyboxColor;
  39609. this._skyboxMaterial.enableNoise = true;
  39610. this._skybox.material = this._skyboxMaterial;
  39611. };
  39612. /**
  39613. * Setup the skybox reflection texture according to the specified options.
  39614. */
  39615. EnvironmentHelper.prototype._setupSkyboxReflectionTexture = function () {
  39616. if (!this._skyboxMaterial) {
  39617. return;
  39618. }
  39619. if (this._skyboxTexture) {
  39620. return;
  39621. }
  39622. if (this._options.skyboxTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39623. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  39624. return;
  39625. }
  39626. this._skyboxTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  39627. this._skyboxTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].SKYBOX_MODE;
  39628. this._skyboxTexture.gammaSpace = false;
  39629. this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
  39630. };
  39631. /**
  39632. * Dispose all the elements created by the Helper.
  39633. */
  39634. EnvironmentHelper.prototype.dispose = function () {
  39635. if (this._groundMaterial) {
  39636. this._groundMaterial.dispose(true, true);
  39637. }
  39638. if (this._skyboxMaterial) {
  39639. this._skyboxMaterial.dispose(true, true);
  39640. }
  39641. this._rootMesh.dispose(false);
  39642. };
  39643. /**
  39644. * Default ground texture URL.
  39645. */
  39646. EnvironmentHelper._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png";
  39647. /**
  39648. * Default skybox texture URL.
  39649. */
  39650. EnvironmentHelper._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds";
  39651. /**
  39652. * Default environment texture URL.
  39653. */
  39654. EnvironmentHelper._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env";
  39655. return EnvironmentHelper;
  39656. }());
  39657. /***/ }),
  39658. /***/ "./Helpers/index.ts":
  39659. /*!**************************!*\
  39660. !*** ./Helpers/index.ts ***!
  39661. \**************************/
  39662. /*! exports provided: EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome */
  39663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39664. "use strict";
  39665. __webpack_require__.r(__webpack_exports__);
  39666. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  39667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _environmentHelper__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  39668. /* harmony import */ var _photoDome__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./photoDome */ "./Helpers/photoDome.ts");
  39669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _photoDome__WEBPACK_IMPORTED_MODULE_1__["PhotoDome"]; });
  39670. /* harmony import */ var _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneHelpers */ "./Helpers/sceneHelpers.ts");
  39671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__["_forceSceneHelpersToBundle"]; });
  39672. /* harmony import */ var _videoDome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./videoDome */ "./Helpers/videoDome.ts");
  39673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _videoDome__WEBPACK_IMPORTED_MODULE_3__["VideoDome"]; });
  39674. /***/ }),
  39675. /***/ "./Helpers/photoDome.ts":
  39676. /*!******************************!*\
  39677. !*** ./Helpers/photoDome.ts ***!
  39678. \******************************/
  39679. /*! exports provided: PhotoDome */
  39680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39681. "use strict";
  39682. __webpack_require__.r(__webpack_exports__);
  39683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return PhotoDome; });
  39684. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39685. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39686. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  39687. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39688. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39689. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39690. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  39691. /**
  39692. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  39693. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  39694. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  39695. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  39696. */
  39697. var PhotoDome = /** @class */ (function (_super) {
  39698. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PhotoDome, _super);
  39699. /**
  39700. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  39701. * @param name Element's name, child elements will append suffixes for their own names.
  39702. * @param urlsOfPhoto defines the url of the photo to display
  39703. * @param options defines an object containing optional or exposed sub element properties
  39704. * @param onError defines a callback called when an error occured while loading the texture
  39705. */
  39706. function PhotoDome(name, urlOfPhoto, options, scene, onError) {
  39707. if (onError === void 0) { onError = null; }
  39708. var _this = _super.call(this, name, scene) || this;
  39709. _this._useDirectMapping = false;
  39710. /**
  39711. * Observable raised when an error occured while loading the 360 image
  39712. */
  39713. _this.onLoadErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39714. // set defaults and manage values
  39715. name = name || "photoDome";
  39716. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  39717. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  39718. if (options.useDirectMapping === undefined) {
  39719. _this._useDirectMapping = true;
  39720. }
  39721. else {
  39722. _this._useDirectMapping = options.useDirectMapping;
  39723. }
  39724. _this._setReady(false);
  39725. // create
  39726. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  39727. _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);
  39728. // configure material
  39729. material.opacityFresnel = false;
  39730. material.useEquirectangularFOV = true;
  39731. material.fovMultiplier = 1.0;
  39732. _this.photoTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](urlOfPhoto, scene, true, !_this._useDirectMapping, undefined, undefined, function (message, exception) {
  39733. _this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
  39734. if (onError) {
  39735. onError(message, exception);
  39736. }
  39737. });
  39738. _this.photoTexture.onLoadObservable.addOnce(function () {
  39739. _this._setReady(true);
  39740. });
  39741. // configure mesh
  39742. _this._mesh.material = material;
  39743. _this._mesh.parent = _this;
  39744. return _this;
  39745. }
  39746. Object.defineProperty(PhotoDome.prototype, "photoTexture", {
  39747. /**
  39748. * Gets or sets the texture being displayed on the sphere
  39749. */
  39750. get: function () {
  39751. return this._photoTexture;
  39752. },
  39753. set: function (value) {
  39754. if (this._photoTexture === value) {
  39755. return;
  39756. }
  39757. this._photoTexture = value;
  39758. if (this._useDirectMapping) {
  39759. this._photoTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39760. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39761. this._material.diffuseTexture = this._photoTexture;
  39762. }
  39763. else {
  39764. this._photoTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  39765. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39766. this._material.reflectionTexture = this._photoTexture;
  39767. }
  39768. },
  39769. enumerable: true,
  39770. configurable: true
  39771. });
  39772. Object.defineProperty(PhotoDome.prototype, "fovMultiplier", {
  39773. /**
  39774. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  39775. * Also see the options.resolution property.
  39776. */
  39777. get: function () {
  39778. return this._material.fovMultiplier;
  39779. },
  39780. set: function (value) {
  39781. this._material.fovMultiplier = value;
  39782. },
  39783. enumerable: true,
  39784. configurable: true
  39785. });
  39786. /**
  39787. * Releases resources associated with this node.
  39788. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  39789. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  39790. */
  39791. PhotoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  39792. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  39793. this._photoTexture.dispose();
  39794. this._mesh.dispose();
  39795. this._material.dispose();
  39796. this.onLoadErrorObservable.clear();
  39797. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  39798. };
  39799. return PhotoDome;
  39800. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__["TransformNode"]));
  39801. /***/ }),
  39802. /***/ "./Helpers/sceneHelpers.ts":
  39803. /*!*********************************!*\
  39804. !*** ./Helpers/sceneHelpers.ts ***!
  39805. \*********************************/
  39806. /*! exports provided: _forceSceneHelpersToBundle */
  39807. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39808. "use strict";
  39809. __webpack_require__.r(__webpack_exports__);
  39810. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _forceSceneHelpersToBundle; });
  39811. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39812. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  39813. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39814. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39815. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39816. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39817. /* harmony import */ var _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/PBR/pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  39818. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  39819. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  39820. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  39821. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  39822. /* harmony import */ var _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/XR/webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  39823. /* harmony import */ var _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/XR/webXRInput */ "./Cameras/XR/webXRInput.ts");
  39824. /* harmony import */ var _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Cameras/XR/webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  39825. /* harmony import */ var _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Cameras/XR/webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  39826. /* harmony import */ var _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Cameras/VR/vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  39827. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  39828. /** @hidden */
  39829. var _forceSceneHelpersToBundle = true;
  39830. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultLight = function (replace) {
  39831. if (replace === void 0) { replace = false; }
  39832. // Dispose existing light in replace mode.
  39833. if (replace) {
  39834. if (this.lights) {
  39835. for (var i = 0; i < this.lights.length; i++) {
  39836. this.lights[i].dispose();
  39837. }
  39838. }
  39839. }
  39840. // Light
  39841. if (this.lights.length === 0) {
  39842. new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]("default light", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up(), this);
  39843. }
  39844. };
  39845. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCamera = function (createArcRotateCamera, replace, attachCameraControls) {
  39846. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  39847. if (replace === void 0) { replace = false; }
  39848. if (attachCameraControls === void 0) { attachCameraControls = false; }
  39849. // Dispose existing camera in replace mode.
  39850. if (replace) {
  39851. if (this.activeCamera) {
  39852. this.activeCamera.dispose();
  39853. this.activeCamera = null;
  39854. }
  39855. }
  39856. // Camera
  39857. if (!this.activeCamera) {
  39858. var worldExtends = this.getWorldExtends();
  39859. var worldSize = worldExtends.max.subtract(worldExtends.min);
  39860. var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
  39861. var camera;
  39862. var radius = worldSize.length() * 1.5;
  39863. // empty scene scenario!
  39864. if (!isFinite(radius)) {
  39865. radius = 1;
  39866. worldCenter.copyFromFloats(0, 0, 0);
  39867. }
  39868. if (createArcRotateCamera) {
  39869. var arcRotateCamera = new _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__["ArcRotateCamera"]("default camera", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);
  39870. arcRotateCamera.lowerRadiusLimit = radius * 0.01;
  39871. arcRotateCamera.wheelPrecision = 100 / radius;
  39872. camera = arcRotateCamera;
  39873. }
  39874. else {
  39875. 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);
  39876. freeCamera.setTarget(worldCenter);
  39877. camera = freeCamera;
  39878. }
  39879. camera.minZ = radius * 0.01;
  39880. camera.maxZ = radius * 1000;
  39881. camera.speed = radius * 0.2;
  39882. this.activeCamera = camera;
  39883. var canvas = this.getEngine().getRenderingCanvas();
  39884. if (attachCameraControls && canvas) {
  39885. camera.attachControl(canvas);
  39886. }
  39887. }
  39888. };
  39889. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCameraOrLight = function (createArcRotateCamera, replace, attachCameraControls) {
  39890. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  39891. if (replace === void 0) { replace = false; }
  39892. if (attachCameraControls === void 0) { attachCameraControls = false; }
  39893. this.createDefaultLight(replace);
  39894. this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);
  39895. };
  39896. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
  39897. if (pbr === void 0) { pbr = false; }
  39898. if (scale === void 0) { scale = 1000; }
  39899. if (blur === void 0) { blur = 0; }
  39900. if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
  39901. if (!environmentTexture) {
  39902. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Can not create default skybox without environment texture.");
  39903. return null;
  39904. }
  39905. if (setGlobalEnvTexture) {
  39906. if (environmentTexture) {
  39907. this.environmentTexture = environmentTexture;
  39908. }
  39909. }
  39910. // Skybox
  39911. var hdrSkybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox("hdrSkyBox", scale, this);
  39912. if (pbr) {
  39913. var hdrSkyboxMaterial = new _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__["PBRMaterial"]("skyBox", this);
  39914. hdrSkyboxMaterial.backFaceCulling = false;
  39915. hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
  39916. if (hdrSkyboxMaterial.reflectionTexture) {
  39917. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  39918. }
  39919. hdrSkyboxMaterial.microSurface = 1.0 - blur;
  39920. hdrSkyboxMaterial.disableLighting = true;
  39921. hdrSkyboxMaterial.twoSidedLighting = true;
  39922. hdrSkybox.infiniteDistance = true;
  39923. hdrSkybox.material = hdrSkyboxMaterial;
  39924. }
  39925. else {
  39926. var skyboxMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("skyBox", this);
  39927. skyboxMaterial.backFaceCulling = false;
  39928. skyboxMaterial.reflectionTexture = environmentTexture.clone();
  39929. if (skyboxMaterial.reflectionTexture) {
  39930. skyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  39931. }
  39932. skyboxMaterial.disableLighting = true;
  39933. hdrSkybox.infiniteDistance = true;
  39934. hdrSkybox.material = skyboxMaterial;
  39935. }
  39936. hdrSkybox.isPickable = false;
  39937. return hdrSkybox;
  39938. };
  39939. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultEnvironment = function (options) {
  39940. if (_environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"]) {
  39941. return new _environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"](options, this);
  39942. }
  39943. return null;
  39944. };
  39945. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultVRExperience = function (webVROptions) {
  39946. if (webVROptions === void 0) { webVROptions = {}; }
  39947. return new _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__["VRExperienceHelper"](this, webVROptions);
  39948. };
  39949. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultXRExperienceAsync = function () {
  39950. var _this = this;
  39951. return _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__["WebXRExperienceHelper"].CreateAsync(this).then(function (helper) {
  39952. var outputCanvas = new _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__["WebXRManagedOutputCanvas"](helper);
  39953. return _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__["WebXREnterExitUI"].CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext })
  39954. .then(function (ui) {
  39955. new _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__["WebXRInput"](helper);
  39956. return helper;
  39957. });
  39958. });
  39959. };
  39960. /***/ }),
  39961. /***/ "./Helpers/videoDome.ts":
  39962. /*!******************************!*\
  39963. !*** ./Helpers/videoDome.ts ***!
  39964. \******************************/
  39965. /*! exports provided: VideoDome */
  39966. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39967. "use strict";
  39968. __webpack_require__.r(__webpack_exports__);
  39969. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return VideoDome; });
  39970. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39971. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  39972. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39973. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39974. /* harmony import */ var _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/videoTexture */ "./Materials/Textures/videoTexture.ts");
  39975. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39976. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  39977. /**
  39978. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  39979. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  39980. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  39981. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  39982. */
  39983. var VideoDome = /** @class */ (function (_super) {
  39984. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoDome, _super);
  39985. /**
  39986. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  39987. * @param name Element's name, child elements will append suffixes for their own names.
  39988. * @param urlsOrVideo defines the url(s) or the video element to use
  39989. * @param options An object containing optional or exposed sub element properties
  39990. */
  39991. function VideoDome(name, urlsOrVideo, options, scene) {
  39992. var _this = _super.call(this, name, scene) || this;
  39993. _this._useDirectMapping = false;
  39994. // set defaults and manage values
  39995. name = name || "videoDome";
  39996. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  39997. options.clickToPlay = Boolean(options.clickToPlay);
  39998. options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
  39999. options.loop = options.loop === undefined ? true : Boolean(options.loop);
  40000. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  40001. if (options.useDirectMapping === undefined) {
  40002. _this._useDirectMapping = true;
  40003. }
  40004. else {
  40005. _this._useDirectMapping = options.useDirectMapping;
  40006. }
  40007. _this._setReady(false);
  40008. // create
  40009. var tempOptions = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
  40010. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  40011. 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);
  40012. _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);
  40013. texture.onLoadObservable.addOnce(function () {
  40014. _this._setReady(true);
  40015. });
  40016. // configure material
  40017. material.useEquirectangularFOV = true;
  40018. material.fovMultiplier = 1.0;
  40019. material.opacityFresnel = false;
  40020. if (_this._useDirectMapping) {
  40021. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40022. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40023. material.diffuseTexture = texture;
  40024. }
  40025. else {
  40026. texture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  40027. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40028. material.reflectionTexture = texture;
  40029. }
  40030. // configure mesh
  40031. _this._mesh.material = material;
  40032. _this._mesh.parent = _this;
  40033. // optional configuration
  40034. if (options.clickToPlay) {
  40035. scene.onPointerUp = function () {
  40036. _this._videoTexture.video.play();
  40037. };
  40038. }
  40039. return _this;
  40040. }
  40041. Object.defineProperty(VideoDome.prototype, "videoTexture", {
  40042. /**
  40043. * Gets the video texture being displayed on the sphere
  40044. */
  40045. get: function () {
  40046. return this._videoTexture;
  40047. },
  40048. enumerable: true,
  40049. configurable: true
  40050. });
  40051. Object.defineProperty(VideoDome.prototype, "fovMultiplier", {
  40052. /**
  40053. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  40054. * Also see the options.resolution property.
  40055. */
  40056. get: function () {
  40057. return this._material.fovMultiplier;
  40058. },
  40059. set: function (value) {
  40060. this._material.fovMultiplier = value;
  40061. },
  40062. enumerable: true,
  40063. configurable: true
  40064. });
  40065. /**
  40066. * Releases resources associated with this node.
  40067. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  40068. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  40069. */
  40070. VideoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  40071. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  40072. this._videoTexture.dispose();
  40073. this._mesh.dispose();
  40074. this._material.dispose();
  40075. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  40076. };
  40077. return VideoDome;
  40078. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]));
  40079. /***/ }),
  40080. /***/ "./Instrumentation/engineInstrumentation.ts":
  40081. /*!**************************************************!*\
  40082. !*** ./Instrumentation/engineInstrumentation.ts ***!
  40083. \**************************************************/
  40084. /*! exports provided: EngineInstrumentation */
  40085. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40086. "use strict";
  40087. __webpack_require__.r(__webpack_exports__);
  40088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return EngineInstrumentation; });
  40089. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40090. /**
  40091. * This class can be used to get instrumentation data from a Babylon engine
  40092. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40093. */
  40094. var EngineInstrumentation = /** @class */ (function () {
  40095. /**
  40096. * Instantiates a new engine instrumentation.
  40097. * This class can be used to get instrumentation data from a Babylon engine
  40098. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40099. * @param engine Defines the engine to instrument
  40100. */
  40101. function EngineInstrumentation(
  40102. /**
  40103. * Define the instrumented engine.
  40104. */
  40105. engine) {
  40106. this.engine = engine;
  40107. this._captureGPUFrameTime = false;
  40108. this._gpuFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40109. this._captureShaderCompilationTime = false;
  40110. this._shaderCompilationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40111. // Observers
  40112. this._onBeginFrameObserver = null;
  40113. this._onEndFrameObserver = null;
  40114. this._onBeforeShaderCompilationObserver = null;
  40115. this._onAfterShaderCompilationObserver = null;
  40116. }
  40117. Object.defineProperty(EngineInstrumentation.prototype, "gpuFrameTimeCounter", {
  40118. // Properties
  40119. /**
  40120. * Gets the perf counter used for GPU frame time
  40121. */
  40122. get: function () {
  40123. return this._gpuFrameTime;
  40124. },
  40125. enumerable: true,
  40126. configurable: true
  40127. });
  40128. Object.defineProperty(EngineInstrumentation.prototype, "captureGPUFrameTime", {
  40129. /**
  40130. * Gets the GPU frame time capture status
  40131. */
  40132. get: function () {
  40133. return this._captureGPUFrameTime;
  40134. },
  40135. /**
  40136. * Enable or disable the GPU frame time capture
  40137. */
  40138. set: function (value) {
  40139. var _this = this;
  40140. if (value === this._captureGPUFrameTime) {
  40141. return;
  40142. }
  40143. this._captureGPUFrameTime = value;
  40144. if (value) {
  40145. this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function () {
  40146. if (!_this._gpuFrameTimeToken) {
  40147. _this._gpuFrameTimeToken = _this.engine.startTimeQuery();
  40148. }
  40149. });
  40150. this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function () {
  40151. if (!_this._gpuFrameTimeToken) {
  40152. return;
  40153. }
  40154. var time = _this.engine.endTimeQuery(_this._gpuFrameTimeToken);
  40155. if (time > -1) {
  40156. _this._gpuFrameTimeToken = null;
  40157. _this._gpuFrameTime.fetchNewFrame();
  40158. _this._gpuFrameTime.addCount(time, true);
  40159. }
  40160. });
  40161. }
  40162. else {
  40163. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  40164. this._onBeginFrameObserver = null;
  40165. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  40166. this._onEndFrameObserver = null;
  40167. }
  40168. },
  40169. enumerable: true,
  40170. configurable: true
  40171. });
  40172. Object.defineProperty(EngineInstrumentation.prototype, "shaderCompilationTimeCounter", {
  40173. /**
  40174. * Gets the perf counter used for shader compilation time
  40175. */
  40176. get: function () {
  40177. return this._shaderCompilationTime;
  40178. },
  40179. enumerable: true,
  40180. configurable: true
  40181. });
  40182. Object.defineProperty(EngineInstrumentation.prototype, "captureShaderCompilationTime", {
  40183. /**
  40184. * Gets the shader compilation time capture status
  40185. */
  40186. get: function () {
  40187. return this._captureShaderCompilationTime;
  40188. },
  40189. /**
  40190. * Enable or disable the shader compilation time capture
  40191. */
  40192. set: function (value) {
  40193. var _this = this;
  40194. if (value === this._captureShaderCompilationTime) {
  40195. return;
  40196. }
  40197. this._captureShaderCompilationTime = value;
  40198. if (value) {
  40199. this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function () {
  40200. _this._shaderCompilationTime.fetchNewFrame();
  40201. _this._shaderCompilationTime.beginMonitoring();
  40202. });
  40203. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function () {
  40204. _this._shaderCompilationTime.endMonitoring();
  40205. });
  40206. }
  40207. else {
  40208. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  40209. this._onBeforeShaderCompilationObserver = null;
  40210. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  40211. this._onAfterShaderCompilationObserver = null;
  40212. }
  40213. },
  40214. enumerable: true,
  40215. configurable: true
  40216. });
  40217. /**
  40218. * Dispose and release associated resources.
  40219. */
  40220. EngineInstrumentation.prototype.dispose = function () {
  40221. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  40222. this._onBeginFrameObserver = null;
  40223. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  40224. this._onEndFrameObserver = null;
  40225. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  40226. this._onBeforeShaderCompilationObserver = null;
  40227. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  40228. this._onAfterShaderCompilationObserver = null;
  40229. this.engine = null;
  40230. };
  40231. return EngineInstrumentation;
  40232. }());
  40233. /***/ }),
  40234. /***/ "./Instrumentation/index.ts":
  40235. /*!**********************************!*\
  40236. !*** ./Instrumentation/index.ts ***!
  40237. \**********************************/
  40238. /*! exports provided: EngineInstrumentation, SceneInstrumentation, _TimeToken */
  40239. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40240. "use strict";
  40241. __webpack_require__.r(__webpack_exports__);
  40242. /* harmony import */ var _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engineInstrumentation */ "./Instrumentation/engineInstrumentation.ts");
  40243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  40244. /* harmony import */ var _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sceneInstrumentation */ "./Instrumentation/sceneInstrumentation.ts");
  40245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__["SceneInstrumentation"]; });
  40246. /* harmony import */ var _timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeToken */ "./Instrumentation/timeToken.ts");
  40247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]; });
  40248. /***/ }),
  40249. /***/ "./Instrumentation/sceneInstrumentation.ts":
  40250. /*!*************************************************!*\
  40251. !*** ./Instrumentation/sceneInstrumentation.ts ***!
  40252. \*************************************************/
  40253. /*! exports provided: SceneInstrumentation */
  40254. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40255. "use strict";
  40256. __webpack_require__.r(__webpack_exports__);
  40257. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return SceneInstrumentation; });
  40258. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40259. /**
  40260. * This class can be used to get instrumentation data from a Babylon engine
  40261. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  40262. */
  40263. var SceneInstrumentation = /** @class */ (function () {
  40264. /**
  40265. * Instantiates a new scene instrumentation.
  40266. * This class can be used to get instrumentation data from a Babylon engine
  40267. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  40268. * @param scene Defines the scene to instrument
  40269. */
  40270. function SceneInstrumentation(
  40271. /**
  40272. * Defines the scene to instrument
  40273. */
  40274. scene) {
  40275. var _this = this;
  40276. this.scene = scene;
  40277. this._captureActiveMeshesEvaluationTime = false;
  40278. this._activeMeshesEvaluationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40279. this._captureRenderTargetsRenderTime = false;
  40280. this._renderTargetsRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40281. this._captureFrameTime = false;
  40282. this._frameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40283. this._captureRenderTime = false;
  40284. this._renderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40285. this._captureInterFrameTime = false;
  40286. this._interFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40287. this._captureParticlesRenderTime = false;
  40288. this._particlesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40289. this._captureSpritesRenderTime = false;
  40290. this._spritesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40291. this._capturePhysicsTime = false;
  40292. this._physicsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40293. this._captureAnimationsTime = false;
  40294. this._animationsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40295. this._captureCameraRenderTime = false;
  40296. this._cameraRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40297. // Observers
  40298. this._onBeforeActiveMeshesEvaluationObserver = null;
  40299. this._onAfterActiveMeshesEvaluationObserver = null;
  40300. this._onBeforeRenderTargetsRenderObserver = null;
  40301. this._onAfterRenderTargetsRenderObserver = null;
  40302. this._onAfterRenderObserver = null;
  40303. this._onBeforeDrawPhaseObserver = null;
  40304. this._onAfterDrawPhaseObserver = null;
  40305. this._onBeforeAnimationsObserver = null;
  40306. this._onBeforeParticlesRenderingObserver = null;
  40307. this._onAfterParticlesRenderingObserver = null;
  40308. this._onBeforeSpritesRenderingObserver = null;
  40309. this._onAfterSpritesRenderingObserver = null;
  40310. this._onBeforePhysicsObserver = null;
  40311. this._onAfterPhysicsObserver = null;
  40312. this._onAfterAnimationsObserver = null;
  40313. this._onBeforeCameraRenderObserver = null;
  40314. this._onAfterCameraRenderObserver = null;
  40315. // Before render
  40316. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  40317. if (_this._captureActiveMeshesEvaluationTime) {
  40318. _this._activeMeshesEvaluationTime.fetchNewFrame();
  40319. }
  40320. if (_this._captureRenderTargetsRenderTime) {
  40321. _this._renderTargetsRenderTime.fetchNewFrame();
  40322. }
  40323. if (_this._captureFrameTime) {
  40324. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Scene rendering");
  40325. _this._frameTime.beginMonitoring();
  40326. }
  40327. if (_this._captureInterFrameTime) {
  40328. _this._interFrameTime.endMonitoring();
  40329. }
  40330. if (_this._captureParticlesRenderTime) {
  40331. _this._particlesRenderTime.fetchNewFrame();
  40332. }
  40333. if (_this._captureSpritesRenderTime) {
  40334. _this._spritesRenderTime.fetchNewFrame();
  40335. }
  40336. if (_this._captureAnimationsTime) {
  40337. _this._animationsTime.beginMonitoring();
  40338. }
  40339. _this.scene.getEngine()._drawCalls.fetchNewFrame();
  40340. _this.scene.getEngine()._textureCollisions.fetchNewFrame();
  40341. });
  40342. // After render
  40343. this._onAfterRenderObserver = scene.onAfterRenderObservable.add(function () {
  40344. if (_this._captureFrameTime) {
  40345. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Scene rendering");
  40346. _this._frameTime.endMonitoring();
  40347. }
  40348. if (_this._captureRenderTime) {
  40349. _this._renderTime.endMonitoring(false);
  40350. }
  40351. if (_this._captureInterFrameTime) {
  40352. _this._interFrameTime.beginMonitoring();
  40353. }
  40354. });
  40355. }
  40356. Object.defineProperty(SceneInstrumentation.prototype, "activeMeshesEvaluationTimeCounter", {
  40357. // Properties
  40358. /**
  40359. * Gets the perf counter used for active meshes evaluation time
  40360. */
  40361. get: function () {
  40362. return this._activeMeshesEvaluationTime;
  40363. },
  40364. enumerable: true,
  40365. configurable: true
  40366. });
  40367. Object.defineProperty(SceneInstrumentation.prototype, "captureActiveMeshesEvaluationTime", {
  40368. /**
  40369. * Gets the active meshes evaluation time capture status
  40370. */
  40371. get: function () {
  40372. return this._captureActiveMeshesEvaluationTime;
  40373. },
  40374. /**
  40375. * Enable or disable the active meshes evaluation time capture
  40376. */
  40377. set: function (value) {
  40378. var _this = this;
  40379. if (value === this._captureActiveMeshesEvaluationTime) {
  40380. return;
  40381. }
  40382. this._captureActiveMeshesEvaluationTime = value;
  40383. if (value) {
  40384. this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function () {
  40385. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Active meshes evaluation");
  40386. _this._activeMeshesEvaluationTime.beginMonitoring();
  40387. });
  40388. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function () {
  40389. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Active meshes evaluation");
  40390. _this._activeMeshesEvaluationTime.endMonitoring();
  40391. });
  40392. }
  40393. else {
  40394. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  40395. this._onBeforeActiveMeshesEvaluationObserver = null;
  40396. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  40397. this._onAfterActiveMeshesEvaluationObserver = null;
  40398. }
  40399. },
  40400. enumerable: true,
  40401. configurable: true
  40402. });
  40403. Object.defineProperty(SceneInstrumentation.prototype, "renderTargetsRenderTimeCounter", {
  40404. /**
  40405. * Gets the perf counter used for render targets render time
  40406. */
  40407. get: function () {
  40408. return this._renderTargetsRenderTime;
  40409. },
  40410. enumerable: true,
  40411. configurable: true
  40412. });
  40413. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTargetsRenderTime", {
  40414. /**
  40415. * Gets the render targets render time capture status
  40416. */
  40417. get: function () {
  40418. return this._captureRenderTargetsRenderTime;
  40419. },
  40420. /**
  40421. * Enable or disable the render targets render time capture
  40422. */
  40423. set: function (value) {
  40424. var _this = this;
  40425. if (value === this._captureRenderTargetsRenderTime) {
  40426. return;
  40427. }
  40428. this._captureRenderTargetsRenderTime = value;
  40429. if (value) {
  40430. this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function () {
  40431. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Render targets rendering");
  40432. _this._renderTargetsRenderTime.beginMonitoring();
  40433. });
  40434. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function () {
  40435. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Render targets rendering");
  40436. _this._renderTargetsRenderTime.endMonitoring(false);
  40437. });
  40438. }
  40439. else {
  40440. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  40441. this._onBeforeRenderTargetsRenderObserver = null;
  40442. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  40443. this._onAfterRenderTargetsRenderObserver = null;
  40444. }
  40445. },
  40446. enumerable: true,
  40447. configurable: true
  40448. });
  40449. Object.defineProperty(SceneInstrumentation.prototype, "particlesRenderTimeCounter", {
  40450. /**
  40451. * Gets the perf counter used for particles render time
  40452. */
  40453. get: function () {
  40454. return this._particlesRenderTime;
  40455. },
  40456. enumerable: true,
  40457. configurable: true
  40458. });
  40459. Object.defineProperty(SceneInstrumentation.prototype, "captureParticlesRenderTime", {
  40460. /**
  40461. * Gets the particles render time capture status
  40462. */
  40463. get: function () {
  40464. return this._captureParticlesRenderTime;
  40465. },
  40466. /**
  40467. * Enable or disable the particles render time capture
  40468. */
  40469. set: function (value) {
  40470. var _this = this;
  40471. if (value === this._captureParticlesRenderTime) {
  40472. return;
  40473. }
  40474. this._captureParticlesRenderTime = value;
  40475. if (value) {
  40476. this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function () {
  40477. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Particles");
  40478. _this._particlesRenderTime.beginMonitoring();
  40479. });
  40480. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function () {
  40481. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Particles");
  40482. _this._particlesRenderTime.endMonitoring(false);
  40483. });
  40484. }
  40485. else {
  40486. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  40487. this._onBeforeParticlesRenderingObserver = null;
  40488. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  40489. this._onAfterParticlesRenderingObserver = null;
  40490. }
  40491. },
  40492. enumerable: true,
  40493. configurable: true
  40494. });
  40495. Object.defineProperty(SceneInstrumentation.prototype, "spritesRenderTimeCounter", {
  40496. /**
  40497. * Gets the perf counter used for sprites render time
  40498. */
  40499. get: function () {
  40500. return this._spritesRenderTime;
  40501. },
  40502. enumerable: true,
  40503. configurable: true
  40504. });
  40505. Object.defineProperty(SceneInstrumentation.prototype, "captureSpritesRenderTime", {
  40506. /**
  40507. * Gets the sprites render time capture status
  40508. */
  40509. get: function () {
  40510. return this._captureSpritesRenderTime;
  40511. },
  40512. /**
  40513. * Enable or disable the sprites render time capture
  40514. */
  40515. set: function (value) {
  40516. var _this = this;
  40517. if (value === this._captureSpritesRenderTime) {
  40518. return;
  40519. }
  40520. this._captureSpritesRenderTime = value;
  40521. if (!this.scene.spriteManagers) {
  40522. return;
  40523. }
  40524. if (value) {
  40525. this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function () {
  40526. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Sprites");
  40527. _this._spritesRenderTime.beginMonitoring();
  40528. });
  40529. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function () {
  40530. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Sprites");
  40531. _this._spritesRenderTime.endMonitoring(false);
  40532. });
  40533. }
  40534. else {
  40535. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  40536. this._onBeforeSpritesRenderingObserver = null;
  40537. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  40538. this._onAfterSpritesRenderingObserver = null;
  40539. }
  40540. },
  40541. enumerable: true,
  40542. configurable: true
  40543. });
  40544. Object.defineProperty(SceneInstrumentation.prototype, "physicsTimeCounter", {
  40545. /**
  40546. * Gets the perf counter used for physics time
  40547. */
  40548. get: function () {
  40549. return this._physicsTime;
  40550. },
  40551. enumerable: true,
  40552. configurable: true
  40553. });
  40554. Object.defineProperty(SceneInstrumentation.prototype, "capturePhysicsTime", {
  40555. /**
  40556. * Gets the physics time capture status
  40557. */
  40558. get: function () {
  40559. return this._capturePhysicsTime;
  40560. },
  40561. /**
  40562. * Enable or disable the physics time capture
  40563. */
  40564. set: function (value) {
  40565. var _this = this;
  40566. if (value === this._capturePhysicsTime) {
  40567. return;
  40568. }
  40569. if (!this.scene.onBeforePhysicsObservable) {
  40570. return;
  40571. }
  40572. this._capturePhysicsTime = value;
  40573. if (value) {
  40574. this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function () {
  40575. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Physics");
  40576. _this._physicsTime.beginMonitoring();
  40577. });
  40578. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function () {
  40579. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Physics");
  40580. _this._physicsTime.endMonitoring();
  40581. });
  40582. }
  40583. else {
  40584. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  40585. this._onBeforePhysicsObserver = null;
  40586. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  40587. this._onAfterPhysicsObserver = null;
  40588. }
  40589. },
  40590. enumerable: true,
  40591. configurable: true
  40592. });
  40593. Object.defineProperty(SceneInstrumentation.prototype, "animationsTimeCounter", {
  40594. /**
  40595. * Gets the perf counter used for animations time
  40596. */
  40597. get: function () {
  40598. return this._animationsTime;
  40599. },
  40600. enumerable: true,
  40601. configurable: true
  40602. });
  40603. Object.defineProperty(SceneInstrumentation.prototype, "captureAnimationsTime", {
  40604. /**
  40605. * Gets the animations time capture status
  40606. */
  40607. get: function () {
  40608. return this._captureAnimationsTime;
  40609. },
  40610. /**
  40611. * Enable or disable the animations time capture
  40612. */
  40613. set: function (value) {
  40614. var _this = this;
  40615. if (value === this._captureAnimationsTime) {
  40616. return;
  40617. }
  40618. this._captureAnimationsTime = value;
  40619. if (value) {
  40620. this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function () {
  40621. _this._animationsTime.endMonitoring();
  40622. });
  40623. }
  40624. else {
  40625. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  40626. this._onAfterAnimationsObserver = null;
  40627. }
  40628. },
  40629. enumerable: true,
  40630. configurable: true
  40631. });
  40632. Object.defineProperty(SceneInstrumentation.prototype, "frameTimeCounter", {
  40633. /**
  40634. * Gets the perf counter used for frame time capture
  40635. */
  40636. get: function () {
  40637. return this._frameTime;
  40638. },
  40639. enumerable: true,
  40640. configurable: true
  40641. });
  40642. Object.defineProperty(SceneInstrumentation.prototype, "captureFrameTime", {
  40643. /**
  40644. * Gets the frame time capture status
  40645. */
  40646. get: function () {
  40647. return this._captureFrameTime;
  40648. },
  40649. /**
  40650. * Enable or disable the frame time capture
  40651. */
  40652. set: function (value) {
  40653. this._captureFrameTime = value;
  40654. },
  40655. enumerable: true,
  40656. configurable: true
  40657. });
  40658. Object.defineProperty(SceneInstrumentation.prototype, "interFrameTimeCounter", {
  40659. /**
  40660. * Gets the perf counter used for inter-frames time capture
  40661. */
  40662. get: function () {
  40663. return this._interFrameTime;
  40664. },
  40665. enumerable: true,
  40666. configurable: true
  40667. });
  40668. Object.defineProperty(SceneInstrumentation.prototype, "captureInterFrameTime", {
  40669. /**
  40670. * Gets the inter-frames time capture status
  40671. */
  40672. get: function () {
  40673. return this._captureInterFrameTime;
  40674. },
  40675. /**
  40676. * Enable or disable the inter-frames time capture
  40677. */
  40678. set: function (value) {
  40679. this._captureInterFrameTime = value;
  40680. },
  40681. enumerable: true,
  40682. configurable: true
  40683. });
  40684. Object.defineProperty(SceneInstrumentation.prototype, "renderTimeCounter", {
  40685. /**
  40686. * Gets the perf counter used for render time capture
  40687. */
  40688. get: function () {
  40689. return this._renderTime;
  40690. },
  40691. enumerable: true,
  40692. configurable: true
  40693. });
  40694. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTime", {
  40695. /**
  40696. * Gets the render time capture status
  40697. */
  40698. get: function () {
  40699. return this._captureRenderTime;
  40700. },
  40701. /**
  40702. * Enable or disable the render time capture
  40703. */
  40704. set: function (value) {
  40705. var _this = this;
  40706. if (value === this._captureRenderTime) {
  40707. return;
  40708. }
  40709. this._captureRenderTime = value;
  40710. if (value) {
  40711. this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function () {
  40712. _this._renderTime.beginMonitoring();
  40713. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Main render");
  40714. });
  40715. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function () {
  40716. _this._renderTime.endMonitoring(false);
  40717. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Main render");
  40718. });
  40719. }
  40720. else {
  40721. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  40722. this._onBeforeDrawPhaseObserver = null;
  40723. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  40724. this._onAfterDrawPhaseObserver = null;
  40725. }
  40726. },
  40727. enumerable: true,
  40728. configurable: true
  40729. });
  40730. Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
  40731. /**
  40732. * Gets the perf counter used for camera render time capture
  40733. */
  40734. get: function () {
  40735. return this._cameraRenderTime;
  40736. },
  40737. enumerable: true,
  40738. configurable: true
  40739. });
  40740. Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
  40741. /**
  40742. * Gets the camera render time capture status
  40743. */
  40744. get: function () {
  40745. return this._captureCameraRenderTime;
  40746. },
  40747. /**
  40748. * Enable or disable the camera render time capture
  40749. */
  40750. set: function (value) {
  40751. var _this = this;
  40752. if (value === this._captureCameraRenderTime) {
  40753. return;
  40754. }
  40755. this._captureCameraRenderTime = value;
  40756. if (value) {
  40757. this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
  40758. _this._cameraRenderTime.beginMonitoring();
  40759. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Rendering camera " + camera.name);
  40760. });
  40761. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
  40762. _this._cameraRenderTime.endMonitoring(false);
  40763. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Rendering camera " + camera.name);
  40764. });
  40765. }
  40766. else {
  40767. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40768. this._onBeforeCameraRenderObserver = null;
  40769. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  40770. this._onAfterCameraRenderObserver = null;
  40771. }
  40772. },
  40773. enumerable: true,
  40774. configurable: true
  40775. });
  40776. Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
  40777. /**
  40778. * Gets the perf counter used for draw calls
  40779. */
  40780. get: function () {
  40781. return this.scene.getEngine()._drawCalls;
  40782. },
  40783. enumerable: true,
  40784. configurable: true
  40785. });
  40786. Object.defineProperty(SceneInstrumentation.prototype, "textureCollisionsCounter", {
  40787. /**
  40788. * Gets the perf counter used for texture collisions
  40789. */
  40790. get: function () {
  40791. return this.scene.getEngine()._textureCollisions;
  40792. },
  40793. enumerable: true,
  40794. configurable: true
  40795. });
  40796. /**
  40797. * Dispose and release associated resources.
  40798. */
  40799. SceneInstrumentation.prototype.dispose = function () {
  40800. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  40801. this._onAfterRenderObserver = null;
  40802. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  40803. this._onBeforeActiveMeshesEvaluationObserver = null;
  40804. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  40805. this._onAfterActiveMeshesEvaluationObserver = null;
  40806. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  40807. this._onBeforeRenderTargetsRenderObserver = null;
  40808. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  40809. this._onAfterRenderTargetsRenderObserver = null;
  40810. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  40811. this._onBeforeAnimationsObserver = null;
  40812. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  40813. this._onBeforeParticlesRenderingObserver = null;
  40814. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  40815. this._onAfterParticlesRenderingObserver = null;
  40816. if (this._onBeforeSpritesRenderingObserver) {
  40817. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  40818. this._onBeforeSpritesRenderingObserver = null;
  40819. }
  40820. if (this._onAfterSpritesRenderingObserver) {
  40821. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  40822. this._onAfterSpritesRenderingObserver = null;
  40823. }
  40824. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  40825. this._onBeforeDrawPhaseObserver = null;
  40826. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  40827. this._onAfterDrawPhaseObserver = null;
  40828. if (this._onBeforePhysicsObserver) {
  40829. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  40830. this._onBeforePhysicsObserver = null;
  40831. }
  40832. if (this._onAfterPhysicsObserver) {
  40833. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  40834. this._onAfterPhysicsObserver = null;
  40835. }
  40836. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  40837. this._onAfterAnimationsObserver = null;
  40838. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40839. this._onBeforeCameraRenderObserver = null;
  40840. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  40841. this._onAfterCameraRenderObserver = null;
  40842. this.scene = null;
  40843. };
  40844. return SceneInstrumentation;
  40845. }());
  40846. /***/ }),
  40847. /***/ "./Instrumentation/timeToken.ts":
  40848. /*!**************************************!*\
  40849. !*** ./Instrumentation/timeToken.ts ***!
  40850. \**************************************/
  40851. /*! exports provided: _TimeToken */
  40852. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40853. "use strict";
  40854. __webpack_require__.r(__webpack_exports__);
  40855. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _TimeToken; });
  40856. /**
  40857. * @hidden
  40858. **/
  40859. var _TimeToken = /** @class */ (function () {
  40860. function _TimeToken() {
  40861. this._timeElapsedQueryEnded = false;
  40862. }
  40863. return _TimeToken;
  40864. }());
  40865. /***/ }),
  40866. /***/ "./Layers/effectLayer.ts":
  40867. /*!*******************************!*\
  40868. !*** ./Layers/effectLayer.ts ***!
  40869. \*******************************/
  40870. /*! exports provided: EffectLayer */
  40871. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40872. "use strict";
  40873. __webpack_require__.r(__webpack_exports__);
  40874. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return EffectLayer; });
  40875. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40876. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  40877. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40878. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40879. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40880. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  40881. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  40882. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40883. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  40884. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  40885. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  40886. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  40887. /* harmony import */ var _Shaders_glowMapGeneration_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.fragment */ "./Shaders/glowMapGeneration.fragment.ts");
  40888. /* harmony import */ var _Shaders_glowMapGeneration_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.vertex */ "./Shaders/glowMapGeneration.vertex.ts");
  40889. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  40890. /**
  40891. * The effect layer Helps adding post process effect blended with the main pass.
  40892. *
  40893. * This can be for instance use to generate glow or higlight effects on the scene.
  40894. *
  40895. * The effect layer class can not be used directly and is intented to inherited from to be
  40896. * customized per effects.
  40897. */
  40898. var EffectLayer = /** @class */ (function () {
  40899. /**
  40900. * Instantiates a new effect Layer and references it in the scene.
  40901. * @param name The name of the layer
  40902. * @param scene The scene to use the layer in
  40903. */
  40904. function EffectLayer(
  40905. /** The Friendly of the effect in the scene */
  40906. name, scene) {
  40907. this._vertexBuffers = {};
  40908. this._maxSize = 0;
  40909. this._mainTextureDesiredSize = { width: 0, height: 0 };
  40910. this._shouldRender = true;
  40911. this._postProcesses = [];
  40912. this._textures = [];
  40913. this._emissiveTextureAndColor = { texture: null, color: new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]() };
  40914. /**
  40915. * The clear color of the texture used to generate the glow map.
  40916. */
  40917. this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]();
  40918. /**
  40919. * Specifies wether the highlight layer is enabled or not.
  40920. */
  40921. this.isEnabled = true;
  40922. /**
  40923. * An event triggered when the effect layer has been disposed.
  40924. */
  40925. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40926. /**
  40927. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  40928. */
  40929. this.onBeforeRenderMainTextureObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40930. /**
  40931. * An event triggered when the generated texture is being merged in the scene.
  40932. */
  40933. this.onBeforeComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40934. /**
  40935. * An event triggered when the generated texture has been merged in the scene.
  40936. */
  40937. this.onAfterComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40938. /**
  40939. * An event triggered when the efffect layer changes its size.
  40940. */
  40941. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40942. this.name = name;
  40943. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  40944. EffectLayer._SceneComponentInitialization(this._scene);
  40945. this._engine = this._scene.getEngine();
  40946. this._maxSize = this._engine.getCaps().maxTextureSize;
  40947. this._scene.effectLayers.push(this);
  40948. // Generate Buffers
  40949. this._generateIndexBuffer();
  40950. this._genrateVertexBuffer();
  40951. }
  40952. Object.defineProperty(EffectLayer.prototype, "camera", {
  40953. /**
  40954. * Gets the camera attached to the layer.
  40955. */
  40956. get: function () {
  40957. return this._effectLayerOptions.camera;
  40958. },
  40959. enumerable: true,
  40960. configurable: true
  40961. });
  40962. Object.defineProperty(EffectLayer.prototype, "renderingGroupId", {
  40963. /**
  40964. * Gets the rendering group id the layer should render in.
  40965. */
  40966. get: function () {
  40967. return this._effectLayerOptions.renderingGroupId;
  40968. },
  40969. enumerable: true,
  40970. configurable: true
  40971. });
  40972. /**
  40973. * Initializes the effect layer with the required options.
  40974. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  40975. */
  40976. EffectLayer.prototype._init = function (options) {
  40977. // Adapt options
  40978. 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);
  40979. this._setMainTextureSize();
  40980. this._createMainTexture();
  40981. this._createTextureAndPostProcesses();
  40982. this._mergeEffect = this._createMergeEffect();
  40983. };
  40984. /**
  40985. * Generates the index buffer of the full screen quad blending to the main canvas.
  40986. */
  40987. EffectLayer.prototype._generateIndexBuffer = function () {
  40988. // Indices
  40989. var indices = [];
  40990. indices.push(0);
  40991. indices.push(1);
  40992. indices.push(2);
  40993. indices.push(0);
  40994. indices.push(2);
  40995. indices.push(3);
  40996. this._indexBuffer = this._engine.createIndexBuffer(indices);
  40997. };
  40998. /**
  40999. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  41000. */
  41001. EffectLayer.prototype._genrateVertexBuffer = function () {
  41002. // VBO
  41003. var vertices = [];
  41004. vertices.push(1, 1);
  41005. vertices.push(-1, 1);
  41006. vertices.push(-1, -1);
  41007. vertices.push(1, -1);
  41008. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"](this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind, false, false, 2);
  41009. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = vertexBuffer;
  41010. };
  41011. /**
  41012. * Sets the main texture desired size which is the closest power of two
  41013. * of the engine canvas size.
  41014. */
  41015. EffectLayer.prototype._setMainTextureSize = function () {
  41016. if (this._effectLayerOptions.mainTextureFixedSize) {
  41017. this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize;
  41018. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize;
  41019. }
  41020. else {
  41021. this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio;
  41022. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio;
  41023. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width;
  41024. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height;
  41025. }
  41026. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width);
  41027. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
  41028. };
  41029. /**
  41030. * Creates the main texture for the effect layer.
  41031. */
  41032. EffectLayer.prototype._createMainTexture = function () {
  41033. var _this = this;
  41034. this._mainTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerMainRTT", {
  41035. width: this._mainTextureDesiredSize.width,
  41036. height: this._mainTextureDesiredSize.height
  41037. }, this._scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  41038. this._mainTexture.activeCamera = this._effectLayerOptions.camera;
  41039. this._mainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41040. this._mainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41041. this._mainTexture.anisotropicFilteringLevel = 1;
  41042. this._mainTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE);
  41043. this._mainTexture.renderParticles = false;
  41044. this._mainTexture.renderList = null;
  41045. this._mainTexture.ignoreCameraViewport = true;
  41046. // Custom render function
  41047. this._mainTexture.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  41048. _this.onBeforeRenderMainTextureObservable.notifyObservers(_this);
  41049. var index;
  41050. var engine = _this._scene.getEngine();
  41051. if (depthOnlySubMeshes.length) {
  41052. engine.setColorWrite(false);
  41053. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  41054. _this._renderSubMesh(depthOnlySubMeshes.data[index]);
  41055. }
  41056. engine.setColorWrite(true);
  41057. }
  41058. for (index = 0; index < opaqueSubMeshes.length; index++) {
  41059. _this._renderSubMesh(opaqueSubMeshes.data[index]);
  41060. }
  41061. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  41062. _this._renderSubMesh(alphaTestSubMeshes.data[index]);
  41063. }
  41064. for (index = 0; index < transparentSubMeshes.length; index++) {
  41065. _this._renderSubMesh(transparentSubMeshes.data[index]);
  41066. }
  41067. };
  41068. this._mainTexture.onClearObservable.add(function (engine) {
  41069. engine.clear(_this.neutralColor, true, true, true);
  41070. });
  41071. };
  41072. /**
  41073. * Adds specific effects defines.
  41074. * @param defines The defines to add specifics to.
  41075. */
  41076. EffectLayer.prototype._addCustomEffectDefines = function (defines) {
  41077. // Nothing to add by default.
  41078. };
  41079. /**
  41080. * Checks for the readiness of the element composing the layer.
  41081. * @param subMesh the mesh to check for
  41082. * @param useInstances specify wether or not to use instances to render the mesh
  41083. * @param emissiveTexture the associated emissive texture used to generate the glow
  41084. * @return true if ready otherwise, false
  41085. */
  41086. EffectLayer.prototype._isReady = function (subMesh, useInstances, emissiveTexture) {
  41087. var material = subMesh.getMaterial();
  41088. if (!material) {
  41089. return false;
  41090. }
  41091. if (!material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances)) {
  41092. return false;
  41093. }
  41094. var defines = [];
  41095. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41096. var mesh = subMesh.getMesh();
  41097. var uv1 = false;
  41098. var uv2 = false;
  41099. // Diffuse
  41100. if (material) {
  41101. var needAlphaTest = material.needAlphaTesting();
  41102. var diffuseTexture = material.getAlphaTestTexture();
  41103. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  41104. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  41105. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  41106. defines.push("#define DIFFUSE");
  41107. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41108. diffuseTexture.coordinatesIndex === 1) {
  41109. defines.push("#define DIFFUSEUV2");
  41110. uv2 = true;
  41111. }
  41112. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41113. defines.push("#define DIFFUSEUV1");
  41114. uv1 = true;
  41115. }
  41116. if (needAlphaTest) {
  41117. defines.push("#define ALPHATEST");
  41118. defines.push("#define ALPHATESTVALUE 0.4");
  41119. }
  41120. }
  41121. var opacityTexture = material.opacityTexture;
  41122. if (opacityTexture) {
  41123. defines.push("#define OPACITY");
  41124. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41125. opacityTexture.coordinatesIndex === 1) {
  41126. defines.push("#define OPACITYUV2");
  41127. uv2 = true;
  41128. }
  41129. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41130. defines.push("#define OPACITYUV1");
  41131. uv1 = true;
  41132. }
  41133. }
  41134. }
  41135. // Emissive
  41136. if (emissiveTexture) {
  41137. defines.push("#define EMISSIVE");
  41138. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41139. emissiveTexture.coordinatesIndex === 1) {
  41140. defines.push("#define EMISSIVEUV2");
  41141. uv2 = true;
  41142. }
  41143. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41144. defines.push("#define EMISSIVEUV1");
  41145. uv1 = true;
  41146. }
  41147. }
  41148. // Vertex
  41149. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind) && mesh.hasVertexAlpha) {
  41150. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind);
  41151. defines.push("#define VERTEXALPHA");
  41152. }
  41153. if (uv1) {
  41154. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind);
  41155. defines.push("#define UV1");
  41156. }
  41157. if (uv2) {
  41158. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind);
  41159. defines.push("#define UV2");
  41160. }
  41161. // Bones
  41162. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  41163. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesKind);
  41164. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsKind);
  41165. if (mesh.numBoneInfluencers > 4) {
  41166. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesExtraKind);
  41167. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsExtraKind);
  41168. }
  41169. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  41170. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  41171. }
  41172. else {
  41173. defines.push("#define NUM_BONE_INFLUENCERS 0");
  41174. }
  41175. // Morph targets
  41176. var manager = mesh.morphTargetManager;
  41177. var morphInfluencers = 0;
  41178. if (manager) {
  41179. if (manager.numInfluencers > 0) {
  41180. defines.push("#define MORPHTARGETS");
  41181. morphInfluencers = manager.numInfluencers;
  41182. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  41183. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  41184. }
  41185. }
  41186. // Instances
  41187. if (useInstances) {
  41188. defines.push("#define INSTANCES");
  41189. attribs.push("world0");
  41190. attribs.push("world1");
  41191. attribs.push("world2");
  41192. attribs.push("world3");
  41193. }
  41194. this._addCustomEffectDefines(defines);
  41195. // Get correct effect
  41196. var join = defines.join("\n");
  41197. if (this._cachedDefines !== join) {
  41198. this._cachedDefines = join;
  41199. this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", attribs, ["world", "mBones", "viewProjection",
  41200. "color", "morphTargetInfluences",
  41201. "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  41202. }
  41203. return this._effectLayerMapGenerationEffect.isReady();
  41204. };
  41205. /**
  41206. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  41207. */
  41208. EffectLayer.prototype.render = function () {
  41209. var currentEffect = this._mergeEffect;
  41210. // Check
  41211. if (!currentEffect.isReady()) {
  41212. return;
  41213. }
  41214. for (var i = 0; i < this._postProcesses.length; i++) {
  41215. if (!this._postProcesses[i].isReady()) {
  41216. return;
  41217. }
  41218. }
  41219. var engine = this._scene.getEngine();
  41220. this.onBeforeComposeObservable.notifyObservers(this);
  41221. // Render
  41222. engine.enableEffect(currentEffect);
  41223. engine.setState(false);
  41224. // VBOs
  41225. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  41226. // Cache
  41227. var previousAlphaMode = engine.getAlphaMode();
  41228. // Go Blend.
  41229. engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
  41230. // Blends the map on the main canvas.
  41231. this._internalRender(currentEffect);
  41232. // Restore Alpha
  41233. engine.setAlphaMode(previousAlphaMode);
  41234. this.onAfterComposeObservable.notifyObservers(this);
  41235. // Handle size changes.
  41236. var size = this._mainTexture.getSize();
  41237. this._setMainTextureSize();
  41238. if (size.width !== this._mainTextureDesiredSize.width || size.height !== this._mainTextureDesiredSize.height) {
  41239. // Recreate RTT and post processes on size change.
  41240. this.onSizeChangedObservable.notifyObservers(this);
  41241. this._disposeTextureAndPostProcesses();
  41242. this._createMainTexture();
  41243. this._createTextureAndPostProcesses();
  41244. }
  41245. };
  41246. /**
  41247. * Determine if a given mesh will be used in the current effect.
  41248. * @param mesh mesh to test
  41249. * @returns true if the mesh will be used
  41250. */
  41251. EffectLayer.prototype.hasMesh = function (mesh) {
  41252. if (this.renderingGroupId === -1 || mesh.renderingGroupId === this.renderingGroupId) {
  41253. return true;
  41254. }
  41255. return false;
  41256. };
  41257. /**
  41258. * Returns true if the layer contains information to display, otherwise false.
  41259. * @returns true if the glow layer should be rendered
  41260. */
  41261. EffectLayer.prototype.shouldRender = function () {
  41262. return this.isEnabled && this._shouldRender;
  41263. };
  41264. /**
  41265. * Returns true if the mesh should render, otherwise false.
  41266. * @param mesh The mesh to render
  41267. * @returns true if it should render otherwise false
  41268. */
  41269. EffectLayer.prototype._shouldRenderMesh = function (mesh) {
  41270. return true;
  41271. };
  41272. /**
  41273. * Returns true if the mesh can be rendered, otherwise false.
  41274. * @param mesh The mesh to render
  41275. * @param material The material used on the mesh
  41276. * @returns true if it can be rendered otherwise false
  41277. */
  41278. EffectLayer.prototype._canRenderMesh = function (mesh, material) {
  41279. return !material.needAlphaBlendingForMesh(mesh);
  41280. };
  41281. /**
  41282. * Returns true if the mesh should render, otherwise false.
  41283. * @param mesh The mesh to render
  41284. * @returns true if it should render otherwise false
  41285. */
  41286. EffectLayer.prototype._shouldRenderEmissiveTextureForMesh = function () {
  41287. return true;
  41288. };
  41289. /**
  41290. * Renders the submesh passed in parameter to the generation map.
  41291. */
  41292. EffectLayer.prototype._renderSubMesh = function (subMesh) {
  41293. var _this = this;
  41294. if (!this.shouldRender()) {
  41295. return;
  41296. }
  41297. var material = subMesh.getMaterial();
  41298. var mesh = subMesh.getRenderingMesh();
  41299. var scene = this._scene;
  41300. var engine = scene.getEngine();
  41301. if (!material) {
  41302. return;
  41303. }
  41304. // Do not block in blend mode.
  41305. if (!this._canRenderMesh(mesh, material)) {
  41306. return;
  41307. }
  41308. // Culling
  41309. engine.setState(material.backFaceCulling);
  41310. // Managing instances
  41311. var batch = mesh._getInstancesRenderList(subMesh._id);
  41312. if (batch.mustReturn) {
  41313. return;
  41314. }
  41315. // Early Exit per mesh
  41316. if (!this._shouldRenderMesh(mesh)) {
  41317. return;
  41318. }
  41319. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  41320. this._setEmissiveTextureAndColor(mesh, subMesh, material);
  41321. if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
  41322. engine.enableEffect(this._effectLayerMapGenerationEffect);
  41323. mesh._bind(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode);
  41324. this._effectLayerMapGenerationEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  41325. this._effectLayerMapGenerationEffect.setFloat4("color", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
  41326. var needAlphaTest = material.needAlphaTesting();
  41327. var diffuseTexture = material.getAlphaTestTexture();
  41328. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  41329. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  41330. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  41331. this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", diffuseTexture);
  41332. var textureMatrix = diffuseTexture.getTextureMatrix();
  41333. if (textureMatrix) {
  41334. this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", textureMatrix);
  41335. }
  41336. }
  41337. var opacityTexture = material.opacityTexture;
  41338. if (opacityTexture) {
  41339. this._effectLayerMapGenerationEffect.setTexture("opacitySampler", opacityTexture);
  41340. this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", opacityTexture.level);
  41341. var textureMatrix = opacityTexture.getTextureMatrix();
  41342. if (textureMatrix) {
  41343. this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", textureMatrix);
  41344. }
  41345. }
  41346. // Glow emissive only
  41347. if (this._emissiveTextureAndColor.texture) {
  41348. this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
  41349. this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
  41350. }
  41351. // Bones
  41352. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  41353. this._effectLayerMapGenerationEffect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  41354. }
  41355. // Morph targets
  41356. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effectLayerMapGenerationEffect);
  41357. // Draw
  41358. mesh._processRendering(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effectLayerMapGenerationEffect.setMatrix("world", world); });
  41359. }
  41360. else {
  41361. // Need to reset refresh rate of the main map
  41362. this._mainTexture.resetRefreshCounter();
  41363. }
  41364. };
  41365. /**
  41366. * Rebuild the required buffers.
  41367. * @hidden Internal use only.
  41368. */
  41369. EffectLayer.prototype._rebuild = function () {
  41370. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41371. if (vb) {
  41372. vb._rebuild();
  41373. }
  41374. this._generateIndexBuffer();
  41375. };
  41376. /**
  41377. * Dispose only the render target textures and post process.
  41378. */
  41379. EffectLayer.prototype._disposeTextureAndPostProcesses = function () {
  41380. this._mainTexture.dispose();
  41381. for (var i = 0; i < this._postProcesses.length; i++) {
  41382. if (this._postProcesses[i]) {
  41383. this._postProcesses[i].dispose();
  41384. }
  41385. }
  41386. this._postProcesses = [];
  41387. for (var i = 0; i < this._textures.length; i++) {
  41388. if (this._textures[i]) {
  41389. this._textures[i].dispose();
  41390. }
  41391. }
  41392. this._textures = [];
  41393. };
  41394. /**
  41395. * Dispose the highlight layer and free resources.
  41396. */
  41397. EffectLayer.prototype.dispose = function () {
  41398. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41399. if (vertexBuffer) {
  41400. vertexBuffer.dispose();
  41401. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = null;
  41402. }
  41403. if (this._indexBuffer) {
  41404. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  41405. this._indexBuffer = null;
  41406. }
  41407. // Clean textures and post processes
  41408. this._disposeTextureAndPostProcesses();
  41409. // Remove from scene
  41410. var index = this._scene.effectLayers.indexOf(this, 0);
  41411. if (index > -1) {
  41412. this._scene.effectLayers.splice(index, 1);
  41413. }
  41414. // Callback
  41415. this.onDisposeObservable.notifyObservers(this);
  41416. this.onDisposeObservable.clear();
  41417. this.onBeforeRenderMainTextureObservable.clear();
  41418. this.onBeforeComposeObservable.clear();
  41419. this.onAfterComposeObservable.clear();
  41420. this.onSizeChangedObservable.clear();
  41421. };
  41422. /**
  41423. * Gets the class name of the effect layer
  41424. * @returns the string with the class name of the effect layer
  41425. */
  41426. EffectLayer.prototype.getClassName = function () {
  41427. return "EffectLayer";
  41428. };
  41429. /**
  41430. * Creates an effect layer from parsed effect layer data
  41431. * @param parsedEffectLayer defines effect layer data
  41432. * @param scene defines the current scene
  41433. * @param rootUrl defines the root URL containing the effect layer information
  41434. * @returns a parsed effect Layer
  41435. */
  41436. EffectLayer.Parse = function (parsedEffectLayer, scene, rootUrl) {
  41437. var effectLayerType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedEffectLayer.customType);
  41438. return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
  41439. };
  41440. /** @hidden */
  41441. EffectLayer._SceneComponentInitialization = function (_) {
  41442. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__["_DevTools"].WarnImport("EffectLayerSceneComponent");
  41443. };
  41444. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41445. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41446. ], EffectLayer.prototype, "name", void 0);
  41447. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41448. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  41449. ], EffectLayer.prototype, "neutralColor", void 0);
  41450. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41451. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41452. ], EffectLayer.prototype, "isEnabled", void 0);
  41453. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41454. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsCameraReference"])()
  41455. ], EffectLayer.prototype, "camera", null);
  41456. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41457. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41458. ], EffectLayer.prototype, "renderingGroupId", null);
  41459. return EffectLayer;
  41460. }());
  41461. /***/ }),
  41462. /***/ "./Layers/effectLayerSceneComponent.ts":
  41463. /*!*********************************************!*\
  41464. !*** ./Layers/effectLayerSceneComponent.ts ***!
  41465. \*********************************************/
  41466. /*! exports provided: EffectLayerSceneComponent */
  41467. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41468. "use strict";
  41469. __webpack_require__.r(__webpack_exports__);
  41470. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return EffectLayerSceneComponent; });
  41471. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  41472. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  41473. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  41474. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  41475. // Adds the parser to the scene parsers.
  41476. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER, function (parsedData, scene, container, rootUrl) {
  41477. if (parsedData.effectLayers) {
  41478. if (!container.effectLayers) {
  41479. container.effectLayers = new Array();
  41480. }
  41481. for (var index = 0; index < parsedData.effectLayers.length; index++) {
  41482. var effectLayer = _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"].Parse(parsedData.effectLayers[index], scene, rootUrl);
  41483. container.effectLayers.push(effectLayer);
  41484. }
  41485. }
  41486. });
  41487. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.removeEffectLayer = function (toRemove) {
  41488. var index = this.effectLayers.indexOf(toRemove);
  41489. if (index !== -1) {
  41490. this.effectLayers.splice(index, 1);
  41491. }
  41492. return index;
  41493. };
  41494. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.addEffectLayer = function (newEffectLayer) {
  41495. this.effectLayers.push(newEffectLayer);
  41496. };
  41497. /**
  41498. * Defines the layer scene component responsible to manage any effect layers
  41499. * in a given scene.
  41500. */
  41501. var EffectLayerSceneComponent = /** @class */ (function () {
  41502. /**
  41503. * Creates a new instance of the component for the given scene
  41504. * @param scene Defines the scene to register the component in
  41505. */
  41506. function EffectLayerSceneComponent(scene) {
  41507. /**
  41508. * The component name helpfull to identify the component in the list of scene components.
  41509. */
  41510. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER;
  41511. this._renderEffects = false;
  41512. this._needStencil = false;
  41513. this._previousStencilState = false;
  41514. this.scene = scene;
  41515. this._engine = scene.getEngine();
  41516. scene.effectLayers = new Array();
  41517. }
  41518. /**
  41519. * Registers the component in a given scene
  41520. */
  41521. EffectLayerSceneComponent.prototype.register = function () {
  41522. this.scene._isReadyForMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh);
  41523. this.scene._cameraDrawRenderTargetStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture);
  41524. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil);
  41525. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup);
  41526. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack);
  41527. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
  41528. };
  41529. /**
  41530. * Rebuilds the elements related to this component in case of
  41531. * context lost for instance.
  41532. */
  41533. EffectLayerSceneComponent.prototype.rebuild = function () {
  41534. var layers = this.scene.effectLayers;
  41535. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  41536. var effectLayer = layers_1[_i];
  41537. effectLayer._rebuild();
  41538. }
  41539. };
  41540. /**
  41541. * Serializes the component data to the specified json object
  41542. * @param serializationObject The object to serialize to
  41543. */
  41544. EffectLayerSceneComponent.prototype.serialize = function (serializationObject) {
  41545. // Effect layers
  41546. serializationObject.effectLayers = [];
  41547. var layers = this.scene.effectLayers;
  41548. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  41549. var effectLayer = layers_2[_i];
  41550. if (effectLayer.serialize) {
  41551. serializationObject.effectLayers.push(effectLayer.serialize());
  41552. }
  41553. }
  41554. };
  41555. /**
  41556. * Adds all the element from the container to the scene
  41557. * @param container the container holding the elements
  41558. */
  41559. EffectLayerSceneComponent.prototype.addFromContainer = function (container) {
  41560. var _this = this;
  41561. if (!container.effectLayers) {
  41562. return;
  41563. }
  41564. container.effectLayers.forEach(function (o) {
  41565. _this.scene.addEffectLayer(o);
  41566. });
  41567. };
  41568. /**
  41569. * Removes all the elements in the container from the scene
  41570. * @param container contains the elements to remove
  41571. */
  41572. EffectLayerSceneComponent.prototype.removeFromContainer = function (container) {
  41573. var _this = this;
  41574. if (!container.effectLayers) {
  41575. return;
  41576. }
  41577. container.effectLayers.forEach(function (o) {
  41578. _this.scene.removeEffectLayer(o);
  41579. });
  41580. };
  41581. /**
  41582. * Disposes the component and the associated ressources.
  41583. */
  41584. EffectLayerSceneComponent.prototype.dispose = function () {
  41585. var layers = this.scene.effectLayers;
  41586. while (layers.length) {
  41587. layers[0].dispose();
  41588. }
  41589. };
  41590. EffectLayerSceneComponent.prototype._isReadyForMesh = function (mesh, hardwareInstancedRendering) {
  41591. var layers = this.scene.effectLayers;
  41592. for (var _i = 0, layers_3 = layers; _i < layers_3.length; _i++) {
  41593. var layer = layers_3[_i];
  41594. if (!layer.hasMesh(mesh)) {
  41595. continue;
  41596. }
  41597. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  41598. var subMesh = _b[_a];
  41599. if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
  41600. return false;
  41601. }
  41602. }
  41603. }
  41604. return true;
  41605. };
  41606. EffectLayerSceneComponent.prototype._renderMainTexture = function (camera) {
  41607. this._renderEffects = false;
  41608. this._needStencil = false;
  41609. var layers = this.scene.effectLayers;
  41610. if (layers && layers.length > 0) {
  41611. this._previousStencilState = this._engine.getStencilBuffer();
  41612. for (var _i = 0, layers_4 = layers; _i < layers_4.length; _i++) {
  41613. var effectLayer = layers_4[_i];
  41614. if (effectLayer.shouldRender() &&
  41615. (!effectLayer.camera ||
  41616. (effectLayer.camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && camera === effectLayer.camera) ||
  41617. (effectLayer.camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
  41618. this._renderEffects = true;
  41619. this._needStencil = this._needStencil || effectLayer.needStencil();
  41620. var renderTarget = effectLayer._mainTexture;
  41621. if (renderTarget._shouldRender()) {
  41622. this.scene.incrementRenderId();
  41623. renderTarget.render(false, false);
  41624. }
  41625. }
  41626. }
  41627. this.scene.incrementRenderId();
  41628. }
  41629. };
  41630. EffectLayerSceneComponent.prototype._setStencil = function () {
  41631. // Activate effect Layer stencil
  41632. if (this._needStencil) {
  41633. this._engine.setStencilBuffer(true);
  41634. }
  41635. };
  41636. EffectLayerSceneComponent.prototype._setStencilBack = function () {
  41637. // Restore effect Layer stencil
  41638. if (this._needStencil) {
  41639. this._engine.setStencilBuffer(this._previousStencilState);
  41640. }
  41641. };
  41642. EffectLayerSceneComponent.prototype._draw = function (renderingGroupId) {
  41643. if (this._renderEffects) {
  41644. this._engine.setDepthBuffer(false);
  41645. var layers = this.scene.effectLayers;
  41646. for (var i = 0; i < layers.length; i++) {
  41647. var effectLayer = layers[i];
  41648. if (effectLayer.renderingGroupId === renderingGroupId) {
  41649. if (effectLayer.shouldRender()) {
  41650. effectLayer.render();
  41651. }
  41652. }
  41653. }
  41654. this._engine.setDepthBuffer(true);
  41655. }
  41656. };
  41657. EffectLayerSceneComponent.prototype._drawCamera = function () {
  41658. if (this._renderEffects) {
  41659. this._draw(-1);
  41660. }
  41661. };
  41662. EffectLayerSceneComponent.prototype._drawRenderingGroup = function (index) {
  41663. if (!this.scene._isInIntermediateRendering() && this._renderEffects) {
  41664. this._draw(index);
  41665. }
  41666. };
  41667. return EffectLayerSceneComponent;
  41668. }());
  41669. _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"]._SceneComponentInitialization = function (scene) {
  41670. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER);
  41671. if (!component) {
  41672. component = new EffectLayerSceneComponent(scene);
  41673. scene._addComponent(component);
  41674. }
  41675. };
  41676. /***/ }),
  41677. /***/ "./Layers/glowLayer.ts":
  41678. /*!*****************************!*\
  41679. !*** ./Layers/glowLayer.ts ***!
  41680. \*****************************/
  41681. /*! exports provided: GlowLayer */
  41682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41683. "use strict";
  41684. __webpack_require__.r(__webpack_exports__);
  41685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return GlowLayer; });
  41686. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41687. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  41688. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41689. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41690. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  41691. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41692. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  41693. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  41694. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  41695. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  41696. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  41697. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  41698. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  41699. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  41700. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  41701. _abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"].prototype.getGlowLayerByName = function (name) {
  41702. for (var index = 0; index < this.effectLayers.length; index++) {
  41703. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
  41704. return this.effectLayers[index];
  41705. }
  41706. }
  41707. return null;
  41708. };
  41709. /**
  41710. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  41711. *
  41712. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  41713. * glowy meshes to your scene.
  41714. *
  41715. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  41716. */
  41717. var GlowLayer = /** @class */ (function (_super) {
  41718. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowLayer, _super);
  41719. /**
  41720. * Instantiates a new glow Layer and references it to the scene.
  41721. * @param name The name of the layer
  41722. * @param scene The scene to use the layer in
  41723. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  41724. */
  41725. function GlowLayer(name, scene, options) {
  41726. var _this = _super.call(this, name, scene) || this;
  41727. _this._intensity = 1.0;
  41728. _this._includedOnlyMeshes = [];
  41729. _this._excludedMeshes = [];
  41730. _this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 1);
  41731. // Adapt options
  41732. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: GlowLayer.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: undefined, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, options);
  41733. // Initialize the layer
  41734. _this._init({
  41735. alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_ADD,
  41736. camera: _this._options.camera,
  41737. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  41738. mainTextureRatio: _this._options.mainTextureRatio,
  41739. renderingGroupId: _this._options.renderingGroupId
  41740. });
  41741. return _this;
  41742. }
  41743. Object.defineProperty(GlowLayer.prototype, "blurKernelSize", {
  41744. /**
  41745. * Gets the kernel size of the blur.
  41746. */
  41747. get: function () {
  41748. return this._horizontalBlurPostprocess1.kernel;
  41749. },
  41750. /**
  41751. * Sets the kernel size of the blur.
  41752. */
  41753. set: function (value) {
  41754. this._horizontalBlurPostprocess1.kernel = value;
  41755. this._verticalBlurPostprocess1.kernel = value;
  41756. this._horizontalBlurPostprocess2.kernel = value;
  41757. this._verticalBlurPostprocess2.kernel = value;
  41758. },
  41759. enumerable: true,
  41760. configurable: true
  41761. });
  41762. Object.defineProperty(GlowLayer.prototype, "intensity", {
  41763. /**
  41764. * Gets the glow intensity.
  41765. */
  41766. get: function () {
  41767. return this._intensity;
  41768. },
  41769. /**
  41770. * Sets the glow intensity.
  41771. */
  41772. set: function (value) {
  41773. this._intensity = value;
  41774. },
  41775. enumerable: true,
  41776. configurable: true
  41777. });
  41778. /**
  41779. * Get the effect name of the layer.
  41780. * @return The effect name
  41781. */
  41782. GlowLayer.prototype.getEffectName = function () {
  41783. return GlowLayer.EffectName;
  41784. };
  41785. /**
  41786. * Create the merge effect. This is the shader use to blit the information back
  41787. * to the main canvas at the end of the scene rendering.
  41788. */
  41789. GlowLayer.prototype._createMergeEffect = function () {
  41790. // Effect
  41791. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler", "textureSampler2"], "#define EMISSIVE \n");
  41792. };
  41793. /**
  41794. * Creates the render target textures and post processes used in the glow layer.
  41795. */
  41796. GlowLayer.prototype._createTextureAndPostProcesses = function () {
  41797. var _this = this;
  41798. var blurTextureWidth = this._mainTextureDesiredSize.width;
  41799. var blurTextureHeight = this._mainTextureDesiredSize.height;
  41800. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  41801. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  41802. var textureType = 0;
  41803. if (this._engine.getCaps().textureHalfFloatRender) {
  41804. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_HALF_FLOAT;
  41805. }
  41806. else {
  41807. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  41808. }
  41809. this._blurTexture1 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT", {
  41810. width: blurTextureWidth,
  41811. height: blurTextureHeight
  41812. }, this._scene, false, true, textureType);
  41813. this._blurTexture1.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41814. this._blurTexture1.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41815. this._blurTexture1.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  41816. this._blurTexture1.renderParticles = false;
  41817. this._blurTexture1.ignoreCameraViewport = true;
  41818. var blurTextureWidth2 = Math.floor(blurTextureWidth / 2);
  41819. var blurTextureHeight2 = Math.floor(blurTextureHeight / 2);
  41820. this._blurTexture2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT2", {
  41821. width: blurTextureWidth2,
  41822. height: blurTextureHeight2
  41823. }, this._scene, false, true, textureType);
  41824. this._blurTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41825. this._blurTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41826. this._blurTexture2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  41827. this._blurTexture2.renderParticles = false;
  41828. this._blurTexture2.ignoreCameraViewport = true;
  41829. this._textures = [this._blurTexture1, this._blurTexture2];
  41830. 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, {
  41831. width: blurTextureWidth,
  41832. height: blurTextureHeight
  41833. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41834. this._horizontalBlurPostprocess1.width = blurTextureWidth;
  41835. this._horizontalBlurPostprocess1.height = blurTextureHeight;
  41836. this._horizontalBlurPostprocess1.onApplyObservable.add(function (effect) {
  41837. effect.setTexture("textureSampler", _this._mainTexture);
  41838. });
  41839. 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, {
  41840. width: blurTextureWidth,
  41841. height: blurTextureHeight
  41842. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41843. 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, {
  41844. width: blurTextureWidth2,
  41845. height: blurTextureHeight2
  41846. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41847. this._horizontalBlurPostprocess2.width = blurTextureWidth2;
  41848. this._horizontalBlurPostprocess2.height = blurTextureHeight2;
  41849. this._horizontalBlurPostprocess2.onApplyObservable.add(function (effect) {
  41850. effect.setTexture("textureSampler", _this._blurTexture1);
  41851. });
  41852. 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, {
  41853. width: blurTextureWidth2,
  41854. height: blurTextureHeight2
  41855. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41856. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  41857. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
  41858. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  41859. this._mainTexture.samples = this._options.mainTextureSamples;
  41860. this._mainTexture.onAfterUnbindObservable.add(function () {
  41861. var internalTexture = _this._blurTexture1.getInternalTexture();
  41862. if (internalTexture) {
  41863. _this._scene.postProcessManager.directRender(_this._postProcesses1, internalTexture, true);
  41864. internalTexture = _this._blurTexture2.getInternalTexture();
  41865. if (internalTexture) {
  41866. _this._scene.postProcessManager.directRender(_this._postProcesses2, internalTexture, true);
  41867. }
  41868. }
  41869. });
  41870. // Prevent autoClear.
  41871. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  41872. };
  41873. /**
  41874. * Checks for the readiness of the element composing the layer.
  41875. * @param subMesh the mesh to check for
  41876. * @param useInstances specify wether or not to use instances to render the mesh
  41877. * @param emissiveTexture the associated emissive texture used to generate the glow
  41878. * @return true if ready otherwise, false
  41879. */
  41880. GlowLayer.prototype.isReady = function (subMesh, useInstances) {
  41881. var material = subMesh.getMaterial();
  41882. var mesh = subMesh.getRenderingMesh();
  41883. if (!material || !mesh) {
  41884. return false;
  41885. }
  41886. var emissiveTexture = material.emissiveTexture;
  41887. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  41888. };
  41889. /**
  41890. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  41891. */
  41892. GlowLayer.prototype.needStencil = function () {
  41893. return false;
  41894. };
  41895. /**
  41896. * Returns true if the mesh can be rendered, otherwise false.
  41897. * @param mesh The mesh to render
  41898. * @param material The material used on the mesh
  41899. * @returns true if it can be rendered otherwise false
  41900. */
  41901. GlowLayer.prototype._canRenderMesh = function (mesh, material) {
  41902. return true;
  41903. };
  41904. /**
  41905. * Implementation specific of rendering the generating effect on the main canvas.
  41906. * @param effect The effect used to render through
  41907. */
  41908. GlowLayer.prototype._internalRender = function (effect) {
  41909. // Texture
  41910. effect.setTexture("textureSampler", this._blurTexture1);
  41911. effect.setTexture("textureSampler2", this._blurTexture2);
  41912. effect.setFloat("offset", this._intensity);
  41913. // Cache
  41914. var engine = this._engine;
  41915. var previousStencilBuffer = engine.getStencilBuffer();
  41916. // Draw order
  41917. engine.setStencilBuffer(false);
  41918. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, 6);
  41919. // Draw order
  41920. engine.setStencilBuffer(previousStencilBuffer);
  41921. };
  41922. /**
  41923. * Sets the required values for both the emissive texture and and the main color.
  41924. */
  41925. GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  41926. var textureLevel = 1.0;
  41927. if (this.customEmissiveTextureSelector) {
  41928. this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
  41929. }
  41930. else {
  41931. if (material) {
  41932. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  41933. if (this._emissiveTextureAndColor.texture) {
  41934. textureLevel = this._emissiveTextureAndColor.texture.level;
  41935. }
  41936. }
  41937. else {
  41938. this._emissiveTextureAndColor.texture = null;
  41939. }
  41940. }
  41941. if (this.customEmissiveColorSelector) {
  41942. this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
  41943. }
  41944. else {
  41945. if (material.emissiveColor) {
  41946. this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
  41947. }
  41948. else {
  41949. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  41950. }
  41951. }
  41952. };
  41953. /**
  41954. * Returns true if the mesh should render, otherwise false.
  41955. * @param mesh The mesh to render
  41956. * @returns true if it should render otherwise false
  41957. */
  41958. GlowLayer.prototype._shouldRenderMesh = function (mesh) {
  41959. return this.hasMesh(mesh);
  41960. };
  41961. /**
  41962. * Adds specific effects defines.
  41963. * @param defines The defines to add specifics to.
  41964. */
  41965. GlowLayer.prototype._addCustomEffectDefines = function (defines) {
  41966. defines.push("#define GLOW");
  41967. };
  41968. /**
  41969. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  41970. * @param mesh The mesh to exclude from the glow layer
  41971. */
  41972. GlowLayer.prototype.addExcludedMesh = function (mesh) {
  41973. if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
  41974. this._excludedMeshes.push(mesh.uniqueId);
  41975. }
  41976. };
  41977. /**
  41978. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  41979. * @param mesh The mesh to remove
  41980. */
  41981. GlowLayer.prototype.removeExcludedMesh = function (mesh) {
  41982. var index = this._excludedMeshes.indexOf(mesh.uniqueId);
  41983. if (index !== -1) {
  41984. this._excludedMeshes.splice(index, 1);
  41985. }
  41986. };
  41987. /**
  41988. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  41989. * @param mesh The mesh to include in the glow layer
  41990. */
  41991. GlowLayer.prototype.addIncludedOnlyMesh = function (mesh) {
  41992. if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
  41993. this._includedOnlyMeshes.push(mesh.uniqueId);
  41994. }
  41995. };
  41996. /**
  41997. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  41998. * @param mesh The mesh to remove
  41999. */
  42000. GlowLayer.prototype.removeIncludedOnlyMesh = function (mesh) {
  42001. var index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
  42002. if (index !== -1) {
  42003. this._includedOnlyMeshes.splice(index, 1);
  42004. }
  42005. };
  42006. /**
  42007. * Determine if a given mesh will be used in the glow layer
  42008. * @param mesh The mesh to test
  42009. * @returns true if the mesh will be highlighted by the current glow layer
  42010. */
  42011. GlowLayer.prototype.hasMesh = function (mesh) {
  42012. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42013. return false;
  42014. }
  42015. // Included Mesh
  42016. if (this._includedOnlyMeshes.length) {
  42017. return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
  42018. }
  42019. // Excluded Mesh
  42020. if (this._excludedMeshes.length) {
  42021. return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
  42022. }
  42023. return true;
  42024. };
  42025. /**
  42026. * Free any resources and references associated to a mesh.
  42027. * Internal use
  42028. * @param mesh The mesh to free.
  42029. * @hidden
  42030. */
  42031. GlowLayer.prototype._disposeMesh = function (mesh) {
  42032. this.removeIncludedOnlyMesh(mesh);
  42033. this.removeExcludedMesh(mesh);
  42034. };
  42035. /**
  42036. * Gets the class name of the effect layer
  42037. * @returns the string with the class name of the effect layer
  42038. */
  42039. GlowLayer.prototype.getClassName = function () {
  42040. return "GlowLayer";
  42041. };
  42042. /**
  42043. * Serializes this glow layer
  42044. * @returns a serialized glow layer object
  42045. */
  42046. GlowLayer.prototype.serialize = function () {
  42047. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  42048. serializationObject.customType = "BABYLON.GlowLayer";
  42049. var index;
  42050. // Included meshes
  42051. serializationObject.includedMeshes = [];
  42052. if (this._includedOnlyMeshes.length) {
  42053. for (index = 0; index < this._includedOnlyMeshes.length; index++) {
  42054. var mesh = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[index]);
  42055. if (mesh) {
  42056. serializationObject.includedMeshes.push(mesh.id);
  42057. }
  42058. }
  42059. }
  42060. // Excluded meshes
  42061. serializationObject.excludedMeshes = [];
  42062. if (this._excludedMeshes.length) {
  42063. for (index = 0; index < this._excludedMeshes.length; index++) {
  42064. var mesh = this._scene.getMeshByUniqueID(this._excludedMeshes[index]);
  42065. if (mesh) {
  42066. serializationObject.excludedMeshes.push(mesh.id);
  42067. }
  42068. }
  42069. }
  42070. return serializationObject;
  42071. };
  42072. /**
  42073. * Creates a Glow Layer from parsed glow layer data
  42074. * @param parsedGlowLayer defines glow layer data
  42075. * @param scene defines the current scene
  42076. * @param rootUrl defines the root URL containing the glow layer information
  42077. * @returns a parsed Glow Layer
  42078. */
  42079. GlowLayer.Parse = function (parsedGlowLayer, scene, rootUrl) {
  42080. var gl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GlowLayer(parsedGlowLayer.name, scene, parsedGlowLayer.options); }, parsedGlowLayer, scene, rootUrl);
  42081. var index;
  42082. // Excluded meshes
  42083. for (index = 0; index < parsedGlowLayer.excludedMeshes.length; index++) {
  42084. var mesh = scene.getMeshByID(parsedGlowLayer.excludedMeshes[index]);
  42085. if (mesh) {
  42086. gl.addExcludedMesh(mesh);
  42087. }
  42088. }
  42089. // Included meshes
  42090. for (index = 0; index < parsedGlowLayer.includedMeshes.length; index++) {
  42091. var mesh = scene.getMeshByID(parsedGlowLayer.includedMeshes[index]);
  42092. if (mesh) {
  42093. gl.addIncludedOnlyMesh(mesh);
  42094. }
  42095. }
  42096. return gl;
  42097. };
  42098. /**
  42099. * Effect Name of the layer.
  42100. */
  42101. GlowLayer.EffectName = "GlowLayer";
  42102. /**
  42103. * The default blur kernel size used for the glow.
  42104. */
  42105. GlowLayer.DefaultBlurKernelSize = 32;
  42106. /**
  42107. * The default texture size ratio used for the glow.
  42108. */
  42109. GlowLayer.DefaultTextureRatio = 0.5;
  42110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42112. ], GlowLayer.prototype, "blurKernelSize", null);
  42113. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42114. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42115. ], GlowLayer.prototype, "intensity", null);
  42116. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42117. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  42118. ], GlowLayer.prototype, "_options", void 0);
  42119. return GlowLayer;
  42120. }(_effectLayer__WEBPACK_IMPORTED_MODULE_9__["EffectLayer"]));
  42121. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.GlowLayer"] = GlowLayer;
  42122. /***/ }),
  42123. /***/ "./Layers/highlightLayer.ts":
  42124. /*!**********************************!*\
  42125. !*** ./Layers/highlightLayer.ts ***!
  42126. \**********************************/
  42127. /*! exports provided: HighlightLayer */
  42128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42129. "use strict";
  42130. __webpack_require__.r(__webpack_exports__);
  42131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return HighlightLayer; });
  42132. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42133. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42134. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42135. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42136. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42137. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42138. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42139. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42140. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42141. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  42142. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  42143. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  42144. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42145. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42146. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42147. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  42148. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  42149. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  42150. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  42151. /* harmony import */ var _Shaders_glowBlurPostProcess_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/glowBlurPostProcess.fragment */ "./Shaders/glowBlurPostProcess.fragment.ts");
  42152. _abstractScene__WEBPACK_IMPORTED_MODULE_13__["AbstractScene"].prototype.getHighlightLayerByName = function (name) {
  42153. for (var index = 0; index < this.effectLayers.length; index++) {
  42154. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
  42155. return this.effectLayers[index];
  42156. }
  42157. }
  42158. return null;
  42159. };
  42160. /**
  42161. * Special Glow Blur post process only blurring the alpha channel
  42162. * It enforces keeping the most luminous color in the color channel.
  42163. */
  42164. var GlowBlurPostProcess = /** @class */ (function (_super) {
  42165. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowBlurPostProcess, _super);
  42166. function GlowBlurPostProcess(name, direction, kernel, options, camera, samplingMode, engine, reusable) {
  42167. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE; }
  42168. var _this = _super.call(this, name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable) || this;
  42169. _this.direction = direction;
  42170. _this.kernel = kernel;
  42171. _this.onApplyObservable.add(function (effect) {
  42172. effect.setFloat2("screenSize", _this.width, _this.height);
  42173. effect.setVector2("direction", _this.direction);
  42174. effect.setFloat("blurWidth", _this.kernel);
  42175. });
  42176. return _this;
  42177. }
  42178. return GlowBlurPostProcess;
  42179. }(_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__["PostProcess"]));
  42180. /**
  42181. * The highlight layer Helps adding a glow effect around a mesh.
  42182. *
  42183. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  42184. * glowy meshes to your scene.
  42185. *
  42186. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  42187. */
  42188. var HighlightLayer = /** @class */ (function (_super) {
  42189. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightLayer, _super);
  42190. /**
  42191. * Instantiates a new highlight Layer and references it to the scene..
  42192. * @param name The name of the layer
  42193. * @param scene The scene to use the layer in
  42194. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  42195. */
  42196. function HighlightLayer(name, scene, options) {
  42197. var _this = _super.call(this, name, scene) || this;
  42198. _this.name = name;
  42199. /**
  42200. * Specifies whether or not the inner glow is ACTIVE in the layer.
  42201. */
  42202. _this.innerGlow = true;
  42203. /**
  42204. * Specifies whether or not the outer glow is ACTIVE in the layer.
  42205. */
  42206. _this.outerGlow = true;
  42207. /**
  42208. * An event triggered when the highlight layer is being blurred.
  42209. */
  42210. _this.onBeforeBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42211. /**
  42212. * An event triggered when the highlight layer has been blurred.
  42213. */
  42214. _this.onAfterBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42215. _this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
  42216. _this._meshes = {};
  42217. _this._excludedMeshes = {};
  42218. _this.neutralColor = HighlightLayer.NeutralColor;
  42219. // Warn on stencil
  42220. if (!_this._engine.isStencilEnable) {
  42221. _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 }");
  42222. }
  42223. // Adapt options
  42224. _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);
  42225. // Initialize the layer
  42226. _this._init({
  42227. alphaBlendingMode: _this._options.alphaBlendingMode,
  42228. camera: _this._options.camera,
  42229. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  42230. mainTextureRatio: _this._options.mainTextureRatio,
  42231. renderingGroupId: _this._options.renderingGroupId
  42232. });
  42233. // Do not render as long as no meshes have been added
  42234. _this._shouldRender = false;
  42235. return _this;
  42236. }
  42237. Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
  42238. /**
  42239. * Gets the horizontal size of the blur.
  42240. */
  42241. get: function () {
  42242. return this._horizontalBlurPostprocess.kernel;
  42243. },
  42244. /**
  42245. * Specifies the horizontal size of the blur.
  42246. */
  42247. set: function (value) {
  42248. this._horizontalBlurPostprocess.kernel = value;
  42249. },
  42250. enumerable: true,
  42251. configurable: true
  42252. });
  42253. Object.defineProperty(HighlightLayer.prototype, "blurVerticalSize", {
  42254. /**
  42255. * Gets the vertical size of the blur.
  42256. */
  42257. get: function () {
  42258. return this._verticalBlurPostprocess.kernel;
  42259. },
  42260. /**
  42261. * Specifies the vertical size of the blur.
  42262. */
  42263. set: function (value) {
  42264. this._verticalBlurPostprocess.kernel = value;
  42265. },
  42266. enumerable: true,
  42267. configurable: true
  42268. });
  42269. /**
  42270. * Get the effect name of the layer.
  42271. * @return The effect name
  42272. */
  42273. HighlightLayer.prototype.getEffectName = function () {
  42274. return HighlightLayer.EffectName;
  42275. };
  42276. /**
  42277. * Create the merge effect. This is the shader use to blit the information back
  42278. * to the main canvas at the end of the scene rendering.
  42279. */
  42280. HighlightLayer.prototype._createMergeEffect = function () {
  42281. // Effect
  42282. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined);
  42283. };
  42284. /**
  42285. * Creates the render target textures and post processes used in the highlight layer.
  42286. */
  42287. HighlightLayer.prototype._createTextureAndPostProcesses = function () {
  42288. var _this = this;
  42289. var blurTextureWidth = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio;
  42290. var blurTextureHeight = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  42291. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  42292. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  42293. var textureType = 0;
  42294. if (this._engine.getCaps().textureHalfFloatRender) {
  42295. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_HALF_FLOAT;
  42296. }
  42297. else {
  42298. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  42299. }
  42300. this._blurTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerBlurRTT", {
  42301. width: blurTextureWidth,
  42302. height: blurTextureHeight
  42303. }, this._scene, false, true, textureType);
  42304. this._blurTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42305. this._blurTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42306. this._blurTexture.anisotropicFilteringLevel = 16;
  42307. this._blurTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].TRILINEAR_SAMPLINGMODE);
  42308. this._blurTexture.renderParticles = false;
  42309. this._blurTexture.ignoreCameraViewport = true;
  42310. this._textures = [this._blurTexture];
  42311. if (this._options.alphaBlendingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE) {
  42312. 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());
  42313. this._downSamplePostprocess.onApplyObservable.add(function (effect) {
  42314. effect.setTexture("textureSampler", _this._mainTexture);
  42315. });
  42316. 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());
  42317. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  42318. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  42319. });
  42320. 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());
  42321. this._verticalBlurPostprocess.onApplyObservable.add(function (effect) {
  42322. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  42323. });
  42324. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  42325. }
  42326. else {
  42327. 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, {
  42328. width: blurTextureWidth,
  42329. height: blurTextureHeight
  42330. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42331. this._horizontalBlurPostprocess.width = blurTextureWidth;
  42332. this._horizontalBlurPostprocess.height = blurTextureHeight;
  42333. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  42334. effect.setTexture("textureSampler", _this._mainTexture);
  42335. });
  42336. 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, {
  42337. width: blurTextureWidth,
  42338. height: blurTextureHeight
  42339. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42340. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  42341. }
  42342. this._mainTexture.onAfterUnbindObservable.add(function () {
  42343. _this.onBeforeBlurObservable.notifyObservers(_this);
  42344. var internalTexture = _this._blurTexture.getInternalTexture();
  42345. if (internalTexture) {
  42346. _this._scene.postProcessManager.directRender(_this._postProcesses, internalTexture, true);
  42347. }
  42348. _this.onAfterBlurObservable.notifyObservers(_this);
  42349. });
  42350. // Prevent autoClear.
  42351. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  42352. };
  42353. /**
  42354. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  42355. */
  42356. HighlightLayer.prototype.needStencil = function () {
  42357. return true;
  42358. };
  42359. /**
  42360. * Checks for the readiness of the element composing the layer.
  42361. * @param subMesh the mesh to check for
  42362. * @param useInstances specify wether or not to use instances to render the mesh
  42363. * @param emissiveTexture the associated emissive texture used to generate the glow
  42364. * @return true if ready otherwise, false
  42365. */
  42366. HighlightLayer.prototype.isReady = function (subMesh, useInstances) {
  42367. var material = subMesh.getMaterial();
  42368. var mesh = subMesh.getRenderingMesh();
  42369. if (!material || !mesh || !this._meshes) {
  42370. return false;
  42371. }
  42372. var emissiveTexture = null;
  42373. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  42374. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  42375. emissiveTexture = material.emissiveTexture;
  42376. }
  42377. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  42378. };
  42379. /**
  42380. * Implementation specific of rendering the generating effect on the main canvas.
  42381. * @param effect The effect used to render through
  42382. */
  42383. HighlightLayer.prototype._internalRender = function (effect) {
  42384. // Texture
  42385. effect.setTexture("textureSampler", this._blurTexture);
  42386. // Cache
  42387. var engine = this._engine;
  42388. var previousStencilBuffer = engine.getStencilBuffer();
  42389. var previousStencilFunction = engine.getStencilFunction();
  42390. var previousStencilMask = engine.getStencilMask();
  42391. var previousStencilOperationPass = engine.getStencilOperationPass();
  42392. var previousStencilOperationFail = engine.getStencilOperationFail();
  42393. var previousStencilOperationDepthFail = engine.getStencilOperationDepthFail();
  42394. var previousStencilReference = engine.getStencilFunctionReference();
  42395. // Stencil operations
  42396. engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].REPLACE);
  42397. engine.setStencilOperationFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  42398. engine.setStencilOperationDepthFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  42399. // Draw order
  42400. engine.setStencilMask(0x00);
  42401. engine.setStencilBuffer(true);
  42402. engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
  42403. // 2 passes inner outer
  42404. if (this.outerGlow) {
  42405. effect.setFloat("offset", 0);
  42406. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].NOTEQUAL);
  42407. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  42408. }
  42409. if (this.innerGlow) {
  42410. effect.setFloat("offset", 1);
  42411. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].EQUAL);
  42412. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  42413. }
  42414. // Restore Cache
  42415. engine.setStencilFunction(previousStencilFunction);
  42416. engine.setStencilMask(previousStencilMask);
  42417. engine.setStencilBuffer(previousStencilBuffer);
  42418. engine.setStencilOperationPass(previousStencilOperationPass);
  42419. engine.setStencilOperationFail(previousStencilOperationFail);
  42420. engine.setStencilOperationDepthFail(previousStencilOperationDepthFail);
  42421. engine.setStencilFunctionReference(previousStencilReference);
  42422. };
  42423. /**
  42424. * Returns true if the layer contains information to display, otherwise false.
  42425. */
  42426. HighlightLayer.prototype.shouldRender = function () {
  42427. if (_super.prototype.shouldRender.call(this)) {
  42428. return this._meshes ? true : false;
  42429. }
  42430. return false;
  42431. };
  42432. /**
  42433. * Returns true if the mesh should render, otherwise false.
  42434. * @param mesh The mesh to render
  42435. * @returns true if it should render otherwise false
  42436. */
  42437. HighlightLayer.prototype._shouldRenderMesh = function (mesh) {
  42438. // Excluded Mesh
  42439. if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
  42440. return false;
  42441. }
  42442. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42443. return false;
  42444. }
  42445. return true;
  42446. };
  42447. /**
  42448. * Sets the required values for both the emissive texture and and the main color.
  42449. */
  42450. HighlightLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  42451. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  42452. if (highlightLayerMesh) {
  42453. this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
  42454. }
  42455. else {
  42456. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  42457. }
  42458. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  42459. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  42460. this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
  42461. }
  42462. else {
  42463. this._emissiveTextureAndColor.texture = null;
  42464. }
  42465. };
  42466. /**
  42467. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  42468. * @param mesh The mesh to exclude from the highlight layer
  42469. */
  42470. HighlightLayer.prototype.addExcludedMesh = function (mesh) {
  42471. if (!this._excludedMeshes) {
  42472. return;
  42473. }
  42474. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  42475. if (!meshExcluded) {
  42476. this._excludedMeshes[mesh.uniqueId] = {
  42477. mesh: mesh,
  42478. beforeBind: mesh.onBeforeBindObservable.add(function (mesh) {
  42479. mesh.getEngine().setStencilBuffer(false);
  42480. }),
  42481. afterRender: mesh.onAfterRenderObservable.add(function (mesh) {
  42482. mesh.getEngine().setStencilBuffer(true);
  42483. }),
  42484. };
  42485. }
  42486. };
  42487. /**
  42488. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  42489. * @param mesh The mesh to highlight
  42490. */
  42491. HighlightLayer.prototype.removeExcludedMesh = function (mesh) {
  42492. if (!this._excludedMeshes) {
  42493. return;
  42494. }
  42495. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  42496. if (meshExcluded) {
  42497. if (meshExcluded.beforeBind) {
  42498. mesh.onBeforeBindObservable.remove(meshExcluded.beforeBind);
  42499. }
  42500. if (meshExcluded.afterRender) {
  42501. mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
  42502. }
  42503. }
  42504. this._excludedMeshes[mesh.uniqueId] = null;
  42505. };
  42506. /**
  42507. * Determine if a given mesh will be highlighted by the current HighlightLayer
  42508. * @param mesh mesh to test
  42509. * @returns true if the mesh will be highlighted by the current HighlightLayer
  42510. */
  42511. HighlightLayer.prototype.hasMesh = function (mesh) {
  42512. if (!this._meshes) {
  42513. return false;
  42514. }
  42515. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42516. return false;
  42517. }
  42518. return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
  42519. };
  42520. /**
  42521. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  42522. * @param mesh The mesh to highlight
  42523. * @param color The color of the highlight
  42524. * @param glowEmissiveOnly Extract the glow from the emissive texture
  42525. */
  42526. HighlightLayer.prototype.addMesh = function (mesh, color, glowEmissiveOnly) {
  42527. var _this = this;
  42528. if (glowEmissiveOnly === void 0) { glowEmissiveOnly = false; }
  42529. if (!this._meshes) {
  42530. return;
  42531. }
  42532. var meshHighlight = this._meshes[mesh.uniqueId];
  42533. if (meshHighlight) {
  42534. meshHighlight.color = color;
  42535. }
  42536. else {
  42537. this._meshes[mesh.uniqueId] = {
  42538. mesh: mesh,
  42539. color: color,
  42540. // Lambda required for capture due to Observable this context
  42541. observerHighlight: mesh.onBeforeBindObservable.add(function (mesh) {
  42542. if (_this._excludedMeshes && _this._excludedMeshes[mesh.uniqueId]) {
  42543. _this._defaultStencilReference(mesh);
  42544. }
  42545. else {
  42546. mesh.getScene().getEngine().setStencilFunctionReference(_this._instanceGlowingMeshStencilReference);
  42547. }
  42548. }),
  42549. observerDefault: mesh.onAfterRenderObservable.add(this._defaultStencilReference),
  42550. glowEmissiveOnly: glowEmissiveOnly
  42551. };
  42552. mesh.onDisposeObservable.add(function () {
  42553. _this._disposeMesh(mesh);
  42554. });
  42555. }
  42556. this._shouldRender = true;
  42557. };
  42558. /**
  42559. * Remove a mesh from the highlight layer in order to make it stop glowing.
  42560. * @param mesh The mesh to highlight
  42561. */
  42562. HighlightLayer.prototype.removeMesh = function (mesh) {
  42563. if (!this._meshes) {
  42564. return;
  42565. }
  42566. var meshHighlight = this._meshes[mesh.uniqueId];
  42567. if (meshHighlight) {
  42568. if (meshHighlight.observerHighlight) {
  42569. mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  42570. }
  42571. if (meshHighlight.observerDefault) {
  42572. mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  42573. }
  42574. delete this._meshes[mesh.uniqueId];
  42575. }
  42576. this._shouldRender = false;
  42577. for (var meshHighlightToCheck in this._meshes) {
  42578. if (this._meshes[meshHighlightToCheck]) {
  42579. this._shouldRender = true;
  42580. break;
  42581. }
  42582. }
  42583. };
  42584. /**
  42585. * Force the stencil to the normal expected value for none glowing parts
  42586. */
  42587. HighlightLayer.prototype._defaultStencilReference = function (mesh) {
  42588. mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
  42589. };
  42590. /**
  42591. * Free any resources and references associated to a mesh.
  42592. * Internal use
  42593. * @param mesh The mesh to free.
  42594. * @hidden
  42595. */
  42596. HighlightLayer.prototype._disposeMesh = function (mesh) {
  42597. this.removeMesh(mesh);
  42598. this.removeExcludedMesh(mesh);
  42599. };
  42600. /**
  42601. * Dispose the highlight layer and free resources.
  42602. */
  42603. HighlightLayer.prototype.dispose = function () {
  42604. if (this._meshes) {
  42605. // Clean mesh references
  42606. for (var id in this._meshes) {
  42607. var meshHighlight = this._meshes[id];
  42608. if (meshHighlight && meshHighlight.mesh) {
  42609. if (meshHighlight.observerHighlight) {
  42610. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  42611. }
  42612. if (meshHighlight.observerDefault) {
  42613. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  42614. }
  42615. }
  42616. }
  42617. this._meshes = null;
  42618. }
  42619. if (this._excludedMeshes) {
  42620. for (var id in this._excludedMeshes) {
  42621. var meshHighlight = this._excludedMeshes[id];
  42622. if (meshHighlight) {
  42623. if (meshHighlight.beforeBind) {
  42624. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.beforeBind);
  42625. }
  42626. if (meshHighlight.afterRender) {
  42627. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
  42628. }
  42629. }
  42630. }
  42631. this._excludedMeshes = null;
  42632. }
  42633. _super.prototype.dispose.call(this);
  42634. };
  42635. /**
  42636. * Gets the class name of the effect layer
  42637. * @returns the string with the class name of the effect layer
  42638. */
  42639. HighlightLayer.prototype.getClassName = function () {
  42640. return "HighlightLayer";
  42641. };
  42642. /**
  42643. * Serializes this Highlight layer
  42644. * @returns a serialized Highlight layer object
  42645. */
  42646. HighlightLayer.prototype.serialize = function () {
  42647. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  42648. serializationObject.customType = "BABYLON.HighlightLayer";
  42649. // Highlighted meshes
  42650. serializationObject.meshes = [];
  42651. if (this._meshes) {
  42652. for (var m in this._meshes) {
  42653. var mesh = this._meshes[m];
  42654. if (mesh) {
  42655. serializationObject.meshes.push({
  42656. glowEmissiveOnly: mesh.glowEmissiveOnly,
  42657. color: mesh.color.asArray(),
  42658. meshId: mesh.mesh.id
  42659. });
  42660. }
  42661. }
  42662. }
  42663. // Excluded meshes
  42664. serializationObject.excludedMeshes = [];
  42665. if (this._excludedMeshes) {
  42666. for (var e in this._excludedMeshes) {
  42667. var excludedMesh = this._excludedMeshes[e];
  42668. if (excludedMesh) {
  42669. serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
  42670. }
  42671. }
  42672. }
  42673. return serializationObject;
  42674. };
  42675. /**
  42676. * Creates a Highlight layer from parsed Highlight layer data
  42677. * @param parsedHightlightLayer defines the Highlight layer data
  42678. * @param scene defines the current scene
  42679. * @param rootUrl defines the root URL containing the Highlight layer information
  42680. * @returns a parsed Highlight layer
  42681. */
  42682. HighlightLayer.Parse = function (parsedHightlightLayer, scene, rootUrl) {
  42683. var hl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new HighlightLayer(parsedHightlightLayer.name, scene, parsedHightlightLayer.options); }, parsedHightlightLayer, scene, rootUrl);
  42684. var index;
  42685. // Excluded meshes
  42686. for (index = 0; index < parsedHightlightLayer.excludedMeshes.length; index++) {
  42687. var mesh = scene.getMeshByID(parsedHightlightLayer.excludedMeshes[index]);
  42688. if (mesh) {
  42689. hl.addExcludedMesh(mesh);
  42690. }
  42691. }
  42692. // Included meshes
  42693. for (index = 0; index < parsedHightlightLayer.meshes.length; index++) {
  42694. var highlightedMesh = parsedHightlightLayer.meshes[index];
  42695. var mesh = scene.getMeshByID(highlightedMesh.meshId);
  42696. if (mesh) {
  42697. hl.addMesh(mesh, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromArray(highlightedMesh.color), highlightedMesh.glowEmissiveOnly);
  42698. }
  42699. }
  42700. return hl;
  42701. };
  42702. /**
  42703. * Effect Name of the highlight layer.
  42704. */
  42705. HighlightLayer.EffectName = "HighlightLayer";
  42706. /**
  42707. * The neutral color used during the preparation of the glow effect.
  42708. * This is black by default as the blend operation is a blend operation.
  42709. */
  42710. HighlightLayer.NeutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  42711. /**
  42712. * Stencil value used for glowing meshes.
  42713. */
  42714. HighlightLayer.GlowingMeshStencilReference = 0x02;
  42715. /**
  42716. * Stencil value used for the other meshes in the scene.
  42717. */
  42718. HighlightLayer.NormalMeshStencilReference = 0x01;
  42719. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42720. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42721. ], HighlightLayer.prototype, "innerGlow", void 0);
  42722. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42723. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42724. ], HighlightLayer.prototype, "outerGlow", void 0);
  42725. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42726. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42727. ], HighlightLayer.prototype, "blurHorizontalSize", null);
  42728. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42729. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42730. ], HighlightLayer.prototype, "blurVerticalSize", null);
  42731. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42732. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  42733. ], HighlightLayer.prototype, "_options", void 0);
  42734. return HighlightLayer;
  42735. }(_effectLayer__WEBPACK_IMPORTED_MODULE_12__["EffectLayer"]));
  42736. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__["_TypeStore"].RegisteredTypes["BABYLON.HighlightLayer"] = HighlightLayer;
  42737. /***/ }),
  42738. /***/ "./Layers/index.ts":
  42739. /*!*************************!*\
  42740. !*** ./Layers/index.ts ***!
  42741. \*************************/
  42742. /*! exports provided: EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent */
  42743. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42744. "use strict";
  42745. __webpack_require__.r(__webpack_exports__);
  42746. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _effectLayer__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  42748. /* harmony import */ var _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  42749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__["EffectLayerSceneComponent"]; });
  42750. /* harmony import */ var _glowLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glowLayer */ "./Layers/glowLayer.ts");
  42751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _glowLayer__WEBPACK_IMPORTED_MODULE_2__["GlowLayer"]; });
  42752. /* harmony import */ var _highlightLayer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./highlightLayer */ "./Layers/highlightLayer.ts");
  42753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _highlightLayer__WEBPACK_IMPORTED_MODULE_3__["HighlightLayer"]; });
  42754. /* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layer */ "./Layers/layer.ts");
  42755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer__WEBPACK_IMPORTED_MODULE_4__["Layer"]; });
  42756. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  42757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__["LayerSceneComponent"]; });
  42758. /***/ }),
  42759. /***/ "./Layers/layer.ts":
  42760. /*!*************************!*\
  42761. !*** ./Layers/layer.ts ***!
  42762. \*************************/
  42763. /*! exports provided: Layer */
  42764. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42765. "use strict";
  42766. __webpack_require__.r(__webpack_exports__);
  42767. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return Layer; });
  42768. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42769. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42770. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  42771. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42772. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42773. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42774. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  42775. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  42776. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42777. /* harmony import */ var _Shaders_layer_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/layer.fragment */ "./Shaders/layer.fragment.ts");
  42778. /* harmony import */ var _Shaders_layer_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/layer.vertex */ "./Shaders/layer.vertex.ts");
  42779. /**
  42780. * This represents a full screen 2d layer.
  42781. * This can be useful to display a picture in the background of your scene for instance.
  42782. * @see https://www.babylonjs-playground.com/#08A2BS#1
  42783. */
  42784. var Layer = /** @class */ (function () {
  42785. /**
  42786. * Instantiates a new layer.
  42787. * This represents a full screen 2d layer.
  42788. * This can be useful to display a picture in the background of your scene for instance.
  42789. * @see https://www.babylonjs-playground.com/#08A2BS#1
  42790. * @param name Define the name of the layer in the scene
  42791. * @param imgUrl Define the url of the texture to display in the layer
  42792. * @param scene Define the scene the layer belongs to
  42793. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  42794. * @param color Defines a color for the layer
  42795. */
  42796. function Layer(
  42797. /**
  42798. * Define the name of the layer.
  42799. */
  42800. name, imgUrl, scene, isBackground, color) {
  42801. this.name = name;
  42802. /**
  42803. * Define the scale of the layer in order to zoom in out of the texture.
  42804. */
  42805. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 1);
  42806. /**
  42807. * Define an offset for the layer in order to shift the texture.
  42808. */
  42809. this.offset = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 0);
  42810. /**
  42811. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  42812. */
  42813. this.alphaBlendingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  42814. /**
  42815. * Define a mask to restrict the layer to only some of the scene cameras.
  42816. */
  42817. this.layerMask = 0x0FFFFFFF;
  42818. /**
  42819. * Define the list of render target the layer is visible into.
  42820. */
  42821. this.renderTargetTextures = [];
  42822. /**
  42823. * Define if the layer is only used in renderTarget or if it also
  42824. * renders in the main frame buffer of the canvas.
  42825. */
  42826. this.renderOnlyInRenderTargetTextures = false;
  42827. this._vertexBuffers = {};
  42828. /**
  42829. * An event triggered when the layer is disposed.
  42830. */
  42831. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42832. /**
  42833. * An event triggered before rendering the scene
  42834. */
  42835. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42836. /**
  42837. * An event triggered after rendering the scene
  42838. */
  42839. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42840. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"](imgUrl, scene, true) : null;
  42841. this.isBackground = isBackground === undefined ? true : isBackground;
  42842. this.color = color === undefined ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1) : color;
  42843. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene);
  42844. var layerComponent = this._scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_LAYER);
  42845. if (!layerComponent) {
  42846. layerComponent = new _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__["LayerSceneComponent"](this._scene);
  42847. this._scene._addComponent(layerComponent);
  42848. }
  42849. this._scene.layers.push(this);
  42850. var engine = this._scene.getEngine();
  42851. // VBO
  42852. var vertices = [];
  42853. vertices.push(1, 1);
  42854. vertices.push(-1, 1);
  42855. vertices.push(-1, -1);
  42856. vertices.push(1, -1);
  42857. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false, false, 2);
  42858. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = vertexBuffer;
  42859. this._createIndexBuffer();
  42860. // Effects
  42861. this._effect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "");
  42862. this._alphaTestEffect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "#define ALPHATEST");
  42863. }
  42864. Object.defineProperty(Layer.prototype, "onDispose", {
  42865. /**
  42866. * Back compatibility with callback before the onDisposeObservable existed.
  42867. * The set callback will be triggered when the layer has been disposed.
  42868. */
  42869. set: function (callback) {
  42870. if (this._onDisposeObserver) {
  42871. this.onDisposeObservable.remove(this._onDisposeObserver);
  42872. }
  42873. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  42874. },
  42875. enumerable: true,
  42876. configurable: true
  42877. });
  42878. Object.defineProperty(Layer.prototype, "onBeforeRender", {
  42879. /**
  42880. * Back compatibility with callback before the onBeforeRenderObservable existed.
  42881. * The set callback will be triggered just before rendering the layer.
  42882. */
  42883. set: function (callback) {
  42884. if (this._onBeforeRenderObserver) {
  42885. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  42886. }
  42887. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  42888. },
  42889. enumerable: true,
  42890. configurable: true
  42891. });
  42892. Object.defineProperty(Layer.prototype, "onAfterRender", {
  42893. /**
  42894. * Back compatibility with callback before the onAfterRenderObservable existed.
  42895. * The set callback will be triggered just after rendering the layer.
  42896. */
  42897. set: function (callback) {
  42898. if (this._onAfterRenderObserver) {
  42899. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  42900. }
  42901. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  42902. },
  42903. enumerable: true,
  42904. configurable: true
  42905. });
  42906. Layer.prototype._createIndexBuffer = function () {
  42907. var engine = this._scene.getEngine();
  42908. // Indices
  42909. var indices = [];
  42910. indices.push(0);
  42911. indices.push(1);
  42912. indices.push(2);
  42913. indices.push(0);
  42914. indices.push(2);
  42915. indices.push(3);
  42916. this._indexBuffer = engine.createIndexBuffer(indices);
  42917. };
  42918. /** @hidden */
  42919. Layer.prototype._rebuild = function () {
  42920. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  42921. if (vb) {
  42922. vb._rebuild();
  42923. }
  42924. this._createIndexBuffer();
  42925. };
  42926. /**
  42927. * Renders the layer in the scene.
  42928. */
  42929. Layer.prototype.render = function () {
  42930. var currentEffect = this.alphaTest ? this._alphaTestEffect : this._effect;
  42931. // Check
  42932. if (!currentEffect.isReady() || !this.texture || !this.texture.isReady()) {
  42933. return;
  42934. }
  42935. var engine = this._scene.getEngine();
  42936. this.onBeforeRenderObservable.notifyObservers(this);
  42937. // Render
  42938. engine.enableEffect(currentEffect);
  42939. engine.setState(false);
  42940. // Texture
  42941. currentEffect.setTexture("textureSampler", this.texture);
  42942. currentEffect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
  42943. // Color
  42944. currentEffect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
  42945. // Scale / offset
  42946. currentEffect.setVector2("offset", this.offset);
  42947. currentEffect.setVector2("scale", this.scale);
  42948. // VBOs
  42949. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  42950. // Draw order
  42951. if (!this.alphaTest) {
  42952. engine.setAlphaMode(this.alphaBlendingMode);
  42953. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  42954. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  42955. }
  42956. else {
  42957. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  42958. }
  42959. this.onAfterRenderObservable.notifyObservers(this);
  42960. };
  42961. /**
  42962. * Disposes and releases the associated ressources.
  42963. */
  42964. Layer.prototype.dispose = function () {
  42965. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  42966. if (vertexBuffer) {
  42967. vertexBuffer.dispose();
  42968. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  42969. }
  42970. if (this._indexBuffer) {
  42971. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  42972. this._indexBuffer = null;
  42973. }
  42974. if (this.texture) {
  42975. this.texture.dispose();
  42976. this.texture = null;
  42977. }
  42978. // Clean RTT list
  42979. this.renderTargetTextures = [];
  42980. // Remove from scene
  42981. var index = this._scene.layers.indexOf(this);
  42982. this._scene.layers.splice(index, 1);
  42983. // Callback
  42984. this.onDisposeObservable.notifyObservers(this);
  42985. this.onDisposeObservable.clear();
  42986. this.onAfterRenderObservable.clear();
  42987. this.onBeforeRenderObservable.clear();
  42988. };
  42989. return Layer;
  42990. }());
  42991. /***/ }),
  42992. /***/ "./Layers/layerSceneComponent.ts":
  42993. /*!***************************************!*\
  42994. !*** ./Layers/layerSceneComponent.ts ***!
  42995. \***************************************/
  42996. /*! exports provided: LayerSceneComponent */
  42997. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42998. "use strict";
  42999. __webpack_require__.r(__webpack_exports__);
  43000. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return LayerSceneComponent; });
  43001. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43002. /**
  43003. * Defines the layer scene component responsible to manage any layers
  43004. * in a given scene.
  43005. */
  43006. var LayerSceneComponent = /** @class */ (function () {
  43007. /**
  43008. * Creates a new instance of the component for the given scene
  43009. * @param scene Defines the scene to register the component in
  43010. */
  43011. function LayerSceneComponent(scene) {
  43012. /**
  43013. * The component name helpfull to identify the component in the list of scene components.
  43014. */
  43015. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_LAYER;
  43016. this.scene = scene;
  43017. this._engine = scene.getEngine();
  43018. scene.layers = new Array();
  43019. }
  43020. /**
  43021. * Registers the component in a given scene
  43022. */
  43023. LayerSceneComponent.prototype.register = function () {
  43024. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground);
  43025. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground);
  43026. this.scene._beforeRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground);
  43027. this.scene._afterRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
  43028. };
  43029. /**
  43030. * Rebuilds the elements related to this component in case of
  43031. * context lost for instance.
  43032. */
  43033. LayerSceneComponent.prototype.rebuild = function () {
  43034. var layers = this.scene.layers;
  43035. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  43036. var layer = layers_1[_i];
  43037. layer._rebuild();
  43038. }
  43039. };
  43040. /**
  43041. * Disposes the component and the associated ressources.
  43042. */
  43043. LayerSceneComponent.prototype.dispose = function () {
  43044. var layers = this.scene.layers;
  43045. while (layers.length) {
  43046. layers[0].dispose();
  43047. }
  43048. };
  43049. LayerSceneComponent.prototype._draw = function (predicate) {
  43050. var layers = this.scene.layers;
  43051. if (layers.length) {
  43052. this._engine.setDepthBuffer(false);
  43053. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  43054. var layer = layers_2[_i];
  43055. if (predicate(layer)) {
  43056. layer.render();
  43057. }
  43058. }
  43059. this._engine.setDepthBuffer(true);
  43060. }
  43061. };
  43062. LayerSceneComponent.prototype._drawCameraPredicate = function (layer, isBackground, cameraLayerMask) {
  43063. return !layer.renderOnlyInRenderTargetTextures &&
  43064. layer.isBackground === isBackground &&
  43065. ((layer.layerMask & cameraLayerMask) !== 0);
  43066. };
  43067. LayerSceneComponent.prototype._drawCameraBackground = function (camera) {
  43068. var _this = this;
  43069. this._draw(function (layer) {
  43070. return _this._drawCameraPredicate(layer, true, camera.layerMask);
  43071. });
  43072. };
  43073. LayerSceneComponent.prototype._drawCameraForeground = function (camera) {
  43074. var _this = this;
  43075. this._draw(function (layer) {
  43076. return _this._drawCameraPredicate(layer, false, camera.layerMask);
  43077. });
  43078. };
  43079. LayerSceneComponent.prototype._drawRenderTargetPredicate = function (layer, isBackground, cameraLayerMask, renderTargetTexture) {
  43080. return (layer.renderTargetTextures.length > 0) &&
  43081. layer.isBackground === isBackground &&
  43082. (layer.renderTargetTextures.indexOf(renderTargetTexture) > -1) &&
  43083. ((layer.layerMask & cameraLayerMask) !== 0);
  43084. };
  43085. LayerSceneComponent.prototype._drawRenderTargetBackground = function (renderTarget) {
  43086. var _this = this;
  43087. this._draw(function (layer) {
  43088. return _this._drawRenderTargetPredicate(layer, true, _this.scene.activeCamera.layerMask, renderTarget);
  43089. });
  43090. };
  43091. LayerSceneComponent.prototype._drawRenderTargetForeground = function (renderTarget) {
  43092. var _this = this;
  43093. this._draw(function (layer) {
  43094. return _this._drawRenderTargetPredicate(layer, false, _this.scene.activeCamera.layerMask, renderTarget);
  43095. });
  43096. };
  43097. return LayerSceneComponent;
  43098. }());
  43099. /***/ }),
  43100. /***/ "./Legacy/legacy.ts":
  43101. /*!**************************!*\
  43102. !*** ./Legacy/legacy.ts ***!
  43103. \**************************/
  43104. /*! exports provided: AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, DiscBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, ReflectionProbe, BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer, Sprite, SpriteManager, SpriteSceneComponent, _AlphaState, _DepthCullingState, _StencilState, AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  43105. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43106. "use strict";
  43107. __webpack_require__.r(__webpack_exports__);
  43108. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  43109. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/index */ "./Debug/index.ts");
  43110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  43111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeepAssets"]; });
  43112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"]; });
  43113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Node"]; });
  43114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scene"]; });
  43115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"]; });
  43116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Stage"]; });
  43117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  43118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionEvent"]; });
  43119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionManager"]; });
  43120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Condition"]; });
  43121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueCondition"]; });
  43122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PredicateCondition"]; });
  43123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StateCondition"]; });
  43124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SwitchBooleanAction"]; });
  43125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetStateAction"]; });
  43126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetValueAction"]; });
  43127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IncrementValueAction"]; });
  43128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlayAnimationAction"]; });
  43129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopAnimationAction"]; });
  43130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DoNothingAction"]; });
  43131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CombineAction"]; });
  43132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExecuteCodeAction"]; });
  43133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetParentAction"]; });
  43134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaySoundAction"]; });
  43135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopSoundAction"]; });
  43136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InterpolateValueAction"]; });
  43137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  43138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animation"]; });
  43139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetedAnimation"]; });
  43140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"]; });
  43141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationPropertiesOverride"]; });
  43142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"]; });
  43143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleEase"]; });
  43144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackEase"]; });
  43145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BounceEase"]; });
  43146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubicEase"]; });
  43147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ElasticEase"]; });
  43148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]; });
  43149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PowerEase"]; });
  43150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuadraticEase"]; });
  43151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuarticEase"]; });
  43152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuinticEase"]; });
  43153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SineEase"]; });
  43154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurveEase"]; });
  43155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"]; });
  43156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"]; });
  43157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"]; });
  43158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationRange"]; });
  43159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  43160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioEngine"]; });
  43161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioSceneComponent"]; });
  43162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sound"]; });
  43163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SoundTrack"]; });
  43164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"]; });
  43165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  43166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneIKController"]; });
  43167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneLookController"]; });
  43168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Skeleton"]; });
  43169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]; });
  43170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputsManager"]; });
  43171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Camera"]; });
  43172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetCamera"]; });
  43173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"]; });
  43174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraInputsManager"]; });
  43175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchCamera"]; });
  43176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCamera"]; });
  43177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraInputsManager"]; });
  43178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeviceOrientationCamera"]; });
  43179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCamera"]; });
  43180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraInputsManager"]; });
  43181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCamera"]; });
  43182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcFollowCamera"]; });
  43183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadCamera"]; });
  43184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniversalCamera"]; });
  43185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoysticksCamera"]; });
  43186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  43187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultCollisionCoordinator"]; });
  43188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PickingInfo"]; });
  43189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IntersectionInfo"]; });
  43190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  43191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingInfo"]; });
  43192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingSphere"]; });
  43193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ray"]; });
  43194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  43195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneAxesViewer"]; });
  43196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DebugLayer"]; });
  43197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsViewer"]; });
  43198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RayHelper"]; });
  43199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkeletonViewer"]; });
  43200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  43201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancingAttributeInfo"]; });
  43202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthTextureCreationOptions"]; });
  43203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineCapabilities"]; });
  43204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Engine"]; });
  43205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineStore"]; });
  43206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngineOptions"]; });
  43207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngine"]; });
  43208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  43209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  43210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  43211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"]; });
  43212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoBase"]; });
  43213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"]; });
  43214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"]; });
  43215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardEventTypes"]; });
  43216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardInfo"]; });
  43217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  43218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  43219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  43220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  43221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  43222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  43223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  43224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  43225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  43226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  43227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StickValues"]; });
  43228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gamepad"]; });
  43229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericPad"]; });
  43230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadManager"]; });
  43231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadSystemSceneComponent"]; });
  43232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Button"]; });
  43233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Dpad"]; });
  43234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Pad"]; });
  43235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  43236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisScaleGizmo"]; });
  43237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxGizmo"]; });
  43238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gizmo"]; });
  43239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GizmoManager"]; });
  43240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneRotationGizmo"]; });
  43241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionGizmo"]; });
  43242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RotationGizmo"]; });
  43243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScaleGizmo"]; });
  43244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LightGizmo"]; });
  43245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  43246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhotoDome"]; });
  43247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceSceneHelpersToBundle"]; });
  43248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoDome"]; });
  43249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  43250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneInstrumentation"]; });
  43251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TimeToken"]; });
  43252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  43253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayerSceneComponent"]; });
  43254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GlowLayer"]; });
  43255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightLayer"]; });
  43256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Layer"]; });
  43257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LayerSceneComponent"]; });
  43258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  43259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystem"]; });
  43260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystemSceneComponent"]; });
  43261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  43262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowLight"]; });
  43263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"]; });
  43264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]; });
  43265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointLight"]; });
  43266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpotLight"]; });
  43267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  43268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"]; });
  43269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]; });
  43270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderFlags"]; });
  43271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCurves"]; });
  43272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectFallbacks"]; });
  43273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectCreationOptions"]; });
  43274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Effect"]; });
  43275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FresnelParameters"]; });
  43276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfigurationDefines"]; });
  43277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfiguration"]; });
  43278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Material"]; });
  43279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialDefines"]; });
  43280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialHelper"]; });
  43281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiMaterial"]; });
  43282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PushMaterial"]; });
  43283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderMaterial"]; });
  43284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterialDefines"]; });
  43285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]; });
  43286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  43287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"]; });
  43288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"]; });
  43289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InternalTexture"]; });
  43290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DummyInternalTextureTracker"]; });
  43291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MirrorTexture"]; });
  43292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiRenderTarget"]; });
  43293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture"]; });
  43294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetTexture"]; });
  43295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Texture"]; });
  43296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniformBuffer"]; });
  43297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialFlags"]; });
  43298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  43299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToGammaSpace"]; });
  43300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]; });
  43301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; });
  43302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3"]; });
  43303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color4"]; });
  43304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2"]; });
  43305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3"]; });
  43306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector4"]; });
  43307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Size"]; });
  43308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]; });
  43309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix"]; });
  43310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Plane"]; });
  43311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Viewport"]; });
  43312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Frustum"]; });
  43313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  43314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  43315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurve"]; });
  43316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Orientation"]; });
  43317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Angle"]; });
  43318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Arc2"]; });
  43319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path2"]; });
  43320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path3D"]; });
  43321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Curve3"]; });
  43322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]; });
  43323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalTextureVertex"]; });
  43324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tmp"]; });
  43325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]; });
  43326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"]; });
  43327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  43328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Buffer"]; });
  43329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"]; });
  43330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CSG"]; });
  43331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Geometry"]; });
  43332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundMesh"]; });
  43333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedMesh"]; });
  43334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesMesh"]; });
  43335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedLinesMesh"]; });
  43336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshLODLevel"]; });
  43337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_CreationDataStorage"]; });
  43338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_InstancesBatch"]; });
  43339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Mesh"]; });
  43340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexData"]; });
  43341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"]; });
  43342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationSettings"]; });
  43343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationQueue"]; });
  43344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationType"]; });
  43345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplicationQueueSceneComponent"]; });
  43346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Polygon"]; });
  43347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonMeshBuilder"]; });
  43348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSubMesh"]; });
  43349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubMesh"]; });
  43350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformNode"]; });
  43351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  43352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DiscBuilder"]; });
  43353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereBuilder"]; });
  43354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderBuilder"]; });
  43355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesBuilder"]; });
  43356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneBuilder"]; });
  43357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  43358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"]; });
  43359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  43360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  43361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GPUParticleSystem"]; });
  43362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Particle"]; });
  43363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleHelper"]; });
  43364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystem"]; });
  43365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IDoNeedToBeInTheBuild"]; });
  43366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystemSet"]; });
  43367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticle"]; });
  43368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ModelShape"]; });
  43369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthSortedParticle"]; });
  43370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticleSystem"]; });
  43371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitterType"]; });
  43372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitter"]; });
  43373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  43374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngineSceneComponent"]; });
  43375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsHelper"]; });
  43376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialExplosionEvent"]; });
  43377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsGravitationalFieldEvent"]; });
  43378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftEvent"]; });
  43379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsVortexEvent"]; });
  43380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialImpulseFalloff"]; });
  43381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftMode"]; });
  43382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"]; });
  43383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsJoint"]; });
  43384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DistanceJoint"]; });
  43385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotorEnabledJoint"]; });
  43386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HingeJoint"]; });
  43387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Hinge2Joint"]; });
  43388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  43389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlackAndWhitePostProcess"]; });
  43390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomEffect"]; });
  43391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomMergePostProcess"]; });
  43392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlurPostProcess"]; });
  43393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ChromaticAberrationPostProcess"]; });
  43394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleOfConfusionPostProcess"]; });
  43395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCorrectionPostProcess"]; });
  43396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConvolutionPostProcess"]; });
  43397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldBlurPostProcess"]; });
  43398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffectBlurLevel"]; });
  43399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffect"]; });
  43400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcessOptions"]; });
  43401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcess"]; });
  43402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayPassPostProcess"]; });
  43403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExtractHighlightsPostProcess"]; });
  43404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilterPostProcess"]; });
  43405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FxaaPostProcess"]; });
  43406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GrainPostProcess"]; });
  43407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightsPostProcess"]; });
  43408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingPostProcess"]; });
  43409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotionBlurPostProcess"]; });
  43410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassPostProcess"]; });
  43411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassCubePostProcess"]; });
  43412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcess"]; });
  43413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessManager"]; });
  43414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionPostProcess"]; });
  43415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SharpenPostProcess"]; });
  43416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicInterlacePostProcess"]; });
  43417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemappingOperator"]; });
  43418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemapPostProcess"]; });
  43419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumetricLightScatteringPostProcess"]; });
  43420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDistortionCorrectionPostProcess"]; });
  43421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  43422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  43423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRenderer"]; });
  43424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRendererSceneComponent"]; });
  43425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EdgesRenderer"]; });
  43426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LineEdgesRenderer"]; });
  43427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRenderer"]; });
  43428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRendererSceneComponent"]; });
  43429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OutlineRenderer"]; });
  43430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"]; });
  43431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroupInfo"]; });
  43432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingManager"]; });
  43433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"]; });
  43434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  43435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteManager"]; });
  43436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteSceneComponent"]; });
  43437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  43438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DepthCullingState"]; });
  43439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_StencilState"]; });
  43440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  43441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetTaskState"]; });
  43442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractAssetTask"]; });
  43443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsProgressEvent"]; });
  43444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshAssetTask"]; });
  43445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextFileAssetTask"]; });
  43446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BinaryFileAssetTask"]; });
  43447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageAssetTask"]; });
  43448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureAssetTask"]; });
  43449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTextureAssetTask"]; });
  43450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTextureAssetTask"]; });
  43451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsManager"]; });
  43452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DDSTools"]; });
  43453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["expandToProperty"]; });
  43454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serialize"]; });
  43455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsTexture"]; });
  43456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor3"]; });
  43457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsFresnelParameters"]; });
  43458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector2"]; });
  43459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector3"]; });
  43460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMeshReference"]; });
  43461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColorCurves"]; });
  43462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor4"]; });
  43463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsImageProcessingConfiguration"]; });
  43464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsQuaternion"]; });
  43465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsCameraReference"]; });
  43466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SerializationHelper"]; });
  43467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Deferred"]; });
  43468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"]; });
  43469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInput"]; });
  43470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"]; });
  43471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EventState"]; });
  43472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observer"]; });
  43473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiObserver"]; });
  43474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observable"]; });
  43475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerformanceMonitor"]; });
  43476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RollingAverage"]; });
  43477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PromisePolyfill"]; });
  43478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimization"]; });
  43479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureOptimization"]; });
  43480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HardwareScalingOptimization"]; });
  43481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowsOptimization"]; });
  43482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessesOptimization"]; });
  43483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlaresOptimization"]; });
  43484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomOptimization"]; });
  43485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticlesOptimization"]; });
  43486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetsOptimization"]; });
  43487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MergeMeshesOptimization"]; });
  43488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizerOptions"]; });
  43489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizer"]; });
  43490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"]; });
  43491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArray"]; });
  43492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"]; });
  43493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StringDictionary"]; });
  43494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tags"]; });
  43495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureTools"]; });
  43496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TGATools"]; });
  43497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradient"]; });
  43498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3Gradient"]; });
  43499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FactorGradient"]; });
  43500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"]; });
  43501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RetryStrategy"]; });
  43502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tools"]; });
  43503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]; });
  43504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["className"]; });
  43505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsyncLoop"]; });
  43506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoRecorder"]; });
  43507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"]; });
  43508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"]; });
  43509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WorkerPool"]; });
  43510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Logger"]; });
  43511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"]; });
  43512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInputStore"]; });
  43513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"]; });
  43514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PivotTools"]; });
  43515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"]; });
  43516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScreenshotTools"]; });
  43517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  43518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  43519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  43520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  43521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FadeInOutBehavior"]; });
  43522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiPointerScaleBehavior"]; });
  43523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]; });
  43524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SixDofDragBehavior"]; });
  43525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  43526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  43527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  43528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  43529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  43530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  43531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  43532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  43533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  43534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  43535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  43536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  43537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  43538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  43539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphFreeCamera"]; });
  43540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphGamepadCamera"]; });
  43541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphUniversalCamera"]; });
  43542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicArcRotateCamera"]; });
  43543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicFreeCamera"]; });
  43544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicGamepadCamera"]; });
  43545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicUniversalCamera"]; });
  43546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  43547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationArcRotateCamera"]; });
  43548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationFreeCamera"]; });
  43549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationGamepadCamera"]; });
  43550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRExperienceHelper"]; });
  43551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRFreeCamera"]; });
  43552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  43553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIButton"]; });
  43554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIOptions"]; });
  43555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUI"]; });
  43556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRState"]; });
  43557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"]; });
  43558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRController"]; });
  43559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRInput"]; });
  43560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRManagedOutputCanvas"]; });
  43561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRSessionManager"]; });
  43562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  43563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeBlock"]; });
  43564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeSceneComponent"]; });
  43565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  43566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceTransformFeedbackToBundle"]; });
  43567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  43568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGeneratorSceneComponent"]; });
  43569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  43570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  43571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  43572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseSimpleMaterial"]; });
  43573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]; });
  43574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]; });
  43575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRSpecularGlossinessMaterial"]; });
  43576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradingTexture"]; });
  43577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DynamicTexture"]; });
  43578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTexture"]; });
  43579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"]; });
  43580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture3D"]; });
  43581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionTexture"]; });
  43582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoTexture"]; });
  43583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  43584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"]; });
  43585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusBuilder"]; });
  43586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusKnotBuilder"]; });
  43587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonBuilder"]; });
  43588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShapeBuilder"]; });
  43589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LatheBuilder"]; });
  43590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundBuilder"]; });
  43591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TubeBuilder"]; });
  43592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolyhedronBuilder"]; });
  43593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IcoSphereBuilder"]; });
  43594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DecalBuilder"]; });
  43595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  43596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConeParticleEmitter"]; });
  43597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderParticleEmitter"]; });
  43598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderDirectedParticleEmitter"]; });
  43599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericParticleEmitter"]; });
  43600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointParticleEmitter"]; });
  43601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereParticleEmitter"]; });
  43602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereDirectedParticleEmitter"]; });
  43603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  43604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AmmoJSPlugin"]; });
  43605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OimoJSPlugin"]; });
  43606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderEffect"]; });
  43607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipeline"]; });
  43608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManager"]; });
  43609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManagerSceneComponent"]; });
  43610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  43611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRTools"]; });
  43612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"]; });
  43613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  43614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_ENVTextureLoader"]; });
  43615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_KTXTextureLoader"]; });
  43616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TGATextureLoader"]; });
  43617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  43618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NoiseProceduralTexture"]; });
  43619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTextureSceneComponent"]; });
  43620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  43621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  43622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  43623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  43624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  43625. /**
  43626. * Legacy support, defining window.BABYLON (global variable).
  43627. *
  43628. * This is the entry point for the UMD module.
  43629. * The entry point for a future ESM package should be index.ts
  43630. */
  43631. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  43632. if (typeof globalObject !== "undefined") {
  43633. globalObject.BABYLON = BABYLON;
  43634. globalObject.BABYLON = globalObject.BABYLON || {};
  43635. var BABYLON = globalObject.BABYLON;
  43636. BABYLON.Debug = BABYLON.Debug || {};
  43637. var keys = [];
  43638. for (var key in _Debug_index__WEBPACK_IMPORTED_MODULE_1__) {
  43639. BABYLON.Debug[key] = _Debug_index__WEBPACK_IMPORTED_MODULE_1__[key];
  43640. keys.push(key);
  43641. }
  43642. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  43643. // Prevent Reassignment.
  43644. // if (keys.indexOf(key) > -1) {
  43645. // continue;
  43646. // }
  43647. BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  43648. }
  43649. }
  43650. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  43651. /***/ }),
  43652. /***/ "./LensFlares/index.ts":
  43653. /*!*****************************!*\
  43654. !*** ./LensFlares/index.ts ***!
  43655. \*****************************/
  43656. /*! exports provided: LensFlare, LensFlareSystem, LensFlareSystemSceneComponent */
  43657. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43658. "use strict";
  43659. __webpack_require__.r(__webpack_exports__);
  43660. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  43661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _lensFlare__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  43662. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  43663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__["LensFlareSystem"]; });
  43664. /* harmony import */ var _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lensFlareSystemSceneComponent */ "./LensFlares/lensFlareSystemSceneComponent.ts");
  43665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__["LensFlareSystemSceneComponent"]; });
  43666. /***/ }),
  43667. /***/ "./LensFlares/lensFlare.ts":
  43668. /*!*********************************!*\
  43669. !*** ./LensFlares/lensFlare.ts ***!
  43670. \*********************************/
  43671. /*! exports provided: LensFlare */
  43672. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43673. "use strict";
  43674. __webpack_require__.r(__webpack_exports__);
  43675. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return LensFlare; });
  43676. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43677. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43678. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43679. /**
  43680. * This represents one of the lens effect in a `lensFlareSystem`.
  43681. * It controls one of the indiviual texture used in the effect.
  43682. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43683. */
  43684. var LensFlare = /** @class */ (function () {
  43685. /**
  43686. * Instantiates a new Lens Flare.
  43687. * This represents one of the lens effect in a `lensFlareSystem`.
  43688. * It controls one of the indiviual texture used in the effect.
  43689. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43690. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  43691. * @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.
  43692. * @param color Define the lens color
  43693. * @param imgUrl Define the lens texture url
  43694. * @param system Define the `lensFlareSystem` this flare is part of
  43695. */
  43696. function LensFlare(
  43697. /**
  43698. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  43699. */
  43700. size,
  43701. /**
  43702. * 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.
  43703. */
  43704. position, color, imgUrl, system) {
  43705. this.size = size;
  43706. this.position = position;
  43707. /**
  43708. * Define the alpha mode to render this particular lens.
  43709. */
  43710. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_ONEONE;
  43711. this.color = color || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](1, 1, 1);
  43712. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](imgUrl, system.getScene(), true) : null;
  43713. this._system = system;
  43714. system.lensFlares.push(this);
  43715. }
  43716. /**
  43717. * Creates a new Lens Flare.
  43718. * This represents one of the lens effect in a `lensFlareSystem`.
  43719. * It controls one of the indiviual texture used in the effect.
  43720. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43721. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  43722. * @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.
  43723. * @param color Define the lens color
  43724. * @param imgUrl Define the lens texture url
  43725. * @param system Define the `lensFlareSystem` this flare is part of
  43726. * @returns The newly created Lens Flare
  43727. */
  43728. LensFlare.AddFlare = function (size, position, color, imgUrl, system) {
  43729. return new LensFlare(size, position, color, imgUrl, system);
  43730. };
  43731. /**
  43732. * Dispose and release the lens flare with its associated resources.
  43733. */
  43734. LensFlare.prototype.dispose = function () {
  43735. if (this.texture) {
  43736. this.texture.dispose();
  43737. }
  43738. // Remove from scene
  43739. var index = this._system.lensFlares.indexOf(this);
  43740. this._system.lensFlares.splice(index, 1);
  43741. };
  43742. return LensFlare;
  43743. }());
  43744. /***/ }),
  43745. /***/ "./LensFlares/lensFlareSystem.ts":
  43746. /*!***************************************!*\
  43747. !*** ./LensFlares/lensFlareSystem.ts ***!
  43748. \***************************************/
  43749. /*! exports provided: LensFlareSystem */
  43750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43751. "use strict";
  43752. __webpack_require__.r(__webpack_exports__);
  43753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return LensFlareSystem; });
  43754. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  43755. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43756. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  43757. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  43758. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43759. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  43760. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43761. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  43762. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43763. /* harmony import */ var _Shaders_lensFlare_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/lensFlare.fragment */ "./Shaders/lensFlare.fragment.ts");
  43764. /* harmony import */ var _Shaders_lensFlare_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/lensFlare.vertex */ "./Shaders/lensFlare.vertex.ts");
  43765. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  43766. /**
  43767. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43768. * It is usually composed of several `lensFlare`.
  43769. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43770. */
  43771. var LensFlareSystem = /** @class */ (function () {
  43772. /**
  43773. * Instantiates a lens flare system.
  43774. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43775. * It is usually composed of several `lensFlare`.
  43776. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43777. * @param name Define the name of the lens flare system in the scene
  43778. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  43779. * @param scene Define the scene the lens flare system belongs to
  43780. */
  43781. function LensFlareSystem(
  43782. /**
  43783. * Define the name of the lens flare system
  43784. */
  43785. name, emitter, scene) {
  43786. this.name = name;
  43787. /**
  43788. * List of lens flares used in this system.
  43789. */
  43790. this.lensFlares = new Array();
  43791. /**
  43792. * Define a limit from the border the lens flare can be visible.
  43793. */
  43794. this.borderLimit = 300;
  43795. /**
  43796. * Define a viewport border we do not want to see the lens flare in.
  43797. */
  43798. this.viewportBorder = 0;
  43799. /**
  43800. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  43801. */
  43802. this.layerMask = 0x0FFFFFFF;
  43803. this._vertexBuffers = {};
  43804. this._isEnabled = true;
  43805. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  43806. LensFlareSystem._SceneComponentInitialization(this._scene);
  43807. this._emitter = emitter;
  43808. this.id = name;
  43809. scene.lensFlareSystems.push(this);
  43810. this.meshesSelectionPredicate = function (m) { return (scene.activeCamera && m.material && m.isVisible && m.isEnabled() && m.isBlocker && ((m.layerMask & scene.activeCamera.layerMask) != 0)); };
  43811. var engine = scene.getEngine();
  43812. // VBO
  43813. var vertices = [];
  43814. vertices.push(1, 1);
  43815. vertices.push(-1, 1);
  43816. vertices.push(-1, -1);
  43817. vertices.push(1, -1);
  43818. 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);
  43819. // Indices
  43820. var indices = [];
  43821. indices.push(0);
  43822. indices.push(1);
  43823. indices.push(2);
  43824. indices.push(0);
  43825. indices.push(2);
  43826. indices.push(3);
  43827. this._indexBuffer = engine.createIndexBuffer(indices);
  43828. // Effects
  43829. this._effect = engine.createEffect("lensFlare", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
  43830. }
  43831. Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
  43832. /**
  43833. * Define if the lens flare system is enabled.
  43834. */
  43835. get: function () {
  43836. return this._isEnabled;
  43837. },
  43838. set: function (value) {
  43839. this._isEnabled = value;
  43840. },
  43841. enumerable: true,
  43842. configurable: true
  43843. });
  43844. /**
  43845. * Get the scene the effects belongs to.
  43846. * @returns the scene holding the lens flare system
  43847. */
  43848. LensFlareSystem.prototype.getScene = function () {
  43849. return this._scene;
  43850. };
  43851. /**
  43852. * Get the emitter of the lens flare system.
  43853. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43854. * @returns the emitter of the lens flare system
  43855. */
  43856. LensFlareSystem.prototype.getEmitter = function () {
  43857. return this._emitter;
  43858. };
  43859. /**
  43860. * Set the emitter of the lens flare system.
  43861. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43862. * @param newEmitter Define the new emitter of the system
  43863. */
  43864. LensFlareSystem.prototype.setEmitter = function (newEmitter) {
  43865. this._emitter = newEmitter;
  43866. };
  43867. /**
  43868. * Get the lens flare system emitter position.
  43869. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  43870. * @returns the position
  43871. */
  43872. LensFlareSystem.prototype.getEmitterPosition = function () {
  43873. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
  43874. };
  43875. /**
  43876. * @hidden
  43877. */
  43878. LensFlareSystem.prototype.computeEffectivePosition = function (globalViewport) {
  43879. var position = this.getEmitterPosition();
  43880. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), this._scene.getTransformMatrix(), globalViewport);
  43881. this._positionX = position.x;
  43882. this._positionY = position.y;
  43883. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix());
  43884. if (this.viewportBorder > 0) {
  43885. globalViewport.x -= this.viewportBorder;
  43886. globalViewport.y -= this.viewportBorder;
  43887. globalViewport.width += this.viewportBorder * 2;
  43888. globalViewport.height += this.viewportBorder * 2;
  43889. position.x += this.viewportBorder;
  43890. position.y += this.viewportBorder;
  43891. this._positionX += this.viewportBorder;
  43892. this._positionY += this.viewportBorder;
  43893. }
  43894. if (position.z > 0) {
  43895. if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
  43896. if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
  43897. return true;
  43898. }
  43899. }
  43900. return true;
  43901. }
  43902. return false;
  43903. };
  43904. /** @hidden */
  43905. LensFlareSystem.prototype._isVisible = function () {
  43906. if (!this._isEnabled || !this._scene.activeCamera) {
  43907. return false;
  43908. }
  43909. var emitterPosition = this.getEmitterPosition();
  43910. var direction = emitterPosition.subtract(this._scene.activeCamera.globalPosition);
  43911. var distance = direction.length();
  43912. direction.normalize();
  43913. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](this._scene.activeCamera.globalPosition, direction);
  43914. var pickInfo = this._scene.pickWithRay(ray, this.meshesSelectionPredicate, true);
  43915. return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
  43916. };
  43917. /**
  43918. * @hidden
  43919. */
  43920. LensFlareSystem.prototype.render = function () {
  43921. if (!this._effect.isReady() || !this._scene.activeCamera) {
  43922. return false;
  43923. }
  43924. var engine = this._scene.getEngine();
  43925. var viewport = this._scene.activeCamera.viewport;
  43926. var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
  43927. // Position
  43928. if (!this.computeEffectivePosition(globalViewport)) {
  43929. return false;
  43930. }
  43931. // Visibility
  43932. if (!this._isVisible()) {
  43933. return false;
  43934. }
  43935. // Intensity
  43936. var awayX;
  43937. var awayY;
  43938. if (this._positionX < this.borderLimit + globalViewport.x) {
  43939. awayX = this.borderLimit + globalViewport.x - this._positionX;
  43940. }
  43941. else if (this._positionX > globalViewport.x + globalViewport.width - this.borderLimit) {
  43942. awayX = this._positionX - globalViewport.x - globalViewport.width + this.borderLimit;
  43943. }
  43944. else {
  43945. awayX = 0;
  43946. }
  43947. if (this._positionY < this.borderLimit + globalViewport.y) {
  43948. awayY = this.borderLimit + globalViewport.y - this._positionY;
  43949. }
  43950. else if (this._positionY > globalViewport.y + globalViewport.height - this.borderLimit) {
  43951. awayY = this._positionY - globalViewport.y - globalViewport.height + this.borderLimit;
  43952. }
  43953. else {
  43954. awayY = 0;
  43955. }
  43956. var away = (awayX > awayY) ? awayX : awayY;
  43957. away -= this.viewportBorder;
  43958. if (away > this.borderLimit) {
  43959. away = this.borderLimit;
  43960. }
  43961. var intensity = 1.0 - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(away / this.borderLimit, 0, 1);
  43962. if (intensity < 0) {
  43963. return false;
  43964. }
  43965. if (intensity > 1.0) {
  43966. intensity = 1.0;
  43967. }
  43968. if (this.viewportBorder > 0) {
  43969. globalViewport.x += this.viewportBorder;
  43970. globalViewport.y += this.viewportBorder;
  43971. globalViewport.width -= this.viewportBorder * 2;
  43972. globalViewport.height -= this.viewportBorder * 2;
  43973. this._positionX -= this.viewportBorder;
  43974. this._positionY -= this.viewportBorder;
  43975. }
  43976. // Position
  43977. var centerX = globalViewport.x + globalViewport.width / 2;
  43978. var centerY = globalViewport.y + globalViewport.height / 2;
  43979. var distX = centerX - this._positionX;
  43980. var distY = centerY - this._positionY;
  43981. // Effects
  43982. engine.enableEffect(this._effect);
  43983. engine.setState(false);
  43984. engine.setDepthBuffer(false);
  43985. // VBOs
  43986. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  43987. // Flares
  43988. for (var index = 0; index < this.lensFlares.length; index++) {
  43989. var flare = this.lensFlares[index];
  43990. engine.setAlphaMode(flare.alphaMode);
  43991. var x = centerX - (distX * flare.position);
  43992. var y = centerY - (distY * flare.position);
  43993. var cw = flare.size;
  43994. var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
  43995. var cx = 2 * (x / (globalViewport.width + globalViewport.x * 2)) - 1.0;
  43996. var cy = 1.0 - 2 * (y / (globalViewport.height + globalViewport.y * 2));
  43997. 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);
  43998. this._effect.setMatrix("viewportMatrix", viewportMatrix);
  43999. // Texture
  44000. this._effect.setTexture("textureSampler", flare.texture);
  44001. // Color
  44002. this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
  44003. // Draw order
  44004. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  44005. }
  44006. engine.setDepthBuffer(true);
  44007. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  44008. return true;
  44009. };
  44010. /**
  44011. * Dispose and release the lens flare with its associated resources.
  44012. */
  44013. LensFlareSystem.prototype.dispose = function () {
  44014. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  44015. if (vertexBuffer) {
  44016. vertexBuffer.dispose();
  44017. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  44018. }
  44019. if (this._indexBuffer) {
  44020. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  44021. this._indexBuffer = null;
  44022. }
  44023. while (this.lensFlares.length) {
  44024. this.lensFlares[0].dispose();
  44025. }
  44026. // Remove from scene
  44027. var index = this._scene.lensFlareSystems.indexOf(this);
  44028. this._scene.lensFlareSystems.splice(index, 1);
  44029. };
  44030. /**
  44031. * Parse a lens flare system from a JSON repressentation
  44032. * @param parsedLensFlareSystem Define the JSON to parse
  44033. * @param scene Define the scene the parsed system should be instantiated in
  44034. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  44035. * @returns the parsed system
  44036. */
  44037. LensFlareSystem.Parse = function (parsedLensFlareSystem, scene, rootUrl) {
  44038. var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
  44039. var name = parsedLensFlareSystem.name || "lensFlareSystem#" + parsedLensFlareSystem.emitterId;
  44040. var lensFlareSystem = new LensFlareSystem(name, emitter, scene);
  44041. lensFlareSystem.id = parsedLensFlareSystem.id || name;
  44042. lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
  44043. for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
  44044. var parsedFlare = parsedLensFlareSystem.flares[index];
  44045. _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);
  44046. }
  44047. return lensFlareSystem;
  44048. };
  44049. /**
  44050. * Serialize the current Lens Flare System into a JSON representation.
  44051. * @returns the serialized JSON
  44052. */
  44053. LensFlareSystem.prototype.serialize = function () {
  44054. var serializationObject = {};
  44055. serializationObject.id = this.id;
  44056. serializationObject.name = this.name;
  44057. serializationObject.emitterId = this.getEmitter().id;
  44058. serializationObject.borderLimit = this.borderLimit;
  44059. serializationObject.flares = [];
  44060. for (var index = 0; index < this.lensFlares.length; index++) {
  44061. var flare = this.lensFlares[index];
  44062. serializationObject.flares.push({
  44063. size: flare.size,
  44064. position: flare.position,
  44065. color: flare.color.asArray(),
  44066. textureName: _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(flare.texture ? flare.texture.name : "")
  44067. });
  44068. }
  44069. return serializationObject;
  44070. };
  44071. /** @hidden */
  44072. LensFlareSystem._SceneComponentInitialization = function (_) {
  44073. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("LensFlareSystemSceneComponent");
  44074. };
  44075. return LensFlareSystem;
  44076. }());
  44077. /***/ }),
  44078. /***/ "./LensFlares/lensFlareSystemSceneComponent.ts":
  44079. /*!*****************************************************!*\
  44080. !*** ./LensFlares/lensFlareSystemSceneComponent.ts ***!
  44081. \*****************************************************/
  44082. /*! exports provided: LensFlareSystemSceneComponent */
  44083. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44084. "use strict";
  44085. __webpack_require__.r(__webpack_exports__);
  44086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return LensFlareSystemSceneComponent; });
  44087. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  44088. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  44089. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  44090. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  44091. // Adds the parser to the scene parsers.
  44092. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM, function (parsedData, scene, container, rootUrl) {
  44093. // Lens flares
  44094. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  44095. if (!container.lensFlareSystems) {
  44096. container.lensFlareSystems = new Array();
  44097. }
  44098. for (var index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  44099. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  44100. var lf = _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"].Parse(parsedLensFlareSystem, scene, rootUrl);
  44101. container.lensFlareSystems.push(lf);
  44102. }
  44103. }
  44104. });
  44105. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByName = function (name) {
  44106. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  44107. if (this.lensFlareSystems[index].name === name) {
  44108. return this.lensFlareSystems[index];
  44109. }
  44110. }
  44111. return null;
  44112. };
  44113. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByID = function (id) {
  44114. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  44115. if (this.lensFlareSystems[index].id === id) {
  44116. return this.lensFlareSystems[index];
  44117. }
  44118. }
  44119. return null;
  44120. };
  44121. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.removeLensFlareSystem = function (toRemove) {
  44122. var index = this.lensFlareSystems.indexOf(toRemove);
  44123. if (index !== -1) {
  44124. this.lensFlareSystems.splice(index, 1);
  44125. }
  44126. return index;
  44127. };
  44128. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.addLensFlareSystem = function (newLensFlareSystem) {
  44129. this.lensFlareSystems.push(newLensFlareSystem);
  44130. };
  44131. /**
  44132. * Defines the lens flare scene component responsible to manage any lens flares
  44133. * in a given scene.
  44134. */
  44135. var LensFlareSystemSceneComponent = /** @class */ (function () {
  44136. /**
  44137. * Creates a new instance of the component for the given scene
  44138. * @param scene Defines the scene to register the component in
  44139. */
  44140. function LensFlareSystemSceneComponent(scene) {
  44141. /**
  44142. * The component name helpfull to identify the component in the list of scene components.
  44143. */
  44144. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM;
  44145. this.scene = scene;
  44146. scene.lensFlareSystems = new Array();
  44147. }
  44148. /**
  44149. * Registers the component in a given scene
  44150. */
  44151. LensFlareSystemSceneComponent.prototype.register = function () {
  44152. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
  44153. };
  44154. /**
  44155. * Rebuilds the elements related to this component in case of
  44156. * context lost for instance.
  44157. */
  44158. LensFlareSystemSceneComponent.prototype.rebuild = function () {
  44159. // Nothing to do for lens flare
  44160. };
  44161. /**
  44162. * Adds all the element from the container to the scene
  44163. * @param container the container holding the elements
  44164. */
  44165. LensFlareSystemSceneComponent.prototype.addFromContainer = function (container) {
  44166. var _this = this;
  44167. if (!container.lensFlareSystems) {
  44168. return;
  44169. }
  44170. container.lensFlareSystems.forEach(function (o) {
  44171. _this.scene.addLensFlareSystem(o);
  44172. });
  44173. };
  44174. /**
  44175. * Removes all the elements in the container from the scene
  44176. * @param container contains the elements to remove
  44177. */
  44178. LensFlareSystemSceneComponent.prototype.removeFromContainer = function (container) {
  44179. var _this = this;
  44180. if (!container.lensFlareSystems) {
  44181. return;
  44182. }
  44183. container.lensFlareSystems.forEach(function (o) {
  44184. _this.scene.removeLensFlareSystem(o);
  44185. });
  44186. };
  44187. /**
  44188. * Serializes the component data to the specified json object
  44189. * @param serializationObject The object to serialize to
  44190. */
  44191. LensFlareSystemSceneComponent.prototype.serialize = function (serializationObject) {
  44192. // Lens flares
  44193. serializationObject.lensFlareSystems = [];
  44194. var lensFlareSystems = this.scene.lensFlareSystems;
  44195. for (var _i = 0, lensFlareSystems_1 = lensFlareSystems; _i < lensFlareSystems_1.length; _i++) {
  44196. var lensFlareSystem = lensFlareSystems_1[_i];
  44197. serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());
  44198. }
  44199. };
  44200. /**
  44201. * Disposes the component and the associated ressources.
  44202. */
  44203. LensFlareSystemSceneComponent.prototype.dispose = function () {
  44204. var lensFlareSystems = this.scene.lensFlareSystems;
  44205. while (lensFlareSystems.length) {
  44206. lensFlareSystems[0].dispose();
  44207. }
  44208. };
  44209. LensFlareSystemSceneComponent.prototype._draw = function (camera) {
  44210. // Lens flares
  44211. if (this.scene.lensFlaresEnabled) {
  44212. var lensFlareSystems = this.scene.lensFlareSystems;
  44213. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  44214. for (var _i = 0, lensFlareSystems_2 = lensFlareSystems; _i < lensFlareSystems_2.length; _i++) {
  44215. var lensFlareSystem = lensFlareSystems_2[_i];
  44216. if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
  44217. lensFlareSystem.render();
  44218. }
  44219. }
  44220. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  44221. }
  44222. };
  44223. return LensFlareSystemSceneComponent;
  44224. }());
  44225. _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"]._SceneComponentInitialization = function (scene) {
  44226. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM);
  44227. if (!component) {
  44228. component = new LensFlareSystemSceneComponent(scene);
  44229. scene._addComponent(component);
  44230. }
  44231. };
  44232. /***/ }),
  44233. /***/ "./Lights/Shadows/index.ts":
  44234. /*!*********************************!*\
  44235. !*** ./Lights/Shadows/index.ts ***!
  44236. \*********************************/
  44237. /*! exports provided: ShadowGenerator, ShadowGeneratorSceneComponent */
  44238. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44239. "use strict";
  44240. __webpack_require__.r(__webpack_exports__);
  44241. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  44242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  44243. /* harmony import */ var _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowGeneratorSceneComponent */ "./Lights/Shadows/shadowGeneratorSceneComponent.ts");
  44244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__["ShadowGeneratorSceneComponent"]; });
  44245. /***/ }),
  44246. /***/ "./Lights/Shadows/shadowGenerator.ts":
  44247. /*!*******************************************!*\
  44248. !*** ./Lights/Shadows/shadowGenerator.ts ***!
  44249. \*******************************************/
  44250. /*! exports provided: ShadowGenerator */
  44251. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44252. "use strict";
  44253. __webpack_require__.r(__webpack_exports__);
  44254. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return ShadowGenerator; });
  44255. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  44256. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  44257. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  44258. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  44259. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  44260. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  44261. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  44262. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  44263. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  44264. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  44265. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  44266. /* harmony import */ var _Shaders_shadowMap_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Shaders/shadowMap.fragment */ "./Shaders/shadowMap.fragment.ts");
  44267. /* harmony import */ var _Shaders_shadowMap_vertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Shaders/shadowMap.vertex */ "./Shaders/shadowMap.vertex.ts");
  44268. /* harmony import */ var _Shaders_depthBoxBlur_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Shaders/depthBoxBlur.fragment */ "./Shaders/depthBoxBlur.fragment.ts");
  44269. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  44270. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  44271. /**
  44272. * Default implementation IShadowGenerator.
  44273. * This is the main object responsible of generating shadows in the framework.
  44274. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44275. */
  44276. var ShadowGenerator = /** @class */ (function () {
  44277. /**
  44278. * Creates a ShadowGenerator object.
  44279. * A ShadowGenerator is the required tool to use the shadows.
  44280. * Each light casting shadows needs to use its own ShadowGenerator.
  44281. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44282. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44283. * @param light The light object generating the shadows.
  44284. * @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.
  44285. */
  44286. function ShadowGenerator(mapSize, light, usefulFloatFirst) {
  44287. /**
  44288. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  44289. */
  44290. this.onBeforeShadowMapRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  44291. this._bias = 0.00005;
  44292. this._normalBias = 0;
  44293. this._blurBoxOffset = 1;
  44294. this._blurScale = 2;
  44295. this._blurKernel = 1;
  44296. this._useKernelBlur = false;
  44297. this._filter = ShadowGenerator.FILTER_NONE;
  44298. this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
  44299. this._contactHardeningLightSizeUVRatio = 0.1;
  44300. this._darkness = 0;
  44301. this._transparencyShadow = false;
  44302. /**
  44303. * Controls the extent to which the shadows fade out at the edge of the frustum
  44304. * Used only by directionals and spots
  44305. */
  44306. this.frustumEdgeFalloff = 0;
  44307. /**
  44308. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44309. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44310. * It might on the other hand introduce peter panning.
  44311. */
  44312. this.forceBackFacesOnly = false;
  44313. this._lightDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  44314. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44315. this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44316. this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44317. this._cachedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  44318. this._cachedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  44319. this._currentFaceIndex = 0;
  44320. this._currentFaceIndexCache = 0;
  44321. this._defaultTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  44322. this._mapSize = mapSize;
  44323. this._light = light;
  44324. this._scene = light.getScene();
  44325. light._shadowGenerator = this;
  44326. ShadowGenerator._SceneComponentInitialization(this._scene);
  44327. // Texture type fallback from float to int if not supported.
  44328. var caps = this._scene.getEngine().getCaps();
  44329. if (!usefulFloatFirst) {
  44330. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  44331. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  44332. }
  44333. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  44334. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  44335. }
  44336. else {
  44337. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  44338. }
  44339. }
  44340. else {
  44341. if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  44342. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  44343. }
  44344. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  44345. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  44346. }
  44347. else {
  44348. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  44349. }
  44350. }
  44351. this._initializeGenerator();
  44352. this._applyFilterValues();
  44353. }
  44354. Object.defineProperty(ShadowGenerator.prototype, "bias", {
  44355. /**
  44356. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44357. */
  44358. get: function () {
  44359. return this._bias;
  44360. },
  44361. /**
  44362. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44363. */
  44364. set: function (bias) {
  44365. this._bias = bias;
  44366. },
  44367. enumerable: true,
  44368. configurable: true
  44369. });
  44370. Object.defineProperty(ShadowGenerator.prototype, "normalBias", {
  44371. /**
  44372. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44373. */
  44374. get: function () {
  44375. return this._normalBias;
  44376. },
  44377. /**
  44378. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44379. */
  44380. set: function (normalBias) {
  44381. this._normalBias = normalBias;
  44382. },
  44383. enumerable: true,
  44384. configurable: true
  44385. });
  44386. Object.defineProperty(ShadowGenerator.prototype, "blurBoxOffset", {
  44387. /**
  44388. * Gets the blur box offset: offset applied during the blur pass.
  44389. * Only useful if useKernelBlur = false
  44390. */
  44391. get: function () {
  44392. return this._blurBoxOffset;
  44393. },
  44394. /**
  44395. * Sets the blur box offset: offset applied during the blur pass.
  44396. * Only useful if useKernelBlur = false
  44397. */
  44398. set: function (value) {
  44399. if (this._blurBoxOffset === value) {
  44400. return;
  44401. }
  44402. this._blurBoxOffset = value;
  44403. this._disposeBlurPostProcesses();
  44404. },
  44405. enumerable: true,
  44406. configurable: true
  44407. });
  44408. Object.defineProperty(ShadowGenerator.prototype, "blurScale", {
  44409. /**
  44410. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44411. * 2 means half of the size.
  44412. */
  44413. get: function () {
  44414. return this._blurScale;
  44415. },
  44416. /**
  44417. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44418. * 2 means half of the size.
  44419. */
  44420. set: function (value) {
  44421. if (this._blurScale === value) {
  44422. return;
  44423. }
  44424. this._blurScale = value;
  44425. this._disposeBlurPostProcesses();
  44426. },
  44427. enumerable: true,
  44428. configurable: true
  44429. });
  44430. Object.defineProperty(ShadowGenerator.prototype, "blurKernel", {
  44431. /**
  44432. * Gets the blur kernel: kernel size of the blur pass.
  44433. * Only useful if useKernelBlur = true
  44434. */
  44435. get: function () {
  44436. return this._blurKernel;
  44437. },
  44438. /**
  44439. * Sets the blur kernel: kernel size of the blur pass.
  44440. * Only useful if useKernelBlur = true
  44441. */
  44442. set: function (value) {
  44443. if (this._blurKernel === value) {
  44444. return;
  44445. }
  44446. this._blurKernel = value;
  44447. this._disposeBlurPostProcesses();
  44448. },
  44449. enumerable: true,
  44450. configurable: true
  44451. });
  44452. Object.defineProperty(ShadowGenerator.prototype, "useKernelBlur", {
  44453. /**
  44454. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44455. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44456. */
  44457. get: function () {
  44458. return this._useKernelBlur;
  44459. },
  44460. /**
  44461. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44462. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44463. */
  44464. set: function (value) {
  44465. if (this._useKernelBlur === value) {
  44466. return;
  44467. }
  44468. this._useKernelBlur = value;
  44469. this._disposeBlurPostProcesses();
  44470. },
  44471. enumerable: true,
  44472. configurable: true
  44473. });
  44474. Object.defineProperty(ShadowGenerator.prototype, "depthScale", {
  44475. /**
  44476. * Gets the depth scale used in ESM mode.
  44477. */
  44478. get: function () {
  44479. return this._depthScale !== undefined ? this._depthScale : this._light.getDepthScale();
  44480. },
  44481. /**
  44482. * Sets the depth scale used in ESM mode.
  44483. * This can override the scale stored on the light.
  44484. */
  44485. set: function (value) {
  44486. this._depthScale = value;
  44487. },
  44488. enumerable: true,
  44489. configurable: true
  44490. });
  44491. Object.defineProperty(ShadowGenerator.prototype, "filter", {
  44492. /**
  44493. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44494. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44495. */
  44496. get: function () {
  44497. return this._filter;
  44498. },
  44499. /**
  44500. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44501. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44502. */
  44503. set: function (value) {
  44504. // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
  44505. if (this._light.needCube()) {
  44506. if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  44507. this.useExponentialShadowMap = true;
  44508. return;
  44509. }
  44510. else if (value === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  44511. this.useCloseExponentialShadowMap = true;
  44512. return;
  44513. }
  44514. // PCF on cubemap would also be expensive
  44515. else if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  44516. this.usePoissonSampling = true;
  44517. return;
  44518. }
  44519. }
  44520. // Weblg1 fallback for PCF.
  44521. if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  44522. if (this._scene.getEngine().webGLVersion === 1) {
  44523. this.usePoissonSampling = true;
  44524. return;
  44525. }
  44526. }
  44527. if (this._filter === value) {
  44528. return;
  44529. }
  44530. this._filter = value;
  44531. this._disposeBlurPostProcesses();
  44532. this._applyFilterValues();
  44533. this._light._markMeshesAsLightDirty();
  44534. },
  44535. enumerable: true,
  44536. configurable: true
  44537. });
  44538. Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
  44539. /**
  44540. * Gets if the current filter is set to Poisson Sampling.
  44541. */
  44542. get: function () {
  44543. return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
  44544. },
  44545. /**
  44546. * Sets the current filter to Poisson Sampling.
  44547. */
  44548. set: function (value) {
  44549. if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
  44550. return;
  44551. }
  44552. this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
  44553. },
  44554. enumerable: true,
  44555. configurable: true
  44556. });
  44557. Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
  44558. /**
  44559. * Gets if the current filter is set to ESM.
  44560. */
  44561. get: function () {
  44562. return this.filter === ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP;
  44563. },
  44564. /**
  44565. * Sets the current filter is to ESM.
  44566. */
  44567. set: function (value) {
  44568. if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
  44569. return;
  44570. }
  44571. this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44572. },
  44573. enumerable: true,
  44574. configurable: true
  44575. });
  44576. Object.defineProperty(ShadowGenerator.prototype, "useBlurExponentialShadowMap", {
  44577. /**
  44578. * Gets if the current filter is set to filtered ESM.
  44579. */
  44580. get: function () {
  44581. return this.filter === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP;
  44582. },
  44583. /**
  44584. * Gets if the current filter is set to filtered ESM.
  44585. */
  44586. set: function (value) {
  44587. if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  44588. return;
  44589. }
  44590. this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44591. },
  44592. enumerable: true,
  44593. configurable: true
  44594. });
  44595. Object.defineProperty(ShadowGenerator.prototype, "useCloseExponentialShadowMap", {
  44596. /**
  44597. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44598. * exponential to prevent steep falloff artifacts).
  44599. */
  44600. get: function () {
  44601. return this.filter === ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP;
  44602. },
  44603. /**
  44604. * Sets the current filter to "close ESM" (using the inverse of the
  44605. * exponential to prevent steep falloff artifacts).
  44606. */
  44607. set: function (value) {
  44608. if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
  44609. return;
  44610. }
  44611. this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44612. },
  44613. enumerable: true,
  44614. configurable: true
  44615. });
  44616. Object.defineProperty(ShadowGenerator.prototype, "useBlurCloseExponentialShadowMap", {
  44617. /**
  44618. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44619. * exponential to prevent steep falloff artifacts).
  44620. */
  44621. get: function () {
  44622. return this.filter === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  44623. },
  44624. /**
  44625. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44626. * exponential to prevent steep falloff artifacts).
  44627. */
  44628. set: function (value) {
  44629. if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  44630. return;
  44631. }
  44632. this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44633. },
  44634. enumerable: true,
  44635. configurable: true
  44636. });
  44637. Object.defineProperty(ShadowGenerator.prototype, "usePercentageCloserFiltering", {
  44638. /**
  44639. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44640. */
  44641. get: function () {
  44642. return this.filter === ShadowGenerator.FILTER_PCF;
  44643. },
  44644. /**
  44645. * Sets the current filter to "PCF" (percentage closer filtering).
  44646. */
  44647. set: function (value) {
  44648. if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
  44649. return;
  44650. }
  44651. this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
  44652. },
  44653. enumerable: true,
  44654. configurable: true
  44655. });
  44656. Object.defineProperty(ShadowGenerator.prototype, "filteringQuality", {
  44657. /**
  44658. * Gets the PCF or PCSS Quality.
  44659. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44660. */
  44661. get: function () {
  44662. return this._filteringQuality;
  44663. },
  44664. /**
  44665. * Sets the PCF or PCSS Quality.
  44666. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44667. */
  44668. set: function (filteringQuality) {
  44669. this._filteringQuality = filteringQuality;
  44670. },
  44671. enumerable: true,
  44672. configurable: true
  44673. });
  44674. Object.defineProperty(ShadowGenerator.prototype, "useContactHardeningShadow", {
  44675. /**
  44676. * Gets if the current filter is set to "PCSS" (contact hardening).
  44677. */
  44678. get: function () {
  44679. return this.filter === ShadowGenerator.FILTER_PCSS;
  44680. },
  44681. /**
  44682. * Sets the current filter to "PCSS" (contact hardening).
  44683. */
  44684. set: function (value) {
  44685. if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
  44686. return;
  44687. }
  44688. this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
  44689. },
  44690. enumerable: true,
  44691. configurable: true
  44692. });
  44693. Object.defineProperty(ShadowGenerator.prototype, "contactHardeningLightSizeUVRatio", {
  44694. /**
  44695. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44696. * Using a ratio helps keeping shape stability independently of the map size.
  44697. *
  44698. * It does not account for the light projection as it was having too much
  44699. * instability during the light setup or during light position changes.
  44700. *
  44701. * Only valid if useContactHardeningShadow is true.
  44702. */
  44703. get: function () {
  44704. return this._contactHardeningLightSizeUVRatio;
  44705. },
  44706. /**
  44707. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44708. * Using a ratio helps keeping shape stability independently of the map size.
  44709. *
  44710. * It does not account for the light projection as it was having too much
  44711. * instability during the light setup or during light position changes.
  44712. *
  44713. * Only valid if useContactHardeningShadow is true.
  44714. */
  44715. set: function (contactHardeningLightSizeUVRatio) {
  44716. this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
  44717. },
  44718. enumerable: true,
  44719. configurable: true
  44720. });
  44721. /**
  44722. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44723. * 0 means strongest and 1 would means no shadow.
  44724. * @returns the darkness.
  44725. */
  44726. ShadowGenerator.prototype.getDarkness = function () {
  44727. return this._darkness;
  44728. };
  44729. /**
  44730. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44731. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44732. * @returns the shadow generator allowing fluent coding.
  44733. */
  44734. ShadowGenerator.prototype.setDarkness = function (darkness) {
  44735. if (darkness >= 1.0) {
  44736. this._darkness = 1.0;
  44737. }
  44738. else if (darkness <= 0.0) {
  44739. this._darkness = 0.0;
  44740. }
  44741. else {
  44742. this._darkness = darkness;
  44743. }
  44744. return this;
  44745. };
  44746. /**
  44747. * Sets the ability to have transparent shadow (boolean).
  44748. * @param transparent True if transparent else False
  44749. * @returns the shadow generator allowing fluent coding
  44750. */
  44751. ShadowGenerator.prototype.setTransparencyShadow = function (transparent) {
  44752. this._transparencyShadow = transparent;
  44753. return this;
  44754. };
  44755. /**
  44756. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44757. * @returns The render target texture if present otherwise, null
  44758. */
  44759. ShadowGenerator.prototype.getShadowMap = function () {
  44760. return this._shadowMap;
  44761. };
  44762. /**
  44763. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44764. * @returns The render target texture if the shadow map is present otherwise, null
  44765. */
  44766. ShadowGenerator.prototype.getShadowMapForRendering = function () {
  44767. if (this._shadowMap2) {
  44768. return this._shadowMap2;
  44769. }
  44770. return this._shadowMap;
  44771. };
  44772. /**
  44773. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44774. * @param mesh Mesh to add
  44775. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44776. * @returns the Shadow Generator itself
  44777. */
  44778. ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
  44779. if (includeDescendants === void 0) { includeDescendants = true; }
  44780. var _a;
  44781. if (!this._shadowMap) {
  44782. return this;
  44783. }
  44784. if (!this._shadowMap.renderList) {
  44785. this._shadowMap.renderList = [];
  44786. }
  44787. this._shadowMap.renderList.push(mesh);
  44788. if (includeDescendants) {
  44789. (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
  44790. }
  44791. return this;
  44792. };
  44793. /**
  44794. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44795. * @param mesh Mesh to remove
  44796. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44797. * @returns the Shadow Generator itself
  44798. */
  44799. ShadowGenerator.prototype.removeShadowCaster = function (mesh, includeDescendants) {
  44800. if (includeDescendants === void 0) { includeDescendants = true; }
  44801. if (!this._shadowMap || !this._shadowMap.renderList) {
  44802. return this;
  44803. }
  44804. var index = this._shadowMap.renderList.indexOf(mesh);
  44805. if (index !== -1) {
  44806. this._shadowMap.renderList.splice(index, 1);
  44807. }
  44808. if (includeDescendants) {
  44809. for (var _i = 0, _a = mesh.getChildren(); _i < _a.length; _i++) {
  44810. var child = _a[_i];
  44811. this.removeShadowCaster(child);
  44812. }
  44813. }
  44814. return this;
  44815. };
  44816. /**
  44817. * Returns the associated light object.
  44818. * @returns the light generating the shadow
  44819. */
  44820. ShadowGenerator.prototype.getLight = function () {
  44821. return this._light;
  44822. };
  44823. ShadowGenerator.prototype._initializeGenerator = function () {
  44824. this._light._markMeshesAsLightDirty();
  44825. this._initializeShadowMap();
  44826. };
  44827. ShadowGenerator.prototype._initializeShadowMap = function () {
  44828. var _this = this;
  44829. // Render target
  44830. var engine = this._scene.getEngine();
  44831. if (engine.webGLVersion > 1) {
  44832. 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);
  44833. this._shadowMap.createDepthStencilTexture(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].LESS, true);
  44834. }
  44835. else {
  44836. 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());
  44837. }
  44838. this._shadowMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44839. this._shadowMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44840. this._shadowMap.anisotropicFilteringLevel = 1;
  44841. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  44842. this._shadowMap.renderParticles = false;
  44843. this._shadowMap.ignoreCameraViewport = true;
  44844. // Record Face Index before render.
  44845. this._shadowMap.onBeforeRenderObservable.add(function (faceIndex) {
  44846. _this._currentFaceIndex = faceIndex;
  44847. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44848. engine.setColorWrite(false);
  44849. }
  44850. });
  44851. // Custom render function.
  44852. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
  44853. // Blur if required afer render.
  44854. this._shadowMap.onAfterUnbindObservable.add(function () {
  44855. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44856. engine.setColorWrite(true);
  44857. }
  44858. if (!_this.useBlurExponentialShadowMap && !_this.useBlurCloseExponentialShadowMap) {
  44859. return;
  44860. }
  44861. var shadowMap = _this.getShadowMapForRendering();
  44862. if (shadowMap) {
  44863. _this._scene.postProcessManager.directRender(_this._blurPostProcesses, shadowMap.getInternalTexture(), true);
  44864. }
  44865. });
  44866. // Clear according to the chosen filter.
  44867. var clearZero = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  44868. var clearOne = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  44869. this._shadowMap.onClearObservable.add(function (engine) {
  44870. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44871. engine.clear(clearOne, false, true, false);
  44872. }
  44873. else if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
  44874. engine.clear(clearZero, true, true, false);
  44875. }
  44876. else {
  44877. engine.clear(clearOne, true, true, false);
  44878. }
  44879. });
  44880. };
  44881. ShadowGenerator.prototype._initializeBlurRTTAndPostProcesses = function () {
  44882. var _this = this;
  44883. var engine = this._scene.getEngine();
  44884. var targetSize = this._mapSize / this.blurScale;
  44885. if (!this.useKernelBlur || this.blurScale !== 1.0) {
  44886. this._shadowMap2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap2", targetSize, this._scene, false, true, this._textureType);
  44887. this._shadowMap2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44888. this._shadowMap2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44889. this._shadowMap2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  44890. }
  44891. if (this.useKernelBlur) {
  44892. 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);
  44893. this._kernelBlurXPostprocess.width = targetSize;
  44894. this._kernelBlurXPostprocess.height = targetSize;
  44895. this._kernelBlurXPostprocess.onApplyObservable.add(function (effect) {
  44896. effect.setTexture("textureSampler", _this._shadowMap);
  44897. });
  44898. 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);
  44899. this._kernelBlurXPostprocess.autoClear = false;
  44900. this._kernelBlurYPostprocess.autoClear = false;
  44901. if (this._textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  44902. this._kernelBlurXPostprocess.packedFloat = true;
  44903. this._kernelBlurYPostprocess.packedFloat = true;
  44904. }
  44905. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess];
  44906. }
  44907. else {
  44908. 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);
  44909. this._boxBlurPostprocess.onApplyObservable.add(function (effect) {
  44910. effect.setFloat2("screenSize", targetSize, targetSize);
  44911. effect.setTexture("textureSampler", _this._shadowMap);
  44912. });
  44913. this._boxBlurPostprocess.autoClear = false;
  44914. this._blurPostProcesses = [this._boxBlurPostprocess];
  44915. }
  44916. };
  44917. ShadowGenerator.prototype._renderForShadowMap = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  44918. var index;
  44919. var engine = this._scene.getEngine();
  44920. if (depthOnlySubMeshes.length) {
  44921. engine.setColorWrite(false);
  44922. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  44923. this._renderSubMeshForShadowMap(depthOnlySubMeshes.data[index]);
  44924. }
  44925. engine.setColorWrite(true);
  44926. }
  44927. for (index = 0; index < opaqueSubMeshes.length; index++) {
  44928. this._renderSubMeshForShadowMap(opaqueSubMeshes.data[index]);
  44929. }
  44930. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  44931. this._renderSubMeshForShadowMap(alphaTestSubMeshes.data[index]);
  44932. }
  44933. if (this._transparencyShadow) {
  44934. for (index = 0; index < transparentSubMeshes.length; index++) {
  44935. this._renderSubMeshForShadowMap(transparentSubMeshes.data[index]);
  44936. }
  44937. }
  44938. };
  44939. ShadowGenerator.prototype._renderSubMeshForShadowMap = function (subMesh) {
  44940. var _this = this;
  44941. var mesh = subMesh.getRenderingMesh();
  44942. var scene = this._scene;
  44943. var engine = scene.getEngine();
  44944. var material = subMesh.getMaterial();
  44945. if (!material || subMesh.verticesCount === 0) {
  44946. return;
  44947. }
  44948. // Culling
  44949. engine.setState(material.backFaceCulling);
  44950. // Managing instances
  44951. var batch = mesh._getInstancesRenderList(subMesh._id);
  44952. if (batch.mustReturn) {
  44953. return;
  44954. }
  44955. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  44956. if (this.isReady(subMesh, hardwareInstancedRendering)) {
  44957. engine.enableEffect(this._effect);
  44958. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  44959. this._effect.setFloat3("biasAndScale", this.bias, this.normalBias, this.depthScale);
  44960. this._effect.setMatrix("viewProjection", this.getTransformMatrix());
  44961. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  44962. this._effect.setVector3("lightData", this._cachedDirection);
  44963. }
  44964. else {
  44965. this._effect.setVector3("lightData", this._cachedPosition);
  44966. }
  44967. if (scene.activeCamera) {
  44968. this._effect.setFloat2("depthValues", this.getLight().getDepthMinZ(scene.activeCamera), this.getLight().getDepthMinZ(scene.activeCamera) + this.getLight().getDepthMaxZ(scene.activeCamera));
  44969. }
  44970. // Alpha test
  44971. if (material && material.needAlphaTesting()) {
  44972. var alphaTexture = material.getAlphaTestTexture();
  44973. if (alphaTexture) {
  44974. this._effect.setTexture("diffuseSampler", alphaTexture);
  44975. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix() || this._defaultTextureMatrix);
  44976. }
  44977. }
  44978. // Bones
  44979. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  44980. var skeleton = mesh.skeleton;
  44981. if (skeleton.isUsingTextureForMatrices) {
  44982. var boneTexture = skeleton.getTransformMatrixTexture();
  44983. if (!boneTexture) {
  44984. return;
  44985. }
  44986. this._effect.setTexture("boneSampler", boneTexture);
  44987. this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  44988. }
  44989. else {
  44990. this._effect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  44991. }
  44992. }
  44993. // Morph targets
  44994. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  44995. if (this.forceBackFacesOnly) {
  44996. engine.setState(true, 0, false, true);
  44997. }
  44998. // Observable
  44999. this.onBeforeShadowMapRenderObservable.notifyObservers(this._effect);
  45000. // Draw
  45001. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  45002. if (this.forceBackFacesOnly) {
  45003. engine.setState(true, 0, false, false);
  45004. }
  45005. }
  45006. else {
  45007. // Need to reset refresh rate of the shadowMap
  45008. if (this._shadowMap) {
  45009. this._shadowMap.resetRefreshCounter();
  45010. }
  45011. }
  45012. };
  45013. ShadowGenerator.prototype._applyFilterValues = function () {
  45014. if (!this._shadowMap) {
  45015. return;
  45016. }
  45017. if (this.filter === ShadowGenerator.FILTER_NONE || this.filter === ShadowGenerator.FILTER_PCSS) {
  45018. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].NEAREST_SAMPLINGMODE);
  45019. }
  45020. else {
  45021. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  45022. }
  45023. };
  45024. /**
  45025. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  45026. * @param onCompiled Callback triggered at the and of the effects compilation
  45027. * @param options Sets of optional options forcing the compilation with different modes
  45028. */
  45029. ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
  45030. var _this = this;
  45031. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ useInstances: false }, options);
  45032. var shadowMap = this.getShadowMap();
  45033. if (!shadowMap) {
  45034. if (onCompiled) {
  45035. onCompiled(this);
  45036. }
  45037. return;
  45038. }
  45039. var renderList = shadowMap.renderList;
  45040. if (!renderList) {
  45041. if (onCompiled) {
  45042. onCompiled(this);
  45043. }
  45044. return;
  45045. }
  45046. var subMeshes = new Array();
  45047. for (var _i = 0, renderList_1 = renderList; _i < renderList_1.length; _i++) {
  45048. var mesh = renderList_1[_i];
  45049. subMeshes.push.apply(subMeshes, mesh.subMeshes);
  45050. }
  45051. if (subMeshes.length === 0) {
  45052. if (onCompiled) {
  45053. onCompiled(this);
  45054. }
  45055. return;
  45056. }
  45057. var currentIndex = 0;
  45058. var checkReady = function () {
  45059. if (!_this._scene || !_this._scene.getEngine()) {
  45060. return;
  45061. }
  45062. while (_this.isReady(subMeshes[currentIndex], localOptions.useInstances)) {
  45063. currentIndex++;
  45064. if (currentIndex >= subMeshes.length) {
  45065. if (onCompiled) {
  45066. onCompiled(_this);
  45067. }
  45068. return;
  45069. }
  45070. }
  45071. setTimeout(checkReady, 16);
  45072. };
  45073. checkReady();
  45074. };
  45075. /**
  45076. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  45077. * @param options Sets of optional options forcing the compilation with different modes
  45078. * @returns A promise that resolves when the compilation completes
  45079. */
  45080. ShadowGenerator.prototype.forceCompilationAsync = function (options) {
  45081. var _this = this;
  45082. return new Promise(function (resolve) {
  45083. _this.forceCompilation(function () {
  45084. resolve();
  45085. }, options);
  45086. });
  45087. };
  45088. /**
  45089. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  45090. * @param subMesh The submesh we want to render in the shadow map
  45091. * @param useInstances Defines wether will draw in the map using instances
  45092. * @returns true if ready otherwise, false
  45093. */
  45094. ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
  45095. var defines = [];
  45096. if (this._textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  45097. defines.push("#define FLOAT");
  45098. }
  45099. if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  45100. defines.push("#define ESM");
  45101. }
  45102. else if (this.usePercentageCloserFiltering || this.useContactHardeningShadow) {
  45103. defines.push("#define DEPTHTEXTURE");
  45104. }
  45105. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  45106. var mesh = subMesh.getMesh();
  45107. var material = subMesh.getMaterial();
  45108. // Normal bias.
  45109. if (this.normalBias && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  45110. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  45111. defines.push("#define NORMAL");
  45112. if (mesh.nonUniformScaling) {
  45113. defines.push("#define NONUNIFORMSCALING");
  45114. }
  45115. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  45116. defines.push("#define DIRECTIONINLIGHTDATA");
  45117. }
  45118. }
  45119. // Alpha test
  45120. if (material && material.needAlphaTesting()) {
  45121. var alphaTexture = material.getAlphaTestTexture();
  45122. if (alphaTexture) {
  45123. defines.push("#define ALPHATEST");
  45124. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  45125. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  45126. defines.push("#define UV1");
  45127. }
  45128. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  45129. if (alphaTexture.coordinatesIndex === 1) {
  45130. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  45131. defines.push("#define UV2");
  45132. }
  45133. }
  45134. }
  45135. }
  45136. // Bones
  45137. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  45138. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  45139. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  45140. if (mesh.numBoneInfluencers > 4) {
  45141. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  45142. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind);
  45143. }
  45144. var skeleton = mesh.skeleton;
  45145. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  45146. if (skeleton.isUsingTextureForMatrices) {
  45147. defines.push("#define BONETEXTURE");
  45148. }
  45149. else {
  45150. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  45151. }
  45152. }
  45153. else {
  45154. defines.push("#define NUM_BONE_INFLUENCERS 0");
  45155. }
  45156. // Morph targets
  45157. var manager = mesh.morphTargetManager;
  45158. var morphInfluencers = 0;
  45159. if (manager) {
  45160. if (manager.numInfluencers > 0) {
  45161. defines.push("#define MORPHTARGETS");
  45162. morphInfluencers = manager.numInfluencers;
  45163. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  45164. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  45165. }
  45166. }
  45167. // Instances
  45168. if (useInstances) {
  45169. defines.push("#define INSTANCES");
  45170. attribs.push("world0");
  45171. attribs.push("world1");
  45172. attribs.push("world2");
  45173. attribs.push("world3");
  45174. }
  45175. if (this.customShaderOptions) {
  45176. if (this.customShaderOptions.defines) {
  45177. for (var _i = 0, _a = this.customShaderOptions.defines; _i < _a.length; _i++) {
  45178. var define = _a[_i];
  45179. if (defines.indexOf(define) === -1) {
  45180. defines.push(define);
  45181. }
  45182. }
  45183. }
  45184. }
  45185. // Get correct effect
  45186. var join = defines.join("\n");
  45187. if (this._cachedDefines !== join) {
  45188. this._cachedDefines = join;
  45189. var shaderName = "shadowMap";
  45190. var uniforms = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences", "boneTextureWidth"];
  45191. var samplers = ["diffuseSampler", "boneSampler"];
  45192. // Custom shader?
  45193. if (this.customShaderOptions) {
  45194. shaderName = this.customShaderOptions.shaderName;
  45195. if (this.customShaderOptions.attributes) {
  45196. for (var _b = 0, _c = this.customShaderOptions.attributes; _b < _c.length; _b++) {
  45197. var attrib = _c[_b];
  45198. if (attribs.indexOf(attrib) === -1) {
  45199. attribs.push(attrib);
  45200. }
  45201. }
  45202. }
  45203. if (this.customShaderOptions.uniforms) {
  45204. for (var _d = 0, _e = this.customShaderOptions.uniforms; _d < _e.length; _d++) {
  45205. var uniform = _e[_d];
  45206. if (uniforms.indexOf(uniform) === -1) {
  45207. uniforms.push(uniform);
  45208. }
  45209. }
  45210. }
  45211. if (this.customShaderOptions.samplers) {
  45212. for (var _f = 0, _g = this.customShaderOptions.samplers; _f < _g.length; _f++) {
  45213. var sampler = _g[_f];
  45214. if (samplers.indexOf(sampler) === -1) {
  45215. samplers.push(sampler);
  45216. }
  45217. }
  45218. }
  45219. }
  45220. this._effect = this._scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  45221. }
  45222. if (!this._effect.isReady()) {
  45223. return false;
  45224. }
  45225. if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  45226. if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
  45227. this._initializeBlurRTTAndPostProcesses();
  45228. }
  45229. }
  45230. if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
  45231. return false;
  45232. }
  45233. if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
  45234. return false;
  45235. }
  45236. if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
  45237. return false;
  45238. }
  45239. return true;
  45240. };
  45241. /**
  45242. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  45243. * @param defines Defines of the material we want to update
  45244. * @param lightIndex Index of the light in the enabled light list of the material
  45245. */
  45246. ShadowGenerator.prototype.prepareDefines = function (defines, lightIndex) {
  45247. var scene = this._scene;
  45248. var light = this._light;
  45249. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  45250. return;
  45251. }
  45252. defines["SHADOW" + lightIndex] = true;
  45253. if (this.useContactHardeningShadow) {
  45254. defines["SHADOWPCSS" + lightIndex] = true;
  45255. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  45256. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  45257. }
  45258. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  45259. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  45260. }
  45261. // else default to high.
  45262. }
  45263. if (this.usePercentageCloserFiltering) {
  45264. defines["SHADOWPCF" + lightIndex] = true;
  45265. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  45266. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  45267. }
  45268. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  45269. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  45270. }
  45271. // else default to high.
  45272. }
  45273. else if (this.usePoissonSampling) {
  45274. defines["SHADOWPOISSON" + lightIndex] = true;
  45275. }
  45276. else if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  45277. defines["SHADOWESM" + lightIndex] = true;
  45278. }
  45279. else if (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  45280. defines["SHADOWCLOSEESM" + lightIndex] = true;
  45281. }
  45282. if (light.needCube()) {
  45283. defines["SHADOWCUBE" + lightIndex] = true;
  45284. }
  45285. };
  45286. /**
  45287. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  45288. * defined in the generator but impacting the effect).
  45289. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  45290. * @param effect The effect we are binfing the information for
  45291. */
  45292. ShadowGenerator.prototype.bindShadowLight = function (lightIndex, effect) {
  45293. var light = this._light;
  45294. var scene = this._scene;
  45295. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  45296. return;
  45297. }
  45298. var camera = scene.activeCamera;
  45299. if (!camera) {
  45300. return;
  45301. }
  45302. var shadowMap = this.getShadowMap();
  45303. if (!shadowMap) {
  45304. return;
  45305. }
  45306. if (!light.needCube()) {
  45307. effect.setMatrix("lightMatrix" + lightIndex, this.getTransformMatrix());
  45308. }
  45309. // Only PCF uses depth stencil texture.
  45310. if (this._filter === ShadowGenerator.FILTER_PCF) {
  45311. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45312. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), shadowMap.getSize().width, 1 / shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  45313. }
  45314. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  45315. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45316. effect.setTexture("depthSampler" + lightIndex, this.getShadowMapForRendering());
  45317. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / shadowMap.getSize().width, this._contactHardeningLightSizeUVRatio * shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  45318. }
  45319. else {
  45320. effect.setTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45321. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / shadowMap.getSize().width, this.depthScale, this.frustumEdgeFalloff, lightIndex);
  45322. }
  45323. light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
  45324. };
  45325. /**
  45326. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  45327. * (eq to shadow prjection matrix * light transform matrix)
  45328. * @returns The transform matrix used to create the shadow map
  45329. */
  45330. ShadowGenerator.prototype.getTransformMatrix = function () {
  45331. var scene = this._scene;
  45332. if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
  45333. return this._transformMatrix;
  45334. }
  45335. this._currentRenderID = scene.getRenderId();
  45336. this._currentFaceIndexCache = this._currentFaceIndex;
  45337. var lightPosition = this._light.position;
  45338. if (this._light.computeTransformedInformation()) {
  45339. lightPosition = this._light.transformedPosition;
  45340. }
  45341. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection);
  45342. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this._lightDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up())) === 1.0) {
  45343. this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
  45344. }
  45345. if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  45346. this._cachedPosition.copyFrom(lightPosition);
  45347. this._cachedDirection.copyFrom(this._lightDirection);
  45348. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up(), this._viewMatrix);
  45349. var shadowMap = this.getShadowMap();
  45350. if (shadowMap) {
  45351. var renderList = shadowMap.renderList;
  45352. if (renderList) {
  45353. this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, renderList);
  45354. }
  45355. }
  45356. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  45357. }
  45358. return this._transformMatrix;
  45359. };
  45360. /**
  45361. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  45362. * Cube and 2D textures for instance.
  45363. */
  45364. ShadowGenerator.prototype.recreateShadowMap = function () {
  45365. var shadowMap = this._shadowMap;
  45366. if (!shadowMap) {
  45367. return;
  45368. }
  45369. // Track render list.
  45370. var renderList = shadowMap.renderList;
  45371. // Clean up existing data.
  45372. this._disposeRTTandPostProcesses();
  45373. // Reinitializes.
  45374. this._initializeGenerator();
  45375. // Reaffect the filter to ensure a correct fallback if necessary.
  45376. this.filter = this.filter;
  45377. // Reaffect the filter.
  45378. this._applyFilterValues();
  45379. // Reaffect Render List.
  45380. this._shadowMap.renderList = renderList;
  45381. };
  45382. ShadowGenerator.prototype._disposeBlurPostProcesses = function () {
  45383. if (this._shadowMap2) {
  45384. this._shadowMap2.dispose();
  45385. this._shadowMap2 = null;
  45386. }
  45387. if (this._boxBlurPostprocess) {
  45388. this._boxBlurPostprocess.dispose();
  45389. this._boxBlurPostprocess = null;
  45390. }
  45391. if (this._kernelBlurXPostprocess) {
  45392. this._kernelBlurXPostprocess.dispose();
  45393. this._kernelBlurXPostprocess = null;
  45394. }
  45395. if (this._kernelBlurYPostprocess) {
  45396. this._kernelBlurYPostprocess.dispose();
  45397. this._kernelBlurYPostprocess = null;
  45398. }
  45399. this._blurPostProcesses = [];
  45400. };
  45401. ShadowGenerator.prototype._disposeRTTandPostProcesses = function () {
  45402. if (this._shadowMap) {
  45403. this._shadowMap.dispose();
  45404. this._shadowMap = null;
  45405. }
  45406. this._disposeBlurPostProcesses();
  45407. };
  45408. /**
  45409. * Disposes the ShadowGenerator.
  45410. * Returns nothing.
  45411. */
  45412. ShadowGenerator.prototype.dispose = function () {
  45413. this._disposeRTTandPostProcesses();
  45414. if (this._light) {
  45415. this._light._shadowGenerator = null;
  45416. this._light._markMeshesAsLightDirty();
  45417. }
  45418. };
  45419. /**
  45420. * Serializes the shadow generator setup to a json object.
  45421. * @returns The serialized JSON object
  45422. */
  45423. ShadowGenerator.prototype.serialize = function () {
  45424. var serializationObject = {};
  45425. var shadowMap = this.getShadowMap();
  45426. if (!shadowMap) {
  45427. return serializationObject;
  45428. }
  45429. serializationObject.lightId = this._light.id;
  45430. serializationObject.mapSize = shadowMap.getRenderSize();
  45431. serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
  45432. serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
  45433. serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  45434. serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  45435. serializationObject.usePoissonSampling = this.usePoissonSampling;
  45436. serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
  45437. serializationObject.depthScale = this.depthScale;
  45438. serializationObject.darkness = this.getDarkness();
  45439. serializationObject.blurBoxOffset = this.blurBoxOffset;
  45440. serializationObject.blurKernel = this.blurKernel;
  45441. serializationObject.blurScale = this.blurScale;
  45442. serializationObject.useKernelBlur = this.useKernelBlur;
  45443. serializationObject.transparencyShadow = this._transparencyShadow;
  45444. serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
  45445. serializationObject.bias = this.bias;
  45446. serializationObject.normalBias = this.normalBias;
  45447. serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
  45448. serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
  45449. serializationObject.filteringQuality = this.filteringQuality;
  45450. serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
  45451. serializationObject.renderList = [];
  45452. if (shadowMap.renderList) {
  45453. for (var meshIndex = 0; meshIndex < shadowMap.renderList.length; meshIndex++) {
  45454. var mesh = shadowMap.renderList[meshIndex];
  45455. serializationObject.renderList.push(mesh.id);
  45456. }
  45457. }
  45458. return serializationObject;
  45459. };
  45460. /**
  45461. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  45462. * @param parsedShadowGenerator The JSON object to parse
  45463. * @param scene The scene to create the shadow map for
  45464. * @returns The parsed shadow generator
  45465. */
  45466. ShadowGenerator.Parse = function (parsedShadowGenerator, scene) {
  45467. var light = scene.getLightByID(parsedShadowGenerator.lightId);
  45468. var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
  45469. var shadowMap = shadowGenerator.getShadowMap();
  45470. for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
  45471. var meshes = scene.getMeshesByID(parsedShadowGenerator.renderList[meshIndex]);
  45472. meshes.forEach(function (mesh) {
  45473. if (!shadowMap) {
  45474. return;
  45475. }
  45476. if (!shadowMap.renderList) {
  45477. shadowMap.renderList = [];
  45478. }
  45479. shadowMap.renderList.push(mesh);
  45480. });
  45481. }
  45482. if (parsedShadowGenerator.usePoissonSampling) {
  45483. shadowGenerator.usePoissonSampling = true;
  45484. }
  45485. else if (parsedShadowGenerator.useExponentialShadowMap) {
  45486. shadowGenerator.useExponentialShadowMap = true;
  45487. }
  45488. else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
  45489. shadowGenerator.useBlurExponentialShadowMap = true;
  45490. }
  45491. else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
  45492. shadowGenerator.useCloseExponentialShadowMap = true;
  45493. }
  45494. else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
  45495. shadowGenerator.useBlurCloseExponentialShadowMap = true;
  45496. }
  45497. else if (parsedShadowGenerator.usePercentageCloserFiltering) {
  45498. shadowGenerator.usePercentageCloserFiltering = true;
  45499. }
  45500. else if (parsedShadowGenerator.useContactHardeningShadow) {
  45501. shadowGenerator.useContactHardeningShadow = true;
  45502. }
  45503. if (parsedShadowGenerator.filteringQuality) {
  45504. shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
  45505. }
  45506. if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
  45507. shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
  45508. }
  45509. // Backward compat
  45510. else if (parsedShadowGenerator.useVarianceShadowMap) {
  45511. shadowGenerator.useExponentialShadowMap = true;
  45512. }
  45513. else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
  45514. shadowGenerator.useBlurExponentialShadowMap = true;
  45515. }
  45516. if (parsedShadowGenerator.depthScale) {
  45517. shadowGenerator.depthScale = parsedShadowGenerator.depthScale;
  45518. }
  45519. if (parsedShadowGenerator.blurScale) {
  45520. shadowGenerator.blurScale = parsedShadowGenerator.blurScale;
  45521. }
  45522. if (parsedShadowGenerator.blurBoxOffset) {
  45523. shadowGenerator.blurBoxOffset = parsedShadowGenerator.blurBoxOffset;
  45524. }
  45525. if (parsedShadowGenerator.useKernelBlur) {
  45526. shadowGenerator.useKernelBlur = parsedShadowGenerator.useKernelBlur;
  45527. }
  45528. if (parsedShadowGenerator.blurKernel) {
  45529. shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
  45530. }
  45531. if (parsedShadowGenerator.bias !== undefined) {
  45532. shadowGenerator.bias = parsedShadowGenerator.bias;
  45533. }
  45534. if (parsedShadowGenerator.normalBias !== undefined) {
  45535. shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
  45536. }
  45537. if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
  45538. shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
  45539. }
  45540. if (parsedShadowGenerator.darkness) {
  45541. shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
  45542. }
  45543. if (parsedShadowGenerator.transparencyShadow) {
  45544. shadowGenerator.setTransparencyShadow(true);
  45545. }
  45546. shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
  45547. return shadowGenerator;
  45548. };
  45549. /**
  45550. * Shadow generator mode None: no filtering applied.
  45551. */
  45552. ShadowGenerator.FILTER_NONE = 0;
  45553. /**
  45554. * Shadow generator mode ESM: Exponential Shadow Mapping.
  45555. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45556. */
  45557. ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP = 1;
  45558. /**
  45559. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  45560. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  45561. */
  45562. ShadowGenerator.FILTER_POISSONSAMPLING = 2;
  45563. /**
  45564. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  45565. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45566. */
  45567. ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP = 3;
  45568. /**
  45569. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  45570. * edge artifacts on steep falloff.
  45571. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45572. */
  45573. ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4;
  45574. /**
  45575. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  45576. * edge artifacts on steep falloff.
  45577. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45578. */
  45579. ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5;
  45580. /**
  45581. * Shadow generator mode PCF: Percentage Closer Filtering
  45582. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  45583. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  45584. */
  45585. ShadowGenerator.FILTER_PCF = 6;
  45586. /**
  45587. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  45588. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  45589. * Contact Hardening
  45590. */
  45591. ShadowGenerator.FILTER_PCSS = 7;
  45592. /**
  45593. * Reserved for PCF and PCSS
  45594. * Highest Quality.
  45595. *
  45596. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  45597. *
  45598. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  45599. */
  45600. ShadowGenerator.QUALITY_HIGH = 0;
  45601. /**
  45602. * Reserved for PCF and PCSS
  45603. * Good tradeoff for quality/perf cross devices
  45604. *
  45605. * Execute PCF on a 3*3 kernel.
  45606. *
  45607. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  45608. */
  45609. ShadowGenerator.QUALITY_MEDIUM = 1;
  45610. /**
  45611. * Reserved for PCF and PCSS
  45612. * The lowest quality but the fastest.
  45613. *
  45614. * Execute PCF on a 1*1 kernel.
  45615. *
  45616. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  45617. */
  45618. ShadowGenerator.QUALITY_LOW = 2;
  45619. /** @hidden */
  45620. ShadowGenerator._SceneComponentInitialization = function (_) {
  45621. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__["_DevTools"].WarnImport("ShadowGeneratorSceneComponent");
  45622. };
  45623. return ShadowGenerator;
  45624. }());
  45625. /***/ }),
  45626. /***/ "./Lights/Shadows/shadowGeneratorSceneComponent.ts":
  45627. /*!*********************************************************!*\
  45628. !*** ./Lights/Shadows/shadowGeneratorSceneComponent.ts ***!
  45629. \*********************************************************/
  45630. /*! exports provided: ShadowGeneratorSceneComponent */
  45631. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45632. "use strict";
  45633. __webpack_require__.r(__webpack_exports__);
  45634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return ShadowGeneratorSceneComponent; });
  45635. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  45636. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  45637. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  45638. // Adds the parser to the scene parsers.
  45639. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR, function (parsedData, scene) {
  45640. // Shadows
  45641. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  45642. for (var index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  45643. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  45644. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"].Parse(parsedShadowGenerator, scene);
  45645. // SG would be available on their associated lights
  45646. }
  45647. }
  45648. });
  45649. /**
  45650. * Defines the shadow generator component responsible to manage any shadow generators
  45651. * in a given scene.
  45652. */
  45653. var ShadowGeneratorSceneComponent = /** @class */ (function () {
  45654. /**
  45655. * Creates a new instance of the component for the given scene
  45656. * @param scene Defines the scene to register the component in
  45657. */
  45658. function ShadowGeneratorSceneComponent(scene) {
  45659. /**
  45660. * The component name helpfull to identify the component in the list of scene components.
  45661. */
  45662. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR;
  45663. this.scene = scene;
  45664. }
  45665. /**
  45666. * Registers the component in a given scene
  45667. */
  45668. ShadowGeneratorSceneComponent.prototype.register = function () {
  45669. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
  45670. };
  45671. /**
  45672. * Rebuilds the elements related to this component in case of
  45673. * context lost for instance.
  45674. */
  45675. ShadowGeneratorSceneComponent.prototype.rebuild = function () {
  45676. // Nothing To Do Here.
  45677. };
  45678. /**
  45679. * Serializes the component data to the specified json object
  45680. * @param serializationObject The object to serialize to
  45681. */
  45682. ShadowGeneratorSceneComponent.prototype.serialize = function (serializationObject) {
  45683. // Shadows
  45684. serializationObject.shadowGenerators = [];
  45685. var lights = this.scene.lights;
  45686. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  45687. var light = lights_1[_i];
  45688. var shadowGenerator = light.getShadowGenerator();
  45689. if (shadowGenerator) {
  45690. serializationObject.shadowGenerators.push(shadowGenerator.serialize());
  45691. }
  45692. }
  45693. };
  45694. /**
  45695. * Adds all the element from the container to the scene
  45696. * @param container the container holding the elements
  45697. */
  45698. ShadowGeneratorSceneComponent.prototype.addFromContainer = function (container) {
  45699. // Nothing To Do Here. (directly attached to a light)
  45700. };
  45701. /**
  45702. * Removes all the elements in the container from the scene
  45703. * @param container contains the elements to remove
  45704. */
  45705. ShadowGeneratorSceneComponent.prototype.removeFromContainer = function (container) {
  45706. // Nothing To Do Here. (directly attached to a light)
  45707. };
  45708. /**
  45709. * Rebuilds the elements related to this component in case of
  45710. * context lost for instance.
  45711. */
  45712. ShadowGeneratorSceneComponent.prototype.dispose = function () {
  45713. // Nothing To Do Here.
  45714. };
  45715. ShadowGeneratorSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  45716. // Shadows
  45717. var scene = this.scene;
  45718. if (this.scene.shadowsEnabled) {
  45719. for (var lightIndex = 0; lightIndex < scene.lights.length; lightIndex++) {
  45720. var light = scene.lights[lightIndex];
  45721. var shadowGenerator = light.getShadowGenerator();
  45722. if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
  45723. var shadowMap = (shadowGenerator.getShadowMap());
  45724. if (scene.textures.indexOf(shadowMap) !== -1) {
  45725. renderTargets.push(shadowMap);
  45726. }
  45727. }
  45728. }
  45729. }
  45730. };
  45731. return ShadowGeneratorSceneComponent;
  45732. }());
  45733. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]._SceneComponentInitialization = function (scene) {
  45734. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR);
  45735. if (!component) {
  45736. component = new ShadowGeneratorSceneComponent(scene);
  45737. scene._addComponent(component);
  45738. }
  45739. };
  45740. /***/ }),
  45741. /***/ "./Lights/directionalLight.ts":
  45742. /*!************************************!*\
  45743. !*** ./Lights/directionalLight.ts ***!
  45744. \************************************/
  45745. /*! exports provided: DirectionalLight */
  45746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45747. "use strict";
  45748. __webpack_require__.r(__webpack_exports__);
  45749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return DirectionalLight; });
  45750. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45751. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45752. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45753. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  45754. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45755. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  45756. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_1", function (name, scene) {
  45757. return function () { return new DirectionalLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  45758. });
  45759. /**
  45760. * A directional light is defined by a direction (what a surprise!).
  45761. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45762. * 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.
  45763. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45764. */
  45765. var DirectionalLight = /** @class */ (function (_super) {
  45766. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DirectionalLight, _super);
  45767. /**
  45768. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45769. * The directional light is emitted from everywhere in the given direction.
  45770. * It can cast shadows.
  45771. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45772. * @param name The friendly name of the light
  45773. * @param direction The direction of the light
  45774. * @param scene The scene the light belongs to
  45775. */
  45776. function DirectionalLight(name, direction, scene) {
  45777. var _this = _super.call(this, name, scene) || this;
  45778. _this._shadowFrustumSize = 0;
  45779. _this._shadowOrthoScale = 0.1;
  45780. /**
  45781. * Automatically compute the projection matrix to best fit (including all the casters)
  45782. * on each frame.
  45783. */
  45784. _this.autoUpdateExtends = true;
  45785. // Cache
  45786. _this._orthoLeft = Number.MAX_VALUE;
  45787. _this._orthoRight = Number.MIN_VALUE;
  45788. _this._orthoTop = Number.MIN_VALUE;
  45789. _this._orthoBottom = Number.MAX_VALUE;
  45790. _this.position = direction.scale(-1.0);
  45791. _this.direction = direction;
  45792. return _this;
  45793. }
  45794. Object.defineProperty(DirectionalLight.prototype, "shadowFrustumSize", {
  45795. /**
  45796. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45797. */
  45798. get: function () {
  45799. return this._shadowFrustumSize;
  45800. },
  45801. /**
  45802. * Specifies a fix frustum size for the shadow generation.
  45803. */
  45804. set: function (value) {
  45805. this._shadowFrustumSize = value;
  45806. this.forceProjectionMatrixCompute();
  45807. },
  45808. enumerable: true,
  45809. configurable: true
  45810. });
  45811. Object.defineProperty(DirectionalLight.prototype, "shadowOrthoScale", {
  45812. /**
  45813. * Gets the shadow projection scale against the optimal computed one.
  45814. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45815. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45816. */
  45817. get: function () {
  45818. return this._shadowOrthoScale;
  45819. },
  45820. /**
  45821. * Sets the shadow projection scale against the optimal computed one.
  45822. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45823. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45824. */
  45825. set: function (value) {
  45826. this._shadowOrthoScale = value;
  45827. this.forceProjectionMatrixCompute();
  45828. },
  45829. enumerable: true,
  45830. configurable: true
  45831. });
  45832. /**
  45833. * Returns the string "DirectionalLight".
  45834. * @return The class name
  45835. */
  45836. DirectionalLight.prototype.getClassName = function () {
  45837. return "DirectionalLight";
  45838. };
  45839. /**
  45840. * Returns the integer 1.
  45841. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45842. */
  45843. DirectionalLight.prototype.getTypeID = function () {
  45844. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT;
  45845. };
  45846. /**
  45847. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45848. * Returns the DirectionalLight Shadow projection matrix.
  45849. */
  45850. DirectionalLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  45851. if (this.shadowFrustumSize > 0) {
  45852. this._setDefaultFixedFrustumShadowProjectionMatrix(matrix);
  45853. }
  45854. else {
  45855. this._setDefaultAutoExtendShadowProjectionMatrix(matrix, viewMatrix, renderList);
  45856. }
  45857. };
  45858. /**
  45859. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45860. * Returns the DirectionalLight Shadow projection matrix.
  45861. */
  45862. DirectionalLight.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function (matrix) {
  45863. var activeCamera = this.getScene().activeCamera;
  45864. if (!activeCamera) {
  45865. return;
  45866. }
  45867. _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);
  45868. };
  45869. /**
  45870. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45871. * Returns the DirectionalLight Shadow projection matrix.
  45872. */
  45873. DirectionalLight.prototype._setDefaultAutoExtendShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  45874. var activeCamera = this.getScene().activeCamera;
  45875. if (!activeCamera) {
  45876. return;
  45877. }
  45878. // Check extends
  45879. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  45880. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  45881. this._orthoLeft = Number.MAX_VALUE;
  45882. this._orthoRight = Number.MIN_VALUE;
  45883. this._orthoTop = Number.MIN_VALUE;
  45884. this._orthoBottom = Number.MAX_VALUE;
  45885. for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
  45886. var mesh = renderList[meshIndex];
  45887. if (!mesh) {
  45888. continue;
  45889. }
  45890. var boundingInfo = mesh.getBoundingInfo();
  45891. var boundingBox = boundingInfo.boundingBox;
  45892. for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
  45893. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
  45894. if (tempVector3.x < this._orthoLeft) {
  45895. this._orthoLeft = tempVector3.x;
  45896. }
  45897. if (tempVector3.y < this._orthoBottom) {
  45898. this._orthoBottom = tempVector3.y;
  45899. }
  45900. if (tempVector3.x > this._orthoRight) {
  45901. this._orthoRight = tempVector3.x;
  45902. }
  45903. if (tempVector3.y > this._orthoTop) {
  45904. this._orthoTop = tempVector3.y;
  45905. }
  45906. }
  45907. }
  45908. }
  45909. var xOffset = this._orthoRight - this._orthoLeft;
  45910. var yOffset = this._orthoTop - this._orthoBottom;
  45911. _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);
  45912. };
  45913. DirectionalLight.prototype._buildUniformLayout = function () {
  45914. this._uniformBuffer.addUniform("vLightData", 4);
  45915. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  45916. this._uniformBuffer.addUniform("vLightSpecular", 3);
  45917. this._uniformBuffer.addUniform("shadowsInfo", 3);
  45918. this._uniformBuffer.addUniform("depthValues", 2);
  45919. this._uniformBuffer.create();
  45920. };
  45921. /**
  45922. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45923. * @param effect The effect to update
  45924. * @param lightIndex The index of the light in the effect to update
  45925. * @returns The directional light
  45926. */
  45927. DirectionalLight.prototype.transferToEffect = function (effect, lightIndex) {
  45928. if (this.computeTransformedInformation()) {
  45929. this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, lightIndex);
  45930. return this;
  45931. }
  45932. this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, lightIndex);
  45933. return this;
  45934. };
  45935. /**
  45936. * Gets the minZ used for shadow according to both the scene and the light.
  45937. *
  45938. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45939. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45940. * @param activeCamera The camera we are returning the min for
  45941. * @returns the depth min z
  45942. */
  45943. DirectionalLight.prototype.getDepthMinZ = function (activeCamera) {
  45944. return 1;
  45945. };
  45946. /**
  45947. * Gets the maxZ used for shadow according to both the scene and the light.
  45948. *
  45949. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45950. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45951. * @param activeCamera The camera we are returning the max for
  45952. * @returns the depth max z
  45953. */
  45954. DirectionalLight.prototype.getDepthMaxZ = function (activeCamera) {
  45955. return 1;
  45956. };
  45957. /**
  45958. * Prepares the list of defines specific to the light type.
  45959. * @param defines the list of defines
  45960. * @param lightIndex defines the index of the light for the effect
  45961. */
  45962. DirectionalLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  45963. defines["DIRLIGHT" + lightIndex] = true;
  45964. };
  45965. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45966. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45967. ], DirectionalLight.prototype, "shadowFrustumSize", null);
  45968. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45969. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45970. ], DirectionalLight.prototype, "shadowOrthoScale", null);
  45971. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45972. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45973. ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
  45974. return DirectionalLight;
  45975. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  45976. /***/ }),
  45977. /***/ "./Lights/hemisphericLight.ts":
  45978. /*!************************************!*\
  45979. !*** ./Lights/hemisphericLight.ts ***!
  45980. \************************************/
  45981. /*! exports provided: HemisphericLight */
  45982. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45983. "use strict";
  45984. __webpack_require__.r(__webpack_exports__);
  45985. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return HemisphericLight; });
  45986. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45987. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45988. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45989. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  45990. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45991. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_3", function (name, scene) {
  45992. return function () { return new HemisphericLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  45993. });
  45994. /**
  45995. * The HemisphericLight simulates the ambient environment light,
  45996. * so the passed direction is the light reflection direction, not the incoming direction.
  45997. */
  45998. var HemisphericLight = /** @class */ (function (_super) {
  45999. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HemisphericLight, _super);
  46000. /**
  46001. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  46002. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  46003. * The HemisphericLight can't cast shadows.
  46004. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46005. * @param name The friendly name of the light
  46006. * @param direction The direction of the light reflection
  46007. * @param scene The scene the light belongs to
  46008. */
  46009. function HemisphericLight(name, direction, scene) {
  46010. var _this = _super.call(this, name, scene) || this;
  46011. /**
  46012. * The groundColor is the light in the opposite direction to the one specified during creation.
  46013. * 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.
  46014. */
  46015. _this.groundColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.0, 0.0, 0.0);
  46016. _this.direction = direction || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  46017. return _this;
  46018. }
  46019. HemisphericLight.prototype._buildUniformLayout = function () {
  46020. this._uniformBuffer.addUniform("vLightData", 4);
  46021. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  46022. this._uniformBuffer.addUniform("vLightSpecular", 3);
  46023. this._uniformBuffer.addUniform("vLightGround", 3);
  46024. this._uniformBuffer.addUniform("shadowsInfo", 3);
  46025. this._uniformBuffer.addUniform("depthValues", 2);
  46026. this._uniformBuffer.create();
  46027. };
  46028. /**
  46029. * Returns the string "HemisphericLight".
  46030. * @return The class name
  46031. */
  46032. HemisphericLight.prototype.getClassName = function () {
  46033. return "HemisphericLight";
  46034. };
  46035. /**
  46036. * Sets the HemisphericLight direction towards the passed target (Vector3).
  46037. * Returns the updated direction.
  46038. * @param target The target the direction should point to
  46039. * @return The computed direction
  46040. */
  46041. HemisphericLight.prototype.setDirectionToTarget = function (target) {
  46042. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero()));
  46043. return this.direction;
  46044. };
  46045. /**
  46046. * Returns the shadow generator associated to the light.
  46047. * @returns Always null for hemispheric lights because it does not support shadows.
  46048. */
  46049. HemisphericLight.prototype.getShadowGenerator = function () {
  46050. return null;
  46051. };
  46052. /**
  46053. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  46054. * @param effect The effect to update
  46055. * @param lightIndex The index of the light in the effect to update
  46056. * @returns The hemispheric light
  46057. */
  46058. HemisphericLight.prototype.transferToEffect = function (effect, lightIndex) {
  46059. var normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  46060. this._uniformBuffer.updateFloat4("vLightData", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0.0, lightIndex);
  46061. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
  46062. return this;
  46063. };
  46064. /**
  46065. * Computes the world matrix of the node
  46066. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  46067. * @param useWasUpdatedFlag defines a reserved property
  46068. * @returns the world matrix
  46069. */
  46070. HemisphericLight.prototype.computeWorldMatrix = function () {
  46071. if (!this._worldMatrix) {
  46072. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  46073. }
  46074. return this._worldMatrix;
  46075. };
  46076. /**
  46077. * Returns the integer 3.
  46078. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46079. */
  46080. HemisphericLight.prototype.getTypeID = function () {
  46081. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_HEMISPHERICLIGHT;
  46082. };
  46083. /**
  46084. * Prepares the list of defines specific to the light type.
  46085. * @param defines the list of defines
  46086. * @param lightIndex defines the index of the light for the effect
  46087. */
  46088. HemisphericLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  46089. defines["HEMILIGHT" + lightIndex] = true;
  46090. };
  46091. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46092. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46093. ], HemisphericLight.prototype, "groundColor", void 0);
  46094. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46095. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  46096. ], HemisphericLight.prototype, "direction", void 0);
  46097. return HemisphericLight;
  46098. }(_light__WEBPACK_IMPORTED_MODULE_4__["Light"]));
  46099. /***/ }),
  46100. /***/ "./Lights/index.ts":
  46101. /*!*************************!*\
  46102. !*** ./Lights/index.ts ***!
  46103. \*************************/
  46104. /*! exports provided: Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, ShadowGenerator, ShadowGeneratorSceneComponent */
  46105. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46106. "use strict";
  46107. __webpack_require__.r(__webpack_exports__);
  46108. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _light__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  46110. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _shadowLight__WEBPACK_IMPORTED_MODULE_1__["ShadowLight"]; });
  46112. /* harmony import */ var _Shadows_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Shadows/index */ "./Lights/Shadows/index.ts");
  46113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGenerator"]; });
  46114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGeneratorSceneComponent"]; });
  46115. /* harmony import */ var _directionalLight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directionalLight */ "./Lights/directionalLight.ts");
  46116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _directionalLight__WEBPACK_IMPORTED_MODULE_3__["DirectionalLight"]; });
  46117. /* harmony import */ var _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphericLight */ "./Lights/hemisphericLight.ts");
  46118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]; });
  46119. /* harmony import */ var _pointLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pointLight */ "./Lights/pointLight.ts");
  46120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _pointLight__WEBPACK_IMPORTED_MODULE_5__["PointLight"]; });
  46121. /* harmony import */ var _spotLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spotLight */ "./Lights/spotLight.ts");
  46122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _spotLight__WEBPACK_IMPORTED_MODULE_6__["SpotLight"]; });
  46123. /***/ }),
  46124. /***/ "./Lights/light.ts":
  46125. /*!*************************!*\
  46126. !*** ./Lights/light.ts ***!
  46127. \*************************/
  46128. /*! exports provided: Light */
  46129. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46130. "use strict";
  46131. __webpack_require__.r(__webpack_exports__);
  46132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return Light; });
  46133. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46134. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46135. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46136. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46137. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  46138. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  46139. /**
  46140. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  46141. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  46142. * 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.
  46143. */
  46144. var Light = /** @class */ (function (_super) {
  46145. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Light, _super);
  46146. /**
  46147. * Creates a Light object in the scene.
  46148. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46149. * @param name The firendly name of the light
  46150. * @param scene The scene the light belongs too
  46151. */
  46152. function Light(name, scene) {
  46153. var _this = _super.call(this, name, scene) || this;
  46154. /**
  46155. * Diffuse gives the basic color to an object.
  46156. */
  46157. _this.diffuse = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  46158. /**
  46159. * Specular produces a highlight color on an object.
  46160. * Note: This is note affecting PBR materials.
  46161. */
  46162. _this.specular = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  46163. /**
  46164. * Defines the falloff type for this light. This lets overrriding how punctual light are
  46165. * falling off base on range or angle.
  46166. * This can be set to any values in Light.FALLOFF_x.
  46167. *
  46168. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  46169. * other types of materials.
  46170. */
  46171. _this.falloffType = Light.FALLOFF_DEFAULT;
  46172. /**
  46173. * Strength of the light.
  46174. * Note: By default it is define in the framework own unit.
  46175. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  46176. */
  46177. _this.intensity = 1.0;
  46178. _this._range = Number.MAX_VALUE;
  46179. _this._inverseSquaredRange = 0;
  46180. /**
  46181. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  46182. * of light.
  46183. */
  46184. _this._photometricScale = 1.0;
  46185. _this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
  46186. _this._radius = 0.00001;
  46187. /**
  46188. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  46189. * exceeding the number allowed of the materials.
  46190. */
  46191. _this.renderPriority = 0;
  46192. _this._shadowEnabled = true;
  46193. _this._excludeWithLayerMask = 0;
  46194. _this._includeOnlyWithLayerMask = 0;
  46195. _this._lightmapMode = 0;
  46196. /**
  46197. * @hidden Internal use only.
  46198. */
  46199. _this._excludedMeshesIds = new Array();
  46200. /**
  46201. * @hidden Internal use only.
  46202. */
  46203. _this._includedOnlyMeshesIds = new Array();
  46204. /** @hidden */
  46205. _this._isLight = true;
  46206. _this.getScene().addLight(_this);
  46207. _this._uniformBuffer = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__["UniformBuffer"](_this.getScene().getEngine());
  46208. _this._buildUniformLayout();
  46209. _this.includedOnlyMeshes = new Array();
  46210. _this.excludedMeshes = new Array();
  46211. _this._resyncMeshes();
  46212. return _this;
  46213. }
  46214. Object.defineProperty(Light.prototype, "range", {
  46215. /**
  46216. * Defines how far from the source the light is impacting in scene units.
  46217. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  46218. */
  46219. get: function () {
  46220. return this._range;
  46221. },
  46222. /**
  46223. * Defines how far from the source the light is impacting in scene units.
  46224. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  46225. */
  46226. set: function (value) {
  46227. this._range = value;
  46228. this._inverseSquaredRange = 1.0 / (this.range * this.range);
  46229. },
  46230. enumerable: true,
  46231. configurable: true
  46232. });
  46233. Object.defineProperty(Light.prototype, "intensityMode", {
  46234. /**
  46235. * Gets the photometric scale used to interpret the intensity.
  46236. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  46237. */
  46238. get: function () {
  46239. return this._intensityMode;
  46240. },
  46241. /**
  46242. * Sets the photometric scale used to interpret the intensity.
  46243. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  46244. */
  46245. set: function (value) {
  46246. this._intensityMode = value;
  46247. this._computePhotometricScale();
  46248. },
  46249. enumerable: true,
  46250. configurable: true
  46251. });
  46252. Object.defineProperty(Light.prototype, "radius", {
  46253. /**
  46254. * Gets the light radius used by PBR Materials to simulate soft area lights.
  46255. */
  46256. get: function () {
  46257. return this._radius;
  46258. },
  46259. /**
  46260. * sets the light radius used by PBR Materials to simulate soft area lights.
  46261. */
  46262. set: function (value) {
  46263. this._radius = value;
  46264. this._computePhotometricScale();
  46265. },
  46266. enumerable: true,
  46267. configurable: true
  46268. });
  46269. Object.defineProperty(Light.prototype, "shadowEnabled", {
  46270. /**
  46271. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  46272. * the current shadow generator.
  46273. */
  46274. get: function () {
  46275. return this._shadowEnabled;
  46276. },
  46277. /**
  46278. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  46279. * the current shadow generator.
  46280. */
  46281. set: function (value) {
  46282. if (this._shadowEnabled === value) {
  46283. return;
  46284. }
  46285. this._shadowEnabled = value;
  46286. this._markMeshesAsLightDirty();
  46287. },
  46288. enumerable: true,
  46289. configurable: true
  46290. });
  46291. Object.defineProperty(Light.prototype, "includedOnlyMeshes", {
  46292. /**
  46293. * Gets the only meshes impacted by this light.
  46294. */
  46295. get: function () {
  46296. return this._includedOnlyMeshes;
  46297. },
  46298. /**
  46299. * Sets the only meshes impacted by this light.
  46300. */
  46301. set: function (value) {
  46302. this._includedOnlyMeshes = value;
  46303. this._hookArrayForIncludedOnly(value);
  46304. },
  46305. enumerable: true,
  46306. configurable: true
  46307. });
  46308. Object.defineProperty(Light.prototype, "excludedMeshes", {
  46309. /**
  46310. * Gets the meshes not impacted by this light.
  46311. */
  46312. get: function () {
  46313. return this._excludedMeshes;
  46314. },
  46315. /**
  46316. * Sets the meshes not impacted by this light.
  46317. */
  46318. set: function (value) {
  46319. this._excludedMeshes = value;
  46320. this._hookArrayForExcluded(value);
  46321. },
  46322. enumerable: true,
  46323. configurable: true
  46324. });
  46325. Object.defineProperty(Light.prototype, "excludeWithLayerMask", {
  46326. /**
  46327. * Gets the layer id use to find what meshes are not impacted by the light.
  46328. * Inactive if 0
  46329. */
  46330. get: function () {
  46331. return this._excludeWithLayerMask;
  46332. },
  46333. /**
  46334. * Sets the layer id use to find what meshes are not impacted by the light.
  46335. * Inactive if 0
  46336. */
  46337. set: function (value) {
  46338. this._excludeWithLayerMask = value;
  46339. this._resyncMeshes();
  46340. },
  46341. enumerable: true,
  46342. configurable: true
  46343. });
  46344. Object.defineProperty(Light.prototype, "includeOnlyWithLayerMask", {
  46345. /**
  46346. * Gets the layer id use to find what meshes are impacted by the light.
  46347. * Inactive if 0
  46348. */
  46349. get: function () {
  46350. return this._includeOnlyWithLayerMask;
  46351. },
  46352. /**
  46353. * Sets the layer id use to find what meshes are impacted by the light.
  46354. * Inactive if 0
  46355. */
  46356. set: function (value) {
  46357. this._includeOnlyWithLayerMask = value;
  46358. this._resyncMeshes();
  46359. },
  46360. enumerable: true,
  46361. configurable: true
  46362. });
  46363. Object.defineProperty(Light.prototype, "lightmapMode", {
  46364. /**
  46365. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  46366. */
  46367. get: function () {
  46368. return this._lightmapMode;
  46369. },
  46370. /**
  46371. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  46372. */
  46373. set: function (value) {
  46374. if (this._lightmapMode === value) {
  46375. return;
  46376. }
  46377. this._lightmapMode = value;
  46378. this._markMeshesAsLightDirty();
  46379. },
  46380. enumerable: true,
  46381. configurable: true
  46382. });
  46383. /**
  46384. * Returns the string "Light".
  46385. * @returns the class name
  46386. */
  46387. Light.prototype.getClassName = function () {
  46388. return "Light";
  46389. };
  46390. /**
  46391. * Converts the light information to a readable string for debug purpose.
  46392. * @param fullDetails Supports for multiple levels of logging within scene loading
  46393. * @returns the human readable light info
  46394. */
  46395. Light.prototype.toString = function (fullDetails) {
  46396. var ret = "Name: " + this.name;
  46397. ret += ", type: " + (["Point", "Directional", "Spot", "Hemispheric"])[this.getTypeID()];
  46398. if (this.animations) {
  46399. for (var i = 0; i < this.animations.length; i++) {
  46400. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  46401. }
  46402. }
  46403. if (fullDetails) {
  46404. }
  46405. return ret;
  46406. };
  46407. /** @hidden */
  46408. Light.prototype._syncParentEnabledState = function () {
  46409. _super.prototype._syncParentEnabledState.call(this);
  46410. this._resyncMeshes();
  46411. };
  46412. /**
  46413. * Set the enabled state of this node.
  46414. * @param value - the new enabled state
  46415. */
  46416. Light.prototype.setEnabled = function (value) {
  46417. _super.prototype.setEnabled.call(this, value);
  46418. this._resyncMeshes();
  46419. };
  46420. /**
  46421. * Returns the Light associated shadow generator if any.
  46422. * @return the associated shadow generator.
  46423. */
  46424. Light.prototype.getShadowGenerator = function () {
  46425. return this._shadowGenerator;
  46426. };
  46427. /**
  46428. * Returns a Vector3, the absolute light position in the World.
  46429. * @returns the world space position of the light
  46430. */
  46431. Light.prototype.getAbsolutePosition = function () {
  46432. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46433. };
  46434. /**
  46435. * Specifies if the light will affect the passed mesh.
  46436. * @param mesh The mesh to test against the light
  46437. * @return true the mesh is affected otherwise, false.
  46438. */
  46439. Light.prototype.canAffectMesh = function (mesh) {
  46440. if (!mesh) {
  46441. return true;
  46442. }
  46443. if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  46444. return false;
  46445. }
  46446. if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  46447. return false;
  46448. }
  46449. if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
  46450. return false;
  46451. }
  46452. if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
  46453. return false;
  46454. }
  46455. return true;
  46456. };
  46457. /**
  46458. * Sort function to order lights for rendering.
  46459. * @param a First Light object to compare to second.
  46460. * @param b Second Light object to compare first.
  46461. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  46462. */
  46463. Light.CompareLightsPriority = function (a, b) {
  46464. //shadow-casting lights have priority over non-shadow-casting lights
  46465. //the renderPrioirty is a secondary sort criterion
  46466. if (a.shadowEnabled !== b.shadowEnabled) {
  46467. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  46468. }
  46469. return b.renderPriority - a.renderPriority;
  46470. };
  46471. /**
  46472. * Releases resources associated with this node.
  46473. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46474. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46475. */
  46476. Light.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  46477. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  46478. if (this._shadowGenerator) {
  46479. this._shadowGenerator.dispose();
  46480. this._shadowGenerator = null;
  46481. }
  46482. // Animations
  46483. this.getScene().stopAnimation(this);
  46484. // Remove from meshes
  46485. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  46486. var mesh = _a[_i];
  46487. mesh._removeLightSource(this);
  46488. }
  46489. this._uniformBuffer.dispose();
  46490. // Remove from scene
  46491. this.getScene().removeLight(this);
  46492. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  46493. };
  46494. /**
  46495. * Returns the light type ID (integer).
  46496. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46497. */
  46498. Light.prototype.getTypeID = function () {
  46499. return 0;
  46500. };
  46501. /**
  46502. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  46503. * @returns the scaled intensity in intensity mode unit
  46504. */
  46505. Light.prototype.getScaledIntensity = function () {
  46506. return this._photometricScale * this.intensity;
  46507. };
  46508. /**
  46509. * Returns a new Light object, named "name", from the current one.
  46510. * @param name The name of the cloned light
  46511. * @returns the new created light
  46512. */
  46513. Light.prototype.clone = function (name) {
  46514. var constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
  46515. if (!constructor) {
  46516. return null;
  46517. }
  46518. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(constructor, this);
  46519. };
  46520. /**
  46521. * Serializes the current light into a Serialization object.
  46522. * @returns the serialized object.
  46523. */
  46524. Light.prototype.serialize = function () {
  46525. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  46526. // Type
  46527. serializationObject.type = this.getTypeID();
  46528. // Parent
  46529. if (this.parent) {
  46530. serializationObject.parentId = this.parent.id;
  46531. }
  46532. // Inclusion / exclusions
  46533. if (this.excludedMeshes.length > 0) {
  46534. serializationObject.excludedMeshesIds = [];
  46535. this.excludedMeshes.forEach(function (mesh) {
  46536. serializationObject.excludedMeshesIds.push(mesh.id);
  46537. });
  46538. }
  46539. if (this.includedOnlyMeshes.length > 0) {
  46540. serializationObject.includedOnlyMeshesIds = [];
  46541. this.includedOnlyMeshes.forEach(function (mesh) {
  46542. serializationObject.includedOnlyMeshesIds.push(mesh.id);
  46543. });
  46544. }
  46545. // Animations
  46546. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  46547. serializationObject.ranges = this.serializeAnimationRanges();
  46548. return serializationObject;
  46549. };
  46550. /**
  46551. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  46552. * This new light is named "name" and added to the passed scene.
  46553. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  46554. * @param name The friendly name of the light
  46555. * @param scene The scene the new light will belong to
  46556. * @returns the constructor function
  46557. */
  46558. Light.GetConstructorFromName = function (type, name, scene) {
  46559. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_3__["Node"].Construct("Light_Type_" + type, name, scene);
  46560. if (constructorFunc) {
  46561. return constructorFunc;
  46562. }
  46563. // Default to no light for none present once.
  46564. return null;
  46565. };
  46566. /**
  46567. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  46568. * @param parsedLight The JSON representation of the light
  46569. * @param scene The scene to create the parsed light in
  46570. * @returns the created light after parsing
  46571. */
  46572. Light.Parse = function (parsedLight, scene) {
  46573. var constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
  46574. if (!constructor) {
  46575. return null;
  46576. }
  46577. var light = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(constructor, parsedLight, scene);
  46578. // Inclusion / exclusions
  46579. if (parsedLight.excludedMeshesIds) {
  46580. light._excludedMeshesIds = parsedLight.excludedMeshesIds;
  46581. }
  46582. if (parsedLight.includedOnlyMeshesIds) {
  46583. light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
  46584. }
  46585. // Parent
  46586. if (parsedLight.parentId) {
  46587. light._waitingParentId = parsedLight.parentId;
  46588. }
  46589. // Animations
  46590. if (parsedLight.animations) {
  46591. for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
  46592. var parsedAnimation = parsedLight.animations[animationIndex];
  46593. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  46594. if (internalClass) {
  46595. light.animations.push(internalClass.Parse(parsedAnimation));
  46596. }
  46597. }
  46598. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].ParseAnimationRanges(light, parsedLight, scene);
  46599. }
  46600. if (parsedLight.autoAnimate) {
  46601. scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
  46602. }
  46603. return light;
  46604. };
  46605. Light.prototype._hookArrayForExcluded = function (array) {
  46606. var _this = this;
  46607. var oldPush = array.push;
  46608. array.push = function () {
  46609. var items = [];
  46610. for (var _i = 0; _i < arguments.length; _i++) {
  46611. items[_i] = arguments[_i];
  46612. }
  46613. var result = oldPush.apply(array, items);
  46614. for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
  46615. var item = items_1[_a];
  46616. item._resyncLighSource(_this);
  46617. }
  46618. return result;
  46619. };
  46620. var oldSplice = array.splice;
  46621. array.splice = function (index, deleteCount) {
  46622. var deleted = oldSplice.apply(array, [index, deleteCount]);
  46623. for (var _i = 0, deleted_1 = deleted; _i < deleted_1.length; _i++) {
  46624. var item = deleted_1[_i];
  46625. item._resyncLighSource(_this);
  46626. }
  46627. return deleted;
  46628. };
  46629. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  46630. var item = array_1[_i];
  46631. item._resyncLighSource(this);
  46632. }
  46633. };
  46634. Light.prototype._hookArrayForIncludedOnly = function (array) {
  46635. var _this = this;
  46636. var oldPush = array.push;
  46637. array.push = function () {
  46638. var items = [];
  46639. for (var _i = 0; _i < arguments.length; _i++) {
  46640. items[_i] = arguments[_i];
  46641. }
  46642. var result = oldPush.apply(array, items);
  46643. _this._resyncMeshes();
  46644. return result;
  46645. };
  46646. var oldSplice = array.splice;
  46647. array.splice = function (index, deleteCount) {
  46648. var deleted = oldSplice.apply(array, [index, deleteCount]);
  46649. _this._resyncMeshes();
  46650. return deleted;
  46651. };
  46652. this._resyncMeshes();
  46653. };
  46654. Light.prototype._resyncMeshes = function () {
  46655. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  46656. var mesh = _a[_i];
  46657. mesh._resyncLighSource(this);
  46658. }
  46659. };
  46660. /**
  46661. * Forces the meshes to update their light related information in their rendering used effects
  46662. * @hidden Internal Use Only
  46663. */
  46664. Light.prototype._markMeshesAsLightDirty = function () {
  46665. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  46666. var mesh = _a[_i];
  46667. if (mesh._lightSources.indexOf(this) !== -1) {
  46668. mesh._markSubMeshesAsLightDirty();
  46669. }
  46670. }
  46671. };
  46672. /**
  46673. * Recomputes the cached photometric scale if needed.
  46674. */
  46675. Light.prototype._computePhotometricScale = function () {
  46676. this._photometricScale = this._getPhotometricScale();
  46677. this.getScene().resetCachedMaterial();
  46678. };
  46679. /**
  46680. * Returns the Photometric Scale according to the light type and intensity mode.
  46681. */
  46682. Light.prototype._getPhotometricScale = function () {
  46683. var photometricScale = 0.0;
  46684. var lightTypeID = this.getTypeID();
  46685. //get photometric mode
  46686. var photometricMode = this.intensityMode;
  46687. if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
  46688. if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
  46689. photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
  46690. }
  46691. else {
  46692. photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
  46693. }
  46694. }
  46695. //compute photometric scale
  46696. switch (lightTypeID) {
  46697. case Light.LIGHTTYPEID_POINTLIGHT:
  46698. case Light.LIGHTTYPEID_SPOTLIGHT:
  46699. switch (photometricMode) {
  46700. case Light.INTENSITYMODE_LUMINOUSPOWER:
  46701. photometricScale = 1.0 / (4.0 * Math.PI);
  46702. break;
  46703. case Light.INTENSITYMODE_LUMINOUSINTENSITY:
  46704. photometricScale = 1.0;
  46705. break;
  46706. case Light.INTENSITYMODE_LUMINANCE:
  46707. photometricScale = this.radius * this.radius;
  46708. break;
  46709. }
  46710. break;
  46711. case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
  46712. switch (photometricMode) {
  46713. case Light.INTENSITYMODE_ILLUMINANCE:
  46714. photometricScale = 1.0;
  46715. break;
  46716. case Light.INTENSITYMODE_LUMINANCE:
  46717. // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
  46718. // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
  46719. var apexAngleRadians = this.radius;
  46720. // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
  46721. apexAngleRadians = Math.max(apexAngleRadians, 0.001);
  46722. var solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
  46723. photometricScale = solidAngle;
  46724. break;
  46725. }
  46726. break;
  46727. case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
  46728. // No fall off in hemisperic light.
  46729. photometricScale = 1.0;
  46730. break;
  46731. }
  46732. return photometricScale;
  46733. };
  46734. /**
  46735. * Reorder the light in the scene according to their defined priority.
  46736. * @hidden Internal Use Only
  46737. */
  46738. Light.prototype._reorderLightsInScene = function () {
  46739. var scene = this.getScene();
  46740. if (this._renderPriority != 0) {
  46741. scene.requireLightSorting = true;
  46742. }
  46743. this.getScene().sortLightsByPriority();
  46744. };
  46745. /**
  46746. * Falloff Default: light is falling off following the material specification:
  46747. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  46748. */
  46749. Light.FALLOFF_DEFAULT = 0;
  46750. /**
  46751. * Falloff Physical: light is falling off following the inverse squared distance law.
  46752. */
  46753. Light.FALLOFF_PHYSICAL = 1;
  46754. /**
  46755. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  46756. * to enhance interoperability with other engines.
  46757. */
  46758. Light.FALLOFF_GLTF = 2;
  46759. /**
  46760. * Falloff Standard: light is falling off like in the standard material
  46761. * to enhance interoperability with other materials.
  46762. */
  46763. Light.FALLOFF_STANDARD = 3;
  46764. //lightmapMode Consts
  46765. /**
  46766. * If every light affecting the material is in this lightmapMode,
  46767. * material.lightmapTexture adds or multiplies
  46768. * (depends on material.useLightmapAsShadowmap)
  46769. * after every other light calculations.
  46770. */
  46771. Light.LIGHTMAP_DEFAULT = 0;
  46772. /**
  46773. * material.lightmapTexture as only diffuse lighting from this light
  46774. * adds only specular lighting from this light
  46775. * adds dynamic shadows
  46776. */
  46777. Light.LIGHTMAP_SPECULAR = 1;
  46778. /**
  46779. * material.lightmapTexture as only lighting
  46780. * no light calculation from this light
  46781. * only adds dynamic shadows from this light
  46782. */
  46783. Light.LIGHTMAP_SHADOWSONLY = 2;
  46784. // Intensity Mode Consts
  46785. /**
  46786. * Each light type uses the default quantity according to its type:
  46787. * point/spot lights use luminous intensity
  46788. * directional lights use illuminance
  46789. */
  46790. Light.INTENSITYMODE_AUTOMATIC = 0;
  46791. /**
  46792. * lumen (lm)
  46793. */
  46794. Light.INTENSITYMODE_LUMINOUSPOWER = 1;
  46795. /**
  46796. * candela (lm/sr)
  46797. */
  46798. Light.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  46799. /**
  46800. * lux (lm/m^2)
  46801. */
  46802. Light.INTENSITYMODE_ILLUMINANCE = 3;
  46803. /**
  46804. * nit (cd/m^2)
  46805. */
  46806. Light.INTENSITYMODE_LUMINANCE = 4;
  46807. // Light types ids const.
  46808. /**
  46809. * Light type const id of the point light.
  46810. */
  46811. Light.LIGHTTYPEID_POINTLIGHT = 0;
  46812. /**
  46813. * Light type const id of the directional light.
  46814. */
  46815. Light.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  46816. /**
  46817. * Light type const id of the spot light.
  46818. */
  46819. Light.LIGHTTYPEID_SPOTLIGHT = 2;
  46820. /**
  46821. * Light type const id of the hemispheric light.
  46822. */
  46823. Light.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  46824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46826. ], Light.prototype, "diffuse", void 0);
  46827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46829. ], Light.prototype, "specular", void 0);
  46830. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46831. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46832. ], Light.prototype, "falloffType", void 0);
  46833. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46834. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46835. ], Light.prototype, "intensity", void 0);
  46836. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46838. ], Light.prototype, "range", null);
  46839. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46840. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46841. ], Light.prototype, "intensityMode", null);
  46842. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46843. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46844. ], Light.prototype, "radius", null);
  46845. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46846. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46847. ], Light.prototype, "_renderPriority", void 0);
  46848. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_reorderLightsInScene")
  46850. ], Light.prototype, "renderPriority", void 0);
  46851. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46852. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("shadowEnabled")
  46853. ], Light.prototype, "_shadowEnabled", void 0);
  46854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46855. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("excludeWithLayerMask")
  46856. ], Light.prototype, "_excludeWithLayerMask", void 0);
  46857. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("includeOnlyWithLayerMask")
  46859. ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
  46860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("lightmapMode")
  46862. ], Light.prototype, "_lightmapMode", void 0);
  46863. return Light;
  46864. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  46865. /***/ }),
  46866. /***/ "./Lights/pointLight.ts":
  46867. /*!******************************!*\
  46868. !*** ./Lights/pointLight.ts ***!
  46869. \******************************/
  46870. /*! exports provided: PointLight */
  46871. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46872. "use strict";
  46873. __webpack_require__.r(__webpack_exports__);
  46874. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return PointLight; });
  46875. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46876. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46877. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46878. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46879. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46880. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46881. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_0", function (name, scene) {
  46882. return function () { return new PointLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46883. });
  46884. /**
  46885. * A point light is a light defined by an unique point in world space.
  46886. * The light is emitted in every direction from this point.
  46887. * A good example of a point light is a standard light bulb.
  46888. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46889. */
  46890. var PointLight = /** @class */ (function (_super) {
  46891. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointLight, _super);
  46892. /**
  46893. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46894. * A PointLight emits the light in every direction.
  46895. * It can cast shadows.
  46896. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46897. * ```javascript
  46898. * var pointLight = new PointLight("pl", camera.position, scene);
  46899. * ```
  46900. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46901. * @param name The light friendly name
  46902. * @param position The position of the point light in the scene
  46903. * @param scene The scene the lights belongs to
  46904. */
  46905. function PointLight(name, position, scene) {
  46906. var _this = _super.call(this, name, scene) || this;
  46907. _this._shadowAngle = Math.PI / 2;
  46908. _this.position = position;
  46909. return _this;
  46910. }
  46911. Object.defineProperty(PointLight.prototype, "shadowAngle", {
  46912. /**
  46913. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46914. * This specifies what angle the shadow will use to be created.
  46915. *
  46916. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46917. */
  46918. get: function () {
  46919. return this._shadowAngle;
  46920. },
  46921. /**
  46922. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46923. * This specifies what angle the shadow will use to be created.
  46924. *
  46925. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46926. */
  46927. set: function (value) {
  46928. this._shadowAngle = value;
  46929. this.forceProjectionMatrixCompute();
  46930. },
  46931. enumerable: true,
  46932. configurable: true
  46933. });
  46934. Object.defineProperty(PointLight.prototype, "direction", {
  46935. /**
  46936. * Gets the direction if it has been set.
  46937. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46938. */
  46939. get: function () {
  46940. return this._direction;
  46941. },
  46942. /**
  46943. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46944. */
  46945. set: function (value) {
  46946. var previousNeedCube = this.needCube();
  46947. this._direction = value;
  46948. if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
  46949. this._shadowGenerator.recreateShadowMap();
  46950. }
  46951. },
  46952. enumerable: true,
  46953. configurable: true
  46954. });
  46955. /**
  46956. * Returns the string "PointLight"
  46957. * @returns the class name
  46958. */
  46959. PointLight.prototype.getClassName = function () {
  46960. return "PointLight";
  46961. };
  46962. /**
  46963. * Returns the integer 0.
  46964. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46965. */
  46966. PointLight.prototype.getTypeID = function () {
  46967. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_POINTLIGHT;
  46968. };
  46969. /**
  46970. * Specifies wether or not the shadowmap should be a cube texture.
  46971. * @returns true if the shadowmap needs to be a cube texture.
  46972. */
  46973. PointLight.prototype.needCube = function () {
  46974. return !this.direction;
  46975. };
  46976. /**
  46977. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46978. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46979. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46980. */
  46981. PointLight.prototype.getShadowDirection = function (faceIndex) {
  46982. if (this.direction) {
  46983. return _super.prototype.getShadowDirection.call(this, faceIndex);
  46984. }
  46985. else {
  46986. switch (faceIndex) {
  46987. case 0:
  46988. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1.0, 0.0, 0.0);
  46989. case 1:
  46990. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1.0, 0.0, 0.0);
  46991. case 2:
  46992. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, -1.0, 0.0);
  46993. case 3:
  46994. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 1.0, 0.0);
  46995. case 4:
  46996. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, 1.0);
  46997. case 5:
  46998. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, -1.0);
  46999. }
  47000. }
  47001. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47002. };
  47003. /**
  47004. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47005. * - fov = PI / 2
  47006. * - aspect ratio : 1.0
  47007. * - z-near and far equal to the active camera minZ and maxZ.
  47008. * Returns the PointLight.
  47009. */
  47010. PointLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47011. var activeCamera = this.getScene().activeCamera;
  47012. if (!activeCamera) {
  47013. return;
  47014. }
  47015. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(this.shadowAngle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  47016. };
  47017. PointLight.prototype._buildUniformLayout = function () {
  47018. this._uniformBuffer.addUniform("vLightData", 4);
  47019. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47020. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47021. this._uniformBuffer.addUniform("vLightFalloff", 4);
  47022. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47023. this._uniformBuffer.addUniform("depthValues", 2);
  47024. this._uniformBuffer.create();
  47025. };
  47026. /**
  47027. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47028. * @param effect The effect to update
  47029. * @param lightIndex The index of the light in the effect to update
  47030. * @returns The point light
  47031. */
  47032. PointLight.prototype.transferToEffect = function (effect, lightIndex) {
  47033. if (this.computeTransformedInformation()) {
  47034. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);
  47035. }
  47036. else {
  47037. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, lightIndex);
  47038. }
  47039. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, lightIndex);
  47040. return this;
  47041. };
  47042. /**
  47043. * Prepares the list of defines specific to the light type.
  47044. * @param defines the list of defines
  47045. * @param lightIndex defines the index of the light for the effect
  47046. */
  47047. PointLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47048. defines["POINTLIGHT" + lightIndex] = true;
  47049. };
  47050. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47051. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47052. ], PointLight.prototype, "shadowAngle", null);
  47053. return PointLight;
  47054. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  47055. /***/ }),
  47056. /***/ "./Lights/shadowLight.ts":
  47057. /*!*******************************!*\
  47058. !*** ./Lights/shadowLight.ts ***!
  47059. \*******************************/
  47060. /*! exports provided: ShadowLight */
  47061. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47062. "use strict";
  47063. __webpack_require__.r(__webpack_exports__);
  47064. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return ShadowLight; });
  47065. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47066. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47067. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47068. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47069. /**
  47070. * Base implementation IShadowLight
  47071. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  47072. */
  47073. var ShadowLight = /** @class */ (function (_super) {
  47074. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowLight, _super);
  47075. function ShadowLight() {
  47076. var _this = _super !== null && _super.apply(this, arguments) || this;
  47077. _this._needProjectionMatrixCompute = true;
  47078. return _this;
  47079. }
  47080. ShadowLight.prototype._setPosition = function (value) {
  47081. this._position = value;
  47082. };
  47083. Object.defineProperty(ShadowLight.prototype, "position", {
  47084. /**
  47085. * Sets the position the shadow will be casted from. Also use as the light position for both
  47086. * point and spot lights.
  47087. */
  47088. get: function () {
  47089. return this._position;
  47090. },
  47091. /**
  47092. * Sets the position the shadow will be casted from. Also use as the light position for both
  47093. * point and spot lights.
  47094. */
  47095. set: function (value) {
  47096. this._setPosition(value);
  47097. },
  47098. enumerable: true,
  47099. configurable: true
  47100. });
  47101. ShadowLight.prototype._setDirection = function (value) {
  47102. this._direction = value;
  47103. };
  47104. Object.defineProperty(ShadowLight.prototype, "direction", {
  47105. /**
  47106. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  47107. * Also use as the light direction on spot and directional lights.
  47108. */
  47109. get: function () {
  47110. return this._direction;
  47111. },
  47112. /**
  47113. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  47114. * Also use as the light direction on spot and directional lights.
  47115. */
  47116. set: function (value) {
  47117. this._setDirection(value);
  47118. },
  47119. enumerable: true,
  47120. configurable: true
  47121. });
  47122. Object.defineProperty(ShadowLight.prototype, "shadowMinZ", {
  47123. /**
  47124. * Gets the shadow projection clipping minimum z value.
  47125. */
  47126. get: function () {
  47127. return this._shadowMinZ;
  47128. },
  47129. /**
  47130. * Sets the shadow projection clipping minimum z value.
  47131. */
  47132. set: function (value) {
  47133. this._shadowMinZ = value;
  47134. this.forceProjectionMatrixCompute();
  47135. },
  47136. enumerable: true,
  47137. configurable: true
  47138. });
  47139. Object.defineProperty(ShadowLight.prototype, "shadowMaxZ", {
  47140. /**
  47141. * Sets the shadow projection clipping maximum z value.
  47142. */
  47143. get: function () {
  47144. return this._shadowMaxZ;
  47145. },
  47146. /**
  47147. * Gets the shadow projection clipping maximum z value.
  47148. */
  47149. set: function (value) {
  47150. this._shadowMaxZ = value;
  47151. this.forceProjectionMatrixCompute();
  47152. },
  47153. enumerable: true,
  47154. configurable: true
  47155. });
  47156. /**
  47157. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  47158. * @returns true if the information has been computed, false if it does not need to (no parenting)
  47159. */
  47160. ShadowLight.prototype.computeTransformedInformation = function () {
  47161. if (this.parent && this.parent.getWorldMatrix) {
  47162. if (!this.transformedPosition) {
  47163. this.transformedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47164. }
  47165. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
  47166. // In case the direction is present.
  47167. if (this.direction) {
  47168. if (!this.transformedDirection) {
  47169. this.transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47170. }
  47171. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);
  47172. }
  47173. return true;
  47174. }
  47175. return false;
  47176. };
  47177. /**
  47178. * Return the depth scale used for the shadow map.
  47179. * @returns the depth scale.
  47180. */
  47181. ShadowLight.prototype.getDepthScale = function () {
  47182. return 50.0;
  47183. };
  47184. /**
  47185. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  47186. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47187. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47188. */
  47189. ShadowLight.prototype.getShadowDirection = function (faceIndex) {
  47190. return this.transformedDirection ? this.transformedDirection : this.direction;
  47191. };
  47192. /**
  47193. * Returns the ShadowLight absolute position in the World.
  47194. * @returns the position vector in world space
  47195. */
  47196. ShadowLight.prototype.getAbsolutePosition = function () {
  47197. return this.transformedPosition ? this.transformedPosition : this.position;
  47198. };
  47199. /**
  47200. * Sets the ShadowLight direction toward the passed target.
  47201. * @param target The point to target in local space
  47202. * @returns the updated ShadowLight direction
  47203. */
  47204. ShadowLight.prototype.setDirectionToTarget = function (target) {
  47205. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(this.position));
  47206. return this.direction;
  47207. };
  47208. /**
  47209. * Returns the light rotation in euler definition.
  47210. * @returns the x y z rotation in local space.
  47211. */
  47212. ShadowLight.prototype.getRotation = function () {
  47213. this.direction.normalize();
  47214. var xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y);
  47215. var yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(xaxis, this.direction);
  47216. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].RotationFromAxis(xaxis, yaxis, this.direction);
  47217. };
  47218. /**
  47219. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  47220. * @returns true if a cube texture needs to be use
  47221. */
  47222. ShadowLight.prototype.needCube = function () {
  47223. return false;
  47224. };
  47225. /**
  47226. * Detects if the projection matrix requires to be recomputed this frame.
  47227. * @returns true if it requires to be recomputed otherwise, false.
  47228. */
  47229. ShadowLight.prototype.needProjectionMatrixCompute = function () {
  47230. return this._needProjectionMatrixCompute;
  47231. };
  47232. /**
  47233. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  47234. */
  47235. ShadowLight.prototype.forceProjectionMatrixCompute = function () {
  47236. this._needProjectionMatrixCompute = true;
  47237. };
  47238. /** @hidden */
  47239. ShadowLight.prototype._initCache = function () {
  47240. _super.prototype._initCache.call(this);
  47241. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47242. };
  47243. /** @hidden */
  47244. ShadowLight.prototype._isSynchronized = function () {
  47245. if (!this._cache.position.equals(this.position)) {
  47246. return false;
  47247. }
  47248. return true;
  47249. };
  47250. /**
  47251. * Computes the world matrix of the node
  47252. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  47253. * @returns the world matrix
  47254. */
  47255. ShadowLight.prototype.computeWorldMatrix = function (force) {
  47256. if (!force && this.isSynchronized()) {
  47257. this._currentRenderId = this.getScene().getRenderId();
  47258. return this._worldMatrix;
  47259. }
  47260. this._updateCache();
  47261. this._cache.position.copyFrom(this.position);
  47262. if (!this._worldMatrix) {
  47263. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  47264. }
  47265. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  47266. if (this.parent && this.parent.getWorldMatrix) {
  47267. this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  47268. this._markSyncedWithParent();
  47269. }
  47270. // Cache the determinant
  47271. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  47272. return this._worldMatrix;
  47273. };
  47274. /**
  47275. * Gets the minZ used for shadow according to both the scene and the light.
  47276. * @param activeCamera The camera we are returning the min for
  47277. * @returns the depth min z
  47278. */
  47279. ShadowLight.prototype.getDepthMinZ = function (activeCamera) {
  47280. return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;
  47281. };
  47282. /**
  47283. * Gets the maxZ used for shadow according to both the scene and the light.
  47284. * @param activeCamera The camera we are returning the max for
  47285. * @returns the depth max z
  47286. */
  47287. ShadowLight.prototype.getDepthMaxZ = function (activeCamera) {
  47288. return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
  47289. };
  47290. /**
  47291. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  47292. * @param matrix The materix to updated with the projection information
  47293. * @param viewMatrix The transform matrix of the light
  47294. * @param renderList The list of mesh to render in the map
  47295. * @returns The current light
  47296. */
  47297. ShadowLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47298. if (this.customProjectionMatrixBuilder) {
  47299. this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
  47300. }
  47301. else {
  47302. this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);
  47303. }
  47304. return this;
  47305. };
  47306. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47307. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47308. ], ShadowLight.prototype, "position", null);
  47309. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47310. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47311. ], ShadowLight.prototype, "direction", null);
  47312. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47313. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47314. ], ShadowLight.prototype, "shadowMinZ", null);
  47315. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47316. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47317. ], ShadowLight.prototype, "shadowMaxZ", null);
  47318. return ShadowLight;
  47319. }(_light__WEBPACK_IMPORTED_MODULE_3__["Light"]));
  47320. /***/ }),
  47321. /***/ "./Lights/spotLight.ts":
  47322. /*!*****************************!*\
  47323. !*** ./Lights/spotLight.ts ***!
  47324. \*****************************/
  47325. /*! exports provided: SpotLight */
  47326. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47327. "use strict";
  47328. __webpack_require__.r(__webpack_exports__);
  47329. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return SpotLight; });
  47330. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47331. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47332. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47333. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47334. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47335. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  47336. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_2", function (name, scene) {
  47337. 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); };
  47338. });
  47339. /**
  47340. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47341. * These values define a cone of light starting from the position, emitting toward the direction.
  47342. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47343. * and the exponent defines the speed of the decay of the light with distance (reach).
  47344. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47345. */
  47346. var SpotLight = /** @class */ (function (_super) {
  47347. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpotLight, _super);
  47348. /**
  47349. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47350. * It can cast shadows.
  47351. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47352. * @param name The light friendly name
  47353. * @param position The position of the spot light in the scene
  47354. * @param direction The direction of the light in the scene
  47355. * @param angle The cone angle of the light in Radians
  47356. * @param exponent The light decay speed with the distance from the emission spot
  47357. * @param scene The scene the lights belongs to
  47358. */
  47359. function SpotLight(name, position, direction, angle, exponent, scene) {
  47360. var _this = _super.call(this, name, scene) || this;
  47361. _this._innerAngle = 0;
  47362. _this._projectionTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47363. _this._projectionTextureLightNear = 1e-6;
  47364. _this._projectionTextureLightFar = 1000.0;
  47365. _this._projectionTextureUpDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  47366. _this._projectionTextureViewLightDirty = true;
  47367. _this._projectionTextureProjectionLightDirty = true;
  47368. _this._projectionTextureDirty = true;
  47369. _this._projectionTextureViewTargetVector = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47370. _this._projectionTextureViewLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47371. _this._projectionTextureProjectionLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47372. _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);
  47373. _this.position = position;
  47374. _this.direction = direction;
  47375. _this.angle = angle;
  47376. _this.exponent = exponent;
  47377. return _this;
  47378. }
  47379. Object.defineProperty(SpotLight.prototype, "angle", {
  47380. /**
  47381. * Gets the cone angle of the spot light in Radians.
  47382. */
  47383. get: function () {
  47384. return this._angle;
  47385. },
  47386. /**
  47387. * Sets the cone angle of the spot light in Radians.
  47388. */
  47389. set: function (value) {
  47390. this._angle = value;
  47391. this._cosHalfAngle = Math.cos(value * 0.5);
  47392. this._projectionTextureProjectionLightDirty = true;
  47393. this.forceProjectionMatrixCompute();
  47394. this._computeAngleValues();
  47395. },
  47396. enumerable: true,
  47397. configurable: true
  47398. });
  47399. Object.defineProperty(SpotLight.prototype, "innerAngle", {
  47400. /**
  47401. * Only used in gltf falloff mode, this defines the angle where
  47402. * the directional falloff will start before cutting at angle which could be seen
  47403. * as outer angle.
  47404. */
  47405. get: function () {
  47406. return this._innerAngle;
  47407. },
  47408. /**
  47409. * Only used in gltf falloff mode, this defines the angle where
  47410. * the directional falloff will start before cutting at angle which could be seen
  47411. * as outer angle.
  47412. */
  47413. set: function (value) {
  47414. this._innerAngle = value;
  47415. this._computeAngleValues();
  47416. },
  47417. enumerable: true,
  47418. configurable: true
  47419. });
  47420. Object.defineProperty(SpotLight.prototype, "shadowAngleScale", {
  47421. /**
  47422. * Allows scaling the angle of the light for shadow generation only.
  47423. */
  47424. get: function () {
  47425. return this._shadowAngleScale;
  47426. },
  47427. /**
  47428. * Allows scaling the angle of the light for shadow generation only.
  47429. */
  47430. set: function (value) {
  47431. this._shadowAngleScale = value;
  47432. this.forceProjectionMatrixCompute();
  47433. },
  47434. enumerable: true,
  47435. configurable: true
  47436. });
  47437. Object.defineProperty(SpotLight.prototype, "projectionTextureMatrix", {
  47438. /**
  47439. * Allows reading the projecton texture
  47440. */
  47441. get: function () {
  47442. return this._projectionTextureMatrix;
  47443. },
  47444. enumerable: true,
  47445. configurable: true
  47446. });
  47447. Object.defineProperty(SpotLight.prototype, "projectionTextureLightNear", {
  47448. /**
  47449. * Gets the near clip of the Spotlight for texture projection.
  47450. */
  47451. get: function () {
  47452. return this._projectionTextureLightNear;
  47453. },
  47454. /**
  47455. * Sets the near clip of the Spotlight for texture projection.
  47456. */
  47457. set: function (value) {
  47458. this._projectionTextureLightNear = value;
  47459. this._projectionTextureProjectionLightDirty = true;
  47460. },
  47461. enumerable: true,
  47462. configurable: true
  47463. });
  47464. Object.defineProperty(SpotLight.prototype, "projectionTextureLightFar", {
  47465. /**
  47466. * Gets the far clip of the Spotlight for texture projection.
  47467. */
  47468. get: function () {
  47469. return this._projectionTextureLightFar;
  47470. },
  47471. /**
  47472. * Sets the far clip of the Spotlight for texture projection.
  47473. */
  47474. set: function (value) {
  47475. this._projectionTextureLightFar = value;
  47476. this._projectionTextureProjectionLightDirty = true;
  47477. },
  47478. enumerable: true,
  47479. configurable: true
  47480. });
  47481. Object.defineProperty(SpotLight.prototype, "projectionTextureUpDirection", {
  47482. /**
  47483. * Gets the Up vector of the Spotlight for texture projection.
  47484. */
  47485. get: function () {
  47486. return this._projectionTextureUpDirection;
  47487. },
  47488. /**
  47489. * Sets the Up vector of the Spotlight for texture projection.
  47490. */
  47491. set: function (value) {
  47492. this._projectionTextureUpDirection = value;
  47493. this._projectionTextureProjectionLightDirty = true;
  47494. },
  47495. enumerable: true,
  47496. configurable: true
  47497. });
  47498. Object.defineProperty(SpotLight.prototype, "projectionTexture", {
  47499. /**
  47500. * Gets the projection texture of the light.
  47501. */
  47502. get: function () {
  47503. return this._projectionTexture;
  47504. },
  47505. /**
  47506. * Sets the projection texture of the light.
  47507. */
  47508. set: function (value) {
  47509. this._projectionTexture = value;
  47510. this._projectionTextureDirty = true;
  47511. },
  47512. enumerable: true,
  47513. configurable: true
  47514. });
  47515. /**
  47516. * Returns the string "SpotLight".
  47517. * @returns the class name
  47518. */
  47519. SpotLight.prototype.getClassName = function () {
  47520. return "SpotLight";
  47521. };
  47522. /**
  47523. * Returns the integer 2.
  47524. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47525. */
  47526. SpotLight.prototype.getTypeID = function () {
  47527. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_SPOTLIGHT;
  47528. };
  47529. /**
  47530. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47531. */
  47532. SpotLight.prototype._setDirection = function (value) {
  47533. _super.prototype._setDirection.call(this, value);
  47534. this._projectionTextureViewLightDirty = true;
  47535. };
  47536. /**
  47537. * Overrides the position setter to recompute the projection texture view light Matrix.
  47538. */
  47539. SpotLight.prototype._setPosition = function (value) {
  47540. _super.prototype._setPosition.call(this, value);
  47541. this._projectionTextureViewLightDirty = true;
  47542. };
  47543. /**
  47544. * 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.
  47545. * Returns the SpotLight.
  47546. */
  47547. SpotLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47548. var activeCamera = this.getScene().activeCamera;
  47549. if (!activeCamera) {
  47550. return;
  47551. }
  47552. this._shadowAngleScale = this._shadowAngleScale || 1;
  47553. var angle = this._shadowAngleScale * this._angle;
  47554. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(angle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  47555. };
  47556. SpotLight.prototype._computeProjectionTextureViewLightMatrix = function () {
  47557. this._projectionTextureViewLightDirty = false;
  47558. this._projectionTextureDirty = true;
  47559. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector);
  47560. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
  47561. };
  47562. SpotLight.prototype._computeProjectionTextureProjectionLightMatrix = function () {
  47563. this._projectionTextureProjectionLightDirty = false;
  47564. this._projectionTextureDirty = true;
  47565. var light_far = this.projectionTextureLightFar;
  47566. var light_near = this.projectionTextureLightNear;
  47567. var P = light_far / (light_far - light_near);
  47568. var Q = -P * light_near;
  47569. var S = 1.0 / Math.tan(this._angle / 2.0);
  47570. var A = 1.0;
  47571. _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);
  47572. };
  47573. /**
  47574. * Main function for light texture projection matrix computing.
  47575. */
  47576. SpotLight.prototype._computeProjectionTextureMatrix = function () {
  47577. this._projectionTextureDirty = false;
  47578. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
  47579. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
  47580. };
  47581. SpotLight.prototype._buildUniformLayout = function () {
  47582. this._uniformBuffer.addUniform("vLightData", 4);
  47583. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47584. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47585. this._uniformBuffer.addUniform("vLightDirection", 3);
  47586. this._uniformBuffer.addUniform("vLightFalloff", 4);
  47587. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47588. this._uniformBuffer.addUniform("depthValues", 2);
  47589. this._uniformBuffer.create();
  47590. };
  47591. SpotLight.prototype._computeAngleValues = function () {
  47592. this._lightAngleScale = 1.0 / Math.max(0.001, (Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle));
  47593. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
  47594. };
  47595. /**
  47596. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47597. * @param effect The effect to update
  47598. * @param lightIndex The index of the light in the effect to update
  47599. * @returns The spot light
  47600. */
  47601. SpotLight.prototype.transferToEffect = function (effect, lightIndex) {
  47602. var normalizeDirection;
  47603. if (this.computeTransformedInformation()) {
  47604. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);
  47605. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.transformedDirection);
  47606. }
  47607. else {
  47608. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);
  47609. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  47610. }
  47611. this._uniformBuffer.updateFloat4("vLightDirection", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);
  47612. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);
  47613. if (this.projectionTexture && this.projectionTexture.isReady()) {
  47614. if (this._projectionTextureViewLightDirty) {
  47615. this._computeProjectionTextureViewLightMatrix();
  47616. }
  47617. if (this._projectionTextureProjectionLightDirty) {
  47618. this._computeProjectionTextureProjectionLightMatrix();
  47619. }
  47620. if (this._projectionTextureDirty) {
  47621. this._computeProjectionTextureMatrix();
  47622. }
  47623. effect.setMatrix("textureProjectionMatrix" + lightIndex, this._projectionTextureMatrix);
  47624. effect.setTexture("projectionLightSampler" + lightIndex, this.projectionTexture);
  47625. }
  47626. return this;
  47627. };
  47628. /**
  47629. * Disposes the light and the associated resources.
  47630. */
  47631. SpotLight.prototype.dispose = function () {
  47632. _super.prototype.dispose.call(this);
  47633. if (this._projectionTexture) {
  47634. this._projectionTexture.dispose();
  47635. }
  47636. };
  47637. /**
  47638. * Prepares the list of defines specific to the light type.
  47639. * @param defines the list of defines
  47640. * @param lightIndex defines the index of the light for the effect
  47641. */
  47642. SpotLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47643. defines["SPOTLIGHT" + lightIndex] = true;
  47644. defines["PROJECTEDLIGHTTEXTURE" + lightIndex] = this.projectionTexture ? true : false;
  47645. };
  47646. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47647. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47648. ], SpotLight.prototype, "angle", null);
  47649. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47650. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47651. ], SpotLight.prototype, "innerAngle", null);
  47652. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47653. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47654. ], SpotLight.prototype, "shadowAngleScale", null);
  47655. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47656. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47657. ], SpotLight.prototype, "exponent", void 0);
  47658. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47659. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47660. ], SpotLight.prototype, "projectionTextureLightNear", null);
  47661. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47662. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47663. ], SpotLight.prototype, "projectionTextureLightFar", null);
  47664. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47665. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47666. ], SpotLight.prototype, "projectionTextureUpDirection", null);
  47667. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47668. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("projectedLightTexture")
  47669. ], SpotLight.prototype, "_projectionTexture", void 0);
  47670. return SpotLight;
  47671. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  47672. /***/ }),
  47673. /***/ "./Loading/Plugins/babylonFileLoader.ts":
  47674. /*!**********************************************!*\
  47675. !*** ./Loading/Plugins/babylonFileLoader.ts ***!
  47676. \**********************************************/
  47677. /*! exports provided: _BabylonLoaderRegistered */
  47678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47679. "use strict";
  47680. __webpack_require__.r(__webpack_exports__);
  47681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _BabylonLoaderRegistered; });
  47682. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  47683. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  47684. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  47685. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  47686. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/geometry */ "./Meshes/geometry.ts");
  47687. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/transformNode */ "./Meshes/transformNode.ts");
  47688. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  47689. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  47690. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  47691. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  47692. /* harmony import */ var _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Animations/animationGroup */ "./Animations/animationGroup.ts");
  47693. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  47694. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  47695. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  47696. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  47697. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../assetContainer */ "./assetContainer.ts");
  47698. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Actions/actionManager */ "./Actions/actionManager.ts");
  47699. /* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Bones/skeleton */ "./Bones/skeleton.ts");
  47700. /* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
  47701. /* harmony import */ var _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Physics/Plugins/cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  47702. /* harmony import */ var _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Physics/Plugins/oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  47703. /* harmony import */ var _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Probes/reflectionProbe */ "./Probes/reflectionProbe.ts");
  47704. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  47705. /** @hidden */
  47706. var _BabylonLoaderRegistered = true;
  47707. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  47708. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  47709. var parsedMaterial = parsedData.materials[index];
  47710. if (parsedMaterial.id === id) {
  47711. return _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  47712. }
  47713. }
  47714. return null;
  47715. };
  47716. var isDescendantOf = function (mesh, names, hierarchyIds) {
  47717. for (var i in names) {
  47718. if (mesh.name === names[i]) {
  47719. hierarchyIds.push(mesh.id);
  47720. return true;
  47721. }
  47722. }
  47723. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  47724. hierarchyIds.push(mesh.id);
  47725. return true;
  47726. }
  47727. return false;
  47728. };
  47729. var logOperation = function (operation, producer) {
  47730. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  47731. };
  47732. var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
  47733. if (addToScene === void 0) { addToScene = false; }
  47734. var container = new _assetContainer__WEBPACK_IMPORTED_MODULE_15__["AssetContainer"](scene);
  47735. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  47736. // when SceneLoader.debugLogging = true (default), or exception encountered.
  47737. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  47738. // and avoid problems with multiple concurrent .babylon loads.
  47739. var log = "importScene has failed JSON parse";
  47740. try {
  47741. var parsedData = JSON.parse(data);
  47742. log = "";
  47743. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  47744. var index;
  47745. var cache;
  47746. // Lights
  47747. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  47748. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  47749. var parsedLight = parsedData.lights[index];
  47750. var light = _Lights_light__WEBPACK_IMPORTED_MODULE_11__["Light"].Parse(parsedLight, scene);
  47751. if (light) {
  47752. container.lights.push(light);
  47753. log += (index === 0 ? "\n\tLights:" : "");
  47754. log += "\n\t\t" + light.toString(fullDetails);
  47755. }
  47756. }
  47757. }
  47758. // Reflection probes
  47759. if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
  47760. for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
  47761. var parsedReflectionProbe = parsedData.reflectionProbes[index];
  47762. var reflectionProbe = _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__["ReflectionProbe"].Parse(parsedReflectionProbe, scene, rootUrl);
  47763. if (reflectionProbe) {
  47764. container.reflectionProbes.push(reflectionProbe);
  47765. log += (index === 0 ? "\n\tReflection Probes:" : "");
  47766. log += "\n\t\t" + reflectionProbe.toString(fullDetails);
  47767. }
  47768. }
  47769. }
  47770. // Animations
  47771. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  47772. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  47773. var parsedAnimation = parsedData.animations[index];
  47774. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__["_TypeStore"].GetClass("BABYLON.Animation");
  47775. if (internalClass) {
  47776. var animation = internalClass.Parse(parsedAnimation);
  47777. scene.animations.push(animation);
  47778. container.animations.push(animation);
  47779. log += (index === 0 ? "\n\tAnimations:" : "");
  47780. log += "\n\t\t" + animation.toString(fullDetails);
  47781. }
  47782. }
  47783. }
  47784. // Materials
  47785. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  47786. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  47787. var parsedMaterial = parsedData.materials[index];
  47788. var mat = _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  47789. container.materials.push(mat);
  47790. log += (index === 0 ? "\n\tMaterials:" : "");
  47791. log += "\n\t\t" + mat.toString(fullDetails);
  47792. }
  47793. }
  47794. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  47795. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  47796. var parsedMultiMaterial = parsedData.multiMaterials[index];
  47797. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  47798. container.multiMaterials.push(mmat);
  47799. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  47800. log += "\n\t\t" + mmat.toString(fullDetails);
  47801. }
  47802. }
  47803. // Morph targets
  47804. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  47805. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  47806. var managerData = _a[_i];
  47807. container.morphTargetManagers.push(_Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene));
  47808. }
  47809. }
  47810. // Skeletons
  47811. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  47812. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  47813. var parsedSkeleton = parsedData.skeletons[index];
  47814. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  47815. container.skeletons.push(skeleton);
  47816. log += (index === 0 ? "\n\tSkeletons:" : "");
  47817. log += "\n\t\t" + skeleton.toString(fullDetails);
  47818. }
  47819. }
  47820. // Geometries
  47821. var geometries = parsedData.geometries;
  47822. if (geometries !== undefined && geometries !== null) {
  47823. var addedGeometry = new Array();
  47824. // VertexData
  47825. var vertexData = geometries.vertexData;
  47826. if (vertexData !== undefined && vertexData !== null) {
  47827. for (index = 0, cache = vertexData.length; index < cache; index++) {
  47828. var parsedVertexData = vertexData[index];
  47829. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedVertexData, scene, rootUrl));
  47830. }
  47831. }
  47832. addedGeometry.forEach(function (g) {
  47833. if (g) {
  47834. container.geometries.push(g);
  47835. }
  47836. });
  47837. }
  47838. // Transform nodes
  47839. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  47840. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  47841. var parsedTransformNode = parsedData.transformNodes[index];
  47842. var node = _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__["TransformNode"].Parse(parsedTransformNode, scene, rootUrl);
  47843. container.transformNodes.push(node);
  47844. }
  47845. }
  47846. // Meshes
  47847. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  47848. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  47849. var parsedMesh = parsedData.meshes[index];
  47850. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  47851. container.meshes.push(mesh);
  47852. log += (index === 0 ? "\n\tMeshes:" : "");
  47853. log += "\n\t\t" + mesh.toString(fullDetails);
  47854. }
  47855. }
  47856. // Cameras
  47857. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  47858. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  47859. var parsedCamera = parsedData.cameras[index];
  47860. var camera = _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].Parse(parsedCamera, scene);
  47861. container.cameras.push(camera);
  47862. log += (index === 0 ? "\n\tCameras:" : "");
  47863. log += "\n\t\t" + camera.toString(fullDetails);
  47864. }
  47865. }
  47866. // Animation Groups
  47867. if (parsedData.animationGroups !== undefined && parsedData.animationGroups !== null) {
  47868. for (index = 0, cache = parsedData.animationGroups.length; index < cache; index++) {
  47869. var parsedAnimationGroup = parsedData.animationGroups[index];
  47870. var animationGroup = _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__["AnimationGroup"].Parse(parsedAnimationGroup, scene);
  47871. container.animationGroups.push(animationGroup);
  47872. log += (index === 0 ? "\n\tAnimationGroups:" : "");
  47873. log += "\n\t\t" + animationGroup.toString(fullDetails);
  47874. }
  47875. }
  47876. // Browsing all the graph to connect the dots
  47877. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  47878. var camera = scene.cameras[index];
  47879. if (camera._waitingParentId) {
  47880. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  47881. camera._waitingParentId = null;
  47882. }
  47883. }
  47884. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  47885. var light_1 = scene.lights[index];
  47886. if (light_1 && light_1._waitingParentId) {
  47887. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  47888. light_1._waitingParentId = null;
  47889. }
  47890. }
  47891. // Connect parents & children and parse actions
  47892. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  47893. var transformNode = scene.transformNodes[index];
  47894. if (transformNode._waitingParentId) {
  47895. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  47896. transformNode._waitingParentId = null;
  47897. }
  47898. }
  47899. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47900. var mesh = scene.meshes[index];
  47901. if (mesh._waitingParentId) {
  47902. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  47903. mesh._waitingParentId = null;
  47904. }
  47905. }
  47906. // freeze world matrix application
  47907. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47908. var currentMesh = scene.meshes[index];
  47909. if (currentMesh._waitingFreezeWorldMatrix) {
  47910. currentMesh.freezeWorldMatrix();
  47911. currentMesh._waitingFreezeWorldMatrix = null;
  47912. }
  47913. else {
  47914. currentMesh.computeWorldMatrix(true);
  47915. }
  47916. }
  47917. // Lights exclusions / inclusions
  47918. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  47919. var light_2 = scene.lights[index];
  47920. // Excluded check
  47921. if (light_2._excludedMeshesIds.length > 0) {
  47922. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  47923. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  47924. if (excludedMesh) {
  47925. light_2.excludedMeshes.push(excludedMesh);
  47926. }
  47927. }
  47928. light_2._excludedMeshesIds = [];
  47929. }
  47930. // Included check
  47931. if (light_2._includedOnlyMeshesIds.length > 0) {
  47932. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  47933. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  47934. if (includedOnlyMesh) {
  47935. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  47936. }
  47937. }
  47938. light_2._includedOnlyMeshesIds = [];
  47939. }
  47940. }
  47941. _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].Parse(parsedData, scene, container, rootUrl);
  47942. // Actions (scene) Done last as it can access other objects.
  47943. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47944. var mesh = scene.meshes[index];
  47945. if (mesh._waitingActions) {
  47946. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(mesh._waitingActions, mesh, scene);
  47947. mesh._waitingActions = null;
  47948. }
  47949. }
  47950. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  47951. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(parsedData.actions, null, scene);
  47952. }
  47953. if (!addToScene) {
  47954. container.removeAllFromScene();
  47955. }
  47956. }
  47957. catch (err) {
  47958. var msg = logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + log;
  47959. if (onError) {
  47960. onError(msg, err);
  47961. }
  47962. else {
  47963. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  47964. throw err;
  47965. }
  47966. }
  47967. finally {
  47968. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  47969. _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 : ""));
  47970. }
  47971. }
  47972. return container;
  47973. };
  47974. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].RegisterPlugin({
  47975. name: "babylon.js",
  47976. extensions: ".babylon",
  47977. canDirectLoad: function (data) {
  47978. if (data.indexOf("babylon") !== -1) { // We consider that the producer string is filled
  47979. return true;
  47980. }
  47981. return false;
  47982. },
  47983. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  47984. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  47985. // when SceneLoader.debugLogging = true (default), or exception encountered.
  47986. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  47987. // and avoid problems with multiple concurrent .babylon loads.
  47988. var log = "importMesh has failed JSON parse";
  47989. try {
  47990. var parsedData = JSON.parse(data);
  47991. log = "";
  47992. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  47993. if (!meshesNames) {
  47994. meshesNames = null;
  47995. }
  47996. else if (!Array.isArray(meshesNames)) {
  47997. meshesNames = [meshesNames];
  47998. }
  47999. var hierarchyIds = new Array();
  48000. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  48001. var loadedSkeletonsIds = [];
  48002. var loadedMaterialsIds = [];
  48003. var index;
  48004. var cache;
  48005. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  48006. var parsedMesh = parsedData.meshes[index];
  48007. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  48008. if (meshesNames !== null) {
  48009. // Remove found mesh name from list.
  48010. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  48011. }
  48012. //Geometry?
  48013. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  48014. //does the file contain geometries?
  48015. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  48016. //find the correct geometry and add it to the scene
  48017. var found = false;
  48018. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  48019. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  48020. return;
  48021. }
  48022. else {
  48023. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  48024. if (parsedGeometryData.id === parsedMesh.geometryId) {
  48025. switch (geometryType) {
  48026. case "vertexData":
  48027. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedGeometryData, scene, rootUrl);
  48028. break;
  48029. }
  48030. found = true;
  48031. }
  48032. });
  48033. }
  48034. });
  48035. if (found === false) {
  48036. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Geometry not found for mesh " + parsedMesh.id);
  48037. }
  48038. }
  48039. }
  48040. // Material ?
  48041. if (parsedMesh.materialId) {
  48042. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  48043. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  48044. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  48045. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  48046. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  48047. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  48048. var subMatId = parsedMultiMaterial.materials[matIndex];
  48049. loadedMaterialsIds.push(subMatId);
  48050. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  48051. if (mat) {
  48052. log += "\n\tMaterial " + mat.toString(fullDetails);
  48053. }
  48054. }
  48055. loadedMaterialsIds.push(parsedMultiMaterial.id);
  48056. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  48057. if (mmat) {
  48058. materialFound = true;
  48059. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  48060. }
  48061. break;
  48062. }
  48063. }
  48064. }
  48065. if (materialFound === false) {
  48066. loadedMaterialsIds.push(parsedMesh.materialId);
  48067. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  48068. if (!mat) {
  48069. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Material not found for mesh " + parsedMesh.id);
  48070. }
  48071. else {
  48072. log += "\n\tMaterial " + mat.toString(fullDetails);
  48073. }
  48074. }
  48075. }
  48076. // Skeleton ?
  48077. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  48078. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  48079. if (skeletonAlreadyLoaded === false) {
  48080. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  48081. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  48082. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  48083. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  48084. skeletons.push(skeleton);
  48085. loadedSkeletonsIds.push(parsedSkeleton.id);
  48086. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  48087. }
  48088. }
  48089. }
  48090. }
  48091. // Morph targets ?
  48092. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  48093. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  48094. var managerData = _a[_i];
  48095. _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene);
  48096. }
  48097. }
  48098. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  48099. meshes.push(mesh);
  48100. log += "\n\tMesh " + mesh.toString(fullDetails);
  48101. }
  48102. }
  48103. // Connecting parents
  48104. var currentMesh;
  48105. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48106. currentMesh = scene.meshes[index];
  48107. if (currentMesh._waitingParentId) {
  48108. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  48109. currentMesh._waitingParentId = null;
  48110. }
  48111. }
  48112. // freeze and compute world matrix application
  48113. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48114. currentMesh = scene.meshes[index];
  48115. if (currentMesh._waitingFreezeWorldMatrix) {
  48116. currentMesh.freezeWorldMatrix();
  48117. currentMesh._waitingFreezeWorldMatrix = null;
  48118. }
  48119. else {
  48120. currentMesh.computeWorldMatrix(true);
  48121. }
  48122. }
  48123. }
  48124. // Particles
  48125. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  48126. var parser = _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_12__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  48127. if (parser) {
  48128. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  48129. var parsedParticleSystem = parsedData.particleSystems[index];
  48130. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  48131. particleSystems.push(parser(parsedParticleSystem, scene, rootUrl));
  48132. }
  48133. }
  48134. }
  48135. }
  48136. return true;
  48137. }
  48138. catch (err) {
  48139. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  48140. if (onError) {
  48141. onError(msg, err);
  48142. }
  48143. else {
  48144. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48145. throw err;
  48146. }
  48147. }
  48148. finally {
  48149. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48150. _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 : ""));
  48151. }
  48152. }
  48153. return false;
  48154. },
  48155. load: function (scene, data, rootUrl, onError) {
  48156. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48157. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48158. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48159. // and avoid problems with multiple concurrent .babylon loads.
  48160. var log = "importScene has failed JSON parse";
  48161. try {
  48162. var parsedData = JSON.parse(data);
  48163. log = "";
  48164. // Scene
  48165. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  48166. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].ForceFullSceneLoadingForIncremental;
  48167. }
  48168. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  48169. scene.autoClear = parsedData.autoClear;
  48170. }
  48171. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  48172. scene.clearColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(parsedData.clearColor);
  48173. }
  48174. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  48175. scene.ambientColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.ambientColor);
  48176. }
  48177. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  48178. scene.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.gravity);
  48179. }
  48180. // Fog
  48181. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  48182. scene.fogMode = parsedData.fogMode;
  48183. scene.fogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.fogColor);
  48184. scene.fogStart = parsedData.fogStart;
  48185. scene.fogEnd = parsedData.fogEnd;
  48186. scene.fogDensity = parsedData.fogDensity;
  48187. log += "\tFog mode for scene: ";
  48188. switch (scene.fogMode) {
  48189. // getters not compiling, so using hardcoded
  48190. case 1:
  48191. log += "exp\n";
  48192. break;
  48193. case 2:
  48194. log += "exp2\n";
  48195. break;
  48196. case 3:
  48197. log += "linear\n";
  48198. break;
  48199. }
  48200. }
  48201. //Physics
  48202. if (parsedData.physicsEnabled) {
  48203. var physicsPlugin;
  48204. if (parsedData.physicsEngine === "cannon") {
  48205. physicsPlugin = new _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__["CannonJSPlugin"]();
  48206. }
  48207. else if (parsedData.physicsEngine === "oimo") {
  48208. physicsPlugin = new _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__["OimoJSPlugin"]();
  48209. }
  48210. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  48211. //else - default engine, which is currently oimo
  48212. var physicsGravity = parsedData.physicsGravity ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.physicsGravity) : null;
  48213. scene.enablePhysics(physicsGravity, physicsPlugin);
  48214. }
  48215. // Metadata
  48216. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  48217. scene.metadata = parsedData.metadata;
  48218. }
  48219. //collisions, if defined. otherwise, default is true
  48220. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  48221. scene.collisionsEnabled = parsedData.collisionsEnabled;
  48222. }
  48223. var container = loadAssetContainer(scene, data, rootUrl, onError, true);
  48224. if (!container) {
  48225. return false;
  48226. }
  48227. if (parsedData.autoAnimate) {
  48228. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  48229. }
  48230. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  48231. scene.setActiveCameraByID(parsedData.activeCameraID);
  48232. }
  48233. // Environment texture
  48234. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  48235. // PBR needed for both HDR texture (gamma space) & a sky box
  48236. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  48237. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  48238. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  48239. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"](rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  48240. if (parsedData.environmentTextureRotationY) {
  48241. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  48242. }
  48243. scene.environmentTexture = hdrTexture;
  48244. }
  48245. else {
  48246. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  48247. if (parsedData.environmentTextureRotationY) {
  48248. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  48249. }
  48250. scene.environmentTexture = cubeTexture;
  48251. }
  48252. if (parsedData.createDefaultSkybox === true) {
  48253. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  48254. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  48255. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  48256. }
  48257. }
  48258. // Finish
  48259. return true;
  48260. }
  48261. catch (err) {
  48262. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  48263. if (onError) {
  48264. onError(msg, err);
  48265. }
  48266. else {
  48267. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48268. throw err;
  48269. }
  48270. }
  48271. finally {
  48272. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48273. _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 : ""));
  48274. }
  48275. }
  48276. return false;
  48277. },
  48278. loadAssetContainer: function (scene, data, rootUrl, onError) {
  48279. var container = loadAssetContainer(scene, data, rootUrl, onError);
  48280. return container;
  48281. }
  48282. });
  48283. /***/ }),
  48284. /***/ "./Loading/Plugins/index.ts":
  48285. /*!**********************************!*\
  48286. !*** ./Loading/Plugins/index.ts ***!
  48287. \**********************************/
  48288. /*! exports provided: _BabylonLoaderRegistered */
  48289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48290. "use strict";
  48291. __webpack_require__.r(__webpack_exports__);
  48292. /* harmony import */ var _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./babylonFileLoader */ "./Loading/Plugins/babylonFileLoader.ts");
  48293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  48294. /***/ }),
  48295. /***/ "./Loading/index.ts":
  48296. /*!**************************!*\
  48297. !*** ./Loading/index.ts ***!
  48298. \**************************/
  48299. /*! exports provided: DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, _BabylonLoaderRegistered */
  48300. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48301. "use strict";
  48302. __webpack_require__.r(__webpack_exports__);
  48303. /* harmony import */ var _loadingScreen__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./loadingScreen */ "./Loading/loadingScreen.ts");
  48304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _loadingScreen__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  48305. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugins/index */ "./Loading/Plugins/index.ts");
  48306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_1__["_BabylonLoaderRegistered"]; });
  48307. /* harmony import */ var _sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneLoader */ "./Loading/sceneLoader.ts");
  48308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoaderProgressEvent"]; });
  48309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"]; });
  48310. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  48311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__["SceneLoaderFlags"]; });
  48312. /***/ }),
  48313. /***/ "./Loading/loadingScreen.ts":
  48314. /*!**********************************!*\
  48315. !*** ./Loading/loadingScreen.ts ***!
  48316. \**********************************/
  48317. /*! exports provided: DefaultLoadingScreen */
  48318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48319. "use strict";
  48320. __webpack_require__.r(__webpack_exports__);
  48321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return DefaultLoadingScreen; });
  48322. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  48323. /**
  48324. * Class used for the default loading screen
  48325. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  48326. */
  48327. var DefaultLoadingScreen = /** @class */ (function () {
  48328. /**
  48329. * Creates a new default loading screen
  48330. * @param _renderingCanvas defines the canvas used to render the scene
  48331. * @param _loadingText defines the default text to display
  48332. * @param _loadingDivBackgroundColor defines the default background color
  48333. */
  48334. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  48335. if (_loadingText === void 0) { _loadingText = ""; }
  48336. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  48337. var _this = this;
  48338. this._renderingCanvas = _renderingCanvas;
  48339. this._loadingText = _loadingText;
  48340. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  48341. // Resize
  48342. this._resizeLoadingUI = function () {
  48343. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  48344. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  48345. if (!_this._loadingDiv) {
  48346. return;
  48347. }
  48348. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  48349. _this._loadingDiv.style.left = canvasRect.left + "px";
  48350. _this._loadingDiv.style.top = canvasRect.top + "px";
  48351. _this._loadingDiv.style.width = canvasRect.width + "px";
  48352. _this._loadingDiv.style.height = canvasRect.height + "px";
  48353. };
  48354. }
  48355. /**
  48356. * Function called to display the loading screen
  48357. */
  48358. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  48359. if (this._loadingDiv) {
  48360. // Do not add a loading screen if there is already one
  48361. return;
  48362. }
  48363. this._loadingDiv = document.createElement("div");
  48364. this._loadingDiv.id = "babylonjsLoadingDiv";
  48365. this._loadingDiv.style.opacity = "0";
  48366. this._loadingDiv.style.transition = "opacity 1.5s ease";
  48367. this._loadingDiv.style.pointerEvents = "none";
  48368. // Loading text
  48369. this._loadingTextDiv = document.createElement("div");
  48370. this._loadingTextDiv.style.position = "absolute";
  48371. this._loadingTextDiv.style.left = "0";
  48372. this._loadingTextDiv.style.top = "50%";
  48373. this._loadingTextDiv.style.marginTop = "80px";
  48374. this._loadingTextDiv.style.width = "100%";
  48375. this._loadingTextDiv.style.height = "20px";
  48376. this._loadingTextDiv.style.fontFamily = "Arial";
  48377. this._loadingTextDiv.style.fontSize = "14px";
  48378. this._loadingTextDiv.style.color = "white";
  48379. this._loadingTextDiv.style.textAlign = "center";
  48380. this._loadingTextDiv.innerHTML = "Loading";
  48381. this._loadingDiv.appendChild(this._loadingTextDiv);
  48382. //set the predefined text
  48383. this._loadingTextDiv.innerHTML = this._loadingText;
  48384. // Generating keyframes
  48385. var style = document.createElement('style');
  48386. style.type = 'text/css';
  48387. 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 }";
  48388. style.innerHTML = keyFrames;
  48389. document.getElementsByTagName('head')[0].appendChild(style);
  48390. // Loading img
  48391. var imgBack = new Image();
  48392. 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";
  48393. imgBack.style.position = "absolute";
  48394. imgBack.style.left = "50%";
  48395. imgBack.style.top = "50%";
  48396. imgBack.style.marginLeft = "-60px";
  48397. imgBack.style.marginTop = "-60px";
  48398. imgBack.style.animation = "spin1 2s infinite ease-in-out";
  48399. imgBack.style.webkitAnimation = "spin1 2s infinite ease-in-out";
  48400. imgBack.style.transformOrigin = "50% 50%";
  48401. imgBack.style.webkitTransformOrigin = "50% 50%";
  48402. this._loadingDiv.appendChild(imgBack);
  48403. this._resizeLoadingUI();
  48404. window.addEventListener("resize", this._resizeLoadingUI);
  48405. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  48406. document.body.appendChild(this._loadingDiv);
  48407. this._loadingDiv.style.opacity = "1";
  48408. };
  48409. /**
  48410. * Function called to hide the loading screen
  48411. */
  48412. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  48413. var _this = this;
  48414. if (!this._loadingDiv) {
  48415. return;
  48416. }
  48417. var onTransitionEnd = function () {
  48418. if (!_this._loadingDiv) {
  48419. return;
  48420. }
  48421. if (_this._loadingDiv.parentElement) {
  48422. _this._loadingDiv.parentElement.removeChild(_this._loadingDiv);
  48423. }
  48424. window.removeEventListener("resize", _this._resizeLoadingUI);
  48425. _this._loadingDiv = null;
  48426. };
  48427. this._loadingDiv.style.opacity = "0";
  48428. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  48429. };
  48430. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  48431. get: function () {
  48432. return this._loadingText;
  48433. },
  48434. /**
  48435. * Gets or sets the text to display while loading
  48436. */
  48437. set: function (text) {
  48438. this._loadingText = text;
  48439. if (this._loadingTextDiv) {
  48440. this._loadingTextDiv.innerHTML = this._loadingText;
  48441. }
  48442. },
  48443. enumerable: true,
  48444. configurable: true
  48445. });
  48446. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  48447. /**
  48448. * Gets or sets the color to use for the background
  48449. */
  48450. get: function () {
  48451. return this._loadingDivBackgroundColor;
  48452. },
  48453. set: function (color) {
  48454. this._loadingDivBackgroundColor = color;
  48455. if (!this._loadingDiv) {
  48456. return;
  48457. }
  48458. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  48459. },
  48460. enumerable: true,
  48461. configurable: true
  48462. });
  48463. return DefaultLoadingScreen;
  48464. }());
  48465. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].DefaultLoadingScreenFactory = function (canvas) { return new DefaultLoadingScreen(canvas); };
  48466. /***/ }),
  48467. /***/ "./Loading/sceneLoader.ts":
  48468. /*!********************************!*\
  48469. !*** ./Loading/sceneLoader.ts ***!
  48470. \********************************/
  48471. /*! exports provided: SceneLoaderProgressEvent, SceneLoader */
  48472. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48473. "use strict";
  48474. __webpack_require__.r(__webpack_exports__);
  48475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return SceneLoaderProgressEvent; });
  48476. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return SceneLoader; });
  48477. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  48478. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  48479. /* harmony import */ var _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/filesInputStore */ "./Misc/filesInputStore.ts");
  48480. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  48481. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  48482. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  48483. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  48484. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  48485. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  48486. /**
  48487. * Class used to represent data loading progression
  48488. */
  48489. var SceneLoaderProgressEvent = /** @class */ (function () {
  48490. /**
  48491. * Create a new progress event
  48492. * @param lengthComputable defines if data length to load can be evaluated
  48493. * @param loaded defines the loaded data length
  48494. * @param total defines the data length to load
  48495. */
  48496. function SceneLoaderProgressEvent(
  48497. /** defines if data length to load can be evaluated */
  48498. lengthComputable,
  48499. /** defines the loaded data length */
  48500. loaded,
  48501. /** defines the data length to load */
  48502. total) {
  48503. this.lengthComputable = lengthComputable;
  48504. this.loaded = loaded;
  48505. this.total = total;
  48506. }
  48507. /**
  48508. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  48509. * @param event defines the source event
  48510. * @returns a new SceneLoaderProgressEvent
  48511. */
  48512. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  48513. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  48514. };
  48515. return SceneLoaderProgressEvent;
  48516. }());
  48517. /**
  48518. * Class used to load scene from various file formats using registered plugins
  48519. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  48520. */
  48521. var SceneLoader = /** @class */ (function () {
  48522. function SceneLoader() {
  48523. }
  48524. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  48525. /**
  48526. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48527. */
  48528. get: function () {
  48529. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental;
  48530. },
  48531. set: function (value) {
  48532. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental = value;
  48533. },
  48534. enumerable: true,
  48535. configurable: true
  48536. });
  48537. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  48538. /**
  48539. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48540. */
  48541. get: function () {
  48542. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen;
  48543. },
  48544. set: function (value) {
  48545. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen = value;
  48546. },
  48547. enumerable: true,
  48548. configurable: true
  48549. });
  48550. Object.defineProperty(SceneLoader, "loggingLevel", {
  48551. /**
  48552. * Defines the current logging level (while loading the scene)
  48553. * @ignorenaming
  48554. */
  48555. get: function () {
  48556. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel;
  48557. },
  48558. set: function (value) {
  48559. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel = value;
  48560. },
  48561. enumerable: true,
  48562. configurable: true
  48563. });
  48564. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  48565. /**
  48566. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48567. */
  48568. get: function () {
  48569. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights;
  48570. },
  48571. set: function (value) {
  48572. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights = value;
  48573. },
  48574. enumerable: true,
  48575. configurable: true
  48576. });
  48577. SceneLoader._getDefaultPlugin = function () {
  48578. return SceneLoader._registeredPlugins[".babylon"];
  48579. };
  48580. SceneLoader._getPluginForExtension = function (extension) {
  48581. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  48582. if (registeredPlugin) {
  48583. return registeredPlugin;
  48584. }
  48585. _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");
  48586. return SceneLoader._getDefaultPlugin();
  48587. };
  48588. SceneLoader._getPluginForDirectLoad = function (data) {
  48589. for (var extension in SceneLoader._registeredPlugins) {
  48590. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  48591. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  48592. return SceneLoader._registeredPlugins[extension];
  48593. }
  48594. }
  48595. return SceneLoader._getDefaultPlugin();
  48596. };
  48597. SceneLoader._getPluginForFilename = function (sceneFilename) {
  48598. var queryStringPosition = sceneFilename.indexOf("?");
  48599. if (queryStringPosition !== -1) {
  48600. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  48601. }
  48602. var dotPosition = sceneFilename.lastIndexOf(".");
  48603. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  48604. return SceneLoader._getPluginForExtension(extension);
  48605. };
  48606. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  48607. SceneLoader._getDirectLoad = function (sceneFilename) {
  48608. if (sceneFilename.substr(0, 5) === "data:") {
  48609. return sceneFilename.substr(5);
  48610. }
  48611. return null;
  48612. };
  48613. SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  48614. var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
  48615. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
  48616. var plugin;
  48617. if (registeredPlugin.plugin.createPlugin) {
  48618. plugin = registeredPlugin.plugin.createPlugin();
  48619. }
  48620. else {
  48621. plugin = registeredPlugin.plugin;
  48622. }
  48623. if (!plugin) {
  48624. 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.";
  48625. }
  48626. var useArrayBuffer = registeredPlugin.isBinary;
  48627. var offlineProvider;
  48628. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  48629. var dataCallback = function (data, responseURL) {
  48630. if (scene.isDisposed) {
  48631. onError("Scene has been disposed");
  48632. return;
  48633. }
  48634. scene.offlineProvider = offlineProvider;
  48635. onSuccess(plugin, data, responseURL);
  48636. };
  48637. var request = null;
  48638. var pluginDisposed = false;
  48639. var onDisposeObservable = plugin.onDisposeObservable;
  48640. if (onDisposeObservable) {
  48641. onDisposeObservable.add(function () {
  48642. pluginDisposed = true;
  48643. if (request) {
  48644. request.abort();
  48645. request = null;
  48646. }
  48647. onDispose();
  48648. });
  48649. }
  48650. var manifestChecked = function () {
  48651. if (pluginDisposed) {
  48652. return;
  48653. }
  48654. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
  48655. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  48656. } : undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  48657. onError("Failed to load scene." + (exception ? " " + exception.message : ""), exception);
  48658. });
  48659. };
  48660. if (directLoad) {
  48661. dataCallback(directLoad);
  48662. return plugin;
  48663. }
  48664. var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
  48665. if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
  48666. var engine = scene.getEngine();
  48667. var canUseOfflineSupport = engine.enableOfflineSupport;
  48668. if (canUseOfflineSupport) {
  48669. // Also check for exceptions
  48670. var exceptionFound = false;
  48671. for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
  48672. var regex = _a[_i];
  48673. if (regex.test(fileInfo.url)) {
  48674. exceptionFound = true;
  48675. break;
  48676. }
  48677. }
  48678. canUseOfflineSupport = !exceptionFound;
  48679. }
  48680. if (canUseOfflineSupport && _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory) {
  48681. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  48682. offlineProvider = _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory(fileInfo.url, manifestChecked, engine.disableManifestCheck);
  48683. }
  48684. else {
  48685. manifestChecked();
  48686. }
  48687. }
  48688. // Loading file from disk via input file or drag'n'drop
  48689. else {
  48690. if (file) {
  48691. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ReadFile(file, dataCallback, onProgress, useArrayBuffer);
  48692. }
  48693. else {
  48694. onError("Unable to find file named " + fileInfo.name);
  48695. }
  48696. }
  48697. return plugin;
  48698. };
  48699. SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
  48700. var url;
  48701. var name;
  48702. var file = null;
  48703. if (!sceneFilename) {
  48704. url = rootUrl;
  48705. name = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(rootUrl);
  48706. rootUrl = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(rootUrl);
  48707. }
  48708. else if (sceneFilename.name) {
  48709. var sceneFile = sceneFilename;
  48710. url = rootUrl + sceneFile.name;
  48711. name = sceneFile.name;
  48712. file = sceneFile;
  48713. }
  48714. else {
  48715. var filename = sceneFilename;
  48716. if (filename.substr(0, 1) === "/") {
  48717. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Wrong sceneFilename parameter");
  48718. return null;
  48719. }
  48720. url = rootUrl + filename;
  48721. name = filename;
  48722. }
  48723. return {
  48724. url: url,
  48725. rootUrl: rootUrl,
  48726. name: name,
  48727. file: file
  48728. };
  48729. };
  48730. // Public functions
  48731. /**
  48732. * Gets a plugin that can load the given extension
  48733. * @param extension defines the extension to load
  48734. * @returns a plugin or null if none works
  48735. */
  48736. SceneLoader.GetPluginForExtension = function (extension) {
  48737. return SceneLoader._getPluginForExtension(extension).plugin;
  48738. };
  48739. /**
  48740. * Gets a boolean indicating that the given extension can be loaded
  48741. * @param extension defines the extension to load
  48742. * @returns true if the extension is supported
  48743. */
  48744. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  48745. return !!SceneLoader._registeredPlugins[extension];
  48746. };
  48747. /**
  48748. * Adds a new plugin to the list of registered plugins
  48749. * @param plugin defines the plugin to add
  48750. */
  48751. SceneLoader.RegisterPlugin = function (plugin) {
  48752. if (typeof plugin.extensions === "string") {
  48753. var extension = plugin.extensions;
  48754. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  48755. plugin: plugin,
  48756. isBinary: false
  48757. };
  48758. }
  48759. else {
  48760. var extensions = plugin.extensions;
  48761. Object.keys(extensions).forEach(function (extension) {
  48762. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  48763. plugin: plugin,
  48764. isBinary: extensions[extension].isBinary
  48765. };
  48766. });
  48767. }
  48768. };
  48769. /**
  48770. * Import meshes into a scene
  48771. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48772. * @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)
  48773. * @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)
  48774. * @param scene the instance of BABYLON.Scene to append to
  48775. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48776. * @param onProgress a callback with a progress event for each file being loaded
  48777. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48778. * @param pluginExtension the extension used to determine the plugin
  48779. * @returns The loaded plugin
  48780. */
  48781. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48782. if (sceneFilename === void 0) { sceneFilename = ""; }
  48783. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48784. if (onSuccess === void 0) { onSuccess = null; }
  48785. if (onProgress === void 0) { onProgress = null; }
  48786. if (onError === void 0) { onError = null; }
  48787. if (pluginExtension === void 0) { pluginExtension = null; }
  48788. if (!scene) {
  48789. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
  48790. return null;
  48791. }
  48792. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48793. if (!fileInfo) {
  48794. return null;
  48795. }
  48796. var loadingToken = {};
  48797. scene._addPendingData(loadingToken);
  48798. var disposeHandler = function () {
  48799. scene._removePendingData(loadingToken);
  48800. };
  48801. var errorHandler = function (message, exception) {
  48802. var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
  48803. if (onError) {
  48804. onError(scene, errorMessage, exception);
  48805. }
  48806. else {
  48807. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  48808. // should the exception be thrown?
  48809. }
  48810. disposeHandler();
  48811. };
  48812. var progressHandler = onProgress ? function (event) {
  48813. try {
  48814. onProgress(event);
  48815. }
  48816. catch (e) {
  48817. errorHandler("Error in onProgress callback", e);
  48818. }
  48819. } : undefined;
  48820. var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
  48821. scene.importedMeshesFiles.push(fileInfo.url);
  48822. if (onSuccess) {
  48823. try {
  48824. onSuccess(meshes, particleSystems, skeletons, animationGroups);
  48825. }
  48826. catch (e) {
  48827. errorHandler("Error in onSuccess callback", e);
  48828. }
  48829. }
  48830. scene._removePendingData(loadingToken);
  48831. };
  48832. return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
  48833. if (plugin.rewriteRootURL) {
  48834. fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
  48835. }
  48836. if (plugin.importMesh) {
  48837. var syncedPlugin = plugin;
  48838. var meshes = new Array();
  48839. var particleSystems = new Array();
  48840. var skeletons = new Array();
  48841. if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  48842. return;
  48843. }
  48844. scene.loadingPluginName = plugin.name;
  48845. successHandler(meshes, particleSystems, skeletons, []);
  48846. }
  48847. else {
  48848. var asyncedPlugin = plugin;
  48849. asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
  48850. scene.loadingPluginName = plugin.name;
  48851. successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
  48852. }).catch(function (error) {
  48853. errorHandler(error.message, error);
  48854. });
  48855. }
  48856. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  48857. };
  48858. /**
  48859. * Import meshes into a scene
  48860. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48861. * @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)
  48862. * @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)
  48863. * @param scene the instance of BABYLON.Scene to append to
  48864. * @param onProgress a callback with a progress event for each file being loaded
  48865. * @param pluginExtension the extension used to determine the plugin
  48866. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48867. */
  48868. SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  48869. if (sceneFilename === void 0) { sceneFilename = ""; }
  48870. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48871. if (onProgress === void 0) { onProgress = null; }
  48872. if (pluginExtension === void 0) { pluginExtension = null; }
  48873. return new Promise(function (resolve, reject) {
  48874. SceneLoader.ImportMesh(meshNames, rootUrl, sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  48875. resolve({
  48876. meshes: meshes,
  48877. particleSystems: particleSystems,
  48878. skeletons: skeletons,
  48879. animationGroups: animationGroups
  48880. });
  48881. }, onProgress, function (scene, message, exception) {
  48882. reject(exception || new Error(message));
  48883. }, pluginExtension);
  48884. });
  48885. };
  48886. /**
  48887. * Load a scene
  48888. * @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)
  48889. * @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)
  48890. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48891. * @param onSuccess a callback with the scene when import succeeds
  48892. * @param onProgress a callback with a progress event for each file being loaded
  48893. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48894. * @param pluginExtension the extension used to determine the plugin
  48895. * @returns The loaded plugin
  48896. */
  48897. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  48898. if (sceneFilename === void 0) { sceneFilename = ""; }
  48899. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  48900. if (onSuccess === void 0) { onSuccess = null; }
  48901. if (onProgress === void 0) { onProgress = null; }
  48902. if (onError === void 0) { onError = null; }
  48903. if (pluginExtension === void 0) { pluginExtension = null; }
  48904. if (!engine) {
  48905. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("No engine available");
  48906. return null;
  48907. }
  48908. return SceneLoader.Append(rootUrl, sceneFilename, new _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"](engine), onSuccess, onProgress, onError, pluginExtension);
  48909. };
  48910. /**
  48911. * Load a scene
  48912. * @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)
  48913. * @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)
  48914. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48915. * @param onProgress a callback with a progress event for each file being loaded
  48916. * @param pluginExtension the extension used to determine the plugin
  48917. * @returns The loaded scene
  48918. */
  48919. SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
  48920. if (sceneFilename === void 0) { sceneFilename = ""; }
  48921. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  48922. if (onProgress === void 0) { onProgress = null; }
  48923. if (pluginExtension === void 0) { pluginExtension = null; }
  48924. return new Promise(function (resolve, reject) {
  48925. SceneLoader.Load(rootUrl, sceneFilename, engine, function (scene) {
  48926. resolve(scene);
  48927. }, onProgress, function (scene, message, exception) {
  48928. reject(exception || new Error(message));
  48929. }, pluginExtension);
  48930. });
  48931. };
  48932. /**
  48933. * Append a scene
  48934. * @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)
  48935. * @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)
  48936. * @param scene is the instance of BABYLON.Scene to append to
  48937. * @param onSuccess a callback with the scene when import succeeds
  48938. * @param onProgress a callback with a progress event for each file being loaded
  48939. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48940. * @param pluginExtension the extension used to determine the plugin
  48941. * @returns The loaded plugin
  48942. */
  48943. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48944. if (sceneFilename === void 0) { sceneFilename = ""; }
  48945. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48946. if (onSuccess === void 0) { onSuccess = null; }
  48947. if (onProgress === void 0) { onProgress = null; }
  48948. if (onError === void 0) { onError = null; }
  48949. if (pluginExtension === void 0) { pluginExtension = null; }
  48950. if (!scene) {
  48951. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
  48952. return null;
  48953. }
  48954. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48955. if (!fileInfo) {
  48956. return null;
  48957. }
  48958. if (SceneLoader.ShowLoadingScreen) {
  48959. scene.getEngine().displayLoadingUI();
  48960. }
  48961. var loadingToken = {};
  48962. scene._addPendingData(loadingToken);
  48963. var disposeHandler = function () {
  48964. scene._removePendingData(loadingToken);
  48965. scene.getEngine().hideLoadingUI();
  48966. };
  48967. var errorHandler = function (message, exception) {
  48968. var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
  48969. if (onError) {
  48970. onError(scene, errorMessage, exception);
  48971. }
  48972. else {
  48973. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  48974. // should the exception be thrown?
  48975. }
  48976. disposeHandler();
  48977. };
  48978. var progressHandler = onProgress ? function (event) {
  48979. try {
  48980. onProgress(event);
  48981. }
  48982. catch (e) {
  48983. errorHandler("Error in onProgress callback", e);
  48984. }
  48985. } : undefined;
  48986. var successHandler = function () {
  48987. if (onSuccess) {
  48988. try {
  48989. onSuccess(scene);
  48990. }
  48991. catch (e) {
  48992. errorHandler("Error in onSuccess callback", e);
  48993. }
  48994. }
  48995. scene._removePendingData(loadingToken);
  48996. };
  48997. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  48998. if (plugin.load) {
  48999. var syncedPlugin = plugin;
  49000. if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
  49001. return;
  49002. }
  49003. scene.loadingPluginName = plugin.name;
  49004. successHandler();
  49005. }
  49006. else {
  49007. var asyncedPlugin = plugin;
  49008. asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
  49009. scene.loadingPluginName = plugin.name;
  49010. successHandler();
  49011. }).catch(function (error) {
  49012. errorHandler(error.message, error);
  49013. });
  49014. }
  49015. if (SceneLoader.ShowLoadingScreen) {
  49016. scene.executeWhenReady(function () {
  49017. scene.getEngine().hideLoadingUI();
  49018. });
  49019. }
  49020. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49021. };
  49022. /**
  49023. * Append a scene
  49024. * @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)
  49025. * @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)
  49026. * @param scene is the instance of BABYLON.Scene to append to
  49027. * @param onProgress a callback with a progress event for each file being loaded
  49028. * @param pluginExtension the extension used to determine the plugin
  49029. * @returns The given scene
  49030. */
  49031. SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49032. if (sceneFilename === void 0) { sceneFilename = ""; }
  49033. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49034. if (onProgress === void 0) { onProgress = null; }
  49035. if (pluginExtension === void 0) { pluginExtension = null; }
  49036. return new Promise(function (resolve, reject) {
  49037. SceneLoader.Append(rootUrl, sceneFilename, scene, function (scene) {
  49038. resolve(scene);
  49039. }, onProgress, function (scene, message, exception) {
  49040. reject(exception || new Error(message));
  49041. }, pluginExtension);
  49042. });
  49043. };
  49044. /**
  49045. * Load a scene into an asset container
  49046. * @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)
  49047. * @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)
  49048. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49049. * @param onSuccess a callback with the scene when import succeeds
  49050. * @param onProgress a callback with a progress event for each file being loaded
  49051. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49052. * @param pluginExtension the extension used to determine the plugin
  49053. * @returns The loaded plugin
  49054. */
  49055. SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  49056. if (sceneFilename === void 0) { sceneFilename = ""; }
  49057. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49058. if (onSuccess === void 0) { onSuccess = null; }
  49059. if (onProgress === void 0) { onProgress = null; }
  49060. if (onError === void 0) { onError = null; }
  49061. if (pluginExtension === void 0) { pluginExtension = null; }
  49062. if (!scene) {
  49063. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
  49064. return null;
  49065. }
  49066. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  49067. if (!fileInfo) {
  49068. return null;
  49069. }
  49070. var loadingToken = {};
  49071. scene._addPendingData(loadingToken);
  49072. var disposeHandler = function () {
  49073. scene._removePendingData(loadingToken);
  49074. };
  49075. var errorHandler = function (message, exception) {
  49076. var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
  49077. if (onError) {
  49078. onError(scene, errorMessage, exception);
  49079. }
  49080. else {
  49081. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  49082. // should the exception be thrown?
  49083. }
  49084. disposeHandler();
  49085. };
  49086. var progressHandler = onProgress ? function (event) {
  49087. try {
  49088. onProgress(event);
  49089. }
  49090. catch (e) {
  49091. errorHandler("Error in onProgress callback", e);
  49092. }
  49093. } : undefined;
  49094. var successHandler = function (assets) {
  49095. if (onSuccess) {
  49096. try {
  49097. onSuccess(assets);
  49098. }
  49099. catch (e) {
  49100. errorHandler("Error in onSuccess callback", e);
  49101. }
  49102. }
  49103. scene._removePendingData(loadingToken);
  49104. };
  49105. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  49106. if (plugin.loadAssetContainer) {
  49107. var syncedPlugin = plugin;
  49108. var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
  49109. if (!assetContainer) {
  49110. return;
  49111. }
  49112. scene.loadingPluginName = plugin.name;
  49113. successHandler(assetContainer);
  49114. }
  49115. else if (plugin.loadAssetContainerAsync) {
  49116. var asyncedPlugin = plugin;
  49117. asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
  49118. scene.loadingPluginName = plugin.name;
  49119. successHandler(assetContainer);
  49120. }).catch(function (error) {
  49121. errorHandler(error.message, error);
  49122. });
  49123. }
  49124. else {
  49125. errorHandler("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
  49126. }
  49127. if (SceneLoader.ShowLoadingScreen) {
  49128. scene.executeWhenReady(function () {
  49129. scene.getEngine().hideLoadingUI();
  49130. });
  49131. }
  49132. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49133. };
  49134. /**
  49135. * Load a scene into an asset container
  49136. * @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)
  49137. * @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)
  49138. * @param scene is the instance of Scene to append to
  49139. * @param onProgress a callback with a progress event for each file being loaded
  49140. * @param pluginExtension the extension used to determine the plugin
  49141. * @returns The loaded asset container
  49142. */
  49143. SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49144. if (sceneFilename === void 0) { sceneFilename = ""; }
  49145. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49146. if (onProgress === void 0) { onProgress = null; }
  49147. if (pluginExtension === void 0) { pluginExtension = null; }
  49148. return new Promise(function (resolve, reject) {
  49149. SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, function (assetContainer) {
  49150. resolve(assetContainer);
  49151. }, onProgress, function (scene, message, exception) {
  49152. reject(exception || new Error(message));
  49153. }, pluginExtension);
  49154. });
  49155. };
  49156. /**
  49157. * No logging while loading
  49158. */
  49159. SceneLoader.NO_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_NO_LOGGING;
  49160. /**
  49161. * Minimal logging while loading
  49162. */
  49163. SceneLoader.MINIMAL_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_MINIMAL_LOGGING;
  49164. /**
  49165. * Summary logging while loading
  49166. */
  49167. SceneLoader.SUMMARY_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_SUMMARY_LOGGING;
  49168. /**
  49169. * Detailled logging while loading
  49170. */
  49171. SceneLoader.DETAILED_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_DETAILED_LOGGING;
  49172. // Members
  49173. /**
  49174. * Event raised when a plugin is used to load a scene
  49175. */
  49176. SceneLoader.OnPluginActivatedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  49177. SceneLoader._registeredPlugins = {};
  49178. return SceneLoader;
  49179. }());
  49180. /***/ }),
  49181. /***/ "./Loading/sceneLoaderFlags.ts":
  49182. /*!*************************************!*\
  49183. !*** ./Loading/sceneLoaderFlags.ts ***!
  49184. \*************************************/
  49185. /*! exports provided: SceneLoaderFlags */
  49186. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49187. "use strict";
  49188. __webpack_require__.r(__webpack_exports__);
  49189. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return SceneLoaderFlags; });
  49190. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  49191. /**
  49192. * Class used to represent data loading progression
  49193. */
  49194. var SceneLoaderFlags = /** @class */ (function () {
  49195. function SceneLoaderFlags() {
  49196. }
  49197. Object.defineProperty(SceneLoaderFlags, "ForceFullSceneLoadingForIncremental", {
  49198. /**
  49199. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49200. */
  49201. get: function () {
  49202. return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
  49203. },
  49204. set: function (value) {
  49205. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
  49206. },
  49207. enumerable: true,
  49208. configurable: true
  49209. });
  49210. Object.defineProperty(SceneLoaderFlags, "ShowLoadingScreen", {
  49211. /**
  49212. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49213. */
  49214. get: function () {
  49215. return SceneLoaderFlags._ShowLoadingScreen;
  49216. },
  49217. set: function (value) {
  49218. SceneLoaderFlags._ShowLoadingScreen = value;
  49219. },
  49220. enumerable: true,
  49221. configurable: true
  49222. });
  49223. Object.defineProperty(SceneLoaderFlags, "loggingLevel", {
  49224. /**
  49225. * Defines the current logging level (while loading the scene)
  49226. * @ignorenaming
  49227. */
  49228. get: function () {
  49229. return SceneLoaderFlags._loggingLevel;
  49230. },
  49231. set: function (value) {
  49232. SceneLoaderFlags._loggingLevel = value;
  49233. },
  49234. enumerable: true,
  49235. configurable: true
  49236. });
  49237. Object.defineProperty(SceneLoaderFlags, "CleanBoneMatrixWeights", {
  49238. /**
  49239. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49240. */
  49241. get: function () {
  49242. return SceneLoaderFlags._CleanBoneMatrixWeights;
  49243. },
  49244. set: function (value) {
  49245. SceneLoaderFlags._CleanBoneMatrixWeights = value;
  49246. },
  49247. enumerable: true,
  49248. configurable: true
  49249. });
  49250. // Flags
  49251. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = false;
  49252. SceneLoaderFlags._ShowLoadingScreen = true;
  49253. SceneLoaderFlags._CleanBoneMatrixWeights = false;
  49254. SceneLoaderFlags._loggingLevel = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].SCENELOADER_NO_LOGGING;
  49255. return SceneLoaderFlags;
  49256. }());
  49257. /***/ }),
  49258. /***/ "./Materials/Background/backgroundMaterial.ts":
  49259. /*!****************************************************!*\
  49260. !*** ./Materials/Background/backgroundMaterial.ts ***!
  49261. \****************************************************/
  49262. /*! exports provided: BackgroundMaterial */
  49263. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49264. "use strict";
  49265. __webpack_require__.r(__webpack_exports__);
  49266. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return BackgroundMaterial; });
  49267. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  49268. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  49269. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  49270. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  49271. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  49272. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  49273. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  49274. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  49275. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  49276. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  49277. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  49278. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  49279. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  49280. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  49281. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  49282. /* harmony import */ var _Shaders_background_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Shaders/background.fragment */ "./Shaders/background.fragment.ts");
  49283. /* harmony import */ var _Shaders_background_vertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/background.vertex */ "./Shaders/background.vertex.ts");
  49284. /**
  49285. * Background material defines definition.
  49286. * @hidden Mainly internal Use
  49287. */
  49288. var BackgroundMaterialDefines = /** @class */ (function (_super) {
  49289. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterialDefines, _super);
  49290. /**
  49291. * Constructor of the defines.
  49292. */
  49293. function BackgroundMaterialDefines() {
  49294. var _this = _super.call(this) || this;
  49295. /**
  49296. * True if the diffuse texture is in use.
  49297. */
  49298. _this.DIFFUSE = false;
  49299. /**
  49300. * The direct UV channel to use.
  49301. */
  49302. _this.DIFFUSEDIRECTUV = 0;
  49303. /**
  49304. * True if the diffuse texture is in gamma space.
  49305. */
  49306. _this.GAMMADIFFUSE = false;
  49307. /**
  49308. * True if the diffuse texture has opacity in the alpha channel.
  49309. */
  49310. _this.DIFFUSEHASALPHA = false;
  49311. /**
  49312. * True if you want the material to fade to transparent at grazing angle.
  49313. */
  49314. _this.OPACITYFRESNEL = false;
  49315. /**
  49316. * True if an extra blur needs to be added in the reflection.
  49317. */
  49318. _this.REFLECTIONBLUR = false;
  49319. /**
  49320. * True if you want the material to fade to reflection at grazing angle.
  49321. */
  49322. _this.REFLECTIONFRESNEL = false;
  49323. /**
  49324. * True if you want the material to falloff as far as you move away from the scene center.
  49325. */
  49326. _this.REFLECTIONFALLOFF = false;
  49327. /**
  49328. * False if the current Webgl implementation does not support the texture lod extension.
  49329. */
  49330. _this.TEXTURELODSUPPORT = false;
  49331. /**
  49332. * True to ensure the data are premultiplied.
  49333. */
  49334. _this.PREMULTIPLYALPHA = false;
  49335. /**
  49336. * True if the texture contains cooked RGB values and not gray scaled multipliers.
  49337. */
  49338. _this.USERGBCOLOR = false;
  49339. /**
  49340. * True if highlight and shadow levels have been specified. It can help ensuring the main perceived color
  49341. * stays aligned with the desired configuration.
  49342. */
  49343. _this.USEHIGHLIGHTANDSHADOWCOLORS = false;
  49344. /**
  49345. * True to add noise in order to reduce the banding effect.
  49346. */
  49347. _this.NOISE = false;
  49348. /**
  49349. * is the reflection texture in BGR color scheme?
  49350. * Mainly used to solve a bug in ios10 video tag
  49351. */
  49352. _this.REFLECTIONBGR = false;
  49353. _this.IMAGEPROCESSING = false;
  49354. _this.VIGNETTE = false;
  49355. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  49356. _this.VIGNETTEBLENDMODEOPAQUE = false;
  49357. _this.TONEMAPPING = false;
  49358. _this.TONEMAPPING_ACES = false;
  49359. _this.CONTRAST = false;
  49360. _this.COLORCURVES = false;
  49361. _this.COLORGRADING = false;
  49362. _this.COLORGRADING3D = false;
  49363. _this.SAMPLER3DGREENDEPTH = false;
  49364. _this.SAMPLER3DBGRMAP = false;
  49365. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  49366. _this.EXPOSURE = false;
  49367. // Reflection.
  49368. _this.REFLECTION = false;
  49369. _this.REFLECTIONMAP_3D = false;
  49370. _this.REFLECTIONMAP_SPHERICAL = false;
  49371. _this.REFLECTIONMAP_PLANAR = false;
  49372. _this.REFLECTIONMAP_CUBIC = false;
  49373. _this.REFLECTIONMAP_PROJECTION = false;
  49374. _this.REFLECTIONMAP_SKYBOX = false;
  49375. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  49376. _this.REFLECTIONMAP_EXPLICIT = false;
  49377. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  49378. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  49379. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  49380. _this.INVERTCUBICMAP = false;
  49381. _this.REFLECTIONMAP_OPPOSITEZ = false;
  49382. _this.LODINREFLECTIONALPHA = false;
  49383. _this.GAMMAREFLECTION = false;
  49384. _this.RGBDREFLECTION = false;
  49385. _this.EQUIRECTANGULAR_RELFECTION_FOV = false;
  49386. // Default BJS.
  49387. _this.MAINUV1 = false;
  49388. _this.MAINUV2 = false;
  49389. _this.UV1 = false;
  49390. _this.UV2 = false;
  49391. _this.CLIPPLANE = false;
  49392. _this.CLIPPLANE2 = false;
  49393. _this.CLIPPLANE3 = false;
  49394. _this.CLIPPLANE4 = false;
  49395. _this.POINTSIZE = false;
  49396. _this.FOG = false;
  49397. _this.NORMAL = false;
  49398. _this.NUM_BONE_INFLUENCERS = 0;
  49399. _this.BonesPerMesh = 0;
  49400. _this.INSTANCES = false;
  49401. _this.SHADOWFLOAT = false;
  49402. _this.rebuild();
  49403. return _this;
  49404. }
  49405. return BackgroundMaterialDefines;
  49406. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  49407. /**
  49408. * Background material used to create an efficient environement around your scene.
  49409. */
  49410. var BackgroundMaterial = /** @class */ (function (_super) {
  49411. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterial, _super);
  49412. /**
  49413. * Instantiates a Background Material in the given scene
  49414. * @param name The friendly name of the material
  49415. * @param scene The scene to add the material to
  49416. */
  49417. function BackgroundMaterial(name, scene) {
  49418. var _this = _super.call(this, name, scene) || this;
  49419. /**
  49420. * Key light Color (multiply against the environement texture)
  49421. */
  49422. _this.primaryColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  49423. _this._primaryColorShadowLevel = 0;
  49424. _this._primaryColorHighlightLevel = 0;
  49425. /**
  49426. * Reflection Texture used in the material.
  49427. * Should be author in a specific way for the best result (refer to the documentation).
  49428. */
  49429. _this.reflectionTexture = null;
  49430. /**
  49431. * Reflection Texture level of blur.
  49432. *
  49433. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49434. * texture twice.
  49435. */
  49436. _this.reflectionBlur = 0;
  49437. /**
  49438. * Diffuse Texture used in the material.
  49439. * Should be author in a specific way for the best result (refer to the documentation).
  49440. */
  49441. _this.diffuseTexture = null;
  49442. _this._shadowLights = null;
  49443. /**
  49444. * Specify the list of lights casting shadow on the material.
  49445. * All scene shadow lights will be included if null.
  49446. */
  49447. _this.shadowLights = null;
  49448. /**
  49449. * Helps adjusting the shadow to a softer level if required.
  49450. * 0 means black shadows and 1 means no shadows.
  49451. */
  49452. _this.shadowLevel = 0;
  49453. /**
  49454. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49455. * It is usually zero but might be interesting to modify according to your setup.
  49456. */
  49457. _this.sceneCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  49458. /**
  49459. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49460. * This helps ensuring a nice transition when the camera goes under the ground.
  49461. */
  49462. _this.opacityFresnel = true;
  49463. /**
  49464. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49465. * This helps adding a mirror texture on the ground.
  49466. */
  49467. _this.reflectionFresnel = false;
  49468. /**
  49469. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49470. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49471. */
  49472. _this.reflectionFalloffDistance = 0.0;
  49473. /**
  49474. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49475. */
  49476. _this.reflectionAmount = 1.0;
  49477. /**
  49478. * This specifies the weight of the reflection at grazing angle.
  49479. */
  49480. _this.reflectionReflectance0 = 0.05;
  49481. /**
  49482. * This specifies the weight of the reflection at a perpendicular point of view.
  49483. */
  49484. _this.reflectionReflectance90 = 0.5;
  49485. /**
  49486. * Helps to directly use the maps channels instead of their level.
  49487. */
  49488. _this.useRGBColor = true;
  49489. /**
  49490. * This helps reducing the banding effect that could occur on the background.
  49491. */
  49492. _this.enableNoise = false;
  49493. _this._fovMultiplier = 1.0;
  49494. /**
  49495. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49496. */
  49497. _this.useEquirectangularFOV = false;
  49498. _this._maxSimultaneousLights = 4;
  49499. /**
  49500. * Number of Simultaneous lights allowed on the material.
  49501. */
  49502. _this.maxSimultaneousLights = 4;
  49503. /**
  49504. * Keep track of the image processing observer to allow dispose and replace.
  49505. */
  49506. _this._imageProcessingObserver = null;
  49507. /**
  49508. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49509. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49510. */
  49511. _this.switchToBGR = false;
  49512. // Temp values kept as cache in the material.
  49513. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  49514. _this._reflectionControls = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector4"].Zero();
  49515. _this._white = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  49516. _this._primaryShadowColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  49517. _this._primaryHighlightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  49518. // Setup the default processing configuration to the scene.
  49519. _this._attachImageProcessingConfiguration(null);
  49520. _this.getRenderTargetTextures = function () {
  49521. _this._renderTargets.reset();
  49522. if (_this._diffuseTexture && _this._diffuseTexture.isRenderTarget) {
  49523. _this._renderTargets.push(_this._diffuseTexture);
  49524. }
  49525. if (_this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  49526. _this._renderTargets.push(_this._reflectionTexture);
  49527. }
  49528. return _this._renderTargets;
  49529. };
  49530. return _this;
  49531. }
  49532. Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
  49533. /**
  49534. * Experimental Internal Use Only.
  49535. *
  49536. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49537. * This acts as a helper to set the primary color to a more "human friendly" value.
  49538. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49539. * output color as close as possible from the chosen value.
  49540. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49541. * part of lighting setup.)
  49542. */
  49543. get: function () {
  49544. return this.__perceptualColor;
  49545. },
  49546. set: function (value) {
  49547. this.__perceptualColor = value;
  49548. this._computePrimaryColorFromPerceptualColor();
  49549. this._markAllSubMeshesAsLightsDirty();
  49550. },
  49551. enumerable: true,
  49552. configurable: true
  49553. });
  49554. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorShadowLevel", {
  49555. /**
  49556. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49557. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49558. */
  49559. get: function () {
  49560. return this._primaryColorShadowLevel;
  49561. },
  49562. set: function (value) {
  49563. this._primaryColorShadowLevel = value;
  49564. this._computePrimaryColors();
  49565. this._markAllSubMeshesAsLightsDirty();
  49566. },
  49567. enumerable: true,
  49568. configurable: true
  49569. });
  49570. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorHighlightLevel", {
  49571. /**
  49572. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49573. * The primary color is used at the level chosen to define what the white area would look.
  49574. */
  49575. get: function () {
  49576. return this._primaryColorHighlightLevel;
  49577. },
  49578. set: function (value) {
  49579. this._primaryColorHighlightLevel = value;
  49580. this._computePrimaryColors();
  49581. this._markAllSubMeshesAsLightsDirty();
  49582. },
  49583. enumerable: true,
  49584. configurable: true
  49585. });
  49586. Object.defineProperty(BackgroundMaterial.prototype, "reflectionStandardFresnelWeight", {
  49587. /**
  49588. * Sets the reflection reflectance fresnel values according to the default standard
  49589. * empirically know to work well :-)
  49590. */
  49591. set: function (value) {
  49592. var reflectionWeight = value;
  49593. if (reflectionWeight < 0.5) {
  49594. reflectionWeight = reflectionWeight * 2.0;
  49595. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 * reflectionWeight;
  49596. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 * reflectionWeight;
  49597. }
  49598. else {
  49599. reflectionWeight = reflectionWeight * 2.0 - 1.0;
  49600. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 + (1.0 - BackgroundMaterial.StandardReflectance0) * reflectionWeight;
  49601. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 + (1.0 - BackgroundMaterial.StandardReflectance90) * reflectionWeight;
  49602. }
  49603. },
  49604. enumerable: true,
  49605. configurable: true
  49606. });
  49607. Object.defineProperty(BackgroundMaterial.prototype, "fovMultiplier", {
  49608. /**
  49609. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49610. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49611. * Recommended to be keep at 1.0 except for special cases.
  49612. */
  49613. get: function () {
  49614. return this._fovMultiplier;
  49615. },
  49616. set: function (value) {
  49617. if (isNaN(value)) {
  49618. value = 1.0;
  49619. }
  49620. this._fovMultiplier = Math.max(0.0, Math.min(2.0, value));
  49621. },
  49622. enumerable: true,
  49623. configurable: true
  49624. });
  49625. /**
  49626. * Attaches a new image processing configuration to the PBR Material.
  49627. * @param configuration (if null the scene configuration will be use)
  49628. */
  49629. BackgroundMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  49630. var _this = this;
  49631. if (configuration === this._imageProcessingConfiguration) {
  49632. return;
  49633. }
  49634. // Detaches observer.
  49635. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  49636. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  49637. }
  49638. // Pick the scene configuration if needed.
  49639. if (!configuration) {
  49640. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  49641. }
  49642. else {
  49643. this._imageProcessingConfiguration = configuration;
  49644. }
  49645. // Attaches observer.
  49646. if (this._imageProcessingConfiguration) {
  49647. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  49648. _this._computePrimaryColorFromPerceptualColor();
  49649. _this._markAllSubMeshesAsImageProcessingDirty();
  49650. });
  49651. }
  49652. };
  49653. Object.defineProperty(BackgroundMaterial.prototype, "imageProcessingConfiguration", {
  49654. /**
  49655. * Gets the image processing configuration used either in this material.
  49656. */
  49657. get: function () {
  49658. return this._imageProcessingConfiguration;
  49659. },
  49660. /**
  49661. * Sets the Default image processing configuration used either in the this material.
  49662. *
  49663. * If sets to null, the scene one is in use.
  49664. */
  49665. set: function (value) {
  49666. this._attachImageProcessingConfiguration(value);
  49667. // Ensure the effect will be rebuilt.
  49668. this._markAllSubMeshesAsTexturesDirty();
  49669. },
  49670. enumerable: true,
  49671. configurable: true
  49672. });
  49673. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurvesEnabled", {
  49674. /**
  49675. * Gets wether the color curves effect is enabled.
  49676. */
  49677. get: function () {
  49678. return this.imageProcessingConfiguration.colorCurvesEnabled;
  49679. },
  49680. /**
  49681. * Sets wether the color curves effect is enabled.
  49682. */
  49683. set: function (value) {
  49684. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  49685. },
  49686. enumerable: true,
  49687. configurable: true
  49688. });
  49689. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingEnabled", {
  49690. /**
  49691. * Gets wether the color grading effect is enabled.
  49692. */
  49693. get: function () {
  49694. return this.imageProcessingConfiguration.colorGradingEnabled;
  49695. },
  49696. /**
  49697. * Gets wether the color grading effect is enabled.
  49698. */
  49699. set: function (value) {
  49700. this.imageProcessingConfiguration.colorGradingEnabled = value;
  49701. },
  49702. enumerable: true,
  49703. configurable: true
  49704. });
  49705. Object.defineProperty(BackgroundMaterial.prototype, "cameraToneMappingEnabled", {
  49706. /**
  49707. * Gets wether tonemapping is enabled or not.
  49708. */
  49709. get: function () {
  49710. return this._imageProcessingConfiguration.toneMappingEnabled;
  49711. },
  49712. /**
  49713. * Sets wether tonemapping is enabled or not
  49714. */
  49715. set: function (value) {
  49716. this._imageProcessingConfiguration.toneMappingEnabled = value;
  49717. },
  49718. enumerable: true,
  49719. configurable: true
  49720. });
  49721. Object.defineProperty(BackgroundMaterial.prototype, "cameraExposure", {
  49722. /**
  49723. * The camera exposure used on this material.
  49724. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49725. * This corresponds to a photographic exposure.
  49726. */
  49727. get: function () {
  49728. return this._imageProcessingConfiguration.exposure;
  49729. },
  49730. /**
  49731. * The camera exposure used on this material.
  49732. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49733. * This corresponds to a photographic exposure.
  49734. */
  49735. set: function (value) {
  49736. this._imageProcessingConfiguration.exposure = value;
  49737. },
  49738. enumerable: true,
  49739. configurable: true
  49740. });
  49741. Object.defineProperty(BackgroundMaterial.prototype, "cameraContrast", {
  49742. /**
  49743. * Gets The camera contrast used on this material.
  49744. */
  49745. get: function () {
  49746. return this._imageProcessingConfiguration.contrast;
  49747. },
  49748. /**
  49749. * Sets The camera contrast used on this material.
  49750. */
  49751. set: function (value) {
  49752. this._imageProcessingConfiguration.contrast = value;
  49753. },
  49754. enumerable: true,
  49755. configurable: true
  49756. });
  49757. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingTexture", {
  49758. /**
  49759. * Gets the Color Grading 2D Lookup Texture.
  49760. */
  49761. get: function () {
  49762. return this._imageProcessingConfiguration.colorGradingTexture;
  49763. },
  49764. /**
  49765. * Sets the Color Grading 2D Lookup Texture.
  49766. */
  49767. set: function (value) {
  49768. this.imageProcessingConfiguration.colorGradingTexture = value;
  49769. },
  49770. enumerable: true,
  49771. configurable: true
  49772. });
  49773. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurves", {
  49774. /**
  49775. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49776. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49777. * 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;
  49778. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49779. */
  49780. get: function () {
  49781. return this.imageProcessingConfiguration.colorCurves;
  49782. },
  49783. /**
  49784. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49785. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49786. * 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;
  49787. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49788. */
  49789. set: function (value) {
  49790. this.imageProcessingConfiguration.colorCurves = value;
  49791. },
  49792. enumerable: true,
  49793. configurable: true
  49794. });
  49795. Object.defineProperty(BackgroundMaterial.prototype, "hasRenderTargetTextures", {
  49796. /**
  49797. * Gets a boolean indicating that current material needs to register RTT
  49798. */
  49799. get: function () {
  49800. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  49801. return true;
  49802. }
  49803. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  49804. return true;
  49805. }
  49806. return false;
  49807. },
  49808. enumerable: true,
  49809. configurable: true
  49810. });
  49811. /**
  49812. * The entire material has been created in order to prevent overdraw.
  49813. * @returns false
  49814. */
  49815. BackgroundMaterial.prototype.needAlphaTesting = function () {
  49816. return true;
  49817. };
  49818. /**
  49819. * The entire material has been created in order to prevent overdraw.
  49820. * @returns true if blending is enable
  49821. */
  49822. BackgroundMaterial.prototype.needAlphaBlending = function () {
  49823. return ((this.alpha < 0) || (this._diffuseTexture != null && this._diffuseTexture.hasAlpha));
  49824. };
  49825. /**
  49826. * Checks wether the material is ready to be rendered for a given mesh.
  49827. * @param mesh The mesh to render
  49828. * @param subMesh The submesh to check against
  49829. * @param useInstances Specify wether or not the material is used with instances
  49830. * @returns true if all the dependencies are ready (Textures, Effects...)
  49831. */
  49832. BackgroundMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  49833. var _this = this;
  49834. if (useInstances === void 0) { useInstances = false; }
  49835. if (subMesh.effect && this.isFrozen) {
  49836. if (this._wasPreviouslyReady) {
  49837. return true;
  49838. }
  49839. }
  49840. if (!subMesh._materialDefines) {
  49841. subMesh._materialDefines = new BackgroundMaterialDefines();
  49842. }
  49843. var scene = this.getScene();
  49844. var defines = subMesh._materialDefines;
  49845. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  49846. if (defines._renderId === scene.getRenderId()) {
  49847. return true;
  49848. }
  49849. }
  49850. var engine = scene.getEngine();
  49851. // Lights
  49852. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  49853. defines._needNormals = true;
  49854. // Textures
  49855. if (defines._areTexturesDirty) {
  49856. defines._needUVs = false;
  49857. if (scene.texturesEnabled) {
  49858. if (scene.getEngine().getCaps().textureLOD) {
  49859. defines.TEXTURELODSUPPORT = true;
  49860. }
  49861. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  49862. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  49863. return false;
  49864. }
  49865. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  49866. defines.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha;
  49867. defines.GAMMADIFFUSE = this._diffuseTexture.gammaSpace;
  49868. defines.OPACITYFRESNEL = this._opacityFresnel;
  49869. }
  49870. else {
  49871. defines.DIFFUSE = false;
  49872. defines.DIFFUSEHASALPHA = false;
  49873. defines.GAMMADIFFUSE = false;
  49874. defines.OPACITYFRESNEL = false;
  49875. }
  49876. var reflectionTexture = this._reflectionTexture;
  49877. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  49878. if (!reflectionTexture.isReadyOrNotBlocking()) {
  49879. return false;
  49880. }
  49881. defines.REFLECTION = true;
  49882. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  49883. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  49884. defines.REFLECTIONBLUR = this._reflectionBlur > 0;
  49885. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  49886. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  49887. defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
  49888. defines.REFLECTIONBGR = this.switchToBGR;
  49889. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE) {
  49890. defines.INVERTCUBICMAP = true;
  49891. }
  49892. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  49893. switch (reflectionTexture.coordinatesMode) {
  49894. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  49895. defines.REFLECTIONMAP_EXPLICIT = true;
  49896. break;
  49897. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  49898. defines.REFLECTIONMAP_PLANAR = true;
  49899. break;
  49900. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  49901. defines.REFLECTIONMAP_PROJECTION = true;
  49902. break;
  49903. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  49904. defines.REFLECTIONMAP_SKYBOX = true;
  49905. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  49906. break;
  49907. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  49908. defines.REFLECTIONMAP_SPHERICAL = true;
  49909. break;
  49910. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  49911. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  49912. break;
  49913. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  49914. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  49915. break;
  49916. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  49917. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  49918. break;
  49919. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  49920. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  49921. default:
  49922. defines.REFLECTIONMAP_CUBIC = true;
  49923. break;
  49924. }
  49925. if (this.reflectionFresnel) {
  49926. defines.REFLECTIONFRESNEL = true;
  49927. defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
  49928. this._reflectionControls.x = this.reflectionAmount;
  49929. this._reflectionControls.y = this.reflectionReflectance0;
  49930. this._reflectionControls.z = this.reflectionReflectance90;
  49931. this._reflectionControls.w = 1 / this.reflectionFalloffDistance;
  49932. }
  49933. else {
  49934. defines.REFLECTIONFRESNEL = false;
  49935. defines.REFLECTIONFALLOFF = false;
  49936. }
  49937. }
  49938. else {
  49939. defines.REFLECTION = false;
  49940. defines.REFLECTIONFRESNEL = false;
  49941. defines.REFLECTIONFALLOFF = false;
  49942. defines.REFLECTIONBLUR = false;
  49943. defines.REFLECTIONMAP_3D = false;
  49944. defines.REFLECTIONMAP_SPHERICAL = false;
  49945. defines.REFLECTIONMAP_PLANAR = false;
  49946. defines.REFLECTIONMAP_CUBIC = false;
  49947. defines.REFLECTIONMAP_PROJECTION = false;
  49948. defines.REFLECTIONMAP_SKYBOX = false;
  49949. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  49950. defines.REFLECTIONMAP_EXPLICIT = false;
  49951. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  49952. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  49953. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  49954. defines.INVERTCUBICMAP = false;
  49955. defines.REFLECTIONMAP_OPPOSITEZ = false;
  49956. defines.LODINREFLECTIONALPHA = false;
  49957. defines.GAMMAREFLECTION = false;
  49958. defines.RGBDREFLECTION = false;
  49959. }
  49960. }
  49961. 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);
  49962. defines.USERGBCOLOR = this._useRGBColor;
  49963. defines.NOISE = this._enableNoise;
  49964. }
  49965. if (defines._areLightsDirty) {
  49966. defines.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0);
  49967. }
  49968. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  49969. if (!this._imageProcessingConfiguration.isReady()) {
  49970. return false;
  49971. }
  49972. this._imageProcessingConfiguration.prepareDefines(defines);
  49973. }
  49974. // Misc.
  49975. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  49976. // Values that need to be evaluated on every frame
  49977. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  49978. // Attribs
  49979. if (_Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
  49980. if (mesh) {
  49981. if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  49982. mesh.createNormals(true);
  49983. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
  49984. }
  49985. }
  49986. }
  49987. // Get correct effect
  49988. if (defines.isDirty) {
  49989. defines.markAsProcessed();
  49990. scene.resetCachedMaterial();
  49991. // Fallbacks
  49992. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  49993. if (defines.FOG) {
  49994. fallbacks.addFallback(0, "FOG");
  49995. }
  49996. if (defines.POINTSIZE) {
  49997. fallbacks.addFallback(1, "POINTSIZE");
  49998. }
  49999. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  50000. if (defines.NUM_BONE_INFLUENCERS > 0) {
  50001. fallbacks.addCPUSkinningFallback(0, mesh);
  50002. }
  50003. //Attributes
  50004. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  50005. if (defines.NORMAL) {
  50006. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  50007. }
  50008. if (defines.UV1) {
  50009. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  50010. }
  50011. if (defines.UV2) {
  50012. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  50013. }
  50014. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  50015. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  50016. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  50017. "vFogInfos", "vFogColor", "pointSize",
  50018. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
  50019. "vPrimaryColor", "vPrimaryColorShadow",
  50020. "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",
  50021. "shadowLevel", "alpha",
  50022. "vBackgroundCenter", "vReflectionControl",
  50023. "vDiffuseInfos", "diffuseMatrix",
  50024. ];
  50025. var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
  50026. var uniformBuffers = ["Material", "Scene"];
  50027. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  50028. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  50029. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  50030. }
  50031. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareUniformsAndSamplersList({
  50032. uniformsNames: uniforms,
  50033. uniformBuffersNames: uniformBuffers,
  50034. samplers: samplers,
  50035. defines: defines,
  50036. maxSimultaneousLights: this._maxSimultaneousLights
  50037. });
  50038. var onCompiled = function (effect) {
  50039. if (_this.onCompiled) {
  50040. _this.onCompiled(effect);
  50041. }
  50042. _this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
  50043. };
  50044. var join = defines.toString();
  50045. subMesh.setEffect(scene.getEngine().createEffect("background", {
  50046. attributes: attribs,
  50047. uniformsNames: uniforms,
  50048. uniformBuffersNames: uniformBuffers,
  50049. samplers: samplers,
  50050. defines: join,
  50051. fallbacks: fallbacks,
  50052. onCompiled: onCompiled,
  50053. onError: this.onError,
  50054. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  50055. }, engine), defines);
  50056. this.buildUniformLayout();
  50057. }
  50058. if (!subMesh.effect || !subMesh.effect.isReady()) {
  50059. return false;
  50060. }
  50061. defines._renderId = scene.getRenderId();
  50062. this._wasPreviouslyReady = true;
  50063. return true;
  50064. };
  50065. /**
  50066. * Compute the primary color according to the chosen perceptual color.
  50067. */
  50068. BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
  50069. if (!this.__perceptualColor) {
  50070. return;
  50071. }
  50072. this._primaryColor.copyFrom(this.__perceptualColor);
  50073. // Revert gamma space.
  50074. this._primaryColor.toLinearSpaceToRef(this._primaryColor);
  50075. // Revert image processing configuration.
  50076. if (this._imageProcessingConfiguration) {
  50077. // Revert Exposure.
  50078. this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
  50079. }
  50080. this._computePrimaryColors();
  50081. };
  50082. /**
  50083. * Compute the highlights and shadow colors according to their chosen levels.
  50084. */
  50085. BackgroundMaterial.prototype._computePrimaryColors = function () {
  50086. if (this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0) {
  50087. return;
  50088. }
  50089. // Find the highlight color based on the configuration.
  50090. this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
  50091. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
  50092. // Find the shadow color based on the configuration.
  50093. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
  50094. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
  50095. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
  50096. };
  50097. /**
  50098. * Build the uniform buffer used in the material.
  50099. */
  50100. BackgroundMaterial.prototype.buildUniformLayout = function () {
  50101. // Order is important !
  50102. this._uniformBuffer.addUniform("vPrimaryColor", 4);
  50103. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4);
  50104. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  50105. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  50106. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  50107. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  50108. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  50109. this._uniformBuffer.addUniform("fFovMultiplier", 1);
  50110. this._uniformBuffer.addUniform("pointSize", 1);
  50111. this._uniformBuffer.addUniform("shadowLevel", 1);
  50112. this._uniformBuffer.addUniform("alpha", 1);
  50113. this._uniformBuffer.addUniform("vBackgroundCenter", 3);
  50114. this._uniformBuffer.addUniform("vReflectionControl", 4);
  50115. this._uniformBuffer.create();
  50116. };
  50117. /**
  50118. * Unbind the material.
  50119. */
  50120. BackgroundMaterial.prototype.unbind = function () {
  50121. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  50122. this._uniformBuffer.setTexture("diffuseSampler", null);
  50123. }
  50124. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50125. this._uniformBuffer.setTexture("reflectionSampler", null);
  50126. }
  50127. _super.prototype.unbind.call(this);
  50128. };
  50129. /**
  50130. * Bind only the world matrix to the material.
  50131. * @param world The world matrix to bind.
  50132. */
  50133. BackgroundMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  50134. this._activeEffect.setMatrix("world", world);
  50135. };
  50136. /**
  50137. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50138. * @param world The world matrix to bind.
  50139. * @param subMesh The submesh to bind for.
  50140. */
  50141. BackgroundMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  50142. var scene = this.getScene();
  50143. var defines = subMesh._materialDefines;
  50144. if (!defines) {
  50145. return;
  50146. }
  50147. var effect = subMesh.effect;
  50148. if (!effect) {
  50149. return;
  50150. }
  50151. this._activeEffect = effect;
  50152. // Matrices
  50153. this.bindOnlyWorldMatrix(world);
  50154. // Bones
  50155. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  50156. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  50157. if (mustRebind) {
  50158. this._uniformBuffer.bindToEffect(effect, "Material");
  50159. this.bindViewProjection(effect);
  50160. var reflectionTexture = this._reflectionTexture;
  50161. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  50162. // Texture uniforms
  50163. if (scene.texturesEnabled) {
  50164. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50165. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  50166. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  50167. }
  50168. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50169. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  50170. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
  50171. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  50172. }
  50173. }
  50174. if (this.shadowLevel > 0) {
  50175. this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel);
  50176. }
  50177. this._uniformBuffer.updateFloat("alpha", this.alpha);
  50178. // Point size
  50179. if (this.pointsCloud) {
  50180. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  50181. }
  50182. if (defines.USEHIGHLIGHTANDSHADOWCOLORS) {
  50183. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1.0);
  50184. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1.0);
  50185. }
  50186. else {
  50187. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1.0);
  50188. }
  50189. }
  50190. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier);
  50191. // Textures
  50192. if (scene.texturesEnabled) {
  50193. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50194. this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture);
  50195. }
  50196. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50197. if (defines.REFLECTIONBLUR && defines.TEXTURELODSUPPORT) {
  50198. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  50199. }
  50200. else if (!defines.REFLECTIONBLUR) {
  50201. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  50202. }
  50203. else {
  50204. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  50205. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  50206. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  50207. }
  50208. if (defines.REFLECTIONFRESNEL) {
  50209. this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
  50210. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
  50211. }
  50212. }
  50213. }
  50214. // Clip plane
  50215. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  50216. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindEyePosition(effect, scene);
  50217. }
  50218. if (mustRebind || !this.isFrozen) {
  50219. if (scene.lightsEnabled) {
  50220. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, false);
  50221. }
  50222. // View
  50223. this.bindView(effect);
  50224. // Fog
  50225. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  50226. // image processing
  50227. if (this._imageProcessingConfiguration) {
  50228. this._imageProcessingConfiguration.bind(this._activeEffect);
  50229. }
  50230. }
  50231. this._uniformBuffer.update();
  50232. this._afterBind(mesh, this._activeEffect);
  50233. };
  50234. /**
  50235. * Dispose the material.
  50236. * @param forceDisposeEffect Force disposal of the associated effect.
  50237. * @param forceDisposeTextures Force disposal of the associated textures.
  50238. */
  50239. BackgroundMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  50240. if (forceDisposeEffect === void 0) { forceDisposeEffect = false; }
  50241. if (forceDisposeTextures === void 0) { forceDisposeTextures = false; }
  50242. if (forceDisposeTextures) {
  50243. if (this.diffuseTexture) {
  50244. this.diffuseTexture.dispose();
  50245. }
  50246. if (this.reflectionTexture) {
  50247. this.reflectionTexture.dispose();
  50248. }
  50249. }
  50250. this._renderTargets.dispose();
  50251. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50252. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50253. }
  50254. _super.prototype.dispose.call(this, forceDisposeEffect);
  50255. };
  50256. /**
  50257. * Clones the material.
  50258. * @param name The cloned name.
  50259. * @returns The cloned material.
  50260. */
  50261. BackgroundMaterial.prototype.clone = function (name) {
  50262. var _this = this;
  50263. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new BackgroundMaterial(name, _this.getScene()); }, this);
  50264. };
  50265. /**
  50266. * Serializes the current material to its JSON representation.
  50267. * @returns The JSON representation.
  50268. */
  50269. BackgroundMaterial.prototype.serialize = function () {
  50270. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  50271. serializationObject.customType = "BABYLON.BackgroundMaterial";
  50272. return serializationObject;
  50273. };
  50274. /**
  50275. * Gets the class name of the material
  50276. * @returns "BackgroundMaterial"
  50277. */
  50278. BackgroundMaterial.prototype.getClassName = function () {
  50279. return "BackgroundMaterial";
  50280. };
  50281. /**
  50282. * Parse a JSON input to create back a background material.
  50283. * @param source The JSON data to parse
  50284. * @param scene The scene to create the parsed material in
  50285. * @param rootUrl The root url of the assets the material depends upon
  50286. * @returns the instantiated BackgroundMaterial.
  50287. */
  50288. BackgroundMaterial.Parse = function (source, scene, rootUrl) {
  50289. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new BackgroundMaterial(source.name, scene); }, source, scene, rootUrl);
  50290. };
  50291. /**
  50292. * Standard reflectance value at parallel view angle.
  50293. */
  50294. BackgroundMaterial.StandardReflectance0 = 0.05;
  50295. /**
  50296. * Standard reflectance value at grazing angle.
  50297. */
  50298. BackgroundMaterial.StandardReflectance90 = 0.5;
  50299. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50300. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  50301. ], BackgroundMaterial.prototype, "_primaryColor", void 0);
  50302. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50303. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  50304. ], BackgroundMaterial.prototype, "primaryColor", void 0);
  50305. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50306. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  50307. ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
  50308. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50309. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50310. ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
  50311. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50312. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50313. ], BackgroundMaterial.prototype, "_primaryColorHighlightLevel", void 0);
  50314. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50315. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  50316. ], BackgroundMaterial.prototype, "primaryColorHighlightLevel", null);
  50317. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50318. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  50319. ], BackgroundMaterial.prototype, "_reflectionTexture", void 0);
  50320. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50321. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50322. ], BackgroundMaterial.prototype, "reflectionTexture", void 0);
  50323. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50324. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50325. ], BackgroundMaterial.prototype, "_reflectionBlur", void 0);
  50326. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50327. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50328. ], BackgroundMaterial.prototype, "reflectionBlur", void 0);
  50329. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50330. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  50331. ], BackgroundMaterial.prototype, "_diffuseTexture", void 0);
  50332. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50333. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50334. ], BackgroundMaterial.prototype, "diffuseTexture", void 0);
  50335. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50336. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50337. ], BackgroundMaterial.prototype, "shadowLights", void 0);
  50338. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50339. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50340. ], BackgroundMaterial.prototype, "_shadowLevel", void 0);
  50341. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50342. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50343. ], BackgroundMaterial.prototype, "shadowLevel", void 0);
  50344. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50345. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  50346. ], BackgroundMaterial.prototype, "_sceneCenter", void 0);
  50347. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50348. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50349. ], BackgroundMaterial.prototype, "sceneCenter", void 0);
  50350. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50351. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50352. ], BackgroundMaterial.prototype, "_opacityFresnel", void 0);
  50353. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50354. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50355. ], BackgroundMaterial.prototype, "opacityFresnel", void 0);
  50356. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50357. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50358. ], BackgroundMaterial.prototype, "_reflectionFresnel", void 0);
  50359. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50360. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50361. ], BackgroundMaterial.prototype, "reflectionFresnel", void 0);
  50362. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50363. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50364. ], BackgroundMaterial.prototype, "_reflectionFalloffDistance", void 0);
  50365. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50366. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50367. ], BackgroundMaterial.prototype, "reflectionFalloffDistance", void 0);
  50368. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50369. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50370. ], BackgroundMaterial.prototype, "_reflectionAmount", void 0);
  50371. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50372. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50373. ], BackgroundMaterial.prototype, "reflectionAmount", void 0);
  50374. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50375. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50376. ], BackgroundMaterial.prototype, "_reflectionReflectance0", void 0);
  50377. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50378. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50379. ], BackgroundMaterial.prototype, "reflectionReflectance0", void 0);
  50380. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50381. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50382. ], BackgroundMaterial.prototype, "_reflectionReflectance90", void 0);
  50383. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50384. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50385. ], BackgroundMaterial.prototype, "reflectionReflectance90", void 0);
  50386. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50387. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50388. ], BackgroundMaterial.prototype, "_useRGBColor", void 0);
  50389. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50390. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50391. ], BackgroundMaterial.prototype, "useRGBColor", void 0);
  50392. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50393. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50394. ], BackgroundMaterial.prototype, "_enableNoise", void 0);
  50395. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50396. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50397. ], BackgroundMaterial.prototype, "enableNoise", void 0);
  50398. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50399. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50400. ], BackgroundMaterial.prototype, "_maxSimultaneousLights", void 0);
  50401. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50402. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50403. ], BackgroundMaterial.prototype, "maxSimultaneousLights", void 0);
  50404. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50405. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  50406. ], BackgroundMaterial.prototype, "_imageProcessingConfiguration", void 0);
  50407. return BackgroundMaterial;
  50408. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  50409. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.BackgroundMaterial"] = BackgroundMaterial;
  50410. /***/ }),
  50411. /***/ "./Materials/Background/index.ts":
  50412. /*!***************************************!*\
  50413. !*** ./Materials/Background/index.ts ***!
  50414. \***************************************/
  50415. /*! exports provided: BackgroundMaterial */
  50416. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50417. "use strict";
  50418. __webpack_require__.r(__webpack_exports__);
  50419. /* harmony import */ var _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  50420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  50421. /***/ }),
  50422. /***/ "./Materials/PBR/index.ts":
  50423. /*!********************************!*\
  50424. !*** ./Materials/PBR/index.ts ***!
  50425. \********************************/
  50426. /*! exports provided: PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial */
  50427. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50428. "use strict";
  50429. __webpack_require__.r(__webpack_exports__);
  50430. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  50431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  50432. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  50433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRBaseSimpleMaterial"]; });
  50434. /* harmony import */ var _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  50435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRMaterial"]; });
  50436. /* harmony import */ var _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrMetallicRoughnessMaterial */ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts");
  50437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRMetallicRoughnessMaterial"]; });
  50438. /* harmony import */ var _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrSpecularGlossinessMaterial */ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts");
  50439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRSpecularGlossinessMaterial"]; });
  50440. /***/ }),
  50441. /***/ "./Materials/PBR/pbrBaseMaterial.ts":
  50442. /*!******************************************!*\
  50443. !*** ./Materials/PBR/pbrBaseMaterial.ts ***!
  50444. \******************************************/
  50445. /*! exports provided: PBRBaseMaterial */
  50446. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50447. "use strict";
  50448. __webpack_require__.r(__webpack_exports__);
  50449. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return PBRBaseMaterial; });
  50450. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  50451. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  50452. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  50453. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  50454. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  50455. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  50456. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  50457. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  50458. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  50459. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  50460. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  50461. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  50462. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  50463. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  50464. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  50465. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  50466. /* harmony import */ var _Shaders_pbr_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/pbr.fragment */ "./Shaders/pbr.fragment.ts");
  50467. /* harmony import */ var _Shaders_pbr_vertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Shaders/pbr.vertex */ "./Shaders/pbr.vertex.ts");
  50468. /**
  50469. * Manages the defines for the PBR Material.
  50470. * @hiddenChildren
  50471. */
  50472. var PBRMaterialDefines = /** @class */ (function (_super) {
  50473. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterialDefines, _super);
  50474. /**
  50475. * Initializes the PBR Material defines.
  50476. */
  50477. function PBRMaterialDefines() {
  50478. var _this = _super.call(this) || this;
  50479. _this.PBR = true;
  50480. _this.MAINUV1 = false;
  50481. _this.MAINUV2 = false;
  50482. _this.UV1 = false;
  50483. _this.UV2 = false;
  50484. _this.ALBEDO = false;
  50485. _this.ALBEDODIRECTUV = 0;
  50486. _this.VERTEXCOLOR = false;
  50487. _this.AMBIENT = false;
  50488. _this.AMBIENTDIRECTUV = 0;
  50489. _this.AMBIENTINGRAYSCALE = false;
  50490. _this.OPACITY = false;
  50491. _this.VERTEXALPHA = false;
  50492. _this.OPACITYDIRECTUV = 0;
  50493. _this.OPACITYRGB = false;
  50494. _this.ALPHATEST = false;
  50495. _this.DEPTHPREPASS = false;
  50496. _this.ALPHABLEND = false;
  50497. _this.ALPHAFROMALBEDO = false;
  50498. _this.ALPHATESTVALUE = "0.5";
  50499. _this.SPECULAROVERALPHA = false;
  50500. _this.RADIANCEOVERALPHA = false;
  50501. _this.ALPHAFRESNEL = false;
  50502. _this.LINEARALPHAFRESNEL = false;
  50503. _this.PREMULTIPLYALPHA = false;
  50504. _this.EMISSIVE = false;
  50505. _this.EMISSIVEDIRECTUV = 0;
  50506. _this.REFLECTIVITY = false;
  50507. _this.REFLECTIVITYDIRECTUV = 0;
  50508. _this.SPECULARTERM = false;
  50509. _this.MICROSURFACEFROMREFLECTIVITYMAP = false;
  50510. _this.MICROSURFACEAUTOMATIC = false;
  50511. _this.LODBASEDMICROSFURACE = false;
  50512. _this.MICROSURFACEMAP = false;
  50513. _this.MICROSURFACEMAPDIRECTUV = 0;
  50514. _this.METALLICWORKFLOW = false;
  50515. _this.ROUGHNESSSTOREINMETALMAPALPHA = false;
  50516. _this.ROUGHNESSSTOREINMETALMAPGREEN = false;
  50517. _this.METALLNESSSTOREINMETALMAPBLUE = false;
  50518. _this.AOSTOREINMETALMAPRED = false;
  50519. _this.ENVIRONMENTBRDF = false;
  50520. _this.NORMAL = false;
  50521. _this.TANGENT = false;
  50522. _this.BUMP = false;
  50523. _this.BUMPDIRECTUV = 0;
  50524. _this.OBJECTSPACE_NORMALMAP = false;
  50525. _this.PARALLAX = false;
  50526. _this.PARALLAXOCCLUSION = false;
  50527. _this.NORMALXYSCALE = true;
  50528. _this.LIGHTMAP = false;
  50529. _this.LIGHTMAPDIRECTUV = 0;
  50530. _this.USELIGHTMAPASSHADOWMAP = false;
  50531. _this.GAMMALIGHTMAP = false;
  50532. _this.REFLECTION = false;
  50533. _this.REFLECTIONMAP_3D = false;
  50534. _this.REFLECTIONMAP_SPHERICAL = false;
  50535. _this.REFLECTIONMAP_PLANAR = false;
  50536. _this.REFLECTIONMAP_CUBIC = false;
  50537. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  50538. _this.REFLECTIONMAP_PROJECTION = false;
  50539. _this.REFLECTIONMAP_SKYBOX = false;
  50540. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50541. _this.REFLECTIONMAP_EXPLICIT = false;
  50542. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50543. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50544. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50545. _this.INVERTCUBICMAP = false;
  50546. _this.USESPHERICALFROMREFLECTIONMAP = false;
  50547. _this.USESPHERICALINVERTEX = false;
  50548. _this.REFLECTIONMAP_OPPOSITEZ = false;
  50549. _this.LODINREFLECTIONALPHA = false;
  50550. _this.GAMMAREFLECTION = false;
  50551. _this.RGBDREFLECTION = false;
  50552. _this.RADIANCEOCCLUSION = false;
  50553. _this.HORIZONOCCLUSION = false;
  50554. _this.REFRACTION = false;
  50555. _this.REFRACTIONMAP_3D = false;
  50556. _this.REFRACTIONMAP_OPPOSITEZ = false;
  50557. _this.LODINREFRACTIONALPHA = false;
  50558. _this.GAMMAREFRACTION = false;
  50559. _this.RGBDREFRACTION = false;
  50560. _this.LINKREFRACTIONTOTRANSPARENCY = false;
  50561. _this.INSTANCES = false;
  50562. _this.NUM_BONE_INFLUENCERS = 0;
  50563. _this.BonesPerMesh = 0;
  50564. _this.BONETEXTURE = false;
  50565. _this.NONUNIFORMSCALING = false;
  50566. _this.MORPHTARGETS = false;
  50567. _this.MORPHTARGETS_NORMAL = false;
  50568. _this.MORPHTARGETS_TANGENT = false;
  50569. _this.NUM_MORPH_INFLUENCERS = 0;
  50570. _this.IMAGEPROCESSING = false;
  50571. _this.VIGNETTE = false;
  50572. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  50573. _this.VIGNETTEBLENDMODEOPAQUE = false;
  50574. _this.TONEMAPPING = false;
  50575. _this.TONEMAPPING_ACES = false;
  50576. _this.CONTRAST = false;
  50577. _this.COLORCURVES = false;
  50578. _this.COLORGRADING = false;
  50579. _this.COLORGRADING3D = false;
  50580. _this.SAMPLER3DGREENDEPTH = false;
  50581. _this.SAMPLER3DBGRMAP = false;
  50582. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  50583. _this.EXPOSURE = false;
  50584. _this.USEPHYSICALLIGHTFALLOFF = false;
  50585. _this.USEGLTFLIGHTFALLOFF = false;
  50586. _this.TWOSIDEDLIGHTING = false;
  50587. _this.SHADOWFLOAT = false;
  50588. _this.CLIPPLANE = false;
  50589. _this.CLIPPLANE2 = false;
  50590. _this.CLIPPLANE3 = false;
  50591. _this.CLIPPLANE4 = false;
  50592. _this.POINTSIZE = false;
  50593. _this.FOG = false;
  50594. _this.LOGARITHMICDEPTH = false;
  50595. _this.FORCENORMALFORWARD = false;
  50596. _this.SPECULARAA = false;
  50597. _this.UNLIT = false;
  50598. _this.rebuild();
  50599. return _this;
  50600. }
  50601. /**
  50602. * Resets the PBR Material defines.
  50603. */
  50604. PBRMaterialDefines.prototype.reset = function () {
  50605. _super.prototype.reset.call(this);
  50606. this.ALPHATESTVALUE = "0.5";
  50607. this.PBR = true;
  50608. };
  50609. return PBRMaterialDefines;
  50610. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_10__["MaterialDefines"]));
  50611. /**
  50612. * The Physically based material base class of BJS.
  50613. *
  50614. * This offers the main features of a standard PBR material.
  50615. * For more information, please refer to the documentation :
  50616. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  50617. */
  50618. var PBRBaseMaterial = /** @class */ (function (_super) {
  50619. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseMaterial, _super);
  50620. /**
  50621. * Instantiates a new PBRMaterial instance.
  50622. *
  50623. * @param name The material name
  50624. * @param scene The scene the material will be use in.
  50625. */
  50626. function PBRBaseMaterial(name, scene) {
  50627. var _this = _super.call(this, name, scene) || this;
  50628. /**
  50629. * Intensity of the direct lights e.g. the four lights available in your scene.
  50630. * This impacts both the direct diffuse and specular highlights.
  50631. */
  50632. _this._directIntensity = 1.0;
  50633. /**
  50634. * Intensity of the emissive part of the material.
  50635. * This helps controlling the emissive effect without modifying the emissive color.
  50636. */
  50637. _this._emissiveIntensity = 1.0;
  50638. /**
  50639. * Intensity of the environment e.g. how much the environment will light the object
  50640. * either through harmonics for rough material or through the refelction for shiny ones.
  50641. */
  50642. _this._environmentIntensity = 1.0;
  50643. /**
  50644. * This is a special control allowing the reduction of the specular highlights coming from the
  50645. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50646. */
  50647. _this._specularIntensity = 1.0;
  50648. /**
  50649. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50650. */
  50651. _this._lightingInfos = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](_this._directIntensity, _this._emissiveIntensity, _this._environmentIntensity, _this._specularIntensity);
  50652. /**
  50653. * Debug Control allowing disabling the bump map on this material.
  50654. */
  50655. _this._disableBumpMap = false;
  50656. /**
  50657. * AKA Occlusion Texture Intensity in other nomenclature.
  50658. */
  50659. _this._ambientTextureStrength = 1.0;
  50660. /**
  50661. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50662. * 1 means it completely occludes it
  50663. * 0 mean it has no impact
  50664. */
  50665. _this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  50666. /**
  50667. * The color of a material in ambient lighting.
  50668. */
  50669. _this._ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  50670. /**
  50671. * AKA Diffuse Color in other nomenclature.
  50672. */
  50673. _this._albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  50674. /**
  50675. * AKA Specular Color in other nomenclature.
  50676. */
  50677. _this._reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  50678. /**
  50679. * The color applied when light is reflected from a material.
  50680. */
  50681. _this._reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  50682. /**
  50683. * The color applied when light is emitted from a material.
  50684. */
  50685. _this._emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  50686. /**
  50687. * AKA Glossiness in other nomenclature.
  50688. */
  50689. _this._microSurface = 0.9;
  50690. /**
  50691. * source material index of refraction (IOR)' / 'destination material IOR.
  50692. */
  50693. _this._indexOfRefraction = 0.66;
  50694. /**
  50695. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50696. */
  50697. _this._invertRefractionY = false;
  50698. /**
  50699. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50700. * Materials half opaque for instance using refraction could benefit from this control.
  50701. */
  50702. _this._linkRefractionWithTransparency = false;
  50703. /**
  50704. * Specifies that the material will use the light map as a show map.
  50705. */
  50706. _this._useLightmapAsShadowmap = false;
  50707. /**
  50708. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50709. * makes the reflect vector face the model (under horizon).
  50710. */
  50711. _this._useHorizonOcclusion = true;
  50712. /**
  50713. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50714. * too much the area relying on ambient texture to define their ambient occlusion.
  50715. */
  50716. _this._useRadianceOcclusion = true;
  50717. /**
  50718. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50719. */
  50720. _this._useAlphaFromAlbedoTexture = false;
  50721. /**
  50722. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50723. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50724. */
  50725. _this._useSpecularOverAlpha = true;
  50726. /**
  50727. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50728. */
  50729. _this._useMicroSurfaceFromReflectivityMapAlpha = false;
  50730. /**
  50731. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50732. */
  50733. _this._useRoughnessFromMetallicTextureAlpha = true;
  50734. /**
  50735. * Specifies if the metallic texture contains the roughness information in its green channel.
  50736. */
  50737. _this._useRoughnessFromMetallicTextureGreen = false;
  50738. /**
  50739. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50740. */
  50741. _this._useMetallnessFromMetallicTextureBlue = false;
  50742. /**
  50743. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50744. */
  50745. _this._useAmbientOcclusionFromMetallicTextureRed = false;
  50746. /**
  50747. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50748. */
  50749. _this._useAmbientInGrayScale = false;
  50750. /**
  50751. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50752. * The material will try to infer what glossiness each pixel should be.
  50753. */
  50754. _this._useAutoMicroSurfaceFromReflectivityMap = false;
  50755. /**
  50756. * Defines the falloff type used in this material.
  50757. * It by default is Physical.
  50758. */
  50759. _this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
  50760. /**
  50761. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50762. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50763. */
  50764. _this._useRadianceOverAlpha = true;
  50765. /**
  50766. * Allows using an object space normal map (instead of tangent space).
  50767. */
  50768. _this._useObjectSpaceNormalMap = false;
  50769. /**
  50770. * Allows using the bump map in parallax mode.
  50771. */
  50772. _this._useParallax = false;
  50773. /**
  50774. * Allows using the bump map in parallax occlusion mode.
  50775. */
  50776. _this._useParallaxOcclusion = false;
  50777. /**
  50778. * Controls the scale bias of the parallax mode.
  50779. */
  50780. _this._parallaxScaleBias = 0.05;
  50781. /**
  50782. * If sets to true, disables all the lights affecting the material.
  50783. */
  50784. _this._disableLighting = false;
  50785. /**
  50786. * Number of Simultaneous lights allowed on the material.
  50787. */
  50788. _this._maxSimultaneousLights = 4;
  50789. /**
  50790. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50791. */
  50792. _this._invertNormalMapX = false;
  50793. /**
  50794. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50795. */
  50796. _this._invertNormalMapY = false;
  50797. /**
  50798. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50799. */
  50800. _this._twoSidedLighting = false;
  50801. /**
  50802. * Defines the alpha limits in alpha test mode.
  50803. */
  50804. _this._alphaCutOff = 0.4;
  50805. /**
  50806. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50807. */
  50808. _this._forceAlphaTest = false;
  50809. /**
  50810. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50811. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50812. */
  50813. _this._useAlphaFresnel = false;
  50814. /**
  50815. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50816. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50817. */
  50818. _this._useLinearAlphaFresnel = false;
  50819. /**
  50820. * The transparency mode of the material.
  50821. */
  50822. _this._transparencyMode = null;
  50823. /**
  50824. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50825. * from cos thetav and roughness:
  50826. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50827. */
  50828. _this._environmentBRDFTexture = null;
  50829. /**
  50830. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50831. */
  50832. _this._forceIrradianceInFragment = false;
  50833. /**
  50834. * Force normal to face away from face.
  50835. */
  50836. _this._forceNormalForward = false;
  50837. /**
  50838. * Enables specular anti aliasing in the PBR shader.
  50839. * It will both interacts on the Geometry for analytical and IBL lighting.
  50840. * It also prefilter the roughness map based on the bump values.
  50841. */
  50842. _this._enableSpecularAntiAliasing = false;
  50843. /**
  50844. * Stores the available render targets.
  50845. */
  50846. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__["SmartArray"](16);
  50847. /**
  50848. * Sets the global ambient color for the material used in lighting calculations.
  50849. */
  50850. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  50851. /**
  50852. * If set to true, no lighting calculations will be applied.
  50853. */
  50854. _this._unlit = false;
  50855. // Setup the default processing configuration to the scene.
  50856. _this._attachImageProcessingConfiguration(null);
  50857. _this.getRenderTargetTextures = function () {
  50858. _this._renderTargets.reset();
  50859. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  50860. _this._renderTargets.push(_this._reflectionTexture);
  50861. }
  50862. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  50863. _this._renderTargets.push(_this._refractionTexture);
  50864. }
  50865. return _this._renderTargets;
  50866. };
  50867. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  50868. return _this;
  50869. }
  50870. /**
  50871. * Attaches a new image processing configuration to the PBR Material.
  50872. * @param configuration
  50873. */
  50874. PBRBaseMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  50875. var _this = this;
  50876. if (configuration === this._imageProcessingConfiguration) {
  50877. return;
  50878. }
  50879. // Detaches observer.
  50880. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50881. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50882. }
  50883. // Pick the scene configuration if needed.
  50884. if (!configuration) {
  50885. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  50886. }
  50887. else {
  50888. this._imageProcessingConfiguration = configuration;
  50889. }
  50890. // Attaches observer.
  50891. if (this._imageProcessingConfiguration) {
  50892. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  50893. _this._markAllSubMeshesAsImageProcessingDirty();
  50894. });
  50895. }
  50896. };
  50897. Object.defineProperty(PBRBaseMaterial.prototype, "hasRenderTargetTextures", {
  50898. /**
  50899. * Gets a boolean indicating that current material needs to register RTT
  50900. */
  50901. get: function () {
  50902. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50903. return true;
  50904. }
  50905. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  50906. return true;
  50907. }
  50908. return false;
  50909. },
  50910. enumerable: true,
  50911. configurable: true
  50912. });
  50913. /**
  50914. * Gets the name of the material class.
  50915. */
  50916. PBRBaseMaterial.prototype.getClassName = function () {
  50917. return "PBRBaseMaterial";
  50918. };
  50919. Object.defineProperty(PBRBaseMaterial.prototype, "useLogarithmicDepth", {
  50920. /**
  50921. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50922. */
  50923. get: function () {
  50924. return this._useLogarithmicDepth;
  50925. },
  50926. /**
  50927. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50928. */
  50929. set: function (value) {
  50930. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  50931. },
  50932. enumerable: true,
  50933. configurable: true
  50934. });
  50935. Object.defineProperty(PBRBaseMaterial.prototype, "transparencyMode", {
  50936. /**
  50937. * Gets the current transparency mode.
  50938. */
  50939. get: function () {
  50940. return this._transparencyMode;
  50941. },
  50942. /**
  50943. * Sets the transparency mode of the material.
  50944. *
  50945. * | Value | Type | Description |
  50946. * | ----- | ----------------------------------- | ----------- |
  50947. * | 0 | OPAQUE | |
  50948. * | 1 | ALPHATEST | |
  50949. * | 2 | ALPHABLEND | |
  50950. * | 3 | ALPHATESTANDBLEND | |
  50951. *
  50952. */
  50953. set: function (value) {
  50954. if (this._transparencyMode === value) {
  50955. return;
  50956. }
  50957. this._transparencyMode = value;
  50958. this._forceAlphaTest = (value === PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
  50959. this._markAllSubMeshesAsTexturesAndMiscDirty();
  50960. },
  50961. enumerable: true,
  50962. configurable: true
  50963. });
  50964. Object.defineProperty(PBRBaseMaterial.prototype, "_disableAlphaBlending", {
  50965. /**
  50966. * Returns true if alpha blending should be disabled.
  50967. */
  50968. get: function () {
  50969. return (this._linkRefractionWithTransparency ||
  50970. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
  50971. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  50972. },
  50973. enumerable: true,
  50974. configurable: true
  50975. });
  50976. /**
  50977. * Specifies whether or not this material should be rendered in alpha blend mode.
  50978. */
  50979. PBRBaseMaterial.prototype.needAlphaBlending = function () {
  50980. if (this._disableAlphaBlending) {
  50981. return false;
  50982. }
  50983. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture();
  50984. };
  50985. /**
  50986. * Specifies if the mesh will require alpha blending.
  50987. * @param mesh - BJS mesh.
  50988. */
  50989. PBRBaseMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  50990. if (this._disableAlphaBlending) {
  50991. return false;
  50992. }
  50993. return _super.prototype.needAlphaBlendingForMesh.call(this, mesh);
  50994. };
  50995. /**
  50996. * Specifies whether or not this material should be rendered in alpha test mode.
  50997. */
  50998. PBRBaseMaterial.prototype.needAlphaTesting = function () {
  50999. if (this._forceAlphaTest) {
  51000. return true;
  51001. }
  51002. if (this._linkRefractionWithTransparency) {
  51003. return false;
  51004. }
  51005. return this._albedoTexture != null && this._albedoTexture.hasAlpha && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  51006. };
  51007. /**
  51008. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51009. */
  51010. PBRBaseMaterial.prototype._shouldUseAlphaFromAlbedoTexture = function () {
  51011. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
  51012. };
  51013. /**
  51014. * Gets the texture used for the alpha test.
  51015. */
  51016. PBRBaseMaterial.prototype.getAlphaTestTexture = function () {
  51017. return this._albedoTexture;
  51018. };
  51019. /**
  51020. * Specifies that the submesh is ready to be used.
  51021. * @param mesh - BJS mesh.
  51022. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51023. * @param useInstances - Specifies that instances should be used.
  51024. * @returns - boolean indicating that the submesh is ready or not.
  51025. */
  51026. PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  51027. if (subMesh.effect && this.isFrozen) {
  51028. if (this._wasPreviouslyReady) {
  51029. return true;
  51030. }
  51031. }
  51032. if (!subMesh._materialDefines) {
  51033. subMesh._materialDefines = new PBRMaterialDefines();
  51034. }
  51035. var defines = subMesh._materialDefines;
  51036. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  51037. if (defines._renderId === this.getScene().getRenderId()) {
  51038. return true;
  51039. }
  51040. }
  51041. var scene = this.getScene();
  51042. var engine = scene.getEngine();
  51043. if (defines._areTexturesDirty) {
  51044. if (scene.texturesEnabled) {
  51045. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51046. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  51047. return false;
  51048. }
  51049. }
  51050. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  51051. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  51052. return false;
  51053. }
  51054. }
  51055. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  51056. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  51057. return false;
  51058. }
  51059. }
  51060. var reflectionTexture = this._getReflectionTexture();
  51061. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51062. if (!reflectionTexture.isReadyOrNotBlocking()) {
  51063. return false;
  51064. }
  51065. }
  51066. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  51067. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  51068. return false;
  51069. }
  51070. }
  51071. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  51072. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  51073. return false;
  51074. }
  51075. }
  51076. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51077. if (this._metallicTexture) {
  51078. if (!this._metallicTexture.isReadyOrNotBlocking()) {
  51079. return false;
  51080. }
  51081. }
  51082. else if (this._reflectivityTexture) {
  51083. if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
  51084. return false;
  51085. }
  51086. }
  51087. if (this._microSurfaceTexture) {
  51088. if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
  51089. return false;
  51090. }
  51091. }
  51092. }
  51093. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51094. // Bump texture cannot be not blocking.
  51095. if (!this._bumpTexture.isReady()) {
  51096. return false;
  51097. }
  51098. }
  51099. var refractionTexture = this._getRefractionTexture();
  51100. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51101. if (!refractionTexture.isReadyOrNotBlocking()) {
  51102. return false;
  51103. }
  51104. }
  51105. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51106. // This is blocking.
  51107. if (!this._environmentBRDFTexture.isReady()) {
  51108. return false;
  51109. }
  51110. }
  51111. }
  51112. }
  51113. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  51114. if (!this._imageProcessingConfiguration.isReady()) {
  51115. return false;
  51116. }
  51117. }
  51118. if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  51119. mesh.createNormals(true);
  51120. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
  51121. }
  51122. var previousEffect = subMesh.effect;
  51123. var effect = this._prepareEffect(mesh, defines, this.onCompiled, this.onError, useInstances);
  51124. if (effect) {
  51125. // Use previous effect while new one is compiling
  51126. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  51127. effect = previousEffect;
  51128. defines.markAsUnprocessed();
  51129. }
  51130. else {
  51131. scene.resetCachedMaterial();
  51132. subMesh.setEffect(effect, defines);
  51133. this.buildUniformLayout();
  51134. }
  51135. }
  51136. if (!subMesh.effect || !subMesh.effect.isReady()) {
  51137. return false;
  51138. }
  51139. defines._renderId = scene.getRenderId();
  51140. this._wasPreviouslyReady = true;
  51141. return true;
  51142. };
  51143. /**
  51144. * Specifies if the material uses metallic roughness workflow.
  51145. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51146. */
  51147. PBRBaseMaterial.prototype.isMetallicWorkflow = function () {
  51148. if (this._metallic != null || this._roughness != null || this._metallicTexture) {
  51149. return true;
  51150. }
  51151. return false;
  51152. };
  51153. PBRBaseMaterial.prototype._prepareEffect = function (mesh, defines, onCompiled, onError, useInstances, useClipPlane) {
  51154. if (onCompiled === void 0) { onCompiled = null; }
  51155. if (onError === void 0) { onError = null; }
  51156. if (useInstances === void 0) { useInstances = null; }
  51157. if (useClipPlane === void 0) { useClipPlane = null; }
  51158. this._prepareDefines(mesh, defines, useInstances, useClipPlane);
  51159. if (!defines.isDirty) {
  51160. return null;
  51161. }
  51162. defines.markAsProcessed();
  51163. var scene = this.getScene();
  51164. var engine = scene.getEngine();
  51165. // Fallbacks
  51166. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["EffectFallbacks"]();
  51167. var fallbackRank = 0;
  51168. if (defines.USESPHERICALINVERTEX) {
  51169. fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
  51170. }
  51171. if (defines.FOG) {
  51172. fallbacks.addFallback(fallbackRank, "FOG");
  51173. }
  51174. if (defines.SPECULARAA) {
  51175. fallbacks.addFallback(fallbackRank, "SPECULARAA");
  51176. }
  51177. if (defines.POINTSIZE) {
  51178. fallbacks.addFallback(fallbackRank, "POINTSIZE");
  51179. }
  51180. if (defines.LOGARITHMICDEPTH) {
  51181. fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
  51182. }
  51183. if (defines.PARALLAX) {
  51184. fallbacks.addFallback(fallbackRank, "PARALLAX");
  51185. }
  51186. if (defines.PARALLAXOCCLUSION) {
  51187. fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
  51188. }
  51189. if (defines.ENVIRONMENTBRDF) {
  51190. fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
  51191. }
  51192. if (defines.TANGENT) {
  51193. fallbacks.addFallback(fallbackRank++, "TANGENT");
  51194. }
  51195. if (defines.BUMP) {
  51196. fallbacks.addFallback(fallbackRank++, "BUMP");
  51197. }
  51198. fallbackRank = _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank++);
  51199. if (defines.SPECULARTERM) {
  51200. fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
  51201. }
  51202. if (defines.USESPHERICALFROMREFLECTIONMAP) {
  51203. fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
  51204. }
  51205. if (defines.LIGHTMAP) {
  51206. fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
  51207. }
  51208. if (defines.NORMAL) {
  51209. fallbacks.addFallback(fallbackRank++, "NORMAL");
  51210. }
  51211. if (defines.AMBIENT) {
  51212. fallbacks.addFallback(fallbackRank++, "AMBIENT");
  51213. }
  51214. if (defines.EMISSIVE) {
  51215. fallbacks.addFallback(fallbackRank++, "EMISSIVE");
  51216. }
  51217. if (defines.VERTEXCOLOR) {
  51218. fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
  51219. }
  51220. if (defines.NUM_BONE_INFLUENCERS > 0) {
  51221. fallbacks.addCPUSkinningFallback(fallbackRank++, mesh);
  51222. }
  51223. if (defines.MORPHTARGETS) {
  51224. fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
  51225. }
  51226. //Attributes
  51227. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  51228. if (defines.NORMAL) {
  51229. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  51230. }
  51231. if (defines.TANGENT) {
  51232. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind);
  51233. }
  51234. if (defines.UV1) {
  51235. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  51236. }
  51237. if (defines.UV2) {
  51238. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  51239. }
  51240. if (defines.VERTEXCOLOR) {
  51241. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  51242. }
  51243. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  51244. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  51245. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  51246. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "vReflectionColor",
  51247. "vFogInfos", "vFogColor", "pointSize",
  51248. "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
  51249. "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  51250. "mBones",
  51251. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
  51252. "vLightingIntensity",
  51253. "logarithmicDepthConstant",
  51254. "vSphericalX", "vSphericalY", "vSphericalZ",
  51255. "vSphericalXX", "vSphericalYY", "vSphericalZZ",
  51256. "vSphericalXY", "vSphericalYZ", "vSphericalZX",
  51257. "vReflectionMicrosurfaceInfos", "vRefractionMicrosurfaceInfos",
  51258. "vTangentSpaceParams", "boneTextureWidth"
  51259. ];
  51260. var samplers = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler",
  51261. "bumpSampler", "lightmapSampler", "opacitySampler",
  51262. "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh",
  51263. "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh",
  51264. "microSurfaceSampler", "environmentBrdfSampler", "boneSampler"];
  51265. var uniformBuffers = ["Material", "Scene"];
  51266. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"]) {
  51267. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  51268. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  51269. }
  51270. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareUniformsAndSamplersList({
  51271. uniformsNames: uniforms,
  51272. uniformBuffersNames: uniformBuffers,
  51273. samplers: samplers,
  51274. defines: defines,
  51275. maxSimultaneousLights: this._maxSimultaneousLights
  51276. });
  51277. var join = defines.toString();
  51278. return engine.createEffect("pbr", {
  51279. attributes: attribs,
  51280. uniformsNames: uniforms,
  51281. uniformBuffersNames: uniformBuffers,
  51282. samplers: samplers,
  51283. defines: join,
  51284. fallbacks: fallbacks,
  51285. onCompiled: onCompiled,
  51286. onError: onError,
  51287. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  51288. }, engine);
  51289. };
  51290. PBRBaseMaterial.prototype._prepareDefines = function (mesh, defines, useInstances, useClipPlane) {
  51291. if (useInstances === void 0) { useInstances = null; }
  51292. if (useClipPlane === void 0) { useClipPlane = null; }
  51293. var scene = this.getScene();
  51294. var engine = scene.getEngine();
  51295. // Lights
  51296. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  51297. defines._needNormals = true;
  51298. // Textures
  51299. defines.METALLICWORKFLOW = this.isMetallicWorkflow();
  51300. if (defines._areTexturesDirty) {
  51301. defines._needUVs = false;
  51302. if (scene.texturesEnabled) {
  51303. if (scene.getEngine().getCaps().textureLOD) {
  51304. defines.LODBASEDMICROSFURACE = true;
  51305. }
  51306. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51307. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
  51308. }
  51309. else {
  51310. defines.ALBEDO = false;
  51311. }
  51312. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  51313. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  51314. defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
  51315. }
  51316. else {
  51317. defines.AMBIENT = false;
  51318. }
  51319. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  51320. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  51321. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  51322. }
  51323. else {
  51324. defines.OPACITY = false;
  51325. }
  51326. var reflectionTexture = this._getReflectionTexture();
  51327. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51328. defines.REFLECTION = true;
  51329. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  51330. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  51331. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  51332. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  51333. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].INVCUBIC_MODE) {
  51334. defines.INVERTCUBICMAP = true;
  51335. }
  51336. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  51337. defines.REFLECTIONMAP_CUBIC = false;
  51338. defines.REFLECTIONMAP_EXPLICIT = false;
  51339. defines.REFLECTIONMAP_PLANAR = false;
  51340. defines.REFLECTIONMAP_PROJECTION = false;
  51341. defines.REFLECTIONMAP_SKYBOX = false;
  51342. defines.REFLECTIONMAP_SPHERICAL = false;
  51343. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51344. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51345. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51346. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51347. switch (reflectionTexture.coordinatesMode) {
  51348. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].EXPLICIT_MODE:
  51349. defines.REFLECTIONMAP_EXPLICIT = true;
  51350. break;
  51351. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].PLANAR_MODE:
  51352. defines.REFLECTIONMAP_PLANAR = true;
  51353. break;
  51354. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].PROJECTION_MODE:
  51355. defines.REFLECTIONMAP_PROJECTION = true;
  51356. break;
  51357. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SKYBOX_MODE:
  51358. defines.REFLECTIONMAP_SKYBOX = true;
  51359. break;
  51360. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SPHERICAL_MODE:
  51361. defines.REFLECTIONMAP_SPHERICAL = true;
  51362. break;
  51363. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].EQUIRECTANGULAR_MODE:
  51364. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  51365. break;
  51366. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  51367. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  51368. break;
  51369. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  51370. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  51371. break;
  51372. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].CUBIC_MODE:
  51373. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].INVCUBIC_MODE:
  51374. default:
  51375. defines.REFLECTIONMAP_CUBIC = true;
  51376. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
  51377. break;
  51378. }
  51379. if (reflectionTexture.coordinatesMode !== _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SKYBOX_MODE) {
  51380. if (reflectionTexture.sphericalPolynomial) {
  51381. defines.USESPHERICALFROMREFLECTIONMAP = true;
  51382. if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {
  51383. defines.USESPHERICALINVERTEX = false;
  51384. }
  51385. else {
  51386. defines.USESPHERICALINVERTEX = true;
  51387. }
  51388. }
  51389. }
  51390. else {
  51391. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  51392. }
  51393. }
  51394. else {
  51395. defines.REFLECTION = false;
  51396. defines.REFLECTIONMAP_3D = false;
  51397. defines.REFLECTIONMAP_SPHERICAL = false;
  51398. defines.REFLECTIONMAP_PLANAR = false;
  51399. defines.REFLECTIONMAP_CUBIC = false;
  51400. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  51401. defines.REFLECTIONMAP_PROJECTION = false;
  51402. defines.REFLECTIONMAP_SKYBOX = false;
  51403. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51404. defines.REFLECTIONMAP_EXPLICIT = false;
  51405. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51406. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51407. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51408. defines.INVERTCUBICMAP = false;
  51409. defines.USESPHERICALFROMREFLECTIONMAP = false;
  51410. defines.USESPHERICALINVERTEX = false;
  51411. defines.REFLECTIONMAP_OPPOSITEZ = false;
  51412. defines.LODINREFLECTIONALPHA = false;
  51413. defines.GAMMAREFLECTION = false;
  51414. defines.RGBDREFLECTION = false;
  51415. }
  51416. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  51417. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  51418. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  51419. defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
  51420. }
  51421. else {
  51422. defines.LIGHTMAP = false;
  51423. }
  51424. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  51425. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  51426. }
  51427. else {
  51428. defines.EMISSIVE = false;
  51429. }
  51430. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51431. if (this._metallicTexture) {
  51432. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
  51433. defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
  51434. defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
  51435. defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
  51436. defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
  51437. }
  51438. else if (this._reflectivityTexture) {
  51439. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
  51440. defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
  51441. defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
  51442. }
  51443. else {
  51444. defines.REFLECTIVITY = false;
  51445. }
  51446. if (this._microSurfaceTexture) {
  51447. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
  51448. }
  51449. else {
  51450. defines.MICROSURFACEMAP = false;
  51451. }
  51452. }
  51453. else {
  51454. defines.REFLECTIVITY = false;
  51455. defines.MICROSURFACEMAP = false;
  51456. }
  51457. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51458. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  51459. if (this._useParallax && this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51460. defines.PARALLAX = true;
  51461. defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
  51462. }
  51463. else {
  51464. defines.PARALLAX = false;
  51465. }
  51466. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  51467. }
  51468. else {
  51469. defines.BUMP = false;
  51470. }
  51471. var refractionTexture = this._getRefractionTexture();
  51472. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51473. defines.REFRACTION = true;
  51474. defines.REFRACTIONMAP_3D = refractionTexture.isCube;
  51475. defines.GAMMAREFRACTION = refractionTexture.gammaSpace;
  51476. defines.RGBDREFRACTION = refractionTexture.isRGBD;
  51477. defines.REFRACTIONMAP_OPPOSITEZ = refractionTexture.invertZ;
  51478. defines.LODINREFRACTIONALPHA = refractionTexture.lodLevelInAlpha;
  51479. if (this._linkRefractionWithTransparency) {
  51480. defines.LINKREFRACTIONTOTRANSPARENCY = true;
  51481. }
  51482. }
  51483. else {
  51484. defines.REFRACTION = false;
  51485. }
  51486. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51487. defines.ENVIRONMENTBRDF = true;
  51488. }
  51489. else {
  51490. defines.ENVIRONMENTBRDF = false;
  51491. }
  51492. if (this._shouldUseAlphaFromAlbedoTexture()) {
  51493. defines.ALPHAFROMALBEDO = true;
  51494. }
  51495. else {
  51496. defines.ALPHAFROMALBEDO = false;
  51497. }
  51498. }
  51499. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  51500. if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
  51501. defines.USEPHYSICALLIGHTFALLOFF = false;
  51502. defines.USEGLTFLIGHTFALLOFF = false;
  51503. }
  51504. else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
  51505. defines.USEPHYSICALLIGHTFALLOFF = false;
  51506. defines.USEGLTFLIGHTFALLOFF = true;
  51507. }
  51508. else {
  51509. defines.USEPHYSICALLIGHTFALLOFF = true;
  51510. defines.USEGLTFLIGHTFALLOFF = false;
  51511. }
  51512. defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
  51513. if (!this.backFaceCulling && this._twoSidedLighting) {
  51514. defines.TWOSIDEDLIGHTING = true;
  51515. }
  51516. else {
  51517. defines.TWOSIDEDLIGHTING = false;
  51518. }
  51519. defines.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : "");
  51520. defines.PREMULTIPLYALPHA = (this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_PREMULTIPLIED || this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF);
  51521. defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
  51522. defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
  51523. defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
  51524. defines.SPECULARAA = scene.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
  51525. }
  51526. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  51527. this._imageProcessingConfiguration.prepareDefines(defines);
  51528. }
  51529. defines.FORCENORMALFORWARD = this._forceNormalForward;
  51530. defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
  51531. defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
  51532. // Misc.
  51533. if (defines._areMiscDirty) {
  51534. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
  51535. defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind));
  51536. }
  51537. // Values that need to be evaluated on every frame
  51538. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, useClipPlane);
  51539. // Attribs
  51540. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
  51541. };
  51542. /**
  51543. * Force shader compilation
  51544. */
  51545. PBRBaseMaterial.prototype.forceCompilation = function (mesh, onCompiled, options) {
  51546. var _this = this;
  51547. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  51548. var defines = new PBRMaterialDefines();
  51549. var effect = this._prepareEffect(mesh, defines, undefined, undefined, undefined, localOptions.clipPlane);
  51550. if (effect.isReady()) {
  51551. if (onCompiled) {
  51552. onCompiled(this);
  51553. }
  51554. }
  51555. else {
  51556. effect.onCompileObservable.add(function () {
  51557. if (onCompiled) {
  51558. onCompiled(_this);
  51559. }
  51560. });
  51561. }
  51562. };
  51563. /**
  51564. * Initializes the uniform buffer layout for the shader.
  51565. */
  51566. PBRBaseMaterial.prototype.buildUniformLayout = function () {
  51567. // Order is important !
  51568. this._uniformBuffer.addUniform("vAlbedoInfos", 2);
  51569. this._uniformBuffer.addUniform("vAmbientInfos", 4);
  51570. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  51571. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  51572. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  51573. this._uniformBuffer.addUniform("vReflectivityInfos", 3);
  51574. this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos", 2);
  51575. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  51576. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  51577. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  51578. this._uniformBuffer.addUniform("vReflectionSize", 3);
  51579. this._uniformBuffer.addUniform("vBumpInfos", 3);
  51580. this._uniformBuffer.addUniform("albedoMatrix", 16);
  51581. this._uniformBuffer.addUniform("ambientMatrix", 16);
  51582. this._uniformBuffer.addUniform("opacityMatrix", 16);
  51583. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  51584. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  51585. this._uniformBuffer.addUniform("reflectivityMatrix", 16);
  51586. this._uniformBuffer.addUniform("microSurfaceSamplerMatrix", 16);
  51587. this._uniformBuffer.addUniform("bumpMatrix", 16);
  51588. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  51589. this._uniformBuffer.addUniform("refractionMatrix", 16);
  51590. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  51591. this._uniformBuffer.addUniform("vReflectionColor", 3);
  51592. this._uniformBuffer.addUniform("vAlbedoColor", 4);
  51593. this._uniformBuffer.addUniform("vLightingIntensity", 4);
  51594. this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos", 3);
  51595. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  51596. this._uniformBuffer.addUniform("vReflectivityColor", 4);
  51597. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  51598. this._uniformBuffer.addUniform("pointSize", 1);
  51599. this._uniformBuffer.create();
  51600. };
  51601. /**
  51602. * Unbinds the textures.
  51603. */
  51604. PBRBaseMaterial.prototype.unbind = function () {
  51605. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  51606. this._uniformBuffer.setTexture("reflectionSampler", null);
  51607. }
  51608. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  51609. this._uniformBuffer.setTexture("refractionSampler", null);
  51610. }
  51611. _super.prototype.unbind.call(this);
  51612. };
  51613. /**
  51614. * Binds the submesh data.
  51615. * @param world - The world matrix.
  51616. * @param mesh - The BJS mesh.
  51617. * @param subMesh - A submesh of the BJS mesh.
  51618. */
  51619. PBRBaseMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  51620. var scene = this.getScene();
  51621. var defines = subMesh._materialDefines;
  51622. if (!defines) {
  51623. return;
  51624. }
  51625. var effect = subMesh.effect;
  51626. if (!effect) {
  51627. return;
  51628. }
  51629. this._activeEffect = effect;
  51630. // Matrices
  51631. this.bindOnlyWorldMatrix(world);
  51632. // Normal Matrix
  51633. if (defines.OBJECTSPACE_NORMALMAP) {
  51634. world.toNormalMatrix(this._normalMatrix);
  51635. this.bindOnlyNormalMatrix(this._normalMatrix);
  51636. }
  51637. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  51638. // Bones
  51639. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  51640. var reflectionTexture = null;
  51641. if (mustRebind) {
  51642. this._uniformBuffer.bindToEffect(effect, "Material");
  51643. this.bindViewProjection(effect);
  51644. reflectionTexture = this._getReflectionTexture();
  51645. var refractionTexture = this._getRefractionTexture();
  51646. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  51647. // Texture uniforms
  51648. if (scene.texturesEnabled) {
  51649. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51650. this._uniformBuffer.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
  51651. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._albedoTexture, this._uniformBuffer, "albedo");
  51652. }
  51653. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  51654. this._uniformBuffer.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
  51655. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  51656. }
  51657. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  51658. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  51659. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  51660. }
  51661. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51662. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  51663. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, 0);
  51664. if (reflectionTexture.boundingBoxSize) {
  51665. var cubeTexture = reflectionTexture;
  51666. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  51667. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  51668. }
  51669. var polynomials = reflectionTexture.sphericalPolynomial;
  51670. if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
  51671. this._activeEffect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
  51672. this._activeEffect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
  51673. this._activeEffect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
  51674. this._activeEffect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
  51675. this._activeEffect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
  51676. this._activeEffect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
  51677. this._activeEffect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
  51678. this._activeEffect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
  51679. this._activeEffect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
  51680. }
  51681. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  51682. }
  51683. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  51684. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  51685. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  51686. }
  51687. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  51688. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  51689. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  51690. }
  51691. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51692. if (this._metallicTexture) {
  51693. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
  51694. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._metallicTexture, this._uniformBuffer, "reflectivity");
  51695. }
  51696. else if (this._reflectivityTexture) {
  51697. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
  51698. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._reflectivityTexture, this._uniformBuffer, "reflectivity");
  51699. }
  51700. if (this._microSurfaceTexture) {
  51701. this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
  51702. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._microSurfaceTexture, this._uniformBuffer, "microSurfaceSampler");
  51703. }
  51704. }
  51705. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51706. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
  51707. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  51708. if (scene._mirroredCameraPosition) {
  51709. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  51710. }
  51711. else {
  51712. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  51713. }
  51714. }
  51715. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51716. this._uniformBuffer.updateMatrix("refractionMatrix", refractionTexture.getReflectionTextureMatrix());
  51717. var depth = 1.0;
  51718. if (!refractionTexture.isCube) {
  51719. if (refractionTexture.depth) {
  51720. depth = refractionTexture.depth;
  51721. }
  51722. }
  51723. this._uniformBuffer.updateFloat4("vRefractionInfos", refractionTexture.level, this._indexOfRefraction, depth, this._invertRefractionY ? -1 : 1);
  51724. this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos", refractionTexture.getSize().width, refractionTexture.lodGenerationScale, refractionTexture.lodGenerationOffset);
  51725. }
  51726. }
  51727. // Point size
  51728. if (this.pointsCloud) {
  51729. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  51730. }
  51731. // Colors
  51732. if (defines.METALLICWORKFLOW) {
  51733. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].r = (this._metallic === undefined || this._metallic === null) ? 1 : this._metallic;
  51734. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].g = (this._roughness === undefined || this._roughness === null) ? 1 : this._roughness;
  51735. this._uniformBuffer.updateColor4("vReflectivityColor", _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0], 0);
  51736. }
  51737. else {
  51738. this._uniformBuffer.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  51739. }
  51740. this._uniformBuffer.updateColor3("vEmissiveColor", _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled ? this._emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"].BlackReadOnly);
  51741. this._uniformBuffer.updateColor3("vReflectionColor", this._reflectionColor);
  51742. this._uniformBuffer.updateColor4("vAlbedoColor", this._albedoColor, this.alpha * mesh.visibility);
  51743. // Misc
  51744. this._lightingInfos.x = this._directIntensity;
  51745. this._lightingInfos.y = this._emissiveIntensity;
  51746. this._lightingInfos.z = this._environmentIntensity;
  51747. this._lightingInfos.w = this._specularIntensity;
  51748. this._uniformBuffer.updateVector4("vLightingIntensity", this._lightingInfos);
  51749. }
  51750. // Textures
  51751. if (scene.texturesEnabled) {
  51752. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51753. this._uniformBuffer.setTexture("albedoSampler", this._albedoTexture);
  51754. }
  51755. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  51756. this._uniformBuffer.setTexture("ambientSampler", this._ambientTexture);
  51757. }
  51758. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  51759. this._uniformBuffer.setTexture("opacitySampler", this._opacityTexture);
  51760. }
  51761. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51762. if (defines.LODBASEDMICROSFURACE) {
  51763. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  51764. }
  51765. else {
  51766. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  51767. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  51768. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  51769. }
  51770. }
  51771. if (defines.ENVIRONMENTBRDF) {
  51772. this._uniformBuffer.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
  51773. }
  51774. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  51775. if (defines.LODBASEDMICROSFURACE) {
  51776. this._uniformBuffer.setTexture("refractionSampler", refractionTexture);
  51777. }
  51778. else {
  51779. this._uniformBuffer.setTexture("refractionSampler", refractionTexture._lodTextureMid || refractionTexture);
  51780. this._uniformBuffer.setTexture("refractionSamplerLow", refractionTexture._lodTextureLow || refractionTexture);
  51781. this._uniformBuffer.setTexture("refractionSamplerHigh", refractionTexture._lodTextureHigh || refractionTexture);
  51782. }
  51783. }
  51784. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  51785. this._uniformBuffer.setTexture("emissiveSampler", this._emissiveTexture);
  51786. }
  51787. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  51788. this._uniformBuffer.setTexture("lightmapSampler", this._lightmapTexture);
  51789. }
  51790. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  51791. if (this._metallicTexture) {
  51792. this._uniformBuffer.setTexture("reflectivitySampler", this._metallicTexture);
  51793. }
  51794. else if (this._reflectivityTexture) {
  51795. this._uniformBuffer.setTexture("reflectivitySampler", this._reflectivityTexture);
  51796. }
  51797. if (this._microSurfaceTexture) {
  51798. this._uniformBuffer.setTexture("microSurfaceSampler", this._microSurfaceTexture);
  51799. }
  51800. }
  51801. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51802. this._uniformBuffer.setTexture("bumpSampler", this._bumpTexture);
  51803. }
  51804. }
  51805. // Clip plane
  51806. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  51807. // Colors
  51808. scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
  51809. var eyePosition = scene._forcedViewPosition ? scene._forcedViewPosition : (scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  51810. var invertNormal = (scene.useRightHandedSystem === (scene._mirroredCameraPosition != null));
  51811. effect.setFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
  51812. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  51813. }
  51814. if (mustRebind || !this.isFrozen) {
  51815. // Lights
  51816. if (scene.lightsEnabled && !this._disableLighting) {
  51817. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, this._lightFalloff !== PBRBaseMaterial.LIGHTFALLOFF_STANDARD);
  51818. }
  51819. // View
  51820. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].FOGMODE_NONE || reflectionTexture) {
  51821. this.bindView(effect);
  51822. }
  51823. // Fog
  51824. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  51825. // Morph targets
  51826. if (defines.NUM_MORPH_INFLUENCERS) {
  51827. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindMorphTargetParameters(mesh, this._activeEffect);
  51828. }
  51829. // image processing
  51830. this._imageProcessingConfiguration.bind(this._activeEffect);
  51831. // Log. depth
  51832. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
  51833. }
  51834. this._uniformBuffer.update();
  51835. this._afterBind(mesh, this._activeEffect);
  51836. };
  51837. /**
  51838. * Returns the animatable textures.
  51839. * @returns - Array of animatable textures.
  51840. */
  51841. PBRBaseMaterial.prototype.getAnimatables = function () {
  51842. var results = [];
  51843. if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
  51844. results.push(this._albedoTexture);
  51845. }
  51846. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  51847. results.push(this._ambientTexture);
  51848. }
  51849. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  51850. results.push(this._opacityTexture);
  51851. }
  51852. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  51853. results.push(this._reflectionTexture);
  51854. }
  51855. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  51856. results.push(this._emissiveTexture);
  51857. }
  51858. if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
  51859. results.push(this._metallicTexture);
  51860. }
  51861. else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
  51862. results.push(this._reflectivityTexture);
  51863. }
  51864. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  51865. results.push(this._bumpTexture);
  51866. }
  51867. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  51868. results.push(this._lightmapTexture);
  51869. }
  51870. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  51871. results.push(this._refractionTexture);
  51872. }
  51873. return results;
  51874. };
  51875. /**
  51876. * Returns the texture used for reflections.
  51877. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51878. */
  51879. PBRBaseMaterial.prototype._getReflectionTexture = function () {
  51880. if (this._reflectionTexture) {
  51881. return this._reflectionTexture;
  51882. }
  51883. return this.getScene().environmentTexture;
  51884. };
  51885. /**
  51886. * Returns the texture used for refraction or null if none is used.
  51887. * @returns - Refection texture if present. If no refraction texture and refraction
  51888. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51889. */
  51890. PBRBaseMaterial.prototype._getRefractionTexture = function () {
  51891. if (this._refractionTexture) {
  51892. return this._refractionTexture;
  51893. }
  51894. if (this._linkRefractionWithTransparency) {
  51895. return this.getScene().environmentTexture;
  51896. }
  51897. return null;
  51898. };
  51899. /**
  51900. * Disposes the resources of the material.
  51901. * @param forceDisposeEffect - Forces the disposal of effects.
  51902. * @param forceDisposeTextures - Forces the disposal of all textures.
  51903. */
  51904. PBRBaseMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  51905. if (forceDisposeTextures) {
  51906. if (this._albedoTexture) {
  51907. this._albedoTexture.dispose();
  51908. }
  51909. if (this._ambientTexture) {
  51910. this._ambientTexture.dispose();
  51911. }
  51912. if (this._opacityTexture) {
  51913. this._opacityTexture.dispose();
  51914. }
  51915. if (this._reflectionTexture) {
  51916. this._reflectionTexture.dispose();
  51917. }
  51918. if (this._environmentBRDFTexture && this.getScene()._environmentBRDFTexture !== this._environmentBRDFTexture) {
  51919. this._environmentBRDFTexture.dispose();
  51920. }
  51921. if (this._emissiveTexture) {
  51922. this._emissiveTexture.dispose();
  51923. }
  51924. if (this._metallicTexture) {
  51925. this._metallicTexture.dispose();
  51926. }
  51927. if (this._reflectivityTexture) {
  51928. this._reflectivityTexture.dispose();
  51929. }
  51930. if (this._bumpTexture) {
  51931. this._bumpTexture.dispose();
  51932. }
  51933. if (this._lightmapTexture) {
  51934. this._lightmapTexture.dispose();
  51935. }
  51936. if (this._refractionTexture) {
  51937. this._refractionTexture.dispose();
  51938. }
  51939. }
  51940. this._renderTargets.dispose();
  51941. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  51942. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  51943. }
  51944. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  51945. };
  51946. /**
  51947. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51948. */
  51949. PBRBaseMaterial.PBRMATERIAL_OPAQUE = 0;
  51950. /**
  51951. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51952. */
  51953. PBRBaseMaterial.PBRMATERIAL_ALPHATEST = 1;
  51954. /**
  51955. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51956. */
  51957. PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = 2;
  51958. /**
  51959. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51960. * They are also discarded below the alpha cutoff threshold to improve performances.
  51961. */
  51962. PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = 3;
  51963. /**
  51964. * Defines the default value of how much AO map is occluding the analytical lights
  51965. * (point spot...).
  51966. */
  51967. PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 1;
  51968. /**
  51969. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51970. */
  51971. PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
  51972. /**
  51973. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51974. * to enhance interoperability with other engines.
  51975. */
  51976. PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
  51977. /**
  51978. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51979. * to enhance interoperability with other materials.
  51980. */
  51981. PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
  51982. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51983. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  51984. ], PBRBaseMaterial.prototype, "_imageProcessingConfiguration", void 0);
  51985. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51986. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51987. ], PBRBaseMaterial.prototype, "useLogarithmicDepth", null);
  51988. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51989. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51990. ], PBRBaseMaterial.prototype, "transparencyMode", null);
  51991. return PBRBaseMaterial;
  51992. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_11__["PushMaterial"]));
  51993. /***/ }),
  51994. /***/ "./Materials/PBR/pbrBaseSimpleMaterial.ts":
  51995. /*!************************************************!*\
  51996. !*** ./Materials/PBR/pbrBaseSimpleMaterial.ts ***!
  51997. \************************************************/
  51998. /*! exports provided: PBRBaseSimpleMaterial */
  51999. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52000. "use strict";
  52001. __webpack_require__.r(__webpack_exports__);
  52002. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return PBRBaseSimpleMaterial; });
  52003. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52004. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52005. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  52006. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  52007. /**
  52008. * The Physically based simple base material of BJS.
  52009. *
  52010. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52011. * It is used as the base class for both the specGloss and metalRough conventions.
  52012. */
  52013. var PBRBaseSimpleMaterial = /** @class */ (function (_super) {
  52014. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseSimpleMaterial, _super);
  52015. /**
  52016. * Instantiates a new PBRMaterial instance.
  52017. *
  52018. * @param name The material name
  52019. * @param scene The scene the material will be use in.
  52020. */
  52021. function PBRBaseSimpleMaterial(name, scene) {
  52022. var _this = _super.call(this, name, scene) || this;
  52023. /**
  52024. * Number of Simultaneous lights allowed on the material.
  52025. */
  52026. _this.maxSimultaneousLights = 4;
  52027. /**
  52028. * If sets to true, disables all the lights affecting the material.
  52029. */
  52030. _this.disableLighting = false;
  52031. /**
  52032. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52033. */
  52034. _this.invertNormalMapX = false;
  52035. /**
  52036. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52037. */
  52038. _this.invertNormalMapY = false;
  52039. /**
  52040. * Emissivie color used to self-illuminate the model.
  52041. */
  52042. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0, 0, 0);
  52043. /**
  52044. * Occlusion Channel Strenght.
  52045. */
  52046. _this.occlusionStrength = 1.0;
  52047. /**
  52048. * If true, the light map contains occlusion information instead of lighting info.
  52049. */
  52050. _this.useLightmapAsShadowmap = false;
  52051. _this._useAlphaFromAlbedoTexture = true;
  52052. _this._useAmbientInGrayScale = true;
  52053. return _this;
  52054. }
  52055. Object.defineProperty(PBRBaseSimpleMaterial.prototype, "doubleSided", {
  52056. /**
  52057. * Gets the current double sided mode.
  52058. */
  52059. get: function () {
  52060. return this._twoSidedLighting;
  52061. },
  52062. /**
  52063. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52064. */
  52065. set: function (value) {
  52066. if (this._twoSidedLighting === value) {
  52067. return;
  52068. }
  52069. this._twoSidedLighting = value;
  52070. this.backFaceCulling = !value;
  52071. this._markAllSubMeshesAsTexturesDirty();
  52072. },
  52073. enumerable: true,
  52074. configurable: true
  52075. });
  52076. /**
  52077. * Return the active textures of the material.
  52078. */
  52079. PBRBaseSimpleMaterial.prototype.getActiveTextures = function () {
  52080. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52081. if (this.environmentTexture) {
  52082. activeTextures.push(this.environmentTexture);
  52083. }
  52084. if (this.normalTexture) {
  52085. activeTextures.push(this.normalTexture);
  52086. }
  52087. if (this.emissiveTexture) {
  52088. activeTextures.push(this.emissiveTexture);
  52089. }
  52090. if (this.occlusionTexture) {
  52091. activeTextures.push(this.occlusionTexture);
  52092. }
  52093. if (this.lightmapTexture) {
  52094. activeTextures.push(this.lightmapTexture);
  52095. }
  52096. return activeTextures;
  52097. };
  52098. PBRBaseSimpleMaterial.prototype.hasTexture = function (texture) {
  52099. if (_super.prototype.hasTexture.call(this, texture)) {
  52100. return true;
  52101. }
  52102. if (this.lightmapTexture === texture) {
  52103. return true;
  52104. }
  52105. return false;
  52106. };
  52107. PBRBaseSimpleMaterial.prototype.getClassName = function () {
  52108. return "PBRBaseSimpleMaterial";
  52109. };
  52110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52112. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52113. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  52114. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52115. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52116. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52117. ], PBRBaseSimpleMaterial.prototype, "disableLighting", void 0);
  52118. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52119. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  52121. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  52122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52124. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52125. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", void 0);
  52126. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52127. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52128. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52129. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapY", void 0);
  52130. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52131. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52132. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  52133. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  52134. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52135. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  52136. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52137. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  52138. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52139. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52140. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52141. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  52142. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52143. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52144. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  52145. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  52146. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52147. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52148. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  52149. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  52150. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52151. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52152. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  52153. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  52154. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52155. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52156. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  52157. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52158. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52159. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  52160. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  52161. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52162. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52163. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52164. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  52165. return PBRBaseSimpleMaterial;
  52166. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRBaseMaterial"]));
  52167. /***/ }),
  52168. /***/ "./Materials/PBR/pbrMaterial.ts":
  52169. /*!**************************************!*\
  52170. !*** ./Materials/PBR/pbrMaterial.ts ***!
  52171. \**************************************/
  52172. /*! exports provided: PBRMaterial */
  52173. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52174. "use strict";
  52175. __webpack_require__.r(__webpack_exports__);
  52176. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return PBRMaterial; });
  52177. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52178. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52179. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  52180. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  52181. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  52182. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  52183. /**
  52184. * The Physically based material of BJS.
  52185. *
  52186. * This offers the main features of a standard PBR material.
  52187. * For more information, please refer to the documentation :
  52188. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  52189. */
  52190. var PBRMaterial = /** @class */ (function (_super) {
  52191. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterial, _super);
  52192. /**
  52193. * Instantiates a new PBRMaterial instance.
  52194. *
  52195. * @param name The material name
  52196. * @param scene The scene the material will be use in.
  52197. */
  52198. function PBRMaterial(name, scene) {
  52199. var _this = _super.call(this, name, scene) || this;
  52200. /**
  52201. * Intensity of the direct lights e.g. the four lights available in your scene.
  52202. * This impacts both the direct diffuse and specular highlights.
  52203. */
  52204. _this.directIntensity = 1.0;
  52205. /**
  52206. * Intensity of the emissive part of the material.
  52207. * This helps controlling the emissive effect without modifying the emissive color.
  52208. */
  52209. _this.emissiveIntensity = 1.0;
  52210. /**
  52211. * Intensity of the environment e.g. how much the environment will light the object
  52212. * either through harmonics for rough material or through the refelction for shiny ones.
  52213. */
  52214. _this.environmentIntensity = 1.0;
  52215. /**
  52216. * This is a special control allowing the reduction of the specular highlights coming from the
  52217. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52218. */
  52219. _this.specularIntensity = 1.0;
  52220. /**
  52221. * Debug Control allowing disabling the bump map on this material.
  52222. */
  52223. _this.disableBumpMap = false;
  52224. /**
  52225. * AKA Occlusion Texture Intensity in other nomenclature.
  52226. */
  52227. _this.ambientTextureStrength = 1.0;
  52228. /**
  52229. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52230. * 1 means it completely occludes it
  52231. * 0 mean it has no impact
  52232. */
  52233. _this.ambientTextureImpactOnAnalyticalLights = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  52234. /**
  52235. * The color of a material in ambient lighting.
  52236. */
  52237. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  52238. /**
  52239. * AKA Diffuse Color in other nomenclature.
  52240. */
  52241. _this.albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  52242. /**
  52243. * AKA Specular Color in other nomenclature.
  52244. */
  52245. _this.reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  52246. /**
  52247. * The color reflected from the material.
  52248. */
  52249. _this.reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  52250. /**
  52251. * The color emitted from the material.
  52252. */
  52253. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  52254. /**
  52255. * AKA Glossiness in other nomenclature.
  52256. */
  52257. _this.microSurface = 1.0;
  52258. /**
  52259. * source material index of refraction (IOR)' / 'destination material IOR.
  52260. */
  52261. _this.indexOfRefraction = 0.66;
  52262. /**
  52263. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52264. */
  52265. _this.invertRefractionY = false;
  52266. /**
  52267. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52268. * Materials half opaque for instance using refraction could benefit from this control.
  52269. */
  52270. _this.linkRefractionWithTransparency = false;
  52271. /**
  52272. * If true, the light map contains occlusion information instead of lighting info.
  52273. */
  52274. _this.useLightmapAsShadowmap = false;
  52275. /**
  52276. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52277. */
  52278. _this.useAlphaFromAlbedoTexture = false;
  52279. /**
  52280. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52281. */
  52282. _this.forceAlphaTest = false;
  52283. /**
  52284. * Defines the alpha limits in alpha test mode.
  52285. */
  52286. _this.alphaCutOff = 0.4;
  52287. /**
  52288. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52289. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52290. */
  52291. _this.useSpecularOverAlpha = true;
  52292. /**
  52293. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52294. */
  52295. _this.useMicroSurfaceFromReflectivityMapAlpha = false;
  52296. /**
  52297. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52298. */
  52299. _this.useRoughnessFromMetallicTextureAlpha = true;
  52300. /**
  52301. * Specifies if the metallic texture contains the roughness information in its green channel.
  52302. */
  52303. _this.useRoughnessFromMetallicTextureGreen = false;
  52304. /**
  52305. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52306. */
  52307. _this.useMetallnessFromMetallicTextureBlue = false;
  52308. /**
  52309. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52310. */
  52311. _this.useAmbientOcclusionFromMetallicTextureRed = false;
  52312. /**
  52313. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52314. */
  52315. _this.useAmbientInGrayScale = false;
  52316. /**
  52317. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52318. * The material will try to infer what glossiness each pixel should be.
  52319. */
  52320. _this.useAutoMicroSurfaceFromReflectivityMap = false;
  52321. /**
  52322. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52323. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52324. */
  52325. _this.useRadianceOverAlpha = true;
  52326. /**
  52327. * Allows using an object space normal map (instead of tangent space).
  52328. */
  52329. _this.useObjectSpaceNormalMap = false;
  52330. /**
  52331. * Allows using the bump map in parallax mode.
  52332. */
  52333. _this.useParallax = false;
  52334. /**
  52335. * Allows using the bump map in parallax occlusion mode.
  52336. */
  52337. _this.useParallaxOcclusion = false;
  52338. /**
  52339. * Controls the scale bias of the parallax mode.
  52340. */
  52341. _this.parallaxScaleBias = 0.05;
  52342. /**
  52343. * If sets to true, disables all the lights affecting the material.
  52344. */
  52345. _this.disableLighting = false;
  52346. /**
  52347. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52348. */
  52349. _this.forceIrradianceInFragment = false;
  52350. /**
  52351. * Number of Simultaneous lights allowed on the material.
  52352. */
  52353. _this.maxSimultaneousLights = 4;
  52354. /**
  52355. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52356. */
  52357. _this.invertNormalMapX = false;
  52358. /**
  52359. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52360. */
  52361. _this.invertNormalMapY = false;
  52362. /**
  52363. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52364. */
  52365. _this.twoSidedLighting = false;
  52366. /**
  52367. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52368. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52369. */
  52370. _this.useAlphaFresnel = false;
  52371. /**
  52372. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52373. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52374. */
  52375. _this.useLinearAlphaFresnel = false;
  52376. /**
  52377. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52378. * And/Or occlude the blended part.
  52379. */
  52380. _this.environmentBRDFTexture = null;
  52381. /**
  52382. * Force normal to face away from face.
  52383. */
  52384. _this.forceNormalForward = false;
  52385. /**
  52386. * Enables specular anti aliasing in the PBR shader.
  52387. * It will both interacts on the Geometry for analytical and IBL lighting.
  52388. * It also prefilter the roughness map based on the bump values.
  52389. */
  52390. _this.enableSpecularAntiAliasing = false;
  52391. /**
  52392. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52393. * makes the reflect vector face the model (under horizon).
  52394. */
  52395. _this.useHorizonOcclusion = true;
  52396. /**
  52397. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52398. * too much the area relying on ambient texture to define their ambient occlusion.
  52399. */
  52400. _this.useRadianceOcclusion = true;
  52401. /**
  52402. * If set to true, no lighting calculations will be applied.
  52403. */
  52404. _this.unlit = false;
  52405. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  52406. return _this;
  52407. }
  52408. Object.defineProperty(PBRMaterial.prototype, "usePhysicalLightFalloff", {
  52409. /**
  52410. * BJS is using an harcoded light falloff based on a manually sets up range.
  52411. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52412. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52413. */
  52414. get: function () {
  52415. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  52416. },
  52417. /**
  52418. * BJS is using an harcoded light falloff based on a manually sets up range.
  52419. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52420. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52421. */
  52422. set: function (value) {
  52423. if (value !== this.usePhysicalLightFalloff) {
  52424. // Ensure the effect will be rebuilt.
  52425. this._markAllSubMeshesAsTexturesDirty();
  52426. if (value) {
  52427. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  52428. }
  52429. else {
  52430. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  52431. }
  52432. }
  52433. },
  52434. enumerable: true,
  52435. configurable: true
  52436. });
  52437. Object.defineProperty(PBRMaterial.prototype, "useGLTFLightFalloff", {
  52438. /**
  52439. * In order to support the falloff compatibility with gltf, a special mode has been added
  52440. * to reproduce the gltf light falloff.
  52441. */
  52442. get: function () {
  52443. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  52444. },
  52445. /**
  52446. * In order to support the falloff compatibility with gltf, a special mode has been added
  52447. * to reproduce the gltf light falloff.
  52448. */
  52449. set: function (value) {
  52450. if (value !== this.useGLTFLightFalloff) {
  52451. // Ensure the effect will be rebuilt.
  52452. this._markAllSubMeshesAsTexturesDirty();
  52453. if (value) {
  52454. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  52455. }
  52456. else {
  52457. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  52458. }
  52459. }
  52460. },
  52461. enumerable: true,
  52462. configurable: true
  52463. });
  52464. Object.defineProperty(PBRMaterial.prototype, "imageProcessingConfiguration", {
  52465. /**
  52466. * Gets the image processing configuration used either in this material.
  52467. */
  52468. get: function () {
  52469. return this._imageProcessingConfiguration;
  52470. },
  52471. /**
  52472. * Sets the Default image processing configuration used either in the this material.
  52473. *
  52474. * If sets to null, the scene one is in use.
  52475. */
  52476. set: function (value) {
  52477. this._attachImageProcessingConfiguration(value);
  52478. // Ensure the effect will be rebuilt.
  52479. this._markAllSubMeshesAsTexturesDirty();
  52480. },
  52481. enumerable: true,
  52482. configurable: true
  52483. });
  52484. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurvesEnabled", {
  52485. /**
  52486. * Gets wether the color curves effect is enabled.
  52487. */
  52488. get: function () {
  52489. return this.imageProcessingConfiguration.colorCurvesEnabled;
  52490. },
  52491. /**
  52492. * Sets wether the color curves effect is enabled.
  52493. */
  52494. set: function (value) {
  52495. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  52496. },
  52497. enumerable: true,
  52498. configurable: true
  52499. });
  52500. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingEnabled", {
  52501. /**
  52502. * Gets wether the color grading effect is enabled.
  52503. */
  52504. get: function () {
  52505. return this.imageProcessingConfiguration.colorGradingEnabled;
  52506. },
  52507. /**
  52508. * Gets wether the color grading effect is enabled.
  52509. */
  52510. set: function (value) {
  52511. this.imageProcessingConfiguration.colorGradingEnabled = value;
  52512. },
  52513. enumerable: true,
  52514. configurable: true
  52515. });
  52516. Object.defineProperty(PBRMaterial.prototype, "cameraToneMappingEnabled", {
  52517. /**
  52518. * Gets wether tonemapping is enabled or not.
  52519. */
  52520. get: function () {
  52521. return this._imageProcessingConfiguration.toneMappingEnabled;
  52522. },
  52523. /**
  52524. * Sets wether tonemapping is enabled or not
  52525. */
  52526. set: function (value) {
  52527. this._imageProcessingConfiguration.toneMappingEnabled = value;
  52528. },
  52529. enumerable: true,
  52530. configurable: true
  52531. });
  52532. Object.defineProperty(PBRMaterial.prototype, "cameraExposure", {
  52533. /**
  52534. * The camera exposure used on this material.
  52535. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52536. * This corresponds to a photographic exposure.
  52537. */
  52538. get: function () {
  52539. return this._imageProcessingConfiguration.exposure;
  52540. },
  52541. /**
  52542. * The camera exposure used on this material.
  52543. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52544. * This corresponds to a photographic exposure.
  52545. */
  52546. set: function (value) {
  52547. this._imageProcessingConfiguration.exposure = value;
  52548. },
  52549. enumerable: true,
  52550. configurable: true
  52551. });
  52552. Object.defineProperty(PBRMaterial.prototype, "cameraContrast", {
  52553. /**
  52554. * Gets The camera contrast used on this material.
  52555. */
  52556. get: function () {
  52557. return this._imageProcessingConfiguration.contrast;
  52558. },
  52559. /**
  52560. * Sets The camera contrast used on this material.
  52561. */
  52562. set: function (value) {
  52563. this._imageProcessingConfiguration.contrast = value;
  52564. },
  52565. enumerable: true,
  52566. configurable: true
  52567. });
  52568. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingTexture", {
  52569. /**
  52570. * Gets the Color Grading 2D Lookup Texture.
  52571. */
  52572. get: function () {
  52573. return this._imageProcessingConfiguration.colorGradingTexture;
  52574. },
  52575. /**
  52576. * Sets the Color Grading 2D Lookup Texture.
  52577. */
  52578. set: function (value) {
  52579. this._imageProcessingConfiguration.colorGradingTexture = value;
  52580. },
  52581. enumerable: true,
  52582. configurable: true
  52583. });
  52584. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurves", {
  52585. /**
  52586. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52587. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52588. * 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;
  52589. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52590. */
  52591. get: function () {
  52592. return this._imageProcessingConfiguration.colorCurves;
  52593. },
  52594. /**
  52595. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52596. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52597. * 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;
  52598. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52599. */
  52600. set: function (value) {
  52601. this._imageProcessingConfiguration.colorCurves = value;
  52602. },
  52603. enumerable: true,
  52604. configurable: true
  52605. });
  52606. /**
  52607. * Returns the name of this material class.
  52608. */
  52609. PBRMaterial.prototype.getClassName = function () {
  52610. return "PBRMaterial";
  52611. };
  52612. /**
  52613. * Returns an array of the actively used textures.
  52614. * @returns - Array of BaseTextures
  52615. */
  52616. PBRMaterial.prototype.getActiveTextures = function () {
  52617. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52618. if (this._albedoTexture) {
  52619. activeTextures.push(this._albedoTexture);
  52620. }
  52621. if (this._ambientTexture) {
  52622. activeTextures.push(this._ambientTexture);
  52623. }
  52624. if (this._opacityTexture) {
  52625. activeTextures.push(this._opacityTexture);
  52626. }
  52627. if (this._reflectionTexture) {
  52628. activeTextures.push(this._reflectionTexture);
  52629. }
  52630. if (this._emissiveTexture) {
  52631. activeTextures.push(this._emissiveTexture);
  52632. }
  52633. if (this._reflectivityTexture) {
  52634. activeTextures.push(this._reflectivityTexture);
  52635. }
  52636. if (this._metallicTexture) {
  52637. activeTextures.push(this._metallicTexture);
  52638. }
  52639. if (this._microSurfaceTexture) {
  52640. activeTextures.push(this._microSurfaceTexture);
  52641. }
  52642. if (this._bumpTexture) {
  52643. activeTextures.push(this._bumpTexture);
  52644. }
  52645. if (this._lightmapTexture) {
  52646. activeTextures.push(this._lightmapTexture);
  52647. }
  52648. if (this._refractionTexture) {
  52649. activeTextures.push(this._refractionTexture);
  52650. }
  52651. return activeTextures;
  52652. };
  52653. /**
  52654. * Checks to see if a texture is used in the material.
  52655. * @param texture - Base texture to use.
  52656. * @returns - Boolean specifying if a texture is used in the material.
  52657. */
  52658. PBRMaterial.prototype.hasTexture = function (texture) {
  52659. if (_super.prototype.hasTexture.call(this, texture)) {
  52660. return true;
  52661. }
  52662. if (this._albedoTexture === texture) {
  52663. return true;
  52664. }
  52665. if (this._ambientTexture === texture) {
  52666. return true;
  52667. }
  52668. if (this._opacityTexture === texture) {
  52669. return true;
  52670. }
  52671. if (this._reflectionTexture === texture) {
  52672. return true;
  52673. }
  52674. if (this._reflectivityTexture === texture) {
  52675. return true;
  52676. }
  52677. if (this._metallicTexture === texture) {
  52678. return true;
  52679. }
  52680. if (this._microSurfaceTexture === texture) {
  52681. return true;
  52682. }
  52683. if (this._bumpTexture === texture) {
  52684. return true;
  52685. }
  52686. if (this._lightmapTexture === texture) {
  52687. return true;
  52688. }
  52689. if (this._refractionTexture === texture) {
  52690. return true;
  52691. }
  52692. return false;
  52693. };
  52694. /**
  52695. * Makes a duplicate of the current material.
  52696. * @param name - name to use for the new material.
  52697. */
  52698. PBRMaterial.prototype.clone = function (name) {
  52699. var _this = this;
  52700. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMaterial(name, _this.getScene()); }, this);
  52701. clone.id = name;
  52702. clone.name = name;
  52703. return clone;
  52704. };
  52705. /**
  52706. * Serializes this PBR Material.
  52707. * @returns - An object with the serialized material.
  52708. */
  52709. PBRMaterial.prototype.serialize = function () {
  52710. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  52711. serializationObject.customType = "BABYLON.PBRMaterial";
  52712. return serializationObject;
  52713. };
  52714. // Statics
  52715. /**
  52716. * Parses a PBR Material from a serialized object.
  52717. * @param source - Serialized object.
  52718. * @param scene - BJS scene instance.
  52719. * @param rootUrl - url for the scene object
  52720. * @returns - PBRMaterial
  52721. */
  52722. PBRMaterial.Parse = function (source, scene, rootUrl) {
  52723. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMaterial(source.name, scene); }, source, scene, rootUrl);
  52724. };
  52725. /**
  52726. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52727. */
  52728. PBRMaterial.PBRMATERIAL_OPAQUE = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_OPAQUE;
  52729. /**
  52730. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52731. */
  52732. PBRMaterial.PBRMATERIAL_ALPHATEST = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATEST;
  52733. /**
  52734. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52735. */
  52736. PBRMaterial.PBRMATERIAL_ALPHABLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHABLEND;
  52737. /**
  52738. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52739. * They are also discarded below the alpha cutoff threshold to improve performances.
  52740. */
  52741. PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATESTANDBLEND;
  52742. /**
  52743. * Defines the default value of how much AO map is occluding the analytical lights
  52744. * (point spot...).
  52745. */
  52746. PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  52747. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52748. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52749. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52750. ], PBRMaterial.prototype, "directIntensity", void 0);
  52751. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52752. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52753. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52754. ], PBRMaterial.prototype, "emissiveIntensity", void 0);
  52755. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52756. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52757. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52758. ], PBRMaterial.prototype, "environmentIntensity", void 0);
  52759. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52760. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52761. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52762. ], PBRMaterial.prototype, "specularIntensity", void 0);
  52763. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52764. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52765. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52766. ], PBRMaterial.prototype, "disableBumpMap", void 0);
  52767. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52768. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52769. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52770. ], PBRMaterial.prototype, "albedoTexture", void 0);
  52771. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52772. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52773. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52774. ], PBRMaterial.prototype, "ambientTexture", void 0);
  52775. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52776. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52777. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52778. ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
  52779. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52780. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52781. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52782. ], PBRMaterial.prototype, "ambientTextureImpactOnAnalyticalLights", void 0);
  52783. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52784. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52785. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52786. ], PBRMaterial.prototype, "opacityTexture", void 0);
  52787. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52788. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52789. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52790. ], PBRMaterial.prototype, "reflectionTexture", void 0);
  52791. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52792. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52793. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52794. ], PBRMaterial.prototype, "emissiveTexture", void 0);
  52795. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52796. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52797. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52798. ], PBRMaterial.prototype, "reflectivityTexture", void 0);
  52799. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52800. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52801. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52802. ], PBRMaterial.prototype, "metallicTexture", void 0);
  52803. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52804. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52805. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52806. ], PBRMaterial.prototype, "metallic", void 0);
  52807. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52808. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52809. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52810. ], PBRMaterial.prototype, "roughness", void 0);
  52811. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52812. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52813. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52814. ], PBRMaterial.prototype, "microSurfaceTexture", void 0);
  52815. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52816. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52817. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52818. ], PBRMaterial.prototype, "bumpTexture", void 0);
  52819. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52820. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  52822. ], PBRMaterial.prototype, "lightmapTexture", void 0);
  52823. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52824. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52826. ], PBRMaterial.prototype, "refractionTexture", void 0);
  52827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient"),
  52829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52830. ], PBRMaterial.prototype, "ambientColor", void 0);
  52831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("albedo"),
  52833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52834. ], PBRMaterial.prototype, "albedoColor", void 0);
  52835. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52836. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflectivity"),
  52837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52838. ], PBRMaterial.prototype, "reflectivityColor", void 0);
  52839. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52840. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflection"),
  52841. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52842. ], PBRMaterial.prototype, "reflectionColor", void 0);
  52843. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52844. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  52845. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52846. ], PBRMaterial.prototype, "emissiveColor", void 0);
  52847. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52848. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52850. ], PBRMaterial.prototype, "microSurface", void 0);
  52851. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52852. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52853. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52854. ], PBRMaterial.prototype, "indexOfRefraction", void 0);
  52855. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52856. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52857. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52858. ], PBRMaterial.prototype, "invertRefractionY", void 0);
  52859. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52860. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52862. ], PBRMaterial.prototype, "linkRefractionWithTransparency", void 0);
  52863. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52864. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52865. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52866. ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
  52867. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52868. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52869. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52870. ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
  52871. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52872. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52873. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52874. ], PBRMaterial.prototype, "forceAlphaTest", void 0);
  52875. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52876. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52877. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52878. ], PBRMaterial.prototype, "alphaCutOff", void 0);
  52879. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52880. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52881. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52882. ], PBRMaterial.prototype, "useSpecularOverAlpha", void 0);
  52883. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52884. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52885. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52886. ], PBRMaterial.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0);
  52887. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52888. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52889. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52890. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureAlpha", void 0);
  52891. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52892. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52893. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52894. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureGreen", void 0);
  52895. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52896. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52897. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52898. ], PBRMaterial.prototype, "useMetallnessFromMetallicTextureBlue", void 0);
  52899. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52900. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52901. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52902. ], PBRMaterial.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0);
  52903. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52904. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52905. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52906. ], PBRMaterial.prototype, "useAmbientInGrayScale", void 0);
  52907. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52908. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52909. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52910. ], PBRMaterial.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0);
  52911. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52912. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52913. ], PBRMaterial.prototype, "usePhysicalLightFalloff", null);
  52914. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52915. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52916. ], PBRMaterial.prototype, "useGLTFLightFalloff", null);
  52917. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52918. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52919. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52920. ], PBRMaterial.prototype, "useRadianceOverAlpha", void 0);
  52921. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52922. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52923. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52924. ], PBRMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  52925. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52926. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52927. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52928. ], PBRMaterial.prototype, "useParallax", void 0);
  52929. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52930. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52931. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52932. ], PBRMaterial.prototype, "useParallaxOcclusion", void 0);
  52933. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52934. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52935. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52936. ], PBRMaterial.prototype, "parallaxScaleBias", void 0);
  52937. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52938. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52939. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52940. ], PBRMaterial.prototype, "disableLighting", void 0);
  52941. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52942. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52943. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52944. ], PBRMaterial.prototype, "forceIrradianceInFragment", void 0);
  52945. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52946. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52947. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52948. ], PBRMaterial.prototype, "maxSimultaneousLights", void 0);
  52949. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52950. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52951. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52952. ], PBRMaterial.prototype, "invertNormalMapX", void 0);
  52953. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52954. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52955. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52956. ], PBRMaterial.prototype, "invertNormalMapY", void 0);
  52957. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52958. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52959. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52960. ], PBRMaterial.prototype, "twoSidedLighting", void 0);
  52961. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52962. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52963. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52964. ], PBRMaterial.prototype, "useAlphaFresnel", void 0);
  52965. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52966. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52967. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52968. ], PBRMaterial.prototype, "useLinearAlphaFresnel", void 0);
  52969. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52970. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52971. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52972. ], PBRMaterial.prototype, "environmentBRDFTexture", void 0);
  52973. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52974. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52975. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52976. ], PBRMaterial.prototype, "forceNormalForward", void 0);
  52977. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52978. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52980. ], PBRMaterial.prototype, "enableSpecularAntiAliasing", void 0);
  52981. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52982. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52983. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52984. ], PBRMaterial.prototype, "useHorizonOcclusion", void 0);
  52985. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52986. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52987. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52988. ], PBRMaterial.prototype, "useRadianceOcclusion", void 0);
  52989. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52990. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52991. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  52992. ], PBRMaterial.prototype, "unlit", void 0);
  52993. return PBRMaterial;
  52994. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"]));
  52995. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PBRMaterial"] = PBRMaterial;
  52996. /***/ }),
  52997. /***/ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts":
  52998. /*!*******************************************************!*\
  52999. !*** ./Materials/PBR/pbrMetallicRoughnessMaterial.ts ***!
  53000. \*******************************************************/
  53001. /*! exports provided: PBRMetallicRoughnessMaterial */
  53002. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53003. "use strict";
  53004. __webpack_require__.r(__webpack_exports__);
  53005. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return PBRMetallicRoughnessMaterial; });
  53006. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53007. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53008. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  53009. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  53010. /**
  53011. * The PBR material of BJS following the metal roughness convention.
  53012. *
  53013. * This fits to the PBR convention in the GLTF definition:
  53014. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53015. */
  53016. var PBRMetallicRoughnessMaterial = /** @class */ (function (_super) {
  53017. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMetallicRoughnessMaterial, _super);
  53018. /**
  53019. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53020. *
  53021. * @param name The material name
  53022. * @param scene The scene the material will be use in.
  53023. */
  53024. function PBRMetallicRoughnessMaterial(name, scene) {
  53025. var _this = _super.call(this, name, scene) || this;
  53026. _this._useRoughnessFromMetallicTextureAlpha = false;
  53027. _this._useRoughnessFromMetallicTextureGreen = true;
  53028. _this._useMetallnessFromMetallicTextureBlue = true;
  53029. _this.metallic = 1.0;
  53030. _this.roughness = 1.0;
  53031. return _this;
  53032. }
  53033. /**
  53034. * Return the currrent class name of the material.
  53035. */
  53036. PBRMetallicRoughnessMaterial.prototype.getClassName = function () {
  53037. return "PBRMetallicRoughnessMaterial";
  53038. };
  53039. /**
  53040. * Return the active textures of the material.
  53041. */
  53042. PBRMetallicRoughnessMaterial.prototype.getActiveTextures = function () {
  53043. var activeTextures = _super.prototype.getActiveTextures.call(this);
  53044. if (this.baseTexture) {
  53045. activeTextures.push(this.baseTexture);
  53046. }
  53047. if (this.metallicRoughnessTexture) {
  53048. activeTextures.push(this.metallicRoughnessTexture);
  53049. }
  53050. return activeTextures;
  53051. };
  53052. /**
  53053. * Checks to see if a texture is used in the material.
  53054. * @param texture - Base texture to use.
  53055. * @returns - Boolean specifying if a texture is used in the material.
  53056. */
  53057. PBRMetallicRoughnessMaterial.prototype.hasTexture = function (texture) {
  53058. if (_super.prototype.hasTexture.call(this, texture)) {
  53059. return true;
  53060. }
  53061. if (this.baseTexture === texture) {
  53062. return true;
  53063. }
  53064. if (this.metallicRoughnessTexture === texture) {
  53065. return true;
  53066. }
  53067. return false;
  53068. };
  53069. /**
  53070. * Makes a duplicate of the current material.
  53071. * @param name - name to use for the new material.
  53072. */
  53073. PBRMetallicRoughnessMaterial.prototype.clone = function (name) {
  53074. var _this = this;
  53075. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMetallicRoughnessMaterial(name, _this.getScene()); }, this);
  53076. clone.id = name;
  53077. clone.name = name;
  53078. return clone;
  53079. };
  53080. /**
  53081. * Serialize the material to a parsable JSON object.
  53082. */
  53083. PBRMetallicRoughnessMaterial.prototype.serialize = function () {
  53084. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  53085. serializationObject.customType = "BABYLON.PBRMetallicRoughnessMaterial";
  53086. return serializationObject;
  53087. };
  53088. /**
  53089. * Parses a JSON object correponding to the serialize function.
  53090. */
  53091. PBRMetallicRoughnessMaterial.Parse = function (source, scene, rootUrl) {
  53092. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMetallicRoughnessMaterial(source.name, scene); }, source, scene, rootUrl);
  53093. };
  53094. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53095. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])(),
  53096. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  53097. ], PBRMetallicRoughnessMaterial.prototype, "baseColor", void 0);
  53098. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53099. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53100. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  53101. ], PBRMetallicRoughnessMaterial.prototype, "baseTexture", void 0);
  53102. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53103. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53104. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53105. ], PBRMetallicRoughnessMaterial.prototype, "metallic", void 0);
  53106. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53107. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53109. ], PBRMetallicRoughnessMaterial.prototype, "roughness", void 0);
  53110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53112. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")
  53113. ], PBRMetallicRoughnessMaterial.prototype, "metallicRoughnessTexture", void 0);
  53114. return PBRMetallicRoughnessMaterial;
  53115. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  53116. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = PBRMetallicRoughnessMaterial;
  53117. /***/ }),
  53118. /***/ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts":
  53119. /*!********************************************************!*\
  53120. !*** ./Materials/PBR/pbrSpecularGlossinessMaterial.ts ***!
  53121. \********************************************************/
  53122. /*! exports provided: PBRSpecularGlossinessMaterial */
  53123. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53124. "use strict";
  53125. __webpack_require__.r(__webpack_exports__);
  53126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return PBRSpecularGlossinessMaterial; });
  53127. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53128. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53129. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  53130. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  53131. /**
  53132. * The PBR material of BJS following the specular glossiness convention.
  53133. *
  53134. * This fits to the PBR convention in the GLTF definition:
  53135. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53136. */
  53137. var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
  53138. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRSpecularGlossinessMaterial, _super);
  53139. /**
  53140. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53141. *
  53142. * @param name The material name
  53143. * @param scene The scene the material will be use in.
  53144. */
  53145. function PBRSpecularGlossinessMaterial(name, scene) {
  53146. var _this = _super.call(this, name, scene) || this;
  53147. _this._useMicroSurfaceFromReflectivityMapAlpha = true;
  53148. return _this;
  53149. }
  53150. /**
  53151. * Return the currrent class name of the material.
  53152. */
  53153. PBRSpecularGlossinessMaterial.prototype.getClassName = function () {
  53154. return "PBRSpecularGlossinessMaterial";
  53155. };
  53156. /**
  53157. * Return the active textures of the material.
  53158. */
  53159. PBRSpecularGlossinessMaterial.prototype.getActiveTextures = function () {
  53160. var activeTextures = _super.prototype.getActiveTextures.call(this);
  53161. if (this.diffuseTexture) {
  53162. activeTextures.push(this.diffuseTexture);
  53163. }
  53164. if (this.specularGlossinessTexture) {
  53165. activeTextures.push(this.specularGlossinessTexture);
  53166. }
  53167. return activeTextures;
  53168. };
  53169. /**
  53170. * Checks to see if a texture is used in the material.
  53171. * @param texture - Base texture to use.
  53172. * @returns - Boolean specifying if a texture is used in the material.
  53173. */
  53174. PBRSpecularGlossinessMaterial.prototype.hasTexture = function (texture) {
  53175. if (_super.prototype.hasTexture.call(this, texture)) {
  53176. return true;
  53177. }
  53178. if (this.diffuseTexture === texture) {
  53179. return true;
  53180. }
  53181. if (this.specularGlossinessTexture === texture) {
  53182. return true;
  53183. }
  53184. return false;
  53185. };
  53186. /**
  53187. * Makes a duplicate of the current material.
  53188. * @param name - name to use for the new material.
  53189. */
  53190. PBRSpecularGlossinessMaterial.prototype.clone = function (name) {
  53191. var _this = this;
  53192. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRSpecularGlossinessMaterial(name, _this.getScene()); }, this);
  53193. clone.id = name;
  53194. clone.name = name;
  53195. return clone;
  53196. };
  53197. /**
  53198. * Serialize the material to a parsable JSON object.
  53199. */
  53200. PBRSpecularGlossinessMaterial.prototype.serialize = function () {
  53201. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  53202. serializationObject.customType = "BABYLON.PBRSpecularGlossinessMaterial";
  53203. return serializationObject;
  53204. };
  53205. /**
  53206. * Parses a JSON object correponding to the serialize function.
  53207. */
  53208. PBRSpecularGlossinessMaterial.Parse = function (source, scene, rootUrl) {
  53209. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRSpecularGlossinessMaterial(source.name, scene); }, source, scene, rootUrl);
  53210. };
  53211. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53212. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse"),
  53213. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  53214. ], PBRSpecularGlossinessMaterial.prototype, "diffuseColor", void 0);
  53215. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53217. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  53218. ], PBRSpecularGlossinessMaterial.prototype, "diffuseTexture", void 0);
  53219. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53220. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular"),
  53221. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")
  53222. ], PBRSpecularGlossinessMaterial.prototype, "specularColor", void 0);
  53223. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53224. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53225. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_microSurface")
  53226. ], PBRSpecularGlossinessMaterial.prototype, "glossiness", void 0);
  53227. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53228. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53229. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")
  53230. ], PBRSpecularGlossinessMaterial.prototype, "specularGlossinessTexture", void 0);
  53231. return PBRSpecularGlossinessMaterial;
  53232. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  53233. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = PBRSpecularGlossinessMaterial;
  53234. /***/ }),
  53235. /***/ "./Materials/Textures/Loaders/ddsTextureLoader.ts":
  53236. /*!********************************************************!*\
  53237. !*** ./Materials/Textures/Loaders/ddsTextureLoader.ts ***!
  53238. \********************************************************/
  53239. /*! exports provided: _DDSTextureLoader */
  53240. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53241. "use strict";
  53242. __webpack_require__.r(__webpack_exports__);
  53243. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _DDSTextureLoader; });
  53244. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  53245. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53246. /* harmony import */ var _Misc_dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/dds */ "./Misc/dds.ts");
  53247. /**
  53248. * Implementation of the DDS Texture Loader.
  53249. * @hidden
  53250. */
  53251. var _DDSTextureLoader = /** @class */ (function () {
  53252. function _DDSTextureLoader() {
  53253. /**
  53254. * Defines wether the loader supports cascade loading the different faces.
  53255. */
  53256. this.supportCascades = true;
  53257. }
  53258. /**
  53259. * This returns if the loader support the current file information.
  53260. * @param extension defines the file extension of the file being loaded
  53261. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53262. * @param fallback defines the fallback internal texture if any
  53263. * @param isBase64 defines whether the texture is encoded as a base64
  53264. * @param isBuffer defines whether the texture data are stored as a buffer
  53265. * @returns true if the loader can load the specified file
  53266. */
  53267. _DDSTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53268. return extension.indexOf(".dds") === 0;
  53269. };
  53270. /**
  53271. * Transform the url before loading if required.
  53272. * @param rootUrl the url of the texture
  53273. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53274. * @returns the transformed texture
  53275. */
  53276. _DDSTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53277. return rootUrl;
  53278. };
  53279. /**
  53280. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53281. * @param rootUrl the url of the texture
  53282. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53283. * @returns the fallback texture
  53284. */
  53285. _DDSTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53286. return null;
  53287. };
  53288. /**
  53289. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53290. * @param data contains the texture data
  53291. * @param texture defines the BabylonJS internal texture
  53292. * @param createPolynomials will be true if polynomials have been requested
  53293. * @param onLoad defines the callback to trigger once the texture is ready
  53294. * @param onError defines the callback to trigger in case of error
  53295. */
  53296. _DDSTextureLoader.prototype.loadCubeData = function (imgs, texture, createPolynomials, onLoad, onError) {
  53297. var engine = texture.getEngine();
  53298. var info;
  53299. var loadMipmap = false;
  53300. if (Array.isArray(imgs)) {
  53301. for (var index = 0; index < imgs.length; index++) {
  53302. var data_1 = imgs[index];
  53303. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data_1);
  53304. texture.width = info.width;
  53305. texture.height = info.height;
  53306. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  53307. engine._unpackFlipY(info.isCompressed);
  53308. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data_1, info, loadMipmap, 6, -1, index);
  53309. if (!info.isFourCC && info.mipmapCount === 1) {
  53310. engine.generateMipMapsForCubemap(texture);
  53311. }
  53312. }
  53313. }
  53314. else {
  53315. var data = imgs;
  53316. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  53317. texture.width = info.width;
  53318. texture.height = info.height;
  53319. if (createPolynomials) {
  53320. info.sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]();
  53321. }
  53322. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  53323. engine._unpackFlipY(info.isCompressed);
  53324. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);
  53325. if (!info.isFourCC && info.mipmapCount === 1) {
  53326. engine.generateMipMapsForCubemap(texture);
  53327. }
  53328. }
  53329. engine._setCubeMapTextureParams(loadMipmap);
  53330. texture.isReady = true;
  53331. if (onLoad) {
  53332. onLoad({ isDDS: true, width: texture.width, info: info, data: imgs, texture: texture });
  53333. }
  53334. };
  53335. /**
  53336. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53337. * @param data contains the texture data
  53338. * @param texture defines the BabylonJS internal texture
  53339. * @param callback defines the method to call once ready to upload
  53340. */
  53341. _DDSTextureLoader.prototype.loadData = function (data, texture, callback) {
  53342. var info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  53343. var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && ((info.width >> (info.mipmapCount - 1)) === 1);
  53344. callback(info.width, info.height, loadMipmap, info.isFourCC, function () {
  53345. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
  53346. });
  53347. };
  53348. return _DDSTextureLoader;
  53349. }());
  53350. // Register the loader.
  53351. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _DDSTextureLoader());
  53352. /***/ }),
  53353. /***/ "./Materials/Textures/Loaders/envTextureLoader.ts":
  53354. /*!********************************************************!*\
  53355. !*** ./Materials/Textures/Loaders/envTextureLoader.ts ***!
  53356. \********************************************************/
  53357. /*! exports provided: _ENVTextureLoader */
  53358. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53359. "use strict";
  53360. __webpack_require__.r(__webpack_exports__);
  53361. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _ENVTextureLoader; });
  53362. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  53363. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53364. /**
  53365. * Implementation of the ENV Texture Loader.
  53366. * @hidden
  53367. */
  53368. var _ENVTextureLoader = /** @class */ (function () {
  53369. function _ENVTextureLoader() {
  53370. /**
  53371. * Defines wether the loader supports cascade loading the different faces.
  53372. */
  53373. this.supportCascades = false;
  53374. }
  53375. /**
  53376. * This returns if the loader support the current file information.
  53377. * @param extension defines the file extension of the file being loaded
  53378. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53379. * @param fallback defines the fallback internal texture if any
  53380. * @param isBase64 defines whether the texture is encoded as a base64
  53381. * @param isBuffer defines whether the texture data are stored as a buffer
  53382. * @returns true if the loader can load the specified file
  53383. */
  53384. _ENVTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53385. return extension.indexOf(".env") === 0;
  53386. };
  53387. /**
  53388. * Transform the url before loading if required.
  53389. * @param rootUrl the url of the texture
  53390. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53391. * @returns the transformed texture
  53392. */
  53393. _ENVTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53394. return rootUrl;
  53395. };
  53396. /**
  53397. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53398. * @param rootUrl the url of the texture
  53399. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53400. * @returns the fallback texture
  53401. */
  53402. _ENVTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53403. return null;
  53404. };
  53405. /**
  53406. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53407. * @param data contains the texture data
  53408. * @param texture defines the BabylonJS internal texture
  53409. * @param createPolynomials will be true if polynomials have been requested
  53410. * @param onLoad defines the callback to trigger once the texture is ready
  53411. * @param onError defines the callback to trigger in case of error
  53412. */
  53413. _ENVTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  53414. if (Array.isArray(data)) {
  53415. return;
  53416. }
  53417. data = data;
  53418. var info = _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].GetEnvInfo(data);
  53419. if (info) {
  53420. texture.width = info.width;
  53421. texture.height = info.width;
  53422. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvSpherical(texture, info);
  53423. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvLevelsAsync(texture, data, info).then(function () {
  53424. texture.isReady = true;
  53425. if (onLoad) {
  53426. onLoad();
  53427. }
  53428. });
  53429. }
  53430. else if (onError) {
  53431. onError("Can not parse the environment file", null);
  53432. }
  53433. };
  53434. /**
  53435. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53436. * @param data contains the texture data
  53437. * @param texture defines the BabylonJS internal texture
  53438. * @param callback defines the method to call once ready to upload
  53439. */
  53440. _ENVTextureLoader.prototype.loadData = function (data, texture, callback) {
  53441. throw ".env not supported in 2d.";
  53442. };
  53443. return _ENVTextureLoader;
  53444. }());
  53445. // Register the loader.
  53446. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _ENVTextureLoader());
  53447. /***/ }),
  53448. /***/ "./Materials/Textures/Loaders/index.ts":
  53449. /*!*********************************************!*\
  53450. !*** ./Materials/Textures/Loaders/index.ts ***!
  53451. \*********************************************/
  53452. /*! exports provided: _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader */
  53453. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53454. "use strict";
  53455. __webpack_require__.r(__webpack_exports__);
  53456. /* harmony import */ var _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  53457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  53458. /* harmony import */ var _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  53459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__["_ENVTextureLoader"]; });
  53460. /* harmony import */ var _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  53461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__["_KTXTextureLoader"]; });
  53462. /* harmony import */ var _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tgaTextureLoader */ "./Materials/Textures/Loaders/tgaTextureLoader.ts");
  53463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__["_TGATextureLoader"]; });
  53464. /***/ }),
  53465. /***/ "./Materials/Textures/Loaders/ktxTextureLoader.ts":
  53466. /*!********************************************************!*\
  53467. !*** ./Materials/Textures/Loaders/ktxTextureLoader.ts ***!
  53468. \********************************************************/
  53469. /*! exports provided: _KTXTextureLoader */
  53470. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53471. "use strict";
  53472. __webpack_require__.r(__webpack_exports__);
  53473. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _KTXTextureLoader; });
  53474. /* harmony import */ var _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  53475. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53476. /**
  53477. * Implementation of the KTX Texture Loader.
  53478. * @hidden
  53479. */
  53480. var _KTXTextureLoader = /** @class */ (function () {
  53481. function _KTXTextureLoader() {
  53482. /**
  53483. * Defines wether the loader supports cascade loading the different faces.
  53484. */
  53485. this.supportCascades = false;
  53486. }
  53487. /**
  53488. * This returns if the loader support the current file information.
  53489. * @param extension defines the file extension of the file being loaded
  53490. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53491. * @param fallback defines the fallback internal texture if any
  53492. * @param isBase64 defines whether the texture is encoded as a base64
  53493. * @param isBuffer defines whether the texture data are stored as a buffer
  53494. * @returns true if the loader can load the specified file
  53495. */
  53496. _KTXTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53497. if (textureFormatInUse && !isBase64 && !fallback && !isBuffer) {
  53498. return true;
  53499. }
  53500. return false;
  53501. };
  53502. /**
  53503. * Transform the url before loading if required.
  53504. * @param rootUrl the url of the texture
  53505. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53506. * @returns the transformed texture
  53507. */
  53508. _KTXTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53509. var lastDot = rootUrl.lastIndexOf('.');
  53510. if (lastDot != -1 && rootUrl.substring(lastDot + 1) == "ktx") {
  53511. // Already transformed
  53512. return rootUrl;
  53513. }
  53514. return (lastDot > -1 ? rootUrl.substring(0, lastDot) : rootUrl) + textureFormatInUse;
  53515. };
  53516. /**
  53517. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53518. * @param rootUrl the url of the texture
  53519. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53520. * @returns the fallback texture
  53521. */
  53522. _KTXTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53523. // remove the format appended to the rootUrl in the original createCubeTexture call.
  53524. var exp = new RegExp("" + textureFormatInUse + "$");
  53525. return rootUrl.replace(exp, "");
  53526. };
  53527. /**
  53528. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53529. * @param data contains the texture data
  53530. * @param texture defines the BabylonJS internal texture
  53531. * @param createPolynomials will be true if polynomials have been requested
  53532. * @param onLoad defines the callback to trigger once the texture is ready
  53533. * @param onError defines the callback to trigger in case of error
  53534. */
  53535. _KTXTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  53536. if (Array.isArray(data)) {
  53537. return;
  53538. }
  53539. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  53540. texture._invertVScale = !texture.invertY;
  53541. var engine = texture.getEngine();
  53542. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 6);
  53543. var loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;
  53544. engine._unpackFlipY(true);
  53545. ktx.uploadLevels(texture, texture.generateMipMaps);
  53546. texture.width = ktx.pixelWidth;
  53547. texture.height = ktx.pixelHeight;
  53548. engine._setCubeMapTextureParams(loadMipmap);
  53549. texture.isReady = true;
  53550. };
  53551. /**
  53552. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53553. * @param data contains the texture data
  53554. * @param texture defines the BabylonJS internal texture
  53555. * @param callback defines the method to call once ready to upload
  53556. */
  53557. _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
  53558. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  53559. texture._invertVScale = !texture.invertY;
  53560. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 1);
  53561. callback(ktx.pixelWidth, ktx.pixelHeight, false, true, function () {
  53562. ktx.uploadLevels(texture, texture.generateMipMaps);
  53563. }, ktx.isInvalid);
  53564. };
  53565. return _KTXTextureLoader;
  53566. }());
  53567. // Register the loader.
  53568. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.unshift(new _KTXTextureLoader());
  53569. /***/ }),
  53570. /***/ "./Materials/Textures/Loaders/tgaTextureLoader.ts":
  53571. /*!********************************************************!*\
  53572. !*** ./Materials/Textures/Loaders/tgaTextureLoader.ts ***!
  53573. \********************************************************/
  53574. /*! exports provided: _TGATextureLoader */
  53575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53576. "use strict";
  53577. __webpack_require__.r(__webpack_exports__);
  53578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _TGATextureLoader; });
  53579. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tga */ "./Misc/tga.ts");
  53580. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53581. /**
  53582. * Implementation of the TGA Texture Loader.
  53583. * @hidden
  53584. */
  53585. var _TGATextureLoader = /** @class */ (function () {
  53586. function _TGATextureLoader() {
  53587. /**
  53588. * Defines wether the loader supports cascade loading the different faces.
  53589. */
  53590. this.supportCascades = false;
  53591. }
  53592. /**
  53593. * This returns if the loader support the current file information.
  53594. * @param extension defines the file extension of the file being loaded
  53595. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53596. * @param fallback defines the fallback internal texture if any
  53597. * @param isBase64 defines whether the texture is encoded as a base64
  53598. * @param isBuffer defines whether the texture data are stored as a buffer
  53599. * @returns true if the loader can load the specified file
  53600. */
  53601. _TGATextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53602. return extension.indexOf(".tga") === 0;
  53603. };
  53604. /**
  53605. * Transform the url before loading if required.
  53606. * @param rootUrl the url of the texture
  53607. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53608. * @returns the transformed texture
  53609. */
  53610. _TGATextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53611. return rootUrl;
  53612. };
  53613. /**
  53614. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53615. * @param rootUrl the url of the texture
  53616. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53617. * @returns the fallback texture
  53618. */
  53619. _TGATextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53620. return null;
  53621. };
  53622. /**
  53623. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53624. * @param data contains the texture data
  53625. * @param texture defines the BabylonJS internal texture
  53626. * @param createPolynomials will be true if polynomials have been requested
  53627. * @param onLoad defines the callback to trigger once the texture is ready
  53628. * @param onError defines the callback to trigger in case of error
  53629. */
  53630. _TGATextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  53631. throw ".env not supported in Cube.";
  53632. };
  53633. /**
  53634. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53635. * @param data contains the texture data
  53636. * @param texture defines the BabylonJS internal texture
  53637. * @param callback defines the method to call once ready to upload
  53638. */
  53639. _TGATextureLoader.prototype.loadData = function (data, texture, callback) {
  53640. var uintData = new Uint8Array(data);
  53641. var header = _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].GetTGAHeader(uintData);
  53642. callback(header.width, header.height, texture.generateMipMaps, false, function () {
  53643. _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].UploadContent(texture, uintData);
  53644. });
  53645. };
  53646. return _TGATextureLoader;
  53647. }());
  53648. // Register the loader.
  53649. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _TGATextureLoader());
  53650. /***/ }),
  53651. /***/ "./Materials/Textures/Procedurals/customProceduralTexture.ts":
  53652. /*!*******************************************************************!*\
  53653. !*** ./Materials/Textures/Procedurals/customProceduralTexture.ts ***!
  53654. \*******************************************************************/
  53655. /*! exports provided: CustomProceduralTexture */
  53656. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53657. "use strict";
  53658. __webpack_require__.r(__webpack_exports__);
  53659. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return CustomProceduralTexture; });
  53660. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53661. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  53662. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  53663. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  53664. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  53665. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  53666. /**
  53667. * 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.
  53668. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53669. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53670. */
  53671. var CustomProceduralTexture = /** @class */ (function (_super) {
  53672. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomProceduralTexture, _super);
  53673. /**
  53674. * Instantiates a new Custom Procedural Texture.
  53675. * 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.
  53676. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53677. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53678. * @param name Define the name of the texture
  53679. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53680. * @param size Define the size of the texture to create
  53681. * @param scene Define the scene the texture belongs to
  53682. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53683. * @param generateMipMaps Define if the texture should creates mip maps or not
  53684. */
  53685. function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
  53686. var _this = _super.call(this, name, size, null, scene, fallbackTexture, generateMipMaps) || this;
  53687. _this._animate = true;
  53688. _this._time = 0;
  53689. _this._texturePath = texturePath;
  53690. //Try to load json
  53691. _this._loadJson(texturePath);
  53692. _this.refreshRate = 1;
  53693. return _this;
  53694. }
  53695. CustomProceduralTexture.prototype._loadJson = function (jsonUrl) {
  53696. var _this = this;
  53697. var noConfigFile = function () {
  53698. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
  53699. try {
  53700. _this.setFragment(_this._texturePath);
  53701. }
  53702. catch (ex) {
  53703. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
  53704. }
  53705. };
  53706. var configFileUrl = jsonUrl + "/config.json";
  53707. var xhr = new XMLHttpRequest();
  53708. xhr.open("GET", configFileUrl, true);
  53709. xhr.addEventListener("load", function () {
  53710. if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {
  53711. try {
  53712. _this._config = JSON.parse(xhr.response);
  53713. _this.updateShaderUniforms();
  53714. _this.updateTextures();
  53715. _this.setFragment(_this._texturePath + "/custom");
  53716. _this._animate = _this._config.animate;
  53717. _this.refreshRate = _this._config.refreshrate;
  53718. }
  53719. catch (ex) {
  53720. noConfigFile();
  53721. }
  53722. }
  53723. else {
  53724. noConfigFile();
  53725. }
  53726. }, false);
  53727. xhr.addEventListener("error", function () {
  53728. noConfigFile();
  53729. }, false);
  53730. try {
  53731. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].UseCustomRequestHeaders) {
  53732. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].InjectCustomRequestHeaders(xhr);
  53733. }
  53734. xhr.send();
  53735. }
  53736. catch (ex) {
  53737. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("CustomProceduralTexture: Error on XHR send request.");
  53738. }
  53739. };
  53740. /**
  53741. * Is the texture ready to be used ? (rendered at least once)
  53742. * @returns true if ready, otherwise, false.
  53743. */
  53744. CustomProceduralTexture.prototype.isReady = function () {
  53745. if (!_super.prototype.isReady.call(this)) {
  53746. return false;
  53747. }
  53748. for (var name in this._textures) {
  53749. var texture = this._textures[name];
  53750. if (!texture.isReady()) {
  53751. return false;
  53752. }
  53753. }
  53754. return true;
  53755. };
  53756. /**
  53757. * Render the texture to its associated render target.
  53758. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53759. */
  53760. CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
  53761. var scene = this.getScene();
  53762. if (this._animate && scene) {
  53763. this._time += scene.getAnimationRatio() * 0.03;
  53764. this.updateShaderUniforms();
  53765. }
  53766. _super.prototype.render.call(this, useCameraPostProcess);
  53767. };
  53768. /**
  53769. * Update the list of dependant textures samplers in the shader.
  53770. */
  53771. CustomProceduralTexture.prototype.updateTextures = function () {
  53772. for (var i = 0; i < this._config.sampler2Ds.length; i++) {
  53773. 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()));
  53774. }
  53775. };
  53776. /**
  53777. * Update the uniform values of the procedural texture in the shader.
  53778. */
  53779. CustomProceduralTexture.prototype.updateShaderUniforms = function () {
  53780. if (this._config) {
  53781. for (var j = 0; j < this._config.uniforms.length; j++) {
  53782. var uniform = this._config.uniforms[j];
  53783. switch (uniform.type) {
  53784. case "float":
  53785. this.setFloat(uniform.name, uniform.value);
  53786. break;
  53787. case "color3":
  53788. this.setColor3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](uniform.r, uniform.g, uniform.b));
  53789. break;
  53790. case "color4":
  53791. this.setColor4(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](uniform.r, uniform.g, uniform.b, uniform.a));
  53792. break;
  53793. case "vector2":
  53794. this.setVector2(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](uniform.x, uniform.y));
  53795. break;
  53796. case "vector3":
  53797. this.setVector3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](uniform.x, uniform.y, uniform.z));
  53798. break;
  53799. }
  53800. }
  53801. }
  53802. this.setFloat("time", this._time);
  53803. };
  53804. Object.defineProperty(CustomProceduralTexture.prototype, "animate", {
  53805. /**
  53806. * Define if the texture animates or not.
  53807. */
  53808. get: function () {
  53809. return this._animate;
  53810. },
  53811. set: function (value) {
  53812. this._animate = value;
  53813. },
  53814. enumerable: true,
  53815. configurable: true
  53816. });
  53817. return CustomProceduralTexture;
  53818. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_5__["ProceduralTexture"]));
  53819. /***/ }),
  53820. /***/ "./Materials/Textures/Procedurals/index.ts":
  53821. /*!*************************************************!*\
  53822. !*** ./Materials/Textures/Procedurals/index.ts ***!
  53823. \*************************************************/
  53824. /*! exports provided: ProceduralTexture, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  53825. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53826. "use strict";
  53827. __webpack_require__.r(__webpack_exports__);
  53828. /* harmony import */ var _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customProceduralTexture */ "./Materials/Textures/Procedurals/customProceduralTexture.ts");
  53829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  53830. /* harmony import */ var _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./noiseProceduralTexture */ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts");
  53831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__["NoiseProceduralTexture"]; });
  53832. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  53833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]; });
  53834. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  53835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__["ProceduralTextureSceneComponent"]; });
  53836. /***/ }),
  53837. /***/ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts":
  53838. /*!******************************************************************!*\
  53839. !*** ./Materials/Textures/Procedurals/noiseProceduralTexture.ts ***!
  53840. \******************************************************************/
  53841. /*! exports provided: NoiseProceduralTexture */
  53842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53843. "use strict";
  53844. __webpack_require__.r(__webpack_exports__);
  53845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return NoiseProceduralTexture; });
  53846. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53847. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  53848. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  53849. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  53850. /* harmony import */ var _Shaders_noise_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Shaders/noise.fragment */ "./Shaders/noise.fragment.ts");
  53851. /**
  53852. * Class used to generate noise procedural textures
  53853. */
  53854. var NoiseProceduralTexture = /** @class */ (function (_super) {
  53855. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NoiseProceduralTexture, _super);
  53856. /**
  53857. * Creates a new NoiseProceduralTexture
  53858. * @param name defines the name fo the texture
  53859. * @param size defines the size of the texture (default is 256)
  53860. * @param scene defines the hosting scene
  53861. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53862. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53863. */
  53864. function NoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  53865. if (size === void 0) { size = 256; }
  53866. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene; }
  53867. var _this = _super.call(this, name, size, "noise", scene, fallbackTexture, generateMipMaps) || this;
  53868. _this._time = 0;
  53869. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53870. _this.brightness = 0.2;
  53871. /** Defines the number of octaves to process */
  53872. _this.octaves = 3;
  53873. /** Defines the level of persistence (0.8 by default) */
  53874. _this.persistence = 0.8;
  53875. /** Gets or sets animation speed factor (default is 1) */
  53876. _this.animationSpeedFactor = 1;
  53877. _this.autoClear = false;
  53878. _this._updateShaderUniforms();
  53879. return _this;
  53880. }
  53881. NoiseProceduralTexture.prototype._updateShaderUniforms = function () {
  53882. var scene = this.getScene();
  53883. if (!scene) {
  53884. return;
  53885. }
  53886. this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
  53887. this.setFloat("brightness", this.brightness);
  53888. this.setFloat("persistence", this.persistence);
  53889. this.setFloat("timeScale", this._time);
  53890. };
  53891. NoiseProceduralTexture.prototype._getDefines = function () {
  53892. return "#define OCTAVES " + (this.octaves | 0);
  53893. };
  53894. /** Generate the current state of the procedural texture */
  53895. NoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  53896. this._updateShaderUniforms();
  53897. _super.prototype.render.call(this, useCameraPostProcess);
  53898. };
  53899. /**
  53900. * Serializes this noise procedural texture
  53901. * @returns a serialized noise procedural texture object
  53902. */
  53903. NoiseProceduralTexture.prototype.serialize = function () {
  53904. var serializationObject = {};
  53905. serializationObject.customType = "BABYLON.NoiseProceduralTexture";
  53906. serializationObject.brightness = this.brightness;
  53907. serializationObject.octaves = this.octaves;
  53908. serializationObject.persistence = this.persistence;
  53909. serializationObject.animationSpeedFactor = this.animationSpeedFactor;
  53910. serializationObject.size = this.getSize().width;
  53911. serializationObject.generateMipMaps = this._generateMipMaps;
  53912. return serializationObject;
  53913. };
  53914. /**
  53915. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53916. * @param parsedTexture defines parsed texture data
  53917. * @param scene defines the current scene
  53918. * @param rootUrl defines the root URL containing noise procedural texture information
  53919. * @returns a parsed NoiseProceduralTexture
  53920. */
  53921. NoiseProceduralTexture.Parse = function (parsedTexture, scene) {
  53922. var texture = new NoiseProceduralTexture(parsedTexture.name, parsedTexture.size, scene, undefined, parsedTexture.generateMipMaps);
  53923. texture.brightness = parsedTexture.brightness;
  53924. texture.octaves = parsedTexture.octaves;
  53925. texture.persistence = parsedTexture.persistence;
  53926. texture.animationSpeedFactor = parsedTexture.animationSpeedFactor;
  53927. return texture;
  53928. };
  53929. return NoiseProceduralTexture;
  53930. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]));
  53931. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.NoiseProceduralTexture"] = NoiseProceduralTexture;
  53932. /***/ }),
  53933. /***/ "./Materials/Textures/Procedurals/proceduralTexture.ts":
  53934. /*!*************************************************************!*\
  53935. !*** ./Materials/Textures/Procedurals/proceduralTexture.ts ***!
  53936. \*************************************************************/
  53937. /*! exports provided: ProceduralTexture */
  53938. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53939. "use strict";
  53940. __webpack_require__.r(__webpack_exports__);
  53941. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return ProceduralTexture; });
  53942. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53943. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  53944. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/observable */ "./Misc/observable.ts");
  53945. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Meshes/buffer */ "./Meshes/buffer.ts");
  53946. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  53947. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/material */ "./Materials/material.ts");
  53948. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  53949. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  53950. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  53951. /* harmony import */ var _Shaders_procedural_vertex__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Shaders/procedural.vertex */ "./Shaders/procedural.vertex.ts");
  53952. /**
  53953. * 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.
  53954. * This is the base class of any Procedural texture and contains most of the shareable code.
  53955. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  53956. */
  53957. var ProceduralTexture = /** @class */ (function (_super) {
  53958. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ProceduralTexture, _super);
  53959. /**
  53960. * Instantiates a new procedural texture.
  53961. * 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.
  53962. * This is the base class of any Procedural texture and contains most of the shareable code.
  53963. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  53964. * @param name Define the name of the texture
  53965. * @param size Define the size of the texture to create
  53966. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  53967. * @param scene Define the scene the texture belongs to
  53968. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53969. * @param generateMipMaps Define if the texture should creates mip maps or not
  53970. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  53971. */
  53972. function ProceduralTexture(name, size, fragment, scene, fallbackTexture, generateMipMaps, isCube) {
  53973. if (fallbackTexture === void 0) { fallbackTexture = null; }
  53974. if (generateMipMaps === void 0) { generateMipMaps = true; }
  53975. if (isCube === void 0) { isCube = false; }
  53976. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  53977. _this.isCube = isCube;
  53978. /**
  53979. * Define if the texture is enabled or not (disabled texture will not render)
  53980. */
  53981. _this.isEnabled = true;
  53982. /**
  53983. * Define if the texture must be cleared before rendering (default is true)
  53984. */
  53985. _this.autoClear = true;
  53986. /**
  53987. * Event raised when the texture is generated
  53988. */
  53989. _this.onGeneratedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  53990. /** @hidden */
  53991. _this._textures = {};
  53992. _this._currentRefreshId = -1;
  53993. _this._refreshRate = 1;
  53994. _this._vertexBuffers = {};
  53995. _this._uniforms = new Array();
  53996. _this._samplers = new Array();
  53997. _this._floats = {};
  53998. _this._ints = {};
  53999. _this._floatsArrays = {};
  54000. _this._colors3 = {};
  54001. _this._colors4 = {};
  54002. _this._vectors2 = {};
  54003. _this._vectors3 = {};
  54004. _this._matrices = {};
  54005. _this._fallbackTextureUsed = false;
  54006. _this._cachedDefines = "";
  54007. _this._contentUpdateId = -1;
  54008. scene = _this.getScene();
  54009. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE);
  54010. if (!component) {
  54011. component = new _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__["ProceduralTextureSceneComponent"](scene);
  54012. scene._addComponent(component);
  54013. }
  54014. scene.proceduralTextures.push(_this);
  54015. _this._engine = scene.getEngine();
  54016. _this.name = name;
  54017. _this.isRenderTarget = true;
  54018. _this._size = size;
  54019. _this._generateMipMaps = generateMipMaps;
  54020. _this.setFragment(fragment);
  54021. _this._fallbackTexture = fallbackTexture;
  54022. if (isCube) {
  54023. _this._texture = _this._engine.createRenderTargetCubeTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  54024. _this.setFloat("face", 0);
  54025. }
  54026. else {
  54027. _this._texture = _this._engine.createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  54028. }
  54029. // VBO
  54030. var vertices = [];
  54031. vertices.push(1, 1);
  54032. vertices.push(-1, 1);
  54033. vertices.push(-1, -1);
  54034. vertices.push(1, -1);
  54035. _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);
  54036. _this._createIndexBuffer();
  54037. return _this;
  54038. }
  54039. /**
  54040. * The effect that is created when initializing the post process.
  54041. * @returns The created effect corrisponding the the postprocess.
  54042. */
  54043. ProceduralTexture.prototype.getEffect = function () {
  54044. return this._effect;
  54045. };
  54046. /**
  54047. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  54048. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  54049. */
  54050. ProceduralTexture.prototype.getContent = function () {
  54051. if (this._contentData && this._currentRefreshId == this._contentUpdateId) {
  54052. return this._contentData;
  54053. }
  54054. this._contentData = this.readPixels(0, 0, this._contentData);
  54055. this._contentUpdateId = this._currentRefreshId;
  54056. return this._contentData;
  54057. };
  54058. ProceduralTexture.prototype._createIndexBuffer = function () {
  54059. var engine = this._engine;
  54060. // Indices
  54061. var indices = [];
  54062. indices.push(0);
  54063. indices.push(1);
  54064. indices.push(2);
  54065. indices.push(0);
  54066. indices.push(2);
  54067. indices.push(3);
  54068. this._indexBuffer = engine.createIndexBuffer(indices);
  54069. };
  54070. /** @hidden */
  54071. ProceduralTexture.prototype._rebuild = function () {
  54072. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  54073. if (vb) {
  54074. vb._rebuild();
  54075. }
  54076. this._createIndexBuffer();
  54077. if (this.refreshRate === _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE) {
  54078. this.refreshRate = _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE;
  54079. }
  54080. };
  54081. /**
  54082. * Resets the texture in order to recreate its associated resources.
  54083. * This can be called in case of context loss
  54084. */
  54085. ProceduralTexture.prototype.reset = function () {
  54086. if (this._effect === undefined) {
  54087. return;
  54088. }
  54089. var engine = this._engine;
  54090. engine._releaseEffect(this._effect);
  54091. };
  54092. ProceduralTexture.prototype._getDefines = function () {
  54093. return "";
  54094. };
  54095. /**
  54096. * Is the texture ready to be used ? (rendered at least once)
  54097. * @returns true if ready, otherwise, false.
  54098. */
  54099. ProceduralTexture.prototype.isReady = function () {
  54100. var _this = this;
  54101. var engine = this._engine;
  54102. var shaders;
  54103. if (!this._fragment) {
  54104. return false;
  54105. }
  54106. if (this._fallbackTextureUsed) {
  54107. return true;
  54108. }
  54109. var defines = this._getDefines();
  54110. if (this._effect && defines === this._cachedDefines && this._effect.isReady()) {
  54111. return true;
  54112. }
  54113. if (this._fragment.fragmentElement !== undefined) {
  54114. shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
  54115. }
  54116. else {
  54117. shaders = { vertex: "procedural", fragment: this._fragment };
  54118. }
  54119. this._cachedDefines = defines;
  54120. this._effect = engine.createEffect(shaders, [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, function () {
  54121. _this.releaseInternalTexture();
  54122. if (_this._fallbackTexture) {
  54123. _this._texture = _this._fallbackTexture._texture;
  54124. if (_this._texture) {
  54125. _this._texture.incrementReferences();
  54126. }
  54127. }
  54128. _this._fallbackTextureUsed = true;
  54129. });
  54130. return this._effect.isReady();
  54131. };
  54132. /**
  54133. * Resets the refresh counter of the texture and start bak from scratch.
  54134. * Could be useful to regenerate the texture if it is setup to render only once.
  54135. */
  54136. ProceduralTexture.prototype.resetRefreshCounter = function () {
  54137. this._currentRefreshId = -1;
  54138. };
  54139. /**
  54140. * Set the fragment shader to use in order to render the texture.
  54141. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  54142. */
  54143. ProceduralTexture.prototype.setFragment = function (fragment) {
  54144. this._fragment = fragment;
  54145. };
  54146. Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
  54147. /**
  54148. * Define the refresh rate of the texture or the rendering frequency.
  54149. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  54150. */
  54151. get: function () {
  54152. return this._refreshRate;
  54153. },
  54154. set: function (value) {
  54155. this._refreshRate = value;
  54156. this.resetRefreshCounter();
  54157. },
  54158. enumerable: true,
  54159. configurable: true
  54160. });
  54161. /** @hidden */
  54162. ProceduralTexture.prototype._shouldRender = function () {
  54163. if (!this.isEnabled || !this.isReady() || !this._texture) {
  54164. if (this._texture) {
  54165. this._texture.isReady = false;
  54166. }
  54167. return false;
  54168. }
  54169. if (this._fallbackTextureUsed) {
  54170. return false;
  54171. }
  54172. if (this._currentRefreshId === -1) { // At least render once
  54173. this._currentRefreshId = 1;
  54174. return true;
  54175. }
  54176. if (this.refreshRate === this._currentRefreshId) {
  54177. this._currentRefreshId = 1;
  54178. return true;
  54179. }
  54180. this._currentRefreshId++;
  54181. return false;
  54182. };
  54183. /**
  54184. * Get the size the texture is rendering at.
  54185. * @returns the size (texture is always squared)
  54186. */
  54187. ProceduralTexture.prototype.getRenderSize = function () {
  54188. return this._size;
  54189. };
  54190. /**
  54191. * Resize the texture to new value.
  54192. * @param size Define the new size the texture should have
  54193. * @param generateMipMaps Define whether the new texture should create mip maps
  54194. */
  54195. ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  54196. if (this._fallbackTextureUsed) {
  54197. return;
  54198. }
  54199. this.releaseInternalTexture();
  54200. this._texture = this._engine.createRenderTargetTexture(size, generateMipMaps);
  54201. // Update properties
  54202. this._size = size;
  54203. this._generateMipMaps = generateMipMaps;
  54204. };
  54205. ProceduralTexture.prototype._checkUniform = function (uniformName) {
  54206. if (this._uniforms.indexOf(uniformName) === -1) {
  54207. this._uniforms.push(uniformName);
  54208. }
  54209. };
  54210. /**
  54211. * Set a texture in the shader program used to render.
  54212. * @param name Define the name of the uniform samplers as defined in the shader
  54213. * @param texture Define the texture to bind to this sampler
  54214. * @return the texture itself allowing "fluent" like uniform updates
  54215. */
  54216. ProceduralTexture.prototype.setTexture = function (name, texture) {
  54217. if (this._samplers.indexOf(name) === -1) {
  54218. this._samplers.push(name);
  54219. }
  54220. this._textures[name] = texture;
  54221. return this;
  54222. };
  54223. /**
  54224. * Set a float in the shader.
  54225. * @param name Define the name of the uniform as defined in the shader
  54226. * @param value Define the value to give to the uniform
  54227. * @return the texture itself allowing "fluent" like uniform updates
  54228. */
  54229. ProceduralTexture.prototype.setFloat = function (name, value) {
  54230. this._checkUniform(name);
  54231. this._floats[name] = value;
  54232. return this;
  54233. };
  54234. /**
  54235. * Set a int in the shader.
  54236. * @param name Define the name of the uniform as defined in the shader
  54237. * @param value Define the value to give to the uniform
  54238. * @return the texture itself allowing "fluent" like uniform updates
  54239. */
  54240. ProceduralTexture.prototype.setInt = function (name, value) {
  54241. this._checkUniform(name);
  54242. this._ints[name] = value;
  54243. return this;
  54244. };
  54245. /**
  54246. * Set an array of floats in the shader.
  54247. * @param name Define the name of the uniform as defined in the shader
  54248. * @param value Define the value to give to the uniform
  54249. * @return the texture itself allowing "fluent" like uniform updates
  54250. */
  54251. ProceduralTexture.prototype.setFloats = function (name, value) {
  54252. this._checkUniform(name);
  54253. this._floatsArrays[name] = value;
  54254. return this;
  54255. };
  54256. /**
  54257. * Set a vec3 in the shader from a Color3.
  54258. * @param name Define the name of the uniform as defined in the shader
  54259. * @param value Define the value to give to the uniform
  54260. * @return the texture itself allowing "fluent" like uniform updates
  54261. */
  54262. ProceduralTexture.prototype.setColor3 = function (name, value) {
  54263. this._checkUniform(name);
  54264. this._colors3[name] = value;
  54265. return this;
  54266. };
  54267. /**
  54268. * Set a vec4 in the shader from a Color4.
  54269. * @param name Define the name of the uniform as defined in the shader
  54270. * @param value Define the value to give to the uniform
  54271. * @return the texture itself allowing "fluent" like uniform updates
  54272. */
  54273. ProceduralTexture.prototype.setColor4 = function (name, value) {
  54274. this._checkUniform(name);
  54275. this._colors4[name] = value;
  54276. return this;
  54277. };
  54278. /**
  54279. * Set a vec2 in the shader from a Vector2.
  54280. * @param name Define the name of the uniform as defined in the shader
  54281. * @param value Define the value to give to the uniform
  54282. * @return the texture itself allowing "fluent" like uniform updates
  54283. */
  54284. ProceduralTexture.prototype.setVector2 = function (name, value) {
  54285. this._checkUniform(name);
  54286. this._vectors2[name] = value;
  54287. return this;
  54288. };
  54289. /**
  54290. * Set a vec3 in the shader from a Vector3.
  54291. * @param name Define the name of the uniform as defined in the shader
  54292. * @param value Define the value to give to the uniform
  54293. * @return the texture itself allowing "fluent" like uniform updates
  54294. */
  54295. ProceduralTexture.prototype.setVector3 = function (name, value) {
  54296. this._checkUniform(name);
  54297. this._vectors3[name] = value;
  54298. return this;
  54299. };
  54300. /**
  54301. * Set a mat4 in the shader from a MAtrix.
  54302. * @param name Define the name of the uniform as defined in the shader
  54303. * @param value Define the value to give to the uniform
  54304. * @return the texture itself allowing "fluent" like uniform updates
  54305. */
  54306. ProceduralTexture.prototype.setMatrix = function (name, value) {
  54307. this._checkUniform(name);
  54308. this._matrices[name] = value;
  54309. return this;
  54310. };
  54311. /**
  54312. * Render the texture to its associated render target.
  54313. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54314. */
  54315. ProceduralTexture.prototype.render = function (useCameraPostProcess) {
  54316. var scene = this.getScene();
  54317. if (!scene) {
  54318. return;
  54319. }
  54320. var engine = this._engine;
  54321. // Render
  54322. engine.enableEffect(this._effect);
  54323. engine.setState(false);
  54324. // Texture
  54325. for (var name in this._textures) {
  54326. this._effect.setTexture(name, this._textures[name]);
  54327. }
  54328. // Float
  54329. for (name in this._ints) {
  54330. this._effect.setInt(name, this._ints[name]);
  54331. }
  54332. // Float
  54333. for (name in this._floats) {
  54334. this._effect.setFloat(name, this._floats[name]);
  54335. }
  54336. // Floats
  54337. for (name in this._floatsArrays) {
  54338. this._effect.setArray(name, this._floatsArrays[name]);
  54339. }
  54340. // Color3
  54341. for (name in this._colors3) {
  54342. this._effect.setColor3(name, this._colors3[name]);
  54343. }
  54344. // Color4
  54345. for (name in this._colors4) {
  54346. var color = this._colors4[name];
  54347. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  54348. }
  54349. // Vector2
  54350. for (name in this._vectors2) {
  54351. this._effect.setVector2(name, this._vectors2[name]);
  54352. }
  54353. // Vector3
  54354. for (name in this._vectors3) {
  54355. this._effect.setVector3(name, this._vectors3[name]);
  54356. }
  54357. // Matrix
  54358. for (name in this._matrices) {
  54359. this._effect.setMatrix(name, this._matrices[name]);
  54360. }
  54361. if (!this._texture) {
  54362. return;
  54363. }
  54364. if (this.isCube) {
  54365. for (var face = 0; face < 6; face++) {
  54366. engine.bindFramebuffer(this._texture, face, undefined, undefined, true);
  54367. // VBOs
  54368. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  54369. this._effect.setFloat("face", face);
  54370. // Clear
  54371. if (this.autoClear) {
  54372. engine.clear(scene.clearColor, true, false, false);
  54373. }
  54374. // Draw order
  54375. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  54376. // Mipmaps
  54377. if (face === 5) {
  54378. engine.generateMipMapsForCubemap(this._texture);
  54379. }
  54380. }
  54381. }
  54382. else {
  54383. engine.bindFramebuffer(this._texture, 0, undefined, undefined, true);
  54384. // VBOs
  54385. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  54386. // Clear
  54387. if (this.autoClear) {
  54388. engine.clear(scene.clearColor, true, false, false);
  54389. }
  54390. // Draw order
  54391. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  54392. }
  54393. // Unbind
  54394. engine.unBindFramebuffer(this._texture, this.isCube);
  54395. if (this.onGenerated) {
  54396. this.onGenerated();
  54397. }
  54398. this.onGeneratedObservable.notifyObservers(this);
  54399. };
  54400. /**
  54401. * Clone the texture.
  54402. * @returns the cloned texture
  54403. */
  54404. ProceduralTexture.prototype.clone = function () {
  54405. var textureSize = this.getSize();
  54406. var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
  54407. // Base texture
  54408. newTexture.hasAlpha = this.hasAlpha;
  54409. newTexture.level = this.level;
  54410. // RenderTarget Texture
  54411. newTexture.coordinatesMode = this.coordinatesMode;
  54412. return newTexture;
  54413. };
  54414. /**
  54415. * Dispose the texture and release its asoociated resources.
  54416. */
  54417. ProceduralTexture.prototype.dispose = function () {
  54418. var scene = this.getScene();
  54419. if (!scene) {
  54420. return;
  54421. }
  54422. var index = scene.proceduralTextures.indexOf(this);
  54423. if (index >= 0) {
  54424. scene.proceduralTextures.splice(index, 1);
  54425. }
  54426. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  54427. if (vertexBuffer) {
  54428. vertexBuffer.dispose();
  54429. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  54430. }
  54431. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  54432. this._indexBuffer = null;
  54433. }
  54434. _super.prototype.dispose.call(this);
  54435. };
  54436. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54437. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54438. ], ProceduralTexture.prototype, "isEnabled", void 0);
  54439. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54440. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54441. ], ProceduralTexture.prototype, "autoClear", void 0);
  54442. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54443. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54444. ], ProceduralTexture.prototype, "_generateMipMaps", void 0);
  54445. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54446. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54447. ], ProceduralTexture.prototype, "_size", void 0);
  54448. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54449. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54450. ], ProceduralTexture.prototype, "refreshRate", null);
  54451. return ProceduralTexture;
  54452. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"]));
  54453. /***/ }),
  54454. /***/ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts":
  54455. /*!***************************************************************************!*\
  54456. !*** ./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts ***!
  54457. \***************************************************************************/
  54458. /*! exports provided: ProceduralTextureSceneComponent */
  54459. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54460. "use strict";
  54461. __webpack_require__.r(__webpack_exports__);
  54462. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return ProceduralTextureSceneComponent; });
  54463. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  54464. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  54465. /**
  54466. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  54467. * in a given scene.
  54468. */
  54469. var ProceduralTextureSceneComponent = /** @class */ (function () {
  54470. /**
  54471. * Creates a new instance of the component for the given scene
  54472. * @param scene Defines the scene to register the component in
  54473. */
  54474. function ProceduralTextureSceneComponent(scene) {
  54475. /**
  54476. * The component name helpfull to identify the component in the list of scene components.
  54477. */
  54478. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE;
  54479. this.scene = scene;
  54480. this.scene.proceduralTextures = new Array();
  54481. scene.layers = new Array();
  54482. }
  54483. /**
  54484. * Registers the component in a given scene
  54485. */
  54486. ProceduralTextureSceneComponent.prototype.register = function () {
  54487. this.scene._beforeClearStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
  54488. };
  54489. /**
  54490. * Rebuilds the elements related to this component in case of
  54491. * context lost for instance.
  54492. */
  54493. ProceduralTextureSceneComponent.prototype.rebuild = function () {
  54494. // Nothing to do here.
  54495. };
  54496. /**
  54497. * Disposes the component and the associated ressources.
  54498. */
  54499. ProceduralTextureSceneComponent.prototype.dispose = function () {
  54500. // Nothing to do here.
  54501. };
  54502. ProceduralTextureSceneComponent.prototype._beforeClear = function () {
  54503. if (this.scene.proceduralTexturesEnabled) {
  54504. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  54505. for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
  54506. var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
  54507. if (proceduralTexture._shouldRender()) {
  54508. proceduralTexture.render();
  54509. }
  54510. }
  54511. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  54512. }
  54513. };
  54514. return ProceduralTextureSceneComponent;
  54515. }());
  54516. /***/ }),
  54517. /***/ "./Materials/Textures/baseTexture.ts":
  54518. /*!*******************************************!*\
  54519. !*** ./Materials/Textures/baseTexture.ts ***!
  54520. \*******************************************/
  54521. /*! exports provided: BaseTexture */
  54522. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54523. "use strict";
  54524. __webpack_require__.r(__webpack_exports__);
  54525. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return BaseTexture; });
  54526. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54527. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54528. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  54529. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  54530. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  54531. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54532. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  54533. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  54534. /**
  54535. * Base class of all the textures in babylon.
  54536. * It groups all the common properties the materials, post process, lights... might need
  54537. * in order to make a correct use of the texture.
  54538. */
  54539. var BaseTexture = /** @class */ (function () {
  54540. /**
  54541. * Instantiates a new BaseTexture.
  54542. * Base class of all the textures in babylon.
  54543. * It groups all the common properties the materials, post process, lights... might need
  54544. * in order to make a correct use of the texture.
  54545. * @param scene Define the scene the texture blongs to
  54546. */
  54547. function BaseTexture(scene) {
  54548. /**
  54549. * Gets or sets an object used to store user defined information.
  54550. */
  54551. this.metadata = null;
  54552. /**
  54553. * For internal use only. Please do not use.
  54554. */
  54555. this.reservedDataStore = null;
  54556. this._hasAlpha = false;
  54557. /**
  54558. * Defines if the alpha value should be determined via the rgb values.
  54559. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  54560. */
  54561. this.getAlphaFromRGB = false;
  54562. /**
  54563. * Intensity or strength of the texture.
  54564. * It is commonly used by materials to fine tune the intensity of the texture
  54565. */
  54566. this.level = 1;
  54567. /**
  54568. * Define the UV chanel to use starting from 0 and defaulting to 0.
  54569. * This is part of the texture as textures usually maps to one uv set.
  54570. */
  54571. this.coordinatesIndex = 0;
  54572. this._coordinatesMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EXPLICIT_MODE;
  54573. /**
  54574. * | Value | Type | Description |
  54575. * | ----- | ------------------ | ----------- |
  54576. * | 0 | CLAMP_ADDRESSMODE | |
  54577. * | 1 | WRAP_ADDRESSMODE | |
  54578. * | 2 | MIRROR_ADDRESSMODE | |
  54579. */
  54580. this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  54581. /**
  54582. * | Value | Type | Description |
  54583. * | ----- | ------------------ | ----------- |
  54584. * | 0 | CLAMP_ADDRESSMODE | |
  54585. * | 1 | WRAP_ADDRESSMODE | |
  54586. * | 2 | MIRROR_ADDRESSMODE | |
  54587. */
  54588. this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  54589. /**
  54590. * | Value | Type | Description |
  54591. * | ----- | ------------------ | ----------- |
  54592. * | 0 | CLAMP_ADDRESSMODE | |
  54593. * | 1 | WRAP_ADDRESSMODE | |
  54594. * | 2 | MIRROR_ADDRESSMODE | |
  54595. */
  54596. this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  54597. /**
  54598. * With compliant hardware and browser (supporting anisotropic filtering)
  54599. * this defines the level of anisotropic filtering in the texture.
  54600. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  54601. */
  54602. this.anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;
  54603. /**
  54604. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  54605. * HDR texture are usually stored in linear space.
  54606. * This only impacts the PBR and Background materials
  54607. */
  54608. this.gammaSpace = true;
  54609. /**
  54610. * Is Z inverted in the texture (useful in a cube texture).
  54611. */
  54612. this.invertZ = false;
  54613. /**
  54614. * @hidden
  54615. */
  54616. this.lodLevelInAlpha = false;
  54617. /**
  54618. * Define if the texture is a render target.
  54619. */
  54620. this.isRenderTarget = false;
  54621. /**
  54622. * Define the list of animation attached to the texture.
  54623. */
  54624. this.animations = new Array();
  54625. /**
  54626. * An event triggered when the texture is disposed.
  54627. */
  54628. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  54629. /**
  54630. * Define the current state of the loading sequence when in delayed load mode.
  54631. */
  54632. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  54633. this._cachedSize = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  54634. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  54635. if (this._scene) {
  54636. this.uniqueId = this._scene.getUniqueId();
  54637. this._scene.addTexture(this);
  54638. }
  54639. this._uid = null;
  54640. }
  54641. Object.defineProperty(BaseTexture.prototype, "hasAlpha", {
  54642. get: function () {
  54643. return this._hasAlpha;
  54644. },
  54645. /**
  54646. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  54647. */
  54648. set: function (value) {
  54649. if (this._hasAlpha === value) {
  54650. return;
  54651. }
  54652. this._hasAlpha = value;
  54653. if (this._scene) {
  54654. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_MiscDirtyFlag);
  54655. }
  54656. },
  54657. enumerable: true,
  54658. configurable: true
  54659. });
  54660. Object.defineProperty(BaseTexture.prototype, "coordinatesMode", {
  54661. get: function () {
  54662. return this._coordinatesMode;
  54663. },
  54664. /**
  54665. * How a texture is mapped.
  54666. *
  54667. * | Value | Type | Description |
  54668. * | ----- | ----------------------------------- | ----------- |
  54669. * | 0 | EXPLICIT_MODE | |
  54670. * | 1 | SPHERICAL_MODE | |
  54671. * | 2 | PLANAR_MODE | |
  54672. * | 3 | CUBIC_MODE | |
  54673. * | 4 | PROJECTION_MODE | |
  54674. * | 5 | SKYBOX_MODE | |
  54675. * | 6 | INVCUBIC_MODE | |
  54676. * | 7 | EQUIRECTANGULAR_MODE | |
  54677. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  54678. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  54679. */
  54680. set: function (value) {
  54681. if (this._coordinatesMode === value) {
  54682. return;
  54683. }
  54684. this._coordinatesMode = value;
  54685. if (this._scene) {
  54686. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  54687. }
  54688. },
  54689. enumerable: true,
  54690. configurable: true
  54691. });
  54692. Object.defineProperty(BaseTexture.prototype, "isCube", {
  54693. /**
  54694. * Define if the texture is a cube texture or if false a 2d texture.
  54695. */
  54696. get: function () {
  54697. if (!this._texture) {
  54698. return false;
  54699. }
  54700. return this._texture.isCube;
  54701. },
  54702. set: function (value) {
  54703. if (!this._texture) {
  54704. return;
  54705. }
  54706. this._texture.isCube = value;
  54707. },
  54708. enumerable: true,
  54709. configurable: true
  54710. });
  54711. Object.defineProperty(BaseTexture.prototype, "is3D", {
  54712. /**
  54713. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  54714. */
  54715. get: function () {
  54716. if (!this._texture) {
  54717. return false;
  54718. }
  54719. return this._texture.is3D;
  54720. },
  54721. set: function (value) {
  54722. if (!this._texture) {
  54723. return;
  54724. }
  54725. this._texture.is3D = value;
  54726. },
  54727. enumerable: true,
  54728. configurable: true
  54729. });
  54730. Object.defineProperty(BaseTexture.prototype, "isRGBD", {
  54731. /**
  54732. * Gets whether or not the texture contains RGBD data.
  54733. */
  54734. get: function () {
  54735. return this._texture != null && this._texture._isRGBD;
  54736. },
  54737. enumerable: true,
  54738. configurable: true
  54739. });
  54740. Object.defineProperty(BaseTexture.prototype, "noMipmap", {
  54741. /**
  54742. * Are mip maps generated for this texture or not.
  54743. */
  54744. get: function () {
  54745. return false;
  54746. },
  54747. enumerable: true,
  54748. configurable: true
  54749. });
  54750. Object.defineProperty(BaseTexture.prototype, "lodGenerationOffset", {
  54751. /**
  54752. * With prefiltered texture, defined the offset used during the prefiltering steps.
  54753. */
  54754. get: function () {
  54755. if (this._texture) {
  54756. return this._texture._lodGenerationOffset;
  54757. }
  54758. return 0.0;
  54759. },
  54760. set: function (value) {
  54761. if (this._texture) {
  54762. this._texture._lodGenerationOffset = value;
  54763. }
  54764. },
  54765. enumerable: true,
  54766. configurable: true
  54767. });
  54768. Object.defineProperty(BaseTexture.prototype, "lodGenerationScale", {
  54769. /**
  54770. * With prefiltered texture, defined the scale used during the prefiltering steps.
  54771. */
  54772. get: function () {
  54773. if (this._texture) {
  54774. return this._texture._lodGenerationScale;
  54775. }
  54776. return 0.0;
  54777. },
  54778. set: function (value) {
  54779. if (this._texture) {
  54780. this._texture._lodGenerationScale = value;
  54781. }
  54782. },
  54783. enumerable: true,
  54784. configurable: true
  54785. });
  54786. Object.defineProperty(BaseTexture.prototype, "uid", {
  54787. /**
  54788. * Define the unique id of the texture in the scene.
  54789. */
  54790. get: function () {
  54791. if (!this._uid) {
  54792. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].RandomId();
  54793. }
  54794. return this._uid;
  54795. },
  54796. enumerable: true,
  54797. configurable: true
  54798. });
  54799. /**
  54800. * Return a string representation of the texture.
  54801. * @returns the texture as a string
  54802. */
  54803. BaseTexture.prototype.toString = function () {
  54804. return this.name;
  54805. };
  54806. /**
  54807. * Get the class name of the texture.
  54808. * @returns "BaseTexture"
  54809. */
  54810. BaseTexture.prototype.getClassName = function () {
  54811. return "BaseTexture";
  54812. };
  54813. Object.defineProperty(BaseTexture.prototype, "onDispose", {
  54814. /**
  54815. * Callback triggered when the texture has been disposed.
  54816. * Kept for back compatibility, you can use the onDisposeObservable instead.
  54817. */
  54818. set: function (callback) {
  54819. if (this._onDisposeObserver) {
  54820. this.onDisposeObservable.remove(this._onDisposeObserver);
  54821. }
  54822. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  54823. },
  54824. enumerable: true,
  54825. configurable: true
  54826. });
  54827. Object.defineProperty(BaseTexture.prototype, "isBlocking", {
  54828. /**
  54829. * Define if the texture is preventinga material to render or not.
  54830. * If not and the texture is not ready, the engine will use a default black texture instead.
  54831. */
  54832. get: function () {
  54833. return true;
  54834. },
  54835. enumerable: true,
  54836. configurable: true
  54837. });
  54838. /**
  54839. * Get the scene the texture belongs to.
  54840. * @returns the scene or null if undefined
  54841. */
  54842. BaseTexture.prototype.getScene = function () {
  54843. return this._scene;
  54844. };
  54845. /**
  54846. * Get the texture transform matrix used to offset tile the texture for istance.
  54847. * @returns the transformation matrix
  54848. */
  54849. BaseTexture.prototype.getTextureMatrix = function () {
  54850. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  54851. };
  54852. /**
  54853. * Get the texture reflection matrix used to rotate/transform the reflection.
  54854. * @returns the reflection matrix
  54855. */
  54856. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  54857. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  54858. };
  54859. /**
  54860. * Get the underlying lower level texture from Babylon.
  54861. * @returns the insternal texture
  54862. */
  54863. BaseTexture.prototype.getInternalTexture = function () {
  54864. return this._texture;
  54865. };
  54866. /**
  54867. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  54868. * @returns true if ready or not blocking
  54869. */
  54870. BaseTexture.prototype.isReadyOrNotBlocking = function () {
  54871. return !this.isBlocking || this.isReady();
  54872. };
  54873. /**
  54874. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  54875. * @returns true if fully ready
  54876. */
  54877. BaseTexture.prototype.isReady = function () {
  54878. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  54879. this.delayLoad();
  54880. return false;
  54881. }
  54882. if (this._texture) {
  54883. return this._texture.isReady;
  54884. }
  54885. return false;
  54886. };
  54887. /**
  54888. * Get the size of the texture.
  54889. * @returns the texture size.
  54890. */
  54891. BaseTexture.prototype.getSize = function () {
  54892. if (this._texture) {
  54893. if (this._texture.width) {
  54894. this._cachedSize.width = this._texture.width;
  54895. this._cachedSize.height = this._texture.height;
  54896. return this._cachedSize;
  54897. }
  54898. if (this._texture._size) {
  54899. this._cachedSize.width = this._texture._size;
  54900. this._cachedSize.height = this._texture._size;
  54901. return this._cachedSize;
  54902. }
  54903. }
  54904. return this._cachedSize;
  54905. };
  54906. /**
  54907. * Get the base size of the texture.
  54908. * It can be different from the size if the texture has been resized for POT for instance
  54909. * @returns the base size
  54910. */
  54911. BaseTexture.prototype.getBaseSize = function () {
  54912. if (!this.isReady() || !this._texture) {
  54913. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  54914. }
  54915. if (this._texture._size) {
  54916. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture._size, this._texture._size);
  54917. }
  54918. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture.baseWidth, this._texture.baseHeight);
  54919. };
  54920. /**
  54921. * Update the sampling mode of the texture.
  54922. * Default is Trilinear mode.
  54923. *
  54924. * | Value | Type | Description |
  54925. * | ----- | ------------------ | ----------- |
  54926. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  54927. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  54928. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  54929. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  54930. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  54931. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  54932. * | 7 | NEAREST_LINEAR | |
  54933. * | 8 | NEAREST_NEAREST | |
  54934. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  54935. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  54936. * | 11 | LINEAR_LINEAR | |
  54937. * | 12 | LINEAR_NEAREST | |
  54938. *
  54939. * > _mag_: magnification filter (close to the viewer)
  54940. * > _min_: minification filter (far from the viewer)
  54941. * > _mip_: filter used between mip map levels
  54942. *@param samplingMode Define the new sampling mode of the texture
  54943. */
  54944. BaseTexture.prototype.updateSamplingMode = function (samplingMode) {
  54945. if (!this._texture) {
  54946. return;
  54947. }
  54948. var scene = this.getScene();
  54949. if (!scene) {
  54950. return;
  54951. }
  54952. scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
  54953. };
  54954. /**
  54955. * Scales the texture if is `canRescale()`
  54956. * @param ratio the resize factor we want to use to rescale
  54957. */
  54958. BaseTexture.prototype.scale = function (ratio) {
  54959. };
  54960. Object.defineProperty(BaseTexture.prototype, "canRescale", {
  54961. /**
  54962. * Get if the texture can rescale.
  54963. */
  54964. get: function () {
  54965. return false;
  54966. },
  54967. enumerable: true,
  54968. configurable: true
  54969. });
  54970. /** @hidden */
  54971. BaseTexture.prototype._getFromCache = function (url, noMipmap, sampling) {
  54972. if (!this._scene) {
  54973. return null;
  54974. }
  54975. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  54976. for (var index = 0; index < texturesCache.length; index++) {
  54977. var texturesCacheEntry = texturesCache[index];
  54978. if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
  54979. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  54980. texturesCacheEntry.incrementReferences();
  54981. return texturesCacheEntry;
  54982. }
  54983. }
  54984. }
  54985. return null;
  54986. };
  54987. /** @hidden */
  54988. BaseTexture.prototype._rebuild = function () {
  54989. };
  54990. /**
  54991. * Triggers the load sequence in delayed load mode.
  54992. */
  54993. BaseTexture.prototype.delayLoad = function () {
  54994. };
  54995. /**
  54996. * Clones the texture.
  54997. * @returns the cloned texture
  54998. */
  54999. BaseTexture.prototype.clone = function () {
  55000. return null;
  55001. };
  55002. Object.defineProperty(BaseTexture.prototype, "textureType", {
  55003. /**
  55004. * Get the texture underlying type (INT, FLOAT...)
  55005. */
  55006. get: function () {
  55007. if (!this._texture) {
  55008. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  55009. }
  55010. return (this._texture.type !== undefined) ? this._texture.type : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  55011. },
  55012. enumerable: true,
  55013. configurable: true
  55014. });
  55015. Object.defineProperty(BaseTexture.prototype, "textureFormat", {
  55016. /**
  55017. * Get the texture underlying format (RGB, RGBA...)
  55018. */
  55019. get: function () {
  55020. if (!this._texture) {
  55021. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  55022. }
  55023. return (this._texture.format !== undefined) ? this._texture.format : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  55024. },
  55025. enumerable: true,
  55026. configurable: true
  55027. });
  55028. /**
  55029. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  55030. * This will returns an RGBA array buffer containing either in values (0-255) or
  55031. * float values (0-1) depending of the underlying buffer type.
  55032. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  55033. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  55034. * @param buffer defines a user defined buffer to fill with data (can be null)
  55035. * @returns The Array buffer containing the pixels data.
  55036. */
  55037. BaseTexture.prototype.readPixels = function (faceIndex, level, buffer) {
  55038. if (faceIndex === void 0) { faceIndex = 0; }
  55039. if (level === void 0) { level = 0; }
  55040. if (buffer === void 0) { buffer = null; }
  55041. if (!this._texture) {
  55042. return null;
  55043. }
  55044. var size = this.getSize();
  55045. var width = size.width;
  55046. var height = size.height;
  55047. var scene = this.getScene();
  55048. if (!scene) {
  55049. return null;
  55050. }
  55051. var engine = scene.getEngine();
  55052. if (level != 0) {
  55053. width = width / Math.pow(2, level);
  55054. height = height / Math.pow(2, level);
  55055. width = Math.round(width);
  55056. height = Math.round(height);
  55057. }
  55058. if (this._texture.isCube) {
  55059. return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer);
  55060. }
  55061. return engine._readTexturePixels(this._texture, width, height, -1, level, buffer);
  55062. };
  55063. /**
  55064. * Release and destroy the underlying lower level texture aka internalTexture.
  55065. */
  55066. BaseTexture.prototype.releaseInternalTexture = function () {
  55067. if (this._texture) {
  55068. this._texture.dispose();
  55069. this._texture = null;
  55070. }
  55071. };
  55072. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  55073. /**
  55074. * Get the polynomial representation of the texture data.
  55075. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  55076. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  55077. */
  55078. get: function () {
  55079. if (!this._texture || !_Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"] || !this.isReady()) {
  55080. return null;
  55081. }
  55082. if (!this._texture._sphericalPolynomial) {
  55083. this._texture._sphericalPolynomial =
  55084. _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapTextureToSphericalPolynomial(this);
  55085. }
  55086. return this._texture._sphericalPolynomial;
  55087. },
  55088. set: function (value) {
  55089. if (this._texture) {
  55090. this._texture._sphericalPolynomial = value;
  55091. }
  55092. },
  55093. enumerable: true,
  55094. configurable: true
  55095. });
  55096. Object.defineProperty(BaseTexture.prototype, "_lodTextureHigh", {
  55097. /** @hidden */
  55098. get: function () {
  55099. if (this._texture) {
  55100. return this._texture._lodTextureHigh;
  55101. }
  55102. return null;
  55103. },
  55104. enumerable: true,
  55105. configurable: true
  55106. });
  55107. Object.defineProperty(BaseTexture.prototype, "_lodTextureMid", {
  55108. /** @hidden */
  55109. get: function () {
  55110. if (this._texture) {
  55111. return this._texture._lodTextureMid;
  55112. }
  55113. return null;
  55114. },
  55115. enumerable: true,
  55116. configurable: true
  55117. });
  55118. Object.defineProperty(BaseTexture.prototype, "_lodTextureLow", {
  55119. /** @hidden */
  55120. get: function () {
  55121. if (this._texture) {
  55122. return this._texture._lodTextureLow;
  55123. }
  55124. return null;
  55125. },
  55126. enumerable: true,
  55127. configurable: true
  55128. });
  55129. /**
  55130. * Dispose the texture and release its associated resources.
  55131. */
  55132. BaseTexture.prototype.dispose = function () {
  55133. if (!this._scene) {
  55134. return;
  55135. }
  55136. // Animations
  55137. this._scene.stopAnimation(this);
  55138. // Remove from scene
  55139. this._scene._removePendingData(this);
  55140. var index = this._scene.textures.indexOf(this);
  55141. if (index >= 0) {
  55142. this._scene.textures.splice(index, 1);
  55143. }
  55144. this._scene.onTextureRemovedObservable.notifyObservers(this);
  55145. if (this._texture === undefined) {
  55146. return;
  55147. }
  55148. // Release
  55149. this.releaseInternalTexture();
  55150. // Callback
  55151. this.onDisposeObservable.notifyObservers(this);
  55152. this.onDisposeObservable.clear();
  55153. };
  55154. /**
  55155. * Serialize the texture into a JSON representation that can be parsed later on.
  55156. * @returns the JSON representation of the texture
  55157. */
  55158. BaseTexture.prototype.serialize = function () {
  55159. if (!this.name) {
  55160. return null;
  55161. }
  55162. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55163. // Animations
  55164. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  55165. return serializationObject;
  55166. };
  55167. /**
  55168. * Helper function to be called back once a list of texture contains only ready textures.
  55169. * @param textures Define the list of textures to wait for
  55170. * @param callback Define the callback triggered once the entire list will be ready
  55171. */
  55172. BaseTexture.WhenAllReady = function (textures, callback) {
  55173. var numRemaining = textures.length;
  55174. if (numRemaining === 0) {
  55175. callback();
  55176. return;
  55177. }
  55178. var _loop_1 = function () {
  55179. texture = textures[i];
  55180. if (texture.isReady()) {
  55181. if (--numRemaining === 0) {
  55182. callback();
  55183. }
  55184. }
  55185. else {
  55186. onLoadObservable = texture.onLoadObservable;
  55187. var onLoadCallback_1 = function () {
  55188. onLoadObservable.removeCallback(onLoadCallback_1);
  55189. if (--numRemaining === 0) {
  55190. callback();
  55191. }
  55192. };
  55193. onLoadObservable.add(onLoadCallback_1);
  55194. }
  55195. };
  55196. var texture, onLoadObservable;
  55197. for (var i = 0; i < textures.length; i++) {
  55198. _loop_1();
  55199. }
  55200. };
  55201. /**
  55202. * Default anisotropic filtering level for the application.
  55203. * It is set to 4 as a good tradeoff between perf and quality.
  55204. */
  55205. BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;
  55206. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55207. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55208. ], BaseTexture.prototype, "uniqueId", void 0);
  55209. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55210. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55211. ], BaseTexture.prototype, "name", void 0);
  55212. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55213. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55214. ], BaseTexture.prototype, "metadata", void 0);
  55215. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("hasAlpha")
  55217. ], BaseTexture.prototype, "_hasAlpha", void 0);
  55218. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55219. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55220. ], BaseTexture.prototype, "getAlphaFromRGB", void 0);
  55221. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55222. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55223. ], BaseTexture.prototype, "level", void 0);
  55224. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55225. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55226. ], BaseTexture.prototype, "coordinatesIndex", void 0);
  55227. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55228. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("coordinatesMode")
  55229. ], BaseTexture.prototype, "_coordinatesMode", void 0);
  55230. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55231. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55232. ], BaseTexture.prototype, "wrapU", void 0);
  55233. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55234. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55235. ], BaseTexture.prototype, "wrapV", void 0);
  55236. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55238. ], BaseTexture.prototype, "wrapR", void 0);
  55239. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55240. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55241. ], BaseTexture.prototype, "anisotropicFilteringLevel", void 0);
  55242. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55243. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55244. ], BaseTexture.prototype, "isCube", null);
  55245. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55246. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55247. ], BaseTexture.prototype, "is3D", null);
  55248. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55249. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55250. ], BaseTexture.prototype, "gammaSpace", void 0);
  55251. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55252. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55253. ], BaseTexture.prototype, "invertZ", void 0);
  55254. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55255. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55256. ], BaseTexture.prototype, "lodLevelInAlpha", void 0);
  55257. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55258. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55259. ], BaseTexture.prototype, "lodGenerationOffset", null);
  55260. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55261. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55262. ], BaseTexture.prototype, "lodGenerationScale", null);
  55263. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55264. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55265. ], BaseTexture.prototype, "isRenderTarget", void 0);
  55266. return BaseTexture;
  55267. }());
  55268. /***/ }),
  55269. /***/ "./Materials/Textures/colorGradingTexture.ts":
  55270. /*!***************************************************!*\
  55271. !*** ./Materials/Textures/colorGradingTexture.ts ***!
  55272. \***************************************************/
  55273. /*! exports provided: ColorGradingTexture */
  55274. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55275. "use strict";
  55276. __webpack_require__.r(__webpack_exports__);
  55277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return ColorGradingTexture; });
  55278. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55279. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55280. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  55281. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55282. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55283. /**
  55284. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55285. * It can help converting any input color in a desired output one. This can then be used to create effects
  55286. * from sepia, black and white to sixties or futuristic rendering...
  55287. *
  55288. * The only supported format is currently 3dl.
  55289. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55290. */
  55291. var ColorGradingTexture = /** @class */ (function (_super) {
  55292. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorGradingTexture, _super);
  55293. /**
  55294. * Instantiates a ColorGradingTexture from the following parameters.
  55295. *
  55296. * @param url The location of the color gradind data (currently only supporting 3dl)
  55297. * @param scene The scene the texture will be used in
  55298. */
  55299. function ColorGradingTexture(url, scene) {
  55300. var _this = _super.call(this, scene) || this;
  55301. if (!url) {
  55302. return _this;
  55303. }
  55304. _this._engine = scene.getEngine();
  55305. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  55306. _this.name = url;
  55307. _this.url = url;
  55308. _this.hasAlpha = false;
  55309. _this.isCube = false;
  55310. _this.is3D = _this._engine.webGLVersion > 1;
  55311. _this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  55312. _this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  55313. _this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  55314. _this.anisotropicFilteringLevel = 1;
  55315. _this._texture = _this._getFromCache(url, true);
  55316. if (!_this._texture) {
  55317. if (!scene.useDelayedTextureLoading) {
  55318. _this.loadTexture();
  55319. }
  55320. else {
  55321. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED;
  55322. }
  55323. }
  55324. return _this;
  55325. }
  55326. /**
  55327. * Returns the texture matrix used in most of the material.
  55328. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55329. */
  55330. ColorGradingTexture.prototype.getTextureMatrix = function () {
  55331. return this._textureMatrix;
  55332. };
  55333. /**
  55334. * Occurs when the file being loaded is a .3dl LUT file.
  55335. */
  55336. ColorGradingTexture.prototype.load3dlTexture = function () {
  55337. var engine = this._engine;
  55338. var texture;
  55339. if (engine.webGLVersion === 1) {
  55340. 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);
  55341. }
  55342. else {
  55343. 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);
  55344. }
  55345. this._texture = texture;
  55346. var callback = function (text) {
  55347. if (typeof text !== "string") {
  55348. return;
  55349. }
  55350. var data = null;
  55351. var tempData = null;
  55352. var line;
  55353. var lines = text.split('\n');
  55354. var size = 0, pixelIndexW = 0, pixelIndexH = 0, pixelIndexSlice = 0;
  55355. var maxColor = 0;
  55356. for (var i = 0; i < lines.length; i++) {
  55357. line = lines[i];
  55358. if (!ColorGradingTexture._noneEmptyLineRegex.test(line)) {
  55359. continue;
  55360. }
  55361. if (line.indexOf('#') === 0) {
  55362. continue;
  55363. }
  55364. var words = line.split(" ");
  55365. if (size === 0) {
  55366. // Number of space + one
  55367. size = words.length;
  55368. data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
  55369. tempData = new Float32Array(size * size * size * 4);
  55370. continue;
  55371. }
  55372. if (size != 0) {
  55373. var r = Math.max(parseInt(words[0]), 0);
  55374. var g = Math.max(parseInt(words[1]), 0);
  55375. var b = Math.max(parseInt(words[2]), 0);
  55376. maxColor = Math.max(r, maxColor);
  55377. maxColor = Math.max(g, maxColor);
  55378. maxColor = Math.max(b, maxColor);
  55379. var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
  55380. if (tempData) {
  55381. tempData[pixelStorageIndex + 0] = r;
  55382. tempData[pixelStorageIndex + 1] = g;
  55383. tempData[pixelStorageIndex + 2] = b;
  55384. }
  55385. // Keep for reference in case of back compat problems.
  55386. // pixelIndexSlice++;
  55387. // if (pixelIndexSlice % size == 0) {
  55388. // pixelIndexH++;
  55389. // pixelIndexSlice = 0;
  55390. // if (pixelIndexH % size == 0) {
  55391. // pixelIndexW++;
  55392. // pixelIndexH = 0;
  55393. // }
  55394. // }
  55395. pixelIndexH++;
  55396. if (pixelIndexH % size == 0) {
  55397. pixelIndexSlice++;
  55398. pixelIndexH = 0;
  55399. if (pixelIndexSlice % size == 0) {
  55400. pixelIndexW++;
  55401. pixelIndexSlice = 0;
  55402. }
  55403. }
  55404. }
  55405. }
  55406. if (tempData && data) {
  55407. for (var i = 0; i < tempData.length; i++) {
  55408. if (i > 0 && (i + 1) % 4 === 0) {
  55409. data[i] = 255;
  55410. }
  55411. else {
  55412. var value = tempData[i];
  55413. data[i] = (value / maxColor * 255);
  55414. }
  55415. }
  55416. }
  55417. if (texture.is3D) {
  55418. texture.updateSize(size, size, size);
  55419. engine.updateRawTexture3D(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  55420. }
  55421. else {
  55422. texture.updateSize(size * size, size);
  55423. engine.updateRawTexture(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  55424. }
  55425. };
  55426. var scene = this.getScene();
  55427. if (scene) {
  55428. scene._loadFile(this.url, callback);
  55429. }
  55430. else {
  55431. this._engine._loadFile(this.url, callback);
  55432. }
  55433. return this._texture;
  55434. };
  55435. /**
  55436. * Starts the loading process of the texture.
  55437. */
  55438. ColorGradingTexture.prototype.loadTexture = function () {
  55439. if (this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == (this.url.length - 4)) {
  55440. this.load3dlTexture();
  55441. }
  55442. };
  55443. /**
  55444. * Clones the color gradind texture.
  55445. */
  55446. ColorGradingTexture.prototype.clone = function () {
  55447. var newTexture = new ColorGradingTexture(this.url, this.getScene());
  55448. // Base texture
  55449. newTexture.level = this.level;
  55450. return newTexture;
  55451. };
  55452. /**
  55453. * Called during delayed load for textures.
  55454. */
  55455. ColorGradingTexture.prototype.delayLoad = function () {
  55456. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  55457. return;
  55458. }
  55459. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED;
  55460. this._texture = this._getFromCache(this.url, true);
  55461. if (!this._texture) {
  55462. this.loadTexture();
  55463. }
  55464. };
  55465. /**
  55466. * Parses a color grading texture serialized by Babylon.
  55467. * @param parsedTexture The texture information being parsedTexture
  55468. * @param scene The scene to load the texture in
  55469. * @param rootUrl The root url of the data assets to load
  55470. * @return A color gradind texture
  55471. */
  55472. ColorGradingTexture.Parse = function (parsedTexture, scene) {
  55473. var texture = null;
  55474. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  55475. texture = new ColorGradingTexture(parsedTexture.name, scene);
  55476. texture.name = parsedTexture.name;
  55477. texture.level = parsedTexture.level;
  55478. }
  55479. return texture;
  55480. };
  55481. /**
  55482. * Serializes the LUT texture to json format.
  55483. */
  55484. ColorGradingTexture.prototype.serialize = function () {
  55485. if (!this.name) {
  55486. return null;
  55487. }
  55488. var serializationObject = {};
  55489. serializationObject.name = this.name;
  55490. serializationObject.level = this.level;
  55491. serializationObject.customType = "BABYLON.ColorGradingTexture";
  55492. return serializationObject;
  55493. };
  55494. /**
  55495. * Empty line regex stored for GC.
  55496. */
  55497. ColorGradingTexture._noneEmptyLineRegex = /\S+/;
  55498. return ColorGradingTexture;
  55499. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__["BaseTexture"]));
  55500. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorGradingTexture"] = ColorGradingTexture;
  55501. /***/ }),
  55502. /***/ "./Materials/Textures/cubeTexture.ts":
  55503. /*!*******************************************!*\
  55504. !*** ./Materials/Textures/cubeTexture.ts ***!
  55505. \*******************************************/
  55506. /*! exports provided: CubeTexture */
  55507. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55508. "use strict";
  55509. __webpack_require__.r(__webpack_exports__);
  55510. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return CubeTexture; });
  55511. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55512. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55513. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  55514. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55515. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  55516. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55517. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55518. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55519. /**
  55520. * Class for creating a cube texture
  55521. */
  55522. var CubeTexture = /** @class */ (function (_super) {
  55523. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTexture, _super);
  55524. /**
  55525. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  55526. * as prefiltered data.
  55527. * @param rootUrl defines the url of the texture or the root name of the six images
  55528. * @param scene defines the scene the texture is attached to
  55529. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  55530. * @param noMipmap defines if mipmaps should be created or not
  55531. * @param files defines the six files to load for the different faces
  55532. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  55533. * @param onError defines a callback triggered in case of error during load
  55534. * @param format defines the internal format to use for the texture once loaded
  55535. * @param prefiltered defines whether or not the texture is created from prefiltered data
  55536. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  55537. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  55538. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55539. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55540. * @return the cube texture
  55541. */
  55542. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
  55543. if (extensions === void 0) { extensions = null; }
  55544. if (noMipmap === void 0) { noMipmap = false; }
  55545. if (files === void 0) { files = null; }
  55546. if (onLoad === void 0) { onLoad = null; }
  55547. if (onError === void 0) { onError = null; }
  55548. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  55549. if (prefiltered === void 0) { prefiltered = false; }
  55550. if (forcedExtension === void 0) { forcedExtension = null; }
  55551. if (createPolynomials === void 0) { createPolynomials = false; }
  55552. if (lodScale === void 0) { lodScale = 0.8; }
  55553. if (lodOffset === void 0) { lodOffset = 0; }
  55554. var _this = _super.call(this, scene) || this;
  55555. /**
  55556. * Gets or sets the center of the bounding box associated with the cube texture.
  55557. * It must define where the camera used to render the texture was set
  55558. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  55559. */
  55560. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  55561. _this._rotationY = 0;
  55562. /** @hidden */
  55563. _this._prefiltered = false;
  55564. _this.name = rootUrl;
  55565. _this.url = rootUrl;
  55566. _this._noMipmap = noMipmap;
  55567. _this.hasAlpha = false;
  55568. _this._format = format;
  55569. _this.isCube = true;
  55570. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  55571. _this._createPolynomials = createPolynomials;
  55572. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CUBIC_MODE;
  55573. if (!rootUrl && !files) {
  55574. return _this;
  55575. }
  55576. var lastDot = rootUrl.lastIndexOf(".");
  55577. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  55578. var isDDS = (extension === ".dds");
  55579. var isEnv = (extension === ".env");
  55580. if (isEnv) {
  55581. _this.gammaSpace = false;
  55582. _this._prefiltered = false;
  55583. }
  55584. else {
  55585. _this._prefiltered = prefiltered;
  55586. if (prefiltered) {
  55587. _this.gammaSpace = false;
  55588. }
  55589. }
  55590. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  55591. if (!files) {
  55592. if (!isEnv && !isDDS && !extensions) {
  55593. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  55594. }
  55595. files = [];
  55596. if (extensions) {
  55597. for (var index = 0; index < extensions.length; index++) {
  55598. files.push(rootUrl + extensions[index]);
  55599. }
  55600. }
  55601. }
  55602. _this._files = files;
  55603. if (!_this._texture) {
  55604. if (!scene.useDelayedTextureLoading) {
  55605. if (prefiltered) {
  55606. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
  55607. }
  55608. else {
  55609. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
  55610. }
  55611. }
  55612. else {
  55613. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  55614. }
  55615. }
  55616. else if (onLoad) {
  55617. if (_this._texture.isReady) {
  55618. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetImmediate(function () { return onLoad(); });
  55619. }
  55620. else {
  55621. _this._texture.onLoadedObservable.add(onLoad);
  55622. }
  55623. }
  55624. return _this;
  55625. }
  55626. Object.defineProperty(CubeTexture.prototype, "boundingBoxSize", {
  55627. /**
  55628. * Returns the bounding box size
  55629. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  55630. */
  55631. get: function () {
  55632. return this._boundingBoxSize;
  55633. },
  55634. /**
  55635. * Gets or sets the size of the bounding box associated with the cube texture
  55636. * When defined, the cubemap will switch to local mode
  55637. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55638. * @example https://www.babylonjs-playground.com/#RNASML
  55639. */
  55640. set: function (value) {
  55641. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  55642. return;
  55643. }
  55644. this._boundingBoxSize = value;
  55645. var scene = this.getScene();
  55646. if (scene) {
  55647. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  55648. }
  55649. },
  55650. enumerable: true,
  55651. configurable: true
  55652. });
  55653. Object.defineProperty(CubeTexture.prototype, "rotationY", {
  55654. /**
  55655. * Gets texture matrix rotation angle around Y axis radians.
  55656. */
  55657. get: function () {
  55658. return this._rotationY;
  55659. },
  55660. /**
  55661. * Sets texture matrix rotation angle around Y axis in radians.
  55662. */
  55663. set: function (value) {
  55664. this._rotationY = value;
  55665. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(this._rotationY));
  55666. },
  55667. enumerable: true,
  55668. configurable: true
  55669. });
  55670. Object.defineProperty(CubeTexture.prototype, "noMipmap", {
  55671. /**
  55672. * Are mip maps generated for this texture or not.
  55673. */
  55674. get: function () {
  55675. return this._noMipmap;
  55676. },
  55677. enumerable: true,
  55678. configurable: true
  55679. });
  55680. /**
  55681. * Creates a cube texture from an array of image urls
  55682. * @param files defines an array of image urls
  55683. * @param scene defines the hosting scene
  55684. * @param noMipmap specifies if mip maps are not used
  55685. * @returns a cube texture
  55686. */
  55687. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  55688. var rootUrlKey = "";
  55689. files.forEach(function (url) { return rootUrlKey += url; });
  55690. return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
  55691. };
  55692. /**
  55693. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  55694. * @param url defines the url of the prefiltered texture
  55695. * @param scene defines the scene the texture is attached to
  55696. * @param forcedExtension defines the extension of the file if different from the url
  55697. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  55698. * @return the prefiltered texture
  55699. */
  55700. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension, createPolynomials) {
  55701. if (forcedExtension === void 0) { forcedExtension = null; }
  55702. if (createPolynomials === void 0) { createPolynomials = true; }
  55703. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);
  55704. };
  55705. /**
  55706. * Get the current class name of the texture useful for serialization or dynamic coding.
  55707. * @returns "CubeTexture"
  55708. */
  55709. CubeTexture.prototype.getClassName = function () {
  55710. return "CubeTexture";
  55711. };
  55712. /**
  55713. * Update the url (and optional buffer) of this texture if url was null during construction.
  55714. * @param url the url of the texture
  55715. * @param forcedExtension defines the extension to use
  55716. * @param onLoad callback called when the texture is loaded (defaults to null)
  55717. */
  55718. CubeTexture.prototype.updateURL = function (url, forcedExtension, onLoad) {
  55719. if (this.url) {
  55720. this.releaseInternalTexture();
  55721. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  55722. }
  55723. this.url = url;
  55724. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  55725. this._prefiltered = false;
  55726. if (onLoad) {
  55727. this._delayedOnLoad = onLoad;
  55728. }
  55729. this.delayLoad(forcedExtension);
  55730. };
  55731. /**
  55732. * Delays loading of the cube texture
  55733. * @param forcedExtension defines the extension to use
  55734. */
  55735. CubeTexture.prototype.delayLoad = function (forcedExtension) {
  55736. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  55737. return;
  55738. }
  55739. var scene = this.getScene();
  55740. if (!scene) {
  55741. return;
  55742. }
  55743. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  55744. this._texture = this._getFromCache(this.url, this._noMipmap);
  55745. if (!this._texture) {
  55746. if (this._prefiltered) {
  55747. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
  55748. }
  55749. else {
  55750. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, undefined, this._format, forcedExtension);
  55751. }
  55752. }
  55753. };
  55754. /**
  55755. * Returns the reflection texture matrix
  55756. * @returns the reflection texture matrix
  55757. */
  55758. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  55759. return this._textureMatrix;
  55760. };
  55761. /**
  55762. * Sets the reflection texture matrix
  55763. * @param value Reflection texture matrix
  55764. */
  55765. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  55766. var _this = this;
  55767. if (value.updateFlag === this._textureMatrix.updateFlag) {
  55768. return;
  55769. }
  55770. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  55771. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  55772. }
  55773. this._textureMatrix = value;
  55774. };
  55775. /**
  55776. * Parses text to create a cube texture
  55777. * @param parsedTexture define the serialized text to read from
  55778. * @param scene defines the hosting scene
  55779. * @param rootUrl defines the root url of the cube texture
  55780. * @returns a cube texture
  55781. */
  55782. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  55783. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  55784. var prefiltered = false;
  55785. if (parsedTexture.prefiltered) {
  55786. prefiltered = parsedTexture.prefiltered;
  55787. }
  55788. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions, false, null, null, null, undefined, prefiltered);
  55789. }, parsedTexture, scene);
  55790. // Local Cubemaps
  55791. if (parsedTexture.boundingBoxPosition) {
  55792. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  55793. }
  55794. if (parsedTexture.boundingBoxSize) {
  55795. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  55796. }
  55797. // Animations
  55798. if (parsedTexture.animations) {
  55799. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  55800. var parsedAnimation = parsedTexture.animations[animationIndex];
  55801. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  55802. if (internalClass) {
  55803. texture.animations.push(internalClass.Parse(parsedAnimation));
  55804. }
  55805. }
  55806. }
  55807. return texture;
  55808. };
  55809. /**
  55810. * Makes a clone, or deep copy, of the cube texture
  55811. * @returns a new cube texture
  55812. */
  55813. CubeTexture.prototype.clone = function () {
  55814. var _this = this;
  55815. var scene = this.getScene();
  55816. var uniqueId = 0;
  55817. var newCubeTexture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  55818. if (!scene) {
  55819. return _this;
  55820. }
  55821. var cubeTexture = new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  55822. uniqueId = cubeTexture.uniqueId;
  55823. return cubeTexture;
  55824. }, this);
  55825. newCubeTexture.uniqueId = uniqueId;
  55826. return newCubeTexture;
  55827. };
  55828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("rotationY")
  55830. ], CubeTexture.prototype, "rotationY", null);
  55831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("textureMatrix")
  55833. ], CubeTexture.prototype, "_textureMatrix", void 0);
  55834. return CubeTexture;
  55835. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  55836. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CubeTextureParser = CubeTexture.Parse;
  55837. // Some exporters relies on Tools.Instantiate
  55838. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.CubeTexture"] = CubeTexture;
  55839. /***/ }),
  55840. /***/ "./Materials/Textures/dynamicTexture.ts":
  55841. /*!**********************************************!*\
  55842. !*** ./Materials/Textures/dynamicTexture.ts ***!
  55843. \**********************************************/
  55844. /*! exports provided: DynamicTexture */
  55845. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55846. "use strict";
  55847. __webpack_require__.r(__webpack_exports__);
  55848. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return DynamicTexture; });
  55849. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55850. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  55851. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55852. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55853. /**
  55854. * A class extending Texture allowing drawing on a texture
  55855. * @see http://doc.babylonjs.com/how_to/dynamictexture
  55856. */
  55857. var DynamicTexture = /** @class */ (function (_super) {
  55858. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DynamicTexture, _super);
  55859. /**
  55860. * Creates a DynamicTexture
  55861. * @param name defines the name of the texture
  55862. * @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
  55863. * @param scene defines the scene where you want the texture
  55864. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  55865. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55866. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  55867. */
  55868. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  55869. if (scene === void 0) { scene = null; }
  55870. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  55871. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA; }
  55872. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  55873. _this.name = name;
  55874. _this._engine = _this.getScene().getEngine();
  55875. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  55876. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  55877. _this._generateMipMaps = generateMipMaps;
  55878. if (options.getContext) {
  55879. _this._canvas = options;
  55880. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  55881. }
  55882. else {
  55883. _this._canvas = document.createElement("canvas");
  55884. if (options.width || options.width === 0) {
  55885. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  55886. }
  55887. else {
  55888. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  55889. }
  55890. }
  55891. var textureSize = _this.getSize();
  55892. _this._canvas.width = textureSize.width;
  55893. _this._canvas.height = textureSize.height;
  55894. _this._context = _this._canvas.getContext("2d");
  55895. return _this;
  55896. }
  55897. /**
  55898. * Get the current class name of the texture useful for serialization or dynamic coding.
  55899. * @returns "DynamicTexture"
  55900. */
  55901. DynamicTexture.prototype.getClassName = function () {
  55902. return "DynamicTexture";
  55903. };
  55904. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  55905. /**
  55906. * Gets the current state of canRescale
  55907. */
  55908. get: function () {
  55909. return true;
  55910. },
  55911. enumerable: true,
  55912. configurable: true
  55913. });
  55914. DynamicTexture.prototype._recreate = function (textureSize) {
  55915. this._canvas.width = textureSize.width;
  55916. this._canvas.height = textureSize.height;
  55917. this.releaseInternalTexture();
  55918. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
  55919. };
  55920. /**
  55921. * Scales the texture
  55922. * @param ratio the scale factor to apply to both width and height
  55923. */
  55924. DynamicTexture.prototype.scale = function (ratio) {
  55925. var textureSize = this.getSize();
  55926. textureSize.width *= ratio;
  55927. textureSize.height *= ratio;
  55928. this._recreate(textureSize);
  55929. };
  55930. /**
  55931. * Resizes the texture
  55932. * @param width the new width
  55933. * @param height the new height
  55934. */
  55935. DynamicTexture.prototype.scaleTo = function (width, height) {
  55936. var textureSize = this.getSize();
  55937. textureSize.width = width;
  55938. textureSize.height = height;
  55939. this._recreate(textureSize);
  55940. };
  55941. /**
  55942. * Gets the context of the canvas used by the texture
  55943. * @returns the canvas context of the dynamic texture
  55944. */
  55945. DynamicTexture.prototype.getContext = function () {
  55946. return this._context;
  55947. };
  55948. /**
  55949. * Clears the texture
  55950. */
  55951. DynamicTexture.prototype.clear = function () {
  55952. var size = this.getSize();
  55953. this._context.fillRect(0, 0, size.width, size.height);
  55954. };
  55955. /**
  55956. * Updates the texture
  55957. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55958. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  55959. */
  55960. DynamicTexture.prototype.update = function (invertY, premulAlpha) {
  55961. if (premulAlpha === void 0) { premulAlpha = false; }
  55962. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined);
  55963. };
  55964. /**
  55965. * Draws text onto the texture
  55966. * @param text defines the text to be drawn
  55967. * @param x defines the placement of the text from the left
  55968. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  55969. * @param font defines the font to be used with font-style, font-size, font-name
  55970. * @param color defines the color used for the text
  55971. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  55972. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55973. * @param update defines whether texture is immediately update (default is true)
  55974. */
  55975. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  55976. if (update === void 0) { update = true; }
  55977. var size = this.getSize();
  55978. if (clearColor) {
  55979. this._context.fillStyle = clearColor;
  55980. this._context.fillRect(0, 0, size.width, size.height);
  55981. }
  55982. this._context.font = font;
  55983. if (x === null || x === undefined) {
  55984. var textSize = this._context.measureText(text);
  55985. x = (size.width - textSize.width) / 2;
  55986. }
  55987. if (y === null || y === undefined) {
  55988. var fontSize = parseInt((font.replace(/\D/g, '')));
  55989. y = (size.height / 2) + (fontSize / 3.65);
  55990. }
  55991. this._context.fillStyle = color;
  55992. this._context.fillText(text, x, y);
  55993. if (update) {
  55994. this.update(invertY);
  55995. }
  55996. };
  55997. /**
  55998. * Clones the texture
  55999. * @returns the clone of the texture.
  56000. */
  56001. DynamicTexture.prototype.clone = function () {
  56002. var scene = this.getScene();
  56003. if (!scene) {
  56004. return this;
  56005. }
  56006. var textureSize = this.getSize();
  56007. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  56008. // Base texture
  56009. newTexture.hasAlpha = this.hasAlpha;
  56010. newTexture.level = this.level;
  56011. // Dynamic Texture
  56012. newTexture.wrapU = this.wrapU;
  56013. newTexture.wrapV = this.wrapV;
  56014. return newTexture;
  56015. };
  56016. /**
  56017. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  56018. * @returns a serialized dynamic texture object
  56019. */
  56020. DynamicTexture.prototype.serialize = function () {
  56021. var scene = this.getScene();
  56022. if (scene && !scene.isReady()) {
  56023. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The scene must be ready before serializing the dynamic texture");
  56024. }
  56025. var serializationObject = _super.prototype.serialize.call(this);
  56026. serializationObject.base64String = this._canvas.toDataURL();
  56027. serializationObject.invertY = this._invertY;
  56028. serializationObject.samplingMode = this.samplingMode;
  56029. return serializationObject;
  56030. };
  56031. /** @hidden */
  56032. DynamicTexture.prototype._rebuild = function () {
  56033. this.update();
  56034. };
  56035. return DynamicTexture;
  56036. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]));
  56037. /***/ }),
  56038. /***/ "./Materials/Textures/hdrCubeTexture.ts":
  56039. /*!**********************************************!*\
  56040. !*** ./Materials/Textures/hdrCubeTexture.ts ***!
  56041. \**********************************************/
  56042. /*! exports provided: HDRCubeTexture */
  56043. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56044. "use strict";
  56045. __webpack_require__.r(__webpack_exports__);
  56046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return HDRCubeTexture; });
  56047. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56048. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56049. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  56050. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  56051. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56052. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56053. /* harmony import */ var _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/hdr */ "./Misc/HighDynamicRange/hdr.ts");
  56054. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  56055. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  56056. /**
  56057. * This represents a texture coming from an HDR input.
  56058. *
  56059. * The only supported format is currently panorama picture stored in RGBE format.
  56060. * Example of such files can be found on HDRLib: http://hdrlib.com/
  56061. */
  56062. var HDRCubeTexture = /** @class */ (function (_super) {
  56063. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTexture, _super);
  56064. /**
  56065. * Instantiates an HDRTexture from the following parameters.
  56066. *
  56067. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  56068. * @param scene The scene the texture will be used in
  56069. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56070. * @param noMipmap Forces to not generate the mipmap if true
  56071. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  56072. * @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)
  56073. * @param reserved Reserved flag for internal use.
  56074. */
  56075. function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
  56076. if (noMipmap === void 0) { noMipmap = false; }
  56077. if (generateHarmonics === void 0) { generateHarmonics = true; }
  56078. if (gammaSpace === void 0) { gammaSpace = false; }
  56079. if (reserved === void 0) { reserved = false; }
  56080. if (onLoad === void 0) { onLoad = null; }
  56081. if (onError === void 0) { onError = null; }
  56082. var _this = _super.call(this, scene) || this;
  56083. _this._generateHarmonics = true;
  56084. _this._onLoad = null;
  56085. _this._onError = null;
  56086. /**
  56087. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  56088. */
  56089. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  56090. _this._isBlocking = true;
  56091. _this._rotationY = 0;
  56092. /**
  56093. * Gets or sets the center of the bounding box associated with the cube texture
  56094. * It must define where the camera used to render the texture was set
  56095. */
  56096. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  56097. if (!url) {
  56098. return _this;
  56099. }
  56100. _this.name = url;
  56101. _this.url = url;
  56102. _this.hasAlpha = false;
  56103. _this.isCube = true;
  56104. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  56105. _this._onLoad = onLoad;
  56106. _this._onError = onError;
  56107. _this.gammaSpace = gammaSpace;
  56108. _this._noMipmap = noMipmap;
  56109. _this._size = size;
  56110. _this._texture = _this._getFromCache(url, _this._noMipmap);
  56111. if (!_this._texture) {
  56112. if (!scene.useDelayedTextureLoading) {
  56113. _this.loadTexture();
  56114. }
  56115. else {
  56116. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  56117. }
  56118. }
  56119. return _this;
  56120. }
  56121. Object.defineProperty(HDRCubeTexture.prototype, "isBlocking", {
  56122. /**
  56123. * Gets wether or not the texture is blocking during loading.
  56124. */
  56125. get: function () {
  56126. return this._isBlocking;
  56127. },
  56128. /**
  56129. * Sets wether or not the texture is blocking during loading.
  56130. */
  56131. set: function (value) {
  56132. this._isBlocking = value;
  56133. },
  56134. enumerable: true,
  56135. configurable: true
  56136. });
  56137. Object.defineProperty(HDRCubeTexture.prototype, "rotationY", {
  56138. /**
  56139. * Gets texture matrix rotation angle around Y axis radians.
  56140. */
  56141. get: function () {
  56142. return this._rotationY;
  56143. },
  56144. /**
  56145. * Sets texture matrix rotation angle around Y axis in radians.
  56146. */
  56147. set: function (value) {
  56148. this._rotationY = value;
  56149. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationY(this._rotationY));
  56150. },
  56151. enumerable: true,
  56152. configurable: true
  56153. });
  56154. Object.defineProperty(HDRCubeTexture.prototype, "boundingBoxSize", {
  56155. get: function () {
  56156. return this._boundingBoxSize;
  56157. },
  56158. /**
  56159. * Gets or sets the size of the bounding box associated with the cube texture
  56160. * When defined, the cubemap will switch to local mode
  56161. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  56162. * @example https://www.babylonjs-playground.com/#RNASML
  56163. */
  56164. set: function (value) {
  56165. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  56166. return;
  56167. }
  56168. this._boundingBoxSize = value;
  56169. var scene = this.getScene();
  56170. if (scene) {
  56171. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  56172. }
  56173. },
  56174. enumerable: true,
  56175. configurable: true
  56176. });
  56177. /**
  56178. * Get the current class name of the texture useful for serialization or dynamic coding.
  56179. * @returns "HDRCubeTexture"
  56180. */
  56181. HDRCubeTexture.prototype.getClassName = function () {
  56182. return "HDRCubeTexture";
  56183. };
  56184. /**
  56185. * Occurs when the file is raw .hdr file.
  56186. */
  56187. HDRCubeTexture.prototype.loadTexture = function () {
  56188. var _this = this;
  56189. var callback = function (buffer) {
  56190. _this.lodGenerationOffset = 0.0;
  56191. _this.lodGenerationScale = 0.8;
  56192. var scene = _this.getScene();
  56193. if (!scene) {
  56194. return null;
  56195. }
  56196. // Extract the raw linear data.
  56197. var data = _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__["HDRTools"].GetCubeMapTextureData(buffer, _this._size);
  56198. // Generate harmonics if needed.
  56199. if (_this._generateHarmonics) {
  56200. var sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial(data);
  56201. _this.sphericalPolynomial = sphericalPolynomial;
  56202. }
  56203. var results = [];
  56204. var byteArray = null;
  56205. // Push each faces.
  56206. for (var j = 0; j < 6; j++) {
  56207. // Create uintarray fallback.
  56208. if (!scene.getEngine().getCaps().textureFloat) {
  56209. // 3 channels of 1 bytes per pixel in bytes.
  56210. var byteBuffer = new ArrayBuffer(_this._size * _this._size * 3);
  56211. byteArray = new Uint8Array(byteBuffer);
  56212. }
  56213. var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
  56214. // If special cases.
  56215. if (_this.gammaSpace || byteArray) {
  56216. for (var i = 0; i < _this._size * _this._size; i++) {
  56217. // Put in gamma space if requested.
  56218. if (_this.gammaSpace) {
  56219. dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  56220. dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  56221. dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  56222. }
  56223. // Convert to int texture for fallback.
  56224. if (byteArray) {
  56225. var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
  56226. var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
  56227. var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
  56228. // May use luminance instead if the result is not accurate.
  56229. var max = Math.max(Math.max(r, g), b);
  56230. if (max > 255) {
  56231. var scale = 255 / max;
  56232. r *= scale;
  56233. g *= scale;
  56234. b *= scale;
  56235. }
  56236. byteArray[(i * 3) + 0] = r;
  56237. byteArray[(i * 3) + 1] = g;
  56238. byteArray[(i * 3) + 2] = b;
  56239. }
  56240. }
  56241. }
  56242. if (byteArray) {
  56243. results.push(byteArray);
  56244. }
  56245. else {
  56246. results.push(dataFace);
  56247. }
  56248. }
  56249. return results;
  56250. };
  56251. var scene = this.getScene();
  56252. if (scene) {
  56253. 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);
  56254. }
  56255. };
  56256. HDRCubeTexture.prototype.clone = function () {
  56257. var scene = this.getScene();
  56258. if (!scene) {
  56259. return this;
  56260. }
  56261. var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
  56262. // Base texture
  56263. newTexture.level = this.level;
  56264. newTexture.wrapU = this.wrapU;
  56265. newTexture.wrapV = this.wrapV;
  56266. newTexture.coordinatesIndex = this.coordinatesIndex;
  56267. newTexture.coordinatesMode = this.coordinatesMode;
  56268. return newTexture;
  56269. };
  56270. // Methods
  56271. HDRCubeTexture.prototype.delayLoad = function () {
  56272. if (this.delayLoadState !== _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED) {
  56273. return;
  56274. }
  56275. this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_LOADED;
  56276. this._texture = this._getFromCache(this.url, this._noMipmap);
  56277. if (!this._texture) {
  56278. this.loadTexture();
  56279. }
  56280. };
  56281. /**
  56282. * Get the texture reflection matrix used to rotate/transform the reflection.
  56283. * @returns the reflection matrix
  56284. */
  56285. HDRCubeTexture.prototype.getReflectionTextureMatrix = function () {
  56286. return this._textureMatrix;
  56287. };
  56288. /**
  56289. * Set the texture reflection matrix used to rotate/transform the reflection.
  56290. * @param value Define the reflection matrix to set
  56291. */
  56292. HDRCubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  56293. var _this = this;
  56294. this._textureMatrix = value;
  56295. if (value.updateFlag === this._textureMatrix.updateFlag) {
  56296. return;
  56297. }
  56298. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  56299. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  56300. }
  56301. };
  56302. /**
  56303. * Parses a JSON representation of an HDR Texture in order to create the texture
  56304. * @param parsedTexture Define the JSON representation
  56305. * @param scene Define the scene the texture should be created in
  56306. * @param rootUrl Define the root url in case we need to load relative dependencies
  56307. * @returns the newly created texture after parsing
  56308. */
  56309. HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  56310. var texture = null;
  56311. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  56312. texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
  56313. texture.name = parsedTexture.name;
  56314. texture.hasAlpha = parsedTexture.hasAlpha;
  56315. texture.level = parsedTexture.level;
  56316. texture.coordinatesMode = parsedTexture.coordinatesMode;
  56317. texture.isBlocking = parsedTexture.isBlocking;
  56318. }
  56319. if (texture) {
  56320. if (parsedTexture.boundingBoxPosition) {
  56321. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  56322. }
  56323. if (parsedTexture.boundingBoxSize) {
  56324. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  56325. }
  56326. if (parsedTexture.rotationY) {
  56327. texture.rotationY = parsedTexture.rotationY;
  56328. }
  56329. }
  56330. return texture;
  56331. };
  56332. HDRCubeTexture.prototype.serialize = function () {
  56333. if (!this.name) {
  56334. return null;
  56335. }
  56336. var serializationObject = {};
  56337. serializationObject.name = this.name;
  56338. serializationObject.hasAlpha = this.hasAlpha;
  56339. serializationObject.isCube = true;
  56340. serializationObject.level = this.level;
  56341. serializationObject.size = this._size;
  56342. serializationObject.coordinatesMode = this.coordinatesMode;
  56343. serializationObject.useInGammaSpace = this.gammaSpace;
  56344. serializationObject.generateHarmonics = this._generateHarmonics;
  56345. serializationObject.customType = "BABYLON.HDRCubeTexture";
  56346. serializationObject.noMipmap = this._noMipmap;
  56347. serializationObject.isBlocking = this._isBlocking;
  56348. serializationObject.rotationY = this._rotationY;
  56349. return serializationObject;
  56350. };
  56351. HDRCubeTexture._facesMapping = [
  56352. "right",
  56353. "left",
  56354. "up",
  56355. "down",
  56356. "front",
  56357. "back"
  56358. ];
  56359. return HDRCubeTexture;
  56360. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  56361. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.HDRCubeTexture"] = HDRCubeTexture;
  56362. /***/ }),
  56363. /***/ "./Materials/Textures/index.ts":
  56364. /*!*************************************!*\
  56365. !*** ./Materials/Textures/index.ts ***!
  56366. \*************************************/
  56367. /*! exports provided: BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  56368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56369. "use strict";
  56370. __webpack_require__.r(__webpack_exports__);
  56371. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  56372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _baseTexture__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  56373. /* harmony import */ var _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorGradingTexture */ "./Materials/Textures/colorGradingTexture.ts");
  56374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__["ColorGradingTexture"]; });
  56375. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  56376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _cubeTexture__WEBPACK_IMPORTED_MODULE_2__["CubeTexture"]; });
  56377. /* harmony import */ var _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  56378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]; });
  56379. /* harmony import */ var _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  56380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__["HDRCubeTexture"]; });
  56381. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  56382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"]; });
  56383. /* harmony import */ var _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  56384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__["DummyInternalTextureTracker"]; });
  56385. /* harmony import */ var _Loaders_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Loaders/index */ "./Materials/Textures/Loaders/index.ts");
  56386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_DDSTextureLoader"]; });
  56387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_ENVTextureLoader"]; });
  56388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_KTXTextureLoader"]; });
  56389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_TGATextureLoader"]; });
  56390. /* harmony import */ var _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  56391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__["MirrorTexture"]; });
  56392. /* harmony import */ var _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  56393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__["MultiRenderTarget"]; });
  56394. /* harmony import */ var _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Procedurals/index */ "./Materials/Textures/Procedurals/index.ts");
  56395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTexture"]; });
  56396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["CustomProceduralTexture"]; });
  56397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["NoiseProceduralTexture"]; });
  56398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTextureSceneComponent"]; });
  56399. /* harmony import */ var _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./rawCubeTexture */ "./Materials/Textures/rawCubeTexture.ts");
  56400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__["RawCubeTexture"]; });
  56401. /* harmony import */ var _rawTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./rawTexture */ "./Materials/Textures/rawTexture.ts");
  56402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _rawTexture__WEBPACK_IMPORTED_MODULE_12__["RawTexture"]; });
  56403. /* harmony import */ var _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./rawTexture3D */ "./Materials/Textures/rawTexture3D.ts");
  56404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  56405. /* harmony import */ var _refractionTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./refractionTexture */ "./Materials/Textures/refractionTexture.ts");
  56406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _refractionTexture__WEBPACK_IMPORTED_MODULE_14__["RefractionTexture"]; });
  56407. /* harmony import */ var _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__["RenderTargetTexture"]; });
  56409. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  56410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _texture__WEBPACK_IMPORTED_MODULE_16__["Texture"]; });
  56411. /* harmony import */ var _videoTexture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./videoTexture */ "./Materials/Textures/videoTexture.ts");
  56412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _videoTexture__WEBPACK_IMPORTED_MODULE_17__["VideoTexture"]; });
  56413. /***/ }),
  56414. /***/ "./Materials/Textures/internalTexture.ts":
  56415. /*!***********************************************!*\
  56416. !*** ./Materials/Textures/internalTexture.ts ***!
  56417. \***********************************************/
  56418. /*! exports provided: InternalTexture */
  56419. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56420. "use strict";
  56421. __webpack_require__.r(__webpack_exports__);
  56422. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return InternalTexture; });
  56423. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  56424. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  56425. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56426. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  56427. /**
  56428. * Class used to store data associated with WebGL texture data for the engine
  56429. * This class should not be used directly
  56430. */
  56431. var InternalTexture = /** @class */ (function () {
  56432. /**
  56433. * Creates a new InternalTexture
  56434. * @param engine defines the engine to use
  56435. * @param dataSource defines the type of data that will be used
  56436. * @param delayAllocation if the texture allocation should be delayed (default: false)
  56437. */
  56438. function InternalTexture(engine, dataSource, delayAllocation) {
  56439. if (delayAllocation === void 0) { delayAllocation = false; }
  56440. /**
  56441. * Observable called when the texture is loaded
  56442. */
  56443. this.onLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  56444. /**
  56445. * Gets or set the previous tracker in the list
  56446. */
  56447. this.previous = null;
  56448. /**
  56449. * Gets or set the next tracker in the list
  56450. */
  56451. this.next = null;
  56452. // Private
  56453. /** @hidden */
  56454. this._invertVScale = false;
  56455. /** @hidden */
  56456. this._initialSlot = -1;
  56457. /** @hidden */
  56458. this._designatedSlot = -1;
  56459. /** @hidden */
  56460. this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
  56461. /** @hidden */
  56462. this._comparisonFunction = 0;
  56463. /** @hidden */
  56464. this._sphericalPolynomial = null;
  56465. /** @hidden */
  56466. this._lodGenerationScale = 0;
  56467. /** @hidden */
  56468. this._lodGenerationOffset = 0;
  56469. /** @hidden */
  56470. this._isRGBD = false;
  56471. /** @hidden */
  56472. this._references = 1;
  56473. this._engine = engine;
  56474. this._dataSource = dataSource;
  56475. if (!delayAllocation) {
  56476. this._webGLTexture = engine._createTexture();
  56477. }
  56478. }
  56479. /**
  56480. * Gets the Engine the texture belongs to.
  56481. * @returns The babylon engine
  56482. */
  56483. InternalTexture.prototype.getEngine = function () {
  56484. return this._engine;
  56485. };
  56486. Object.defineProperty(InternalTexture.prototype, "dataSource", {
  56487. /**
  56488. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  56489. */
  56490. get: function () {
  56491. return this._dataSource;
  56492. },
  56493. enumerable: true,
  56494. configurable: true
  56495. });
  56496. /**
  56497. * Increments the number of references (ie. the number of Texture that point to it)
  56498. */
  56499. InternalTexture.prototype.incrementReferences = function () {
  56500. this._references++;
  56501. };
  56502. /**
  56503. * Change the size of the texture (not the size of the content)
  56504. * @param width defines the new width
  56505. * @param height defines the new height
  56506. * @param depth defines the new depth (1 by default)
  56507. */
  56508. InternalTexture.prototype.updateSize = function (width, height, depth) {
  56509. if (depth === void 0) { depth = 1; }
  56510. this.width = width;
  56511. this.height = height;
  56512. this.depth = depth;
  56513. this.baseWidth = width;
  56514. this.baseHeight = height;
  56515. this.baseDepth = depth;
  56516. this._size = width * height * depth;
  56517. };
  56518. /** @hidden */
  56519. InternalTexture.prototype._rebuild = function () {
  56520. var _this = this;
  56521. var proxy;
  56522. this.isReady = false;
  56523. this._cachedCoordinatesMode = null;
  56524. this._cachedWrapU = null;
  56525. this._cachedWrapV = null;
  56526. this._cachedAnisotropicFilteringLevel = null;
  56527. switch (this._dataSource) {
  56528. case InternalTexture.DATASOURCE_TEMP:
  56529. return;
  56530. case InternalTexture.DATASOURCE_URL:
  56531. proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {
  56532. proxy._swapAndDie(_this);
  56533. _this.isReady = true;
  56534. }, null, this._buffer, undefined, this.format);
  56535. return;
  56536. case InternalTexture.DATASOURCE_RAW:
  56537. proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56538. proxy._swapAndDie(this);
  56539. this.isReady = true;
  56540. return;
  56541. case InternalTexture.DATASOURCE_RAW3D:
  56542. proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56543. proxy._swapAndDie(this);
  56544. this.isReady = true;
  56545. return;
  56546. case InternalTexture.DATASOURCE_DYNAMIC:
  56547. proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
  56548. proxy._swapAndDie(this);
  56549. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);
  56550. // The engine will make sure to update content so no need to flag it as isReady = true
  56551. return;
  56552. case InternalTexture.DATASOURCE_RENDERTARGET:
  56553. var options = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__["RenderTargetCreationOptions"]();
  56554. options.generateDepthBuffer = this._generateDepthBuffer;
  56555. options.generateMipMaps = this.generateMipMaps;
  56556. options.generateStencilBuffer = this._generateStencilBuffer;
  56557. options.samplingMode = this.samplingMode;
  56558. options.type = this.type;
  56559. if (this.isCube) {
  56560. proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
  56561. }
  56562. else {
  56563. var size = {
  56564. width: this.width,
  56565. height: this.height
  56566. };
  56567. proxy = this._engine.createRenderTargetTexture(size, options);
  56568. }
  56569. proxy._swapAndDie(this);
  56570. this.isReady = true;
  56571. return;
  56572. case InternalTexture.DATASOURCE_DEPTHTEXTURE:
  56573. var depthTextureOptions = {
  56574. bilinearFiltering: this.samplingMode !== _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  56575. comparisonFunction: this._comparisonFunction,
  56576. generateStencil: this._generateStencilBuffer,
  56577. isCube: this.isCube
  56578. };
  56579. proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
  56580. proxy._swapAndDie(this);
  56581. this.isReady = true;
  56582. return;
  56583. case InternalTexture.DATASOURCE_CUBE:
  56584. proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
  56585. proxy._swapAndDie(_this);
  56586. _this.isReady = true;
  56587. }, null, this.format, this._extension);
  56588. return;
  56589. case InternalTexture.DATASOURCE_CUBERAW:
  56590. proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56591. proxy._swapAndDie(this);
  56592. this.isReady = true;
  56593. return;
  56594. case InternalTexture.DATASOURCE_CUBERAW_RGBD:
  56595. proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56596. InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {
  56597. proxy._swapAndDie(_this);
  56598. _this.isReady = true;
  56599. });
  56600. return;
  56601. case InternalTexture.DATASOURCE_CUBEPREFILTERED:
  56602. proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {
  56603. if (proxy) {
  56604. proxy._swapAndDie(_this);
  56605. }
  56606. _this.isReady = true;
  56607. }, null, this.format, this._extension);
  56608. proxy._sphericalPolynomial = this._sphericalPolynomial;
  56609. return;
  56610. }
  56611. };
  56612. /** @hidden */
  56613. InternalTexture.prototype._swapAndDie = function (target) {
  56614. target._webGLTexture = this._webGLTexture;
  56615. if (this._framebuffer) {
  56616. target._framebuffer = this._framebuffer;
  56617. }
  56618. if (this._depthStencilBuffer) {
  56619. target._depthStencilBuffer = this._depthStencilBuffer;
  56620. }
  56621. if (this._lodTextureHigh) {
  56622. if (target._lodTextureHigh) {
  56623. target._lodTextureHigh.dispose();
  56624. }
  56625. target._lodTextureHigh = this._lodTextureHigh;
  56626. }
  56627. if (this._lodTextureMid) {
  56628. if (target._lodTextureMid) {
  56629. target._lodTextureMid.dispose();
  56630. }
  56631. target._lodTextureMid = this._lodTextureMid;
  56632. }
  56633. if (this._lodTextureLow) {
  56634. if (target._lodTextureLow) {
  56635. target._lodTextureLow.dispose();
  56636. }
  56637. target._lodTextureLow = this._lodTextureLow;
  56638. }
  56639. var cache = this._engine.getLoadedTexturesCache();
  56640. var index = cache.indexOf(this);
  56641. if (index !== -1) {
  56642. cache.splice(index, 1);
  56643. }
  56644. };
  56645. /**
  56646. * Dispose the current allocated resources
  56647. */
  56648. InternalTexture.prototype.dispose = function () {
  56649. if (!this._webGLTexture) {
  56650. return;
  56651. }
  56652. this._references--;
  56653. if (this._references === 0) {
  56654. this._engine._releaseTexture(this);
  56655. this._webGLTexture = null;
  56656. this.previous = null;
  56657. this.next = null;
  56658. }
  56659. };
  56660. /** hidden */
  56661. InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  56662. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("environmentTextureTools");
  56663. };
  56664. /**
  56665. * The source of the texture data is unknown
  56666. */
  56667. InternalTexture.DATASOURCE_UNKNOWN = 0;
  56668. /**
  56669. * Texture data comes from an URL
  56670. */
  56671. InternalTexture.DATASOURCE_URL = 1;
  56672. /**
  56673. * Texture data is only used for temporary storage
  56674. */
  56675. InternalTexture.DATASOURCE_TEMP = 2;
  56676. /**
  56677. * Texture data comes from raw data (ArrayBuffer)
  56678. */
  56679. InternalTexture.DATASOURCE_RAW = 3;
  56680. /**
  56681. * Texture content is dynamic (video or dynamic texture)
  56682. */
  56683. InternalTexture.DATASOURCE_DYNAMIC = 4;
  56684. /**
  56685. * Texture content is generated by rendering to it
  56686. */
  56687. InternalTexture.DATASOURCE_RENDERTARGET = 5;
  56688. /**
  56689. * Texture content is part of a multi render target process
  56690. */
  56691. InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
  56692. /**
  56693. * Texture data comes from a cube data file
  56694. */
  56695. InternalTexture.DATASOURCE_CUBE = 7;
  56696. /**
  56697. * Texture data comes from a raw cube data
  56698. */
  56699. InternalTexture.DATASOURCE_CUBERAW = 8;
  56700. /**
  56701. * Texture data come from a prefiltered cube data file
  56702. */
  56703. InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
  56704. /**
  56705. * Texture content is raw 3D data
  56706. */
  56707. InternalTexture.DATASOURCE_RAW3D = 10;
  56708. /**
  56709. * Texture content is a depth texture
  56710. */
  56711. InternalTexture.DATASOURCE_DEPTHTEXTURE = 11;
  56712. /**
  56713. * Texture data comes from a raw cube data encoded with RGBD
  56714. */
  56715. InternalTexture.DATASOURCE_CUBERAW_RGBD = 12;
  56716. return InternalTexture;
  56717. }());
  56718. /***/ }),
  56719. /***/ "./Materials/Textures/internalTextureTracker.ts":
  56720. /*!******************************************************!*\
  56721. !*** ./Materials/Textures/internalTextureTracker.ts ***!
  56722. \******************************************************/
  56723. /*! exports provided: DummyInternalTextureTracker */
  56724. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56725. "use strict";
  56726. __webpack_require__.r(__webpack_exports__);
  56727. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return DummyInternalTextureTracker; });
  56728. /**
  56729. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  56730. */
  56731. var DummyInternalTextureTracker = /** @class */ (function () {
  56732. function DummyInternalTextureTracker() {
  56733. /**
  56734. * Gets or set the previous tracker in the list
  56735. */
  56736. this.previous = null;
  56737. /**
  56738. * Gets or set the next tracker in the list
  56739. */
  56740. this.next = null;
  56741. }
  56742. return DummyInternalTextureTracker;
  56743. }());
  56744. /***/ }),
  56745. /***/ "./Materials/Textures/mirrorTexture.ts":
  56746. /*!*********************************************!*\
  56747. !*** ./Materials/Textures/mirrorTexture.ts ***!
  56748. \*********************************************/
  56749. /*! exports provided: MirrorTexture */
  56750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56751. "use strict";
  56752. __webpack_require__.r(__webpack_exports__);
  56753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return MirrorTexture; });
  56754. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56755. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56756. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56757. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56758. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  56759. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56760. /**
  56761. * Mirror texture can be used to simulate the view from a mirror in a scene.
  56762. * It will dynamically be rendered every frame to adapt to the camera point of view.
  56763. * You can then easily use it as a reflectionTexture on a flat surface.
  56764. * In case the surface is not a plane, please consider relying on reflection probes.
  56765. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  56766. */
  56767. var MirrorTexture = /** @class */ (function (_super) {
  56768. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MirrorTexture, _super);
  56769. /**
  56770. * Instantiates a Mirror Texture.
  56771. * Mirror texture can be used to simulate the view from a mirror in a scene.
  56772. * It will dynamically be rendered every frame to adapt to the camera point of view.
  56773. * You can then easily use it as a reflectionTexture on a flat surface.
  56774. * In case the surface is not a plane, please consider relying on reflection probes.
  56775. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  56776. * @param name
  56777. * @param size
  56778. * @param scene
  56779. * @param generateMipMaps
  56780. * @param type
  56781. * @param samplingMode
  56782. * @param generateDepthBuffer
  56783. */
  56784. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  56785. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56786. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  56787. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  56788. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  56789. _this.scene = scene;
  56790. /**
  56791. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  56792. * 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.
  56793. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  56794. */
  56795. _this.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  56796. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  56797. _this._mirrorMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  56798. _this._adaptiveBlurKernel = 0;
  56799. _this._blurKernelX = 0;
  56800. _this._blurKernelY = 0;
  56801. _this._blurRatio = 1.0;
  56802. _this.ignoreCameraViewport = true;
  56803. _this._updateGammaSpace();
  56804. _this._imageProcessingConfigChangeObserver = scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  56805. _this._updateGammaSpace;
  56806. });
  56807. _this.onBeforeRenderObservable.add(function () {
  56808. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  56809. _this._savedViewMatrix = scene.getViewMatrix();
  56810. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  56811. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  56812. scene.clipPlane = _this.mirrorPlane;
  56813. scene.getEngine().cullBackFaces = false;
  56814. scene._mirroredCameraPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  56815. });
  56816. _this.onAfterRenderObservable.add(function () {
  56817. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  56818. scene.getEngine().cullBackFaces = true;
  56819. scene._mirroredCameraPosition = null;
  56820. delete scene.clipPlane;
  56821. });
  56822. return _this;
  56823. }
  56824. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  56825. get: function () {
  56826. return this._blurRatio;
  56827. },
  56828. /**
  56829. * Define the blur ratio used to blur the reflection if needed.
  56830. */
  56831. set: function (value) {
  56832. if (this._blurRatio === value) {
  56833. return;
  56834. }
  56835. this._blurRatio = value;
  56836. this._preparePostProcesses();
  56837. },
  56838. enumerable: true,
  56839. configurable: true
  56840. });
  56841. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  56842. /**
  56843. * Define the adaptive blur kernel used to blur the reflection if needed.
  56844. * This will autocompute the closest best match for the `blurKernel`
  56845. */
  56846. set: function (value) {
  56847. this._adaptiveBlurKernel = value;
  56848. this._autoComputeBlurKernel();
  56849. },
  56850. enumerable: true,
  56851. configurable: true
  56852. });
  56853. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  56854. /**
  56855. * Define the blur kernel used to blur the reflection if needed.
  56856. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56857. */
  56858. set: function (value) {
  56859. this.blurKernelX = value;
  56860. this.blurKernelY = value;
  56861. },
  56862. enumerable: true,
  56863. configurable: true
  56864. });
  56865. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  56866. get: function () {
  56867. return this._blurKernelX;
  56868. },
  56869. /**
  56870. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  56871. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56872. */
  56873. set: function (value) {
  56874. if (this._blurKernelX === value) {
  56875. return;
  56876. }
  56877. this._blurKernelX = value;
  56878. this._preparePostProcesses();
  56879. },
  56880. enumerable: true,
  56881. configurable: true
  56882. });
  56883. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  56884. get: function () {
  56885. return this._blurKernelY;
  56886. },
  56887. /**
  56888. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  56889. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56890. */
  56891. set: function (value) {
  56892. if (this._blurKernelY === value) {
  56893. return;
  56894. }
  56895. this._blurKernelY = value;
  56896. this._preparePostProcesses();
  56897. },
  56898. enumerable: true,
  56899. configurable: true
  56900. });
  56901. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  56902. var engine = this.getScene().getEngine();
  56903. var dw = this.getRenderWidth() / engine.getRenderWidth();
  56904. var dh = this.getRenderHeight() / engine.getRenderHeight();
  56905. this.blurKernelX = this._adaptiveBlurKernel * dw;
  56906. this.blurKernelY = this._adaptiveBlurKernel * dh;
  56907. };
  56908. MirrorTexture.prototype._onRatioRescale = function () {
  56909. if (this._sizeRatio) {
  56910. this.resize(this._initialSizeParameter);
  56911. if (!this._adaptiveBlurKernel) {
  56912. this._preparePostProcesses();
  56913. }
  56914. }
  56915. if (this._adaptiveBlurKernel) {
  56916. this._autoComputeBlurKernel();
  56917. }
  56918. };
  56919. MirrorTexture.prototype._updateGammaSpace = function () {
  56920. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
  56921. };
  56922. MirrorTexture.prototype._preparePostProcesses = function () {
  56923. this.clearPostProcesses(true);
  56924. if (this._blurKernelX && this._blurKernelY) {
  56925. var engine = this.getScene().getEngine();
  56926. var textureType = engine.getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_HALF_FLOAT;
  56927. 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);
  56928. this._blurX.autoClear = false;
  56929. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  56930. this._blurX.inputTexture = this._texture;
  56931. }
  56932. else {
  56933. this._blurX.alwaysForcePOT = true;
  56934. }
  56935. 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);
  56936. this._blurY.autoClear = false;
  56937. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  56938. this.addPostProcess(this._blurX);
  56939. this.addPostProcess(this._blurY);
  56940. }
  56941. else {
  56942. if (this._blurY) {
  56943. this.removePostProcess(this._blurY);
  56944. this._blurY.dispose();
  56945. this._blurY = null;
  56946. }
  56947. if (this._blurX) {
  56948. this.removePostProcess(this._blurX);
  56949. this._blurX.dispose();
  56950. this._blurX = null;
  56951. }
  56952. }
  56953. };
  56954. /**
  56955. * Clone the mirror texture.
  56956. * @returns the cloned texture
  56957. */
  56958. MirrorTexture.prototype.clone = function () {
  56959. var scene = this.getScene();
  56960. if (!scene) {
  56961. return this;
  56962. }
  56963. var textureSize = this.getSize();
  56964. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  56965. // Base texture
  56966. newTexture.hasAlpha = this.hasAlpha;
  56967. newTexture.level = this.level;
  56968. // Mirror Texture
  56969. newTexture.mirrorPlane = this.mirrorPlane.clone();
  56970. if (this.renderList) {
  56971. newTexture.renderList = this.renderList.slice(0);
  56972. }
  56973. return newTexture;
  56974. };
  56975. /**
  56976. * Serialize the texture to a JSON representation you could use in Parse later on
  56977. * @returns the serialized JSON representation
  56978. */
  56979. MirrorTexture.prototype.serialize = function () {
  56980. if (!this.name) {
  56981. return null;
  56982. }
  56983. var serializationObject = _super.prototype.serialize.call(this);
  56984. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  56985. return serializationObject;
  56986. };
  56987. /**
  56988. * Dispose the texture and release its associated resources.
  56989. */
  56990. MirrorTexture.prototype.dispose = function () {
  56991. _super.prototype.dispose.call(this);
  56992. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
  56993. };
  56994. return MirrorTexture;
  56995. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]));
  56996. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  56997. return new MirrorTexture(name, renderTargetSize, scene, generateMipMaps);
  56998. };
  56999. /***/ }),
  57000. /***/ "./Materials/Textures/multiRenderTarget.ts":
  57001. /*!*************************************************!*\
  57002. !*** ./Materials/Textures/multiRenderTarget.ts ***!
  57003. \*************************************************/
  57004. /*! exports provided: MultiRenderTarget */
  57005. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57006. "use strict";
  57007. __webpack_require__.r(__webpack_exports__);
  57008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return MultiRenderTarget; });
  57009. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57010. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57011. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  57012. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57013. /**
  57014. * A multi render target, like a render target provides the ability to render to a texture.
  57015. * Unlike the render target, it can render to several draw buffers in one draw.
  57016. * This is specially interesting in deferred rendering or for any effects requiring more than
  57017. * just one color from a single pass.
  57018. */
  57019. var MultiRenderTarget = /** @class */ (function (_super) {
  57020. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiRenderTarget, _super);
  57021. /**
  57022. * Instantiate a new multi render target texture.
  57023. * A multi render target, like a render target provides the ability to render to a texture.
  57024. * Unlike the render target, it can render to several draw buffers in one draw.
  57025. * This is specially interesting in deferred rendering or for any effects requiring more than
  57026. * just one color from a single pass.
  57027. * @param name Define the name of the texture
  57028. * @param size Define the size of the buffers to render to
  57029. * @param count Define the number of target we are rendering into
  57030. * @param scene Define the scene the texture belongs to
  57031. * @param options Define the options used to create the multi render target
  57032. */
  57033. function MultiRenderTarget(name, size, count, scene, options) {
  57034. var _this = this;
  57035. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  57036. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  57037. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  57038. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  57039. _this._engine = scene.getEngine();
  57040. if (!_this.isSupported) {
  57041. _this.dispose();
  57042. return;
  57043. }
  57044. var types = [];
  57045. var samplingModes = [];
  57046. for (var i = 0; i < count; i++) {
  57047. if (options && options.types && options.types[i] !== undefined) {
  57048. types.push(options.types[i]);
  57049. }
  57050. else {
  57051. types.push(options && options.defaultType ? options.defaultType : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  57052. }
  57053. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  57054. samplingModes.push(options.samplingModes[i]);
  57055. }
  57056. else {
  57057. samplingModes.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  57058. }
  57059. }
  57060. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  57061. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  57062. _this._size = size;
  57063. _this._multiRenderTargetOptions = {
  57064. samplingModes: samplingModes,
  57065. generateMipMaps: generateMipMaps,
  57066. generateDepthBuffer: generateDepthBuffer,
  57067. generateStencilBuffer: generateStencilBuffer,
  57068. generateDepthTexture: generateDepthTexture,
  57069. types: types,
  57070. textureCount: count
  57071. };
  57072. _this._createInternalTextures();
  57073. _this._createTextures();
  57074. return _this;
  57075. }
  57076. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  57077. /**
  57078. * Get if draw buffers are currently supported by the used hardware and browser.
  57079. */
  57080. get: function () {
  57081. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  57082. },
  57083. enumerable: true,
  57084. configurable: true
  57085. });
  57086. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  57087. /**
  57088. * Get the list of textures generated by the multi render target.
  57089. */
  57090. get: function () {
  57091. return this._textures;
  57092. },
  57093. enumerable: true,
  57094. configurable: true
  57095. });
  57096. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  57097. /**
  57098. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  57099. */
  57100. get: function () {
  57101. return this._textures[this._textures.length - 1];
  57102. },
  57103. enumerable: true,
  57104. configurable: true
  57105. });
  57106. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  57107. /**
  57108. * Set the wrapping mode on U of all the textures we are rendering to.
  57109. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  57110. */
  57111. set: function (wrap) {
  57112. if (this._textures) {
  57113. for (var i = 0; i < this._textures.length; i++) {
  57114. this._textures[i].wrapU = wrap;
  57115. }
  57116. }
  57117. },
  57118. enumerable: true,
  57119. configurable: true
  57120. });
  57121. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  57122. /**
  57123. * Set the wrapping mode on V of all the textures we are rendering to.
  57124. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  57125. */
  57126. set: function (wrap) {
  57127. if (this._textures) {
  57128. for (var i = 0; i < this._textures.length; i++) {
  57129. this._textures[i].wrapV = wrap;
  57130. }
  57131. }
  57132. },
  57133. enumerable: true,
  57134. configurable: true
  57135. });
  57136. /** @hidden */
  57137. MultiRenderTarget.prototype._rebuild = function () {
  57138. this.releaseInternalTextures();
  57139. this._createInternalTextures();
  57140. for (var i = 0; i < this._internalTextures.length; i++) {
  57141. var texture = this._textures[i];
  57142. texture._texture = this._internalTextures[i];
  57143. }
  57144. // Keeps references to frame buffer and stencil/depth buffer
  57145. this._texture = this._internalTextures[0];
  57146. };
  57147. MultiRenderTarget.prototype._createInternalTextures = function () {
  57148. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  57149. };
  57150. MultiRenderTarget.prototype._createTextures = function () {
  57151. this._textures = [];
  57152. for (var i = 0; i < this._internalTextures.length; i++) {
  57153. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](null, this.getScene());
  57154. texture._texture = this._internalTextures[i];
  57155. this._textures.push(texture);
  57156. }
  57157. // Keeps references to frame buffer and stencil/depth buffer
  57158. this._texture = this._internalTextures[0];
  57159. };
  57160. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  57161. /**
  57162. * Define the number of samples used if MSAA is enabled.
  57163. */
  57164. get: function () {
  57165. return this._samples;
  57166. },
  57167. set: function (value) {
  57168. if (this._samples === value) {
  57169. return;
  57170. }
  57171. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  57172. },
  57173. enumerable: true,
  57174. configurable: true
  57175. });
  57176. /**
  57177. * Resize all the textures in the multi render target.
  57178. * Be carrefull as it will recreate all the data in the new texture.
  57179. * @param size Define the new size
  57180. */
  57181. MultiRenderTarget.prototype.resize = function (size) {
  57182. this.releaseInternalTextures();
  57183. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  57184. this._createInternalTextures();
  57185. };
  57186. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  57187. var _this = this;
  57188. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  57189. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  57190. });
  57191. };
  57192. /**
  57193. * Dispose the render targets and their associated resources
  57194. */
  57195. MultiRenderTarget.prototype.dispose = function () {
  57196. this.releaseInternalTextures();
  57197. _super.prototype.dispose.call(this);
  57198. };
  57199. /**
  57200. * Release all the underlying texture used as draw buffers.
  57201. */
  57202. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  57203. if (!this._internalTextures) {
  57204. return;
  57205. }
  57206. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  57207. if (this._internalTextures[i] !== undefined) {
  57208. this._internalTextures[i].dispose();
  57209. this._internalTextures.splice(i, 1);
  57210. }
  57211. }
  57212. };
  57213. return MultiRenderTarget;
  57214. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  57215. /***/ }),
  57216. /***/ "./Materials/Textures/rawCubeTexture.ts":
  57217. /*!**********************************************!*\
  57218. !*** ./Materials/Textures/rawCubeTexture.ts ***!
  57219. \**********************************************/
  57220. /*! exports provided: RawCubeTexture */
  57221. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57222. "use strict";
  57223. __webpack_require__.r(__webpack_exports__);
  57224. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return RawCubeTexture; });
  57225. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57226. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  57227. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  57228. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  57229. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  57230. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57231. /**
  57232. * Raw cube texture where the raw buffers are passed in
  57233. */
  57234. var RawCubeTexture = /** @class */ (function (_super) {
  57235. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawCubeTexture, _super);
  57236. /**
  57237. * Creates a cube texture where the raw buffers are passed in.
  57238. * @param scene defines the scene the texture is attached to
  57239. * @param data defines the array of data to use to create each face
  57240. * @param size defines the size of the textures
  57241. * @param format defines the format of the data
  57242. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57243. * @param generateMipMaps defines if the engine should generate the mip levels
  57244. * @param invertY defines if data must be stored with Y axis inverted
  57245. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57246. * @param compression defines the compression used (null by default)
  57247. */
  57248. function RawCubeTexture(scene, data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  57249. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  57250. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57251. if (generateMipMaps === void 0) { generateMipMaps = false; }
  57252. if (invertY === void 0) { invertY = false; }
  57253. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57254. if (compression === void 0) { compression = null; }
  57255. var _this = _super.call(this, "", scene) || this;
  57256. _this._texture = scene.getEngine().createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression);
  57257. return _this;
  57258. }
  57259. /**
  57260. * Updates the raw cube texture.
  57261. * @param data defines the data to store
  57262. * @param format defines the data format
  57263. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57264. * @param invertY defines if data must be stored with Y axis inverted
  57265. * @param compression defines the compression used (null by default)
  57266. * @param level defines which level of the texture to update
  57267. */
  57268. RawCubeTexture.prototype.update = function (data, format, type, invertY, compression) {
  57269. if (compression === void 0) { compression = null; }
  57270. this._texture.getEngine().updateRawCubeTexture(this._texture, data, format, type, invertY, compression);
  57271. };
  57272. /**
  57273. * Updates a raw cube texture with RGBD encoded data.
  57274. * @param data defines the array of data [mipmap][face] to use to create each face
  57275. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57276. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57277. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57278. * @returns a promsie that resolves when the operation is complete
  57279. */
  57280. RawCubeTexture.prototype.updateRGBDAsync = function (data, sphericalPolynomial, lodScale, lodOffset) {
  57281. if (sphericalPolynomial === void 0) { sphericalPolynomial = null; }
  57282. if (lodScale === void 0) { lodScale = 0.8; }
  57283. if (lodOffset === void 0) { lodOffset = 0; }
  57284. return RawCubeTexture._UpdateRGBDAsync(this._texture, data, sphericalPolynomial, lodScale, lodOffset);
  57285. };
  57286. /**
  57287. * Clones the raw cube texture.
  57288. * @return a new cube texture
  57289. */
  57290. RawCubeTexture.prototype.clone = function () {
  57291. var _this = this;
  57292. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  57293. var scene = _this.getScene();
  57294. var internalTexture = _this._texture;
  57295. var texture = new RawCubeTexture(scene, internalTexture._bufferViewArray, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
  57296. if (internalTexture.dataSource === _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD) {
  57297. texture.updateRGBDAsync(internalTexture._bufferViewArrayArray, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
  57298. }
  57299. return texture;
  57300. }, this);
  57301. };
  57302. /** @hidden */
  57303. RawCubeTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  57304. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  57305. internalTexture._bufferViewArrayArray = data;
  57306. internalTexture._lodGenerationScale = lodScale;
  57307. internalTexture._lodGenerationOffset = lodOffset;
  57308. internalTexture._sphericalPolynomial = sphericalPolynomial;
  57309. return _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__["EnvironmentTextureTools"].UploadLevelsAsync(internalTexture, data).then(function () {
  57310. internalTexture.isReady = true;
  57311. });
  57312. };
  57313. return RawCubeTexture;
  57314. }(_Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__["CubeTexture"]));
  57315. /***/ }),
  57316. /***/ "./Materials/Textures/rawTexture.ts":
  57317. /*!******************************************!*\
  57318. !*** ./Materials/Textures/rawTexture.ts ***!
  57319. \******************************************/
  57320. /*! exports provided: RawTexture */
  57321. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57322. "use strict";
  57323. __webpack_require__.r(__webpack_exports__);
  57324. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return RawTexture; });
  57325. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57326. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57327. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57328. /**
  57329. * Raw texture can help creating a texture directly from an array of data.
  57330. * This can be super useful if you either get the data from an uncompressed source or
  57331. * if you wish to create your texture pixel by pixel.
  57332. */
  57333. var RawTexture = /** @class */ (function (_super) {
  57334. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture, _super);
  57335. /**
  57336. * Instantiates a new RawTexture.
  57337. * Raw texture can help creating a texture directly from an array of data.
  57338. * This can be super useful if you either get the data from an uncompressed source or
  57339. * if you wish to create your texture pixel by pixel.
  57340. * @param data define the array of data to use to create the texture
  57341. * @param width define the width of the texture
  57342. * @param height define the height of the texture
  57343. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  57344. * @param scene define the scene the texture belongs to
  57345. * @param generateMipMaps define whether mip maps should be generated or not
  57346. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57347. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57348. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57349. */
  57350. function RawTexture(data, width, height,
  57351. /**
  57352. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  57353. */
  57354. format, scene, generateMipMaps, invertY, samplingMode, type) {
  57355. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57356. if (invertY === void 0) { invertY = false; }
  57357. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57358. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57359. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  57360. _this.format = format;
  57361. _this._engine = scene.getEngine();
  57362. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  57363. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  57364. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  57365. return _this;
  57366. }
  57367. /**
  57368. * Updates the texture underlying data.
  57369. * @param data Define the new data of the texture
  57370. */
  57371. RawTexture.prototype.update = function (data) {
  57372. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  57373. };
  57374. /**
  57375. * Creates a luminance texture from some data.
  57376. * @param data Define the texture data
  57377. * @param width Define the width of the texture
  57378. * @param height Define the height of the texture
  57379. * @param scene Define the scene the texture belongs to
  57380. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57381. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57382. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57383. * @returns the luminance texture
  57384. */
  57385. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  57386. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57387. if (invertY === void 0) { invertY = false; }
  57388. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57389. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  57390. };
  57391. /**
  57392. * Creates a luminance alpha texture from some data.
  57393. * @param data Define the texture data
  57394. * @param width Define the width of the texture
  57395. * @param height Define the height of the texture
  57396. * @param scene Define the scene the texture belongs to
  57397. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57398. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57399. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57400. * @returns the luminance alpha texture
  57401. */
  57402. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  57403. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57404. if (invertY === void 0) { invertY = false; }
  57405. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57406. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  57407. };
  57408. /**
  57409. * Creates an alpha texture from some data.
  57410. * @param data Define the texture data
  57411. * @param width Define the width of the texture
  57412. * @param height Define the height of the texture
  57413. * @param scene Define the scene the texture belongs to
  57414. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57415. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57416. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57417. * @returns the alpha texture
  57418. */
  57419. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  57420. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57421. if (invertY === void 0) { invertY = false; }
  57422. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57423. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  57424. };
  57425. /**
  57426. * Creates a RGB texture from some data.
  57427. * @param data Define the texture data
  57428. * @param width Define the width of the texture
  57429. * @param height Define the height of the texture
  57430. * @param scene Define the scene the texture belongs to
  57431. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57432. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57433. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57434. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57435. * @returns the RGB alpha texture
  57436. */
  57437. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  57438. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57439. if (invertY === void 0) { invertY = false; }
  57440. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57441. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57442. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  57443. };
  57444. /**
  57445. * Creates a RGBA texture from some data.
  57446. * @param data Define the texture data
  57447. * @param width Define the width of the texture
  57448. * @param height Define the height of the texture
  57449. * @param scene Define the scene the texture belongs to
  57450. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57451. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57452. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57453. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57454. * @returns the RGBA texture
  57455. */
  57456. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  57457. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57458. if (invertY === void 0) { invertY = false; }
  57459. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57460. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57461. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  57462. };
  57463. /**
  57464. * Creates a R texture from some data.
  57465. * @param data Define the texture data
  57466. * @param width Define the width of the texture
  57467. * @param height Define the height of the texture
  57468. * @param scene Define the scene the texture belongs to
  57469. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57470. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57471. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57472. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57473. * @returns the R texture
  57474. */
  57475. RawTexture.CreateRTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  57476. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57477. if (invertY === void 0) { invertY = false; }
  57478. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  57479. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT; }
  57480. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
  57481. };
  57482. return RawTexture;
  57483. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  57484. /***/ }),
  57485. /***/ "./Materials/Textures/rawTexture3D.ts":
  57486. /*!********************************************!*\
  57487. !*** ./Materials/Textures/rawTexture3D.ts ***!
  57488. \********************************************/
  57489. /*! exports provided: RawTexture3D */
  57490. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57491. "use strict";
  57492. __webpack_require__.r(__webpack_exports__);
  57493. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return RawTexture3D; });
  57494. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57495. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57496. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57497. /**
  57498. * Class used to store 3D textures containing user data
  57499. */
  57500. var RawTexture3D = /** @class */ (function (_super) {
  57501. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture3D, _super);
  57502. /**
  57503. * Create a new RawTexture3D
  57504. * @param data defines the data of the texture
  57505. * @param width defines the width of the texture
  57506. * @param height defines the height of the texture
  57507. * @param depth defines the depth of the texture
  57508. * @param format defines the texture format to use
  57509. * @param scene defines the hosting scene
  57510. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57511. * @param invertY defines if texture must be stored with Y axis inverted
  57512. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57513. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57514. */
  57515. function RawTexture3D(data, width, height, depth,
  57516. /** Gets or sets the texture format to use */
  57517. format, scene, generateMipMaps, invertY, samplingMode, textureType) {
  57518. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57519. if (invertY === void 0) { invertY = false; }
  57520. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  57521. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57522. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  57523. _this.format = format;
  57524. _this._engine = scene.getEngine();
  57525. _this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, undefined, textureType);
  57526. _this.is3D = true;
  57527. return _this;
  57528. }
  57529. /**
  57530. * Update the texture with new data
  57531. * @param data defines the data to store in the texture
  57532. */
  57533. RawTexture3D.prototype.update = function (data) {
  57534. if (!this._texture) {
  57535. return;
  57536. }
  57537. this._engine.updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  57538. };
  57539. return RawTexture3D;
  57540. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  57541. /***/ }),
  57542. /***/ "./Materials/Textures/refractionTexture.ts":
  57543. /*!*************************************************!*\
  57544. !*** ./Materials/Textures/refractionTexture.ts ***!
  57545. \*************************************************/
  57546. /*! exports provided: RefractionTexture */
  57547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57548. "use strict";
  57549. __webpack_require__.r(__webpack_exports__);
  57550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return RefractionTexture; });
  57551. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57552. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57553. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  57554. /**
  57555. * Creates a refraction texture used by refraction channel of the standard material.
  57556. * It is like a mirror but to see through a material.
  57557. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57558. */
  57559. var RefractionTexture = /** @class */ (function (_super) {
  57560. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionTexture, _super);
  57561. /**
  57562. * Creates a refraction texture used by refraction channel of the standard material.
  57563. * It is like a mirror but to see through a material.
  57564. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57565. * @param name Define the texture name
  57566. * @param size Define the size of the underlying texture
  57567. * @param scene Define the scene the refraction belongs to
  57568. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57569. */
  57570. function RefractionTexture(name, size, scene, generateMipMaps) {
  57571. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  57572. /**
  57573. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57574. * 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.
  57575. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57576. */
  57577. _this.refractionPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  57578. /**
  57579. * Define how deep under the surface we should see.
  57580. */
  57581. _this.depth = 2.0;
  57582. _this.onBeforeRenderObservable.add(function () {
  57583. scene.clipPlane = _this.refractionPlane;
  57584. });
  57585. _this.onAfterRenderObservable.add(function () {
  57586. delete scene.clipPlane;
  57587. });
  57588. return _this;
  57589. }
  57590. /**
  57591. * Clone the refraction texture.
  57592. * @returns the cloned texture
  57593. */
  57594. RefractionTexture.prototype.clone = function () {
  57595. var scene = this.getScene();
  57596. if (!scene) {
  57597. return this;
  57598. }
  57599. var textureSize = this.getSize();
  57600. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  57601. // Base texture
  57602. newTexture.hasAlpha = this.hasAlpha;
  57603. newTexture.level = this.level;
  57604. // Refraction Texture
  57605. newTexture.refractionPlane = this.refractionPlane.clone();
  57606. if (this.renderList) {
  57607. newTexture.renderList = this.renderList.slice(0);
  57608. }
  57609. newTexture.depth = this.depth;
  57610. return newTexture;
  57611. };
  57612. /**
  57613. * Serialize the texture to a JSON representation you could use in Parse later on
  57614. * @returns the serialized JSON representation
  57615. */
  57616. RefractionTexture.prototype.serialize = function () {
  57617. if (!this.name) {
  57618. return null;
  57619. }
  57620. var serializationObject = _super.prototype.serialize.call(this);
  57621. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  57622. serializationObject.depth = this.depth;
  57623. return serializationObject;
  57624. };
  57625. return RefractionTexture;
  57626. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  57627. /***/ }),
  57628. /***/ "./Materials/Textures/renderTargetCreationOptions.ts":
  57629. /*!***********************************************************!*\
  57630. !*** ./Materials/Textures/renderTargetCreationOptions.ts ***!
  57631. \***********************************************************/
  57632. /*! exports provided: RenderTargetCreationOptions */
  57633. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57634. "use strict";
  57635. __webpack_require__.r(__webpack_exports__);
  57636. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetCreationOptions", function() { return RenderTargetCreationOptions; });
  57637. /**
  57638. * Define options used to create a render target texture
  57639. */
  57640. var RenderTargetCreationOptions = /** @class */ (function () {
  57641. function RenderTargetCreationOptions() {
  57642. }
  57643. return RenderTargetCreationOptions;
  57644. }());
  57645. /***/ }),
  57646. /***/ "./Materials/Textures/renderTargetTexture.ts":
  57647. /*!***************************************************!*\
  57648. !*** ./Materials/Textures/renderTargetTexture.ts ***!
  57649. \***************************************************/
  57650. /*! exports provided: RenderTargetTexture */
  57651. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57652. "use strict";
  57653. __webpack_require__.r(__webpack_exports__);
  57654. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return RenderTargetTexture; });
  57655. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57656. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  57657. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  57658. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57659. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57660. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  57661. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  57662. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57663. /**
  57664. * This Helps creating a texture that will be created from a camera in your scene.
  57665. * It is basically a dynamic texture that could be used to create special effects for instance.
  57666. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  57667. */
  57668. var RenderTargetTexture = /** @class */ (function (_super) {
  57669. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetTexture, _super);
  57670. /**
  57671. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  57672. * or used a shadow, depth texture...
  57673. * @param name The friendly name of the texture
  57674. * @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)
  57675. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  57676. * @param generateMipMaps True if mip maps need to be generated after render.
  57677. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  57678. * @param type The type of the buffer in the RTT (int, half float, float...)
  57679. * @param isCube True if a cube texture needs to be created
  57680. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  57681. * @param generateDepthBuffer True to generate a depth buffer
  57682. * @param generateStencilBuffer True to generate a stencil buffer
  57683. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  57684. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  57685. * @param delayAllocation if the texture allocation should be delayed (default: false)
  57686. */
  57687. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
  57688. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  57689. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57690. if (isCube === void 0) { isCube = false; }
  57691. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  57692. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  57693. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  57694. if (isMulti === void 0) { isMulti = false; }
  57695. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  57696. if (delayAllocation === void 0) { delayAllocation = false; }
  57697. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  57698. _this.isCube = isCube;
  57699. /**
  57700. * Define if particles should be rendered in your texture.
  57701. */
  57702. _this.renderParticles = true;
  57703. /**
  57704. * Define if sprites should be rendered in your texture.
  57705. */
  57706. _this.renderSprites = false;
  57707. /**
  57708. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  57709. */
  57710. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].PROJECTION_MODE;
  57711. /**
  57712. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  57713. */
  57714. _this.ignoreCameraViewport = false;
  57715. /**
  57716. * An event triggered when the texture is unbind.
  57717. */
  57718. _this.onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57719. /**
  57720. * An event triggered when the texture is unbind.
  57721. */
  57722. _this.onAfterUnbindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57723. /**
  57724. * An event triggered before rendering the texture
  57725. */
  57726. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57727. /**
  57728. * An event triggered after rendering the texture
  57729. */
  57730. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57731. /**
  57732. * An event triggered after the texture clear
  57733. */
  57734. _this.onClearObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  57735. _this._currentRefreshId = -1;
  57736. _this._refreshRate = 1;
  57737. _this._samples = 1;
  57738. /**
  57739. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  57740. * It must define where the camera used to render the texture is set
  57741. */
  57742. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  57743. scene = _this.getScene();
  57744. if (!scene) {
  57745. return _this;
  57746. }
  57747. _this.renderList = new Array();
  57748. _this._engine = scene.getEngine();
  57749. _this.name = name;
  57750. _this.isRenderTarget = true;
  57751. _this._initialSizeParameter = size;
  57752. _this._processSizeParameter(size);
  57753. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  57754. });
  57755. _this._generateMipMaps = generateMipMaps ? true : false;
  57756. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  57757. // Rendering groups
  57758. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__["RenderingManager"](scene);
  57759. _this._renderingManager._useSceneAutoClearSetup = true;
  57760. if (isMulti) {
  57761. return _this;
  57762. }
  57763. _this._renderTargetOptions = {
  57764. generateMipMaps: generateMipMaps,
  57765. type: type,
  57766. format: format,
  57767. samplingMode: samplingMode,
  57768. generateDepthBuffer: generateDepthBuffer,
  57769. generateStencilBuffer: generateStencilBuffer
  57770. };
  57771. if (samplingMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].NEAREST_SAMPLINGMODE) {
  57772. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  57773. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  57774. }
  57775. if (!delayAllocation) {
  57776. if (isCube) {
  57777. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  57778. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].INVCUBIC_MODE;
  57779. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  57780. }
  57781. else {
  57782. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  57783. }
  57784. }
  57785. return _this;
  57786. }
  57787. Object.defineProperty(RenderTargetTexture.prototype, "renderList", {
  57788. /**
  57789. * Use this list to define the list of mesh you want to render.
  57790. */
  57791. get: function () {
  57792. return this._renderList;
  57793. },
  57794. set: function (value) {
  57795. this._renderList = value;
  57796. if (this._renderList) {
  57797. this._hookArray(this._renderList);
  57798. }
  57799. },
  57800. enumerable: true,
  57801. configurable: true
  57802. });
  57803. RenderTargetTexture.prototype._hookArray = function (array) {
  57804. var _this = this;
  57805. var oldPush = array.push;
  57806. array.push = function () {
  57807. var items = [];
  57808. for (var _i = 0; _i < arguments.length; _i++) {
  57809. items[_i] = arguments[_i];
  57810. }
  57811. var wasEmpty = array.length === 0;
  57812. var result = oldPush.apply(array, items);
  57813. if (wasEmpty) {
  57814. _this.getScene().meshes.forEach(function (mesh) {
  57815. mesh._markSubMeshesAsLightDirty();
  57816. });
  57817. }
  57818. return result;
  57819. };
  57820. var oldSplice = array.splice;
  57821. array.splice = function (index, deleteCount) {
  57822. var deleted = oldSplice.apply(array, [index, deleteCount]);
  57823. if (array.length === 0) {
  57824. _this.getScene().meshes.forEach(function (mesh) {
  57825. mesh._markSubMeshesAsLightDirty();
  57826. });
  57827. }
  57828. return deleted;
  57829. };
  57830. };
  57831. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  57832. /**
  57833. * Set a after unbind callback in the texture.
  57834. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  57835. */
  57836. set: function (callback) {
  57837. if (this._onAfterUnbindObserver) {
  57838. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  57839. }
  57840. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  57841. },
  57842. enumerable: true,
  57843. configurable: true
  57844. });
  57845. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  57846. /**
  57847. * Set a before render callback in the texture.
  57848. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  57849. */
  57850. set: function (callback) {
  57851. if (this._onBeforeRenderObserver) {
  57852. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  57853. }
  57854. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  57855. },
  57856. enumerable: true,
  57857. configurable: true
  57858. });
  57859. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  57860. /**
  57861. * Set a after render callback in the texture.
  57862. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  57863. */
  57864. set: function (callback) {
  57865. if (this._onAfterRenderObserver) {
  57866. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  57867. }
  57868. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  57869. },
  57870. enumerable: true,
  57871. configurable: true
  57872. });
  57873. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  57874. /**
  57875. * Set a clear callback in the texture.
  57876. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  57877. */
  57878. set: function (callback) {
  57879. if (this._onClearObserver) {
  57880. this.onClearObservable.remove(this._onClearObserver);
  57881. }
  57882. this._onClearObserver = this.onClearObservable.add(callback);
  57883. },
  57884. enumerable: true,
  57885. configurable: true
  57886. });
  57887. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  57888. /**
  57889. * Gets render target creation options that were used.
  57890. */
  57891. get: function () {
  57892. return this._renderTargetOptions;
  57893. },
  57894. enumerable: true,
  57895. configurable: true
  57896. });
  57897. RenderTargetTexture.prototype._onRatioRescale = function () {
  57898. if (this._sizeRatio) {
  57899. this.resize(this._initialSizeParameter);
  57900. }
  57901. };
  57902. Object.defineProperty(RenderTargetTexture.prototype, "boundingBoxSize", {
  57903. get: function () {
  57904. return this._boundingBoxSize;
  57905. },
  57906. /**
  57907. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  57908. * When defined, the cubemap will switch to local mode
  57909. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57910. * @example https://www.babylonjs-playground.com/#RNASML
  57911. */
  57912. set: function (value) {
  57913. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  57914. return;
  57915. }
  57916. this._boundingBoxSize = value;
  57917. var scene = this.getScene();
  57918. if (scene) {
  57919. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  57920. }
  57921. },
  57922. enumerable: true,
  57923. configurable: true
  57924. });
  57925. /**
  57926. * Creates a depth stencil texture.
  57927. * This is only available in WebGL 2 or with the depth texture extension available.
  57928. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  57929. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  57930. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  57931. */
  57932. RenderTargetTexture.prototype.createDepthStencilTexture = function (comparisonFunction, bilinearFiltering, generateStencil) {
  57933. if (comparisonFunction === void 0) { comparisonFunction = 0; }
  57934. if (bilinearFiltering === void 0) { bilinearFiltering = true; }
  57935. if (generateStencil === void 0) { generateStencil = false; }
  57936. if (!this.getScene()) {
  57937. return;
  57938. }
  57939. var engine = this.getScene().getEngine();
  57940. this.depthStencilTexture = engine.createDepthStencilTexture(this._size, {
  57941. bilinearFiltering: bilinearFiltering,
  57942. comparisonFunction: comparisonFunction,
  57943. generateStencil: generateStencil,
  57944. isCube: this.isCube
  57945. });
  57946. engine.setFrameBufferDepthStencilTexture(this);
  57947. };
  57948. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  57949. if (size.ratio) {
  57950. this._sizeRatio = size.ratio;
  57951. this._size = {
  57952. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  57953. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  57954. };
  57955. }
  57956. else {
  57957. this._size = size;
  57958. }
  57959. };
  57960. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  57961. /**
  57962. * Define the number of samples to use in case of MSAA.
  57963. * It defaults to one meaning no MSAA has been enabled.
  57964. */
  57965. get: function () {
  57966. return this._samples;
  57967. },
  57968. set: function (value) {
  57969. if (this._samples === value) {
  57970. return;
  57971. }
  57972. var scene = this.getScene();
  57973. if (!scene) {
  57974. return;
  57975. }
  57976. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  57977. },
  57978. enumerable: true,
  57979. configurable: true
  57980. });
  57981. /**
  57982. * Resets the refresh counter of the texture and start bak from scratch.
  57983. * Could be useful to regenerate the texture if it is setup to render only once.
  57984. */
  57985. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  57986. this._currentRefreshId = -1;
  57987. };
  57988. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  57989. /**
  57990. * Define the refresh rate of the texture or the rendering frequency.
  57991. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  57992. */
  57993. get: function () {
  57994. return this._refreshRate;
  57995. },
  57996. set: function (value) {
  57997. this._refreshRate = value;
  57998. this.resetRefreshCounter();
  57999. },
  58000. enumerable: true,
  58001. configurable: true
  58002. });
  58003. /**
  58004. * Adds a post process to the render target rendering passes.
  58005. * @param postProcess define the post process to add
  58006. */
  58007. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  58008. if (!this._postProcessManager) {
  58009. var scene = this.getScene();
  58010. if (!scene) {
  58011. return;
  58012. }
  58013. this._postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__["PostProcessManager"](scene);
  58014. this._postProcesses = new Array();
  58015. }
  58016. this._postProcesses.push(postProcess);
  58017. this._postProcesses[0].autoClear = false;
  58018. };
  58019. /**
  58020. * Clear all the post processes attached to the render target
  58021. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  58022. */
  58023. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  58024. if (dispose === void 0) { dispose = false; }
  58025. if (!this._postProcesses) {
  58026. return;
  58027. }
  58028. if (dispose) {
  58029. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  58030. var postProcess = _a[_i];
  58031. postProcess.dispose();
  58032. }
  58033. }
  58034. this._postProcesses = [];
  58035. };
  58036. /**
  58037. * Remove one of the post process from the list of attached post processes to the texture
  58038. * @param postProcess define the post process to remove from the list
  58039. */
  58040. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  58041. if (!this._postProcesses) {
  58042. return;
  58043. }
  58044. var index = this._postProcesses.indexOf(postProcess);
  58045. if (index === -1) {
  58046. return;
  58047. }
  58048. this._postProcesses.splice(index, 1);
  58049. if (this._postProcesses.length > 0) {
  58050. this._postProcesses[0].autoClear = false;
  58051. }
  58052. };
  58053. /** @hidden */
  58054. RenderTargetTexture.prototype._shouldRender = function () {
  58055. if (this._currentRefreshId === -1) { // At least render once
  58056. this._currentRefreshId = 1;
  58057. return true;
  58058. }
  58059. if (this.refreshRate === this._currentRefreshId) {
  58060. this._currentRefreshId = 1;
  58061. return true;
  58062. }
  58063. this._currentRefreshId++;
  58064. return false;
  58065. };
  58066. /**
  58067. * Gets the actual render size of the texture.
  58068. * @returns the width of the render size
  58069. */
  58070. RenderTargetTexture.prototype.getRenderSize = function () {
  58071. return this.getRenderWidth();
  58072. };
  58073. /**
  58074. * Gets the actual render width of the texture.
  58075. * @returns the width of the render size
  58076. */
  58077. RenderTargetTexture.prototype.getRenderWidth = function () {
  58078. if (this._size.width) {
  58079. return this._size.width;
  58080. }
  58081. return this._size;
  58082. };
  58083. /**
  58084. * Gets the actual render height of the texture.
  58085. * @returns the height of the render size
  58086. */
  58087. RenderTargetTexture.prototype.getRenderHeight = function () {
  58088. if (this._size.width) {
  58089. return this._size.height;
  58090. }
  58091. return this._size;
  58092. };
  58093. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  58094. /**
  58095. * Get if the texture can be rescaled or not.
  58096. */
  58097. get: function () {
  58098. return true;
  58099. },
  58100. enumerable: true,
  58101. configurable: true
  58102. });
  58103. /**
  58104. * Resize the texture using a ratio.
  58105. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  58106. */
  58107. RenderTargetTexture.prototype.scale = function (ratio) {
  58108. var newSize = this.getRenderSize() * ratio;
  58109. this.resize(newSize);
  58110. };
  58111. /**
  58112. * Get the texture reflection matrix used to rotate/transform the reflection.
  58113. * @returns the reflection matrix
  58114. */
  58115. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  58116. if (this.isCube) {
  58117. return this._textureMatrix;
  58118. }
  58119. return _super.prototype.getReflectionTextureMatrix.call(this);
  58120. };
  58121. /**
  58122. * Resize the texture to a new desired size.
  58123. * Be carrefull as it will recreate all the data in the new texture.
  58124. * @param size Define the new size. It can be:
  58125. * - a number for squared texture,
  58126. * - an object containing { width: number, height: number }
  58127. * - or an object containing a ratio { ratio: number }
  58128. */
  58129. RenderTargetTexture.prototype.resize = function (size) {
  58130. this.releaseInternalTexture();
  58131. var scene = this.getScene();
  58132. if (!scene) {
  58133. return;
  58134. }
  58135. this._processSizeParameter(size);
  58136. if (this.isCube) {
  58137. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  58138. }
  58139. else {
  58140. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  58141. }
  58142. };
  58143. /**
  58144. * Renders all the objects from the render list into the texture.
  58145. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  58146. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  58147. */
  58148. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  58149. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  58150. if (dumpForDebug === void 0) { dumpForDebug = false; }
  58151. var scene = this.getScene();
  58152. if (!scene) {
  58153. return;
  58154. }
  58155. var engine = scene.getEngine();
  58156. if (this.useCameraPostProcesses !== undefined) {
  58157. useCameraPostProcess = this.useCameraPostProcesses;
  58158. }
  58159. if (this._waitingRenderList) {
  58160. this.renderList = [];
  58161. for (var index = 0; index < this._waitingRenderList.length; index++) {
  58162. var id = this._waitingRenderList[index];
  58163. var mesh_1 = scene.getMeshByID(id);
  58164. if (mesh_1) {
  58165. this.renderList.push(mesh_1);
  58166. }
  58167. }
  58168. delete this._waitingRenderList;
  58169. }
  58170. // Is predicate defined?
  58171. if (this.renderListPredicate) {
  58172. if (this.renderList) {
  58173. this.renderList.length = 0; // Clear previous renderList
  58174. }
  58175. else {
  58176. this.renderList = [];
  58177. }
  58178. var scene = this.getScene();
  58179. if (!scene) {
  58180. return;
  58181. }
  58182. var sceneMeshes = scene.meshes;
  58183. for (var index = 0; index < sceneMeshes.length; index++) {
  58184. var mesh = sceneMeshes[index];
  58185. if (this.renderListPredicate(mesh)) {
  58186. this.renderList.push(mesh);
  58187. }
  58188. }
  58189. }
  58190. this.onBeforeBindObservable.notifyObservers(this);
  58191. // Set custom projection.
  58192. // Needs to be before binding to prevent changing the aspect ratio.
  58193. var camera;
  58194. if (this.activeCamera) {
  58195. camera = this.activeCamera;
  58196. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  58197. if (this.activeCamera !== scene.activeCamera) {
  58198. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  58199. }
  58200. }
  58201. else {
  58202. camera = scene.activeCamera;
  58203. if (camera) {
  58204. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  58205. }
  58206. }
  58207. // Prepare renderingManager
  58208. this._renderingManager.reset();
  58209. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  58210. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  58211. var sceneRenderId = scene.getRenderId();
  58212. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  58213. var mesh = currentRenderList[meshIndex];
  58214. if (mesh) {
  58215. if (!mesh.isReady(this.refreshRate === 0)) {
  58216. this.resetRefreshCounter();
  58217. continue;
  58218. }
  58219. mesh._preActivateForIntermediateRendering(sceneRenderId);
  58220. var isMasked = void 0;
  58221. if (!this.renderList && camera) {
  58222. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  58223. }
  58224. else {
  58225. isMasked = false;
  58226. }
  58227. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  58228. mesh._activate(sceneRenderId);
  58229. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  58230. var subMesh = mesh.subMeshes[subIndex];
  58231. scene._activeIndices.addCount(subMesh.indexCount, false);
  58232. this._renderingManager.dispatch(subMesh, mesh);
  58233. }
  58234. }
  58235. }
  58236. }
  58237. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  58238. var particleSystem = scene.particleSystems[particleIndex];
  58239. var emitter = particleSystem.emitter;
  58240. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  58241. continue;
  58242. }
  58243. if (currentRenderList.indexOf(emitter) >= 0) {
  58244. this._renderingManager.dispatchParticles(particleSystem);
  58245. }
  58246. }
  58247. if (this.isCube) {
  58248. for (var face = 0; face < 6; face++) {
  58249. this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
  58250. scene.incrementRenderId();
  58251. scene.resetCachedMaterial();
  58252. }
  58253. }
  58254. else {
  58255. this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);
  58256. }
  58257. this.onAfterUnbindObservable.notifyObservers(this);
  58258. if (scene.activeCamera) {
  58259. if (this.activeCamera && this.activeCamera !== scene.activeCamera) {
  58260. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  58261. }
  58262. engine.setViewport(scene.activeCamera.viewport);
  58263. }
  58264. scene.resetCachedMaterial();
  58265. };
  58266. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  58267. var minimum = 128;
  58268. var x = renderDimension * scale;
  58269. var curved = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].NearestPOT(x + (minimum * minimum / (minimum + x)));
  58270. // Ensure we don't exceed the render dimension (while staying POT)
  58271. return Math.min(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].FloorPOT(renderDimension), curved);
  58272. };
  58273. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  58274. var _this = this;
  58275. if (!this._texture) {
  58276. return;
  58277. }
  58278. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  58279. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  58280. });
  58281. };
  58282. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, useCameraPostProcess, dumpForDebug) {
  58283. var scene = this.getScene();
  58284. if (!scene) {
  58285. return;
  58286. }
  58287. var engine = scene.getEngine();
  58288. if (!this._texture) {
  58289. return;
  58290. }
  58291. // Bind
  58292. if (this._postProcessManager) {
  58293. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  58294. }
  58295. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  58296. if (this._texture) {
  58297. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
  58298. }
  58299. }
  58300. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  58301. // Clear
  58302. if (this.onClearObservable.hasObservers()) {
  58303. this.onClearObservable.notifyObservers(engine);
  58304. }
  58305. else {
  58306. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  58307. }
  58308. if (!this._doNotChangeAspectRatio) {
  58309. scene.updateTransformMatrix(true);
  58310. }
  58311. // Before Camera Draw
  58312. for (var _i = 0, _a = scene._beforeRenderTargetDrawStage; _i < _a.length; _i++) {
  58313. var step = _a[_i];
  58314. step.action(this);
  58315. }
  58316. // Render
  58317. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  58318. // After Camera Draw
  58319. for (var _b = 0, _c = scene._afterRenderTargetDrawStage; _b < _c.length; _b++) {
  58320. var step = _c[_b];
  58321. step.action(this);
  58322. }
  58323. if (this._postProcessManager) {
  58324. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  58325. }
  58326. else if (useCameraPostProcess) {
  58327. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  58328. }
  58329. if (!this._doNotChangeAspectRatio) {
  58330. scene.updateTransformMatrix(true);
  58331. }
  58332. // Dump ?
  58333. if (dumpForDebug) {
  58334. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  58335. }
  58336. // Unbind
  58337. if (!this.isCube || faceIndex === 5) {
  58338. if (this.isCube) {
  58339. if (faceIndex === 5) {
  58340. engine.generateMipMapsForCubemap(this._texture);
  58341. }
  58342. }
  58343. this.unbindFrameBuffer(engine, faceIndex);
  58344. }
  58345. else {
  58346. this.onAfterRenderObservable.notifyObservers(faceIndex);
  58347. }
  58348. };
  58349. /**
  58350. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  58351. * This allowed control for front to back rendering or reversly depending of the special needs.
  58352. *
  58353. * @param renderingGroupId The rendering group id corresponding to its index
  58354. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  58355. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  58356. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  58357. */
  58358. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  58359. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  58360. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  58361. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  58362. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  58363. };
  58364. /**
  58365. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  58366. *
  58367. * @param renderingGroupId The rendering group id corresponding to its index
  58368. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58369. */
  58370. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  58371. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  58372. this._renderingManager._useSceneAutoClearSetup = false;
  58373. };
  58374. /**
  58375. * Clones the texture.
  58376. * @returns the cloned texture
  58377. */
  58378. RenderTargetTexture.prototype.clone = function () {
  58379. var textureSize = this.getSize();
  58380. 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);
  58381. // Base texture
  58382. newTexture.hasAlpha = this.hasAlpha;
  58383. newTexture.level = this.level;
  58384. // RenderTarget Texture
  58385. newTexture.coordinatesMode = this.coordinatesMode;
  58386. if (this.renderList) {
  58387. newTexture.renderList = this.renderList.slice(0);
  58388. }
  58389. return newTexture;
  58390. };
  58391. /**
  58392. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  58393. * @returns The JSON representation of the texture
  58394. */
  58395. RenderTargetTexture.prototype.serialize = function () {
  58396. if (!this.name) {
  58397. return null;
  58398. }
  58399. var serializationObject = _super.prototype.serialize.call(this);
  58400. serializationObject.renderTargetSize = this.getRenderSize();
  58401. serializationObject.renderList = [];
  58402. if (this.renderList) {
  58403. for (var index = 0; index < this.renderList.length; index++) {
  58404. serializationObject.renderList.push(this.renderList[index].id);
  58405. }
  58406. }
  58407. return serializationObject;
  58408. };
  58409. /**
  58410. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  58411. */
  58412. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  58413. var objBuffer = this.getInternalTexture();
  58414. var scene = this.getScene();
  58415. if (objBuffer && scene) {
  58416. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  58417. }
  58418. };
  58419. /**
  58420. * Dispose the texture and release its associated resources.
  58421. */
  58422. RenderTargetTexture.prototype.dispose = function () {
  58423. if (this._postProcessManager) {
  58424. this._postProcessManager.dispose();
  58425. this._postProcessManager = null;
  58426. }
  58427. this.clearPostProcesses(true);
  58428. if (this._resizeObserver) {
  58429. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  58430. this._resizeObserver = null;
  58431. }
  58432. this.renderList = null;
  58433. // Remove from custom render targets
  58434. var scene = this.getScene();
  58435. if (!scene) {
  58436. return;
  58437. }
  58438. var index = scene.customRenderTargets.indexOf(this);
  58439. if (index >= 0) {
  58440. scene.customRenderTargets.splice(index, 1);
  58441. }
  58442. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  58443. var camera = _a[_i];
  58444. index = camera.customRenderTargets.indexOf(this);
  58445. if (index >= 0) {
  58446. camera.customRenderTargets.splice(index, 1);
  58447. }
  58448. }
  58449. _super.prototype.dispose.call(this);
  58450. };
  58451. /** @hidden */
  58452. RenderTargetTexture.prototype._rebuild = function () {
  58453. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  58454. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  58455. }
  58456. if (this._postProcessManager) {
  58457. this._postProcessManager._rebuild();
  58458. }
  58459. };
  58460. /**
  58461. * Clear the info related to rendering groups preventing retention point in material dispose.
  58462. */
  58463. RenderTargetTexture.prototype.freeRenderingGroups = function () {
  58464. if (this._renderingManager) {
  58465. this._renderingManager.freeRenderingGroups();
  58466. }
  58467. };
  58468. /**
  58469. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  58470. */
  58471. RenderTargetTexture.REFRESHRATE_RENDER_ONCE = 0;
  58472. /**
  58473. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  58474. */
  58475. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  58476. /**
  58477. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  58478. * the central point of your effect and can save a lot of performances.
  58479. */
  58480. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  58481. return RenderTargetTexture;
  58482. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  58483. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  58484. return new RenderTargetTexture(name, renderTargetSize, scene, generateMipMaps);
  58485. };
  58486. /***/ }),
  58487. /***/ "./Materials/Textures/texture.ts":
  58488. /*!***************************************!*\
  58489. !*** ./Materials/Textures/texture.ts ***!
  58490. \***************************************/
  58491. /*! exports provided: Texture */
  58492. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58493. "use strict";
  58494. __webpack_require__.r(__webpack_exports__);
  58495. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return Texture; });
  58496. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58497. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  58498. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  58499. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  58500. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58501. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  58502. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58503. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  58504. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  58505. /**
  58506. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  58507. * @see http://doc.babylonjs.com/babylon101/materials#texture
  58508. */
  58509. var Texture = /** @class */ (function (_super) {
  58510. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Texture, _super);
  58511. /**
  58512. * Instantiates a new texture.
  58513. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  58514. * @see http://doc.babylonjs.com/babylon101/materials#texture
  58515. * @param url define the url of the picture to load as a texture
  58516. * @param scene define the scene the texture will belong to
  58517. * @param noMipmap define if the texture will require mip maps or not
  58518. * @param invertY define if the texture needs to be inverted on the y axis during loading
  58519. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  58520. * @param onLoad define a callback triggered when the texture has been loaded
  58521. * @param onError define a callback triggered when an error occurred during the loading session
  58522. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  58523. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  58524. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  58525. */
  58526. function Texture(url, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
  58527. if (noMipmap === void 0) { noMipmap = false; }
  58528. if (invertY === void 0) { invertY = true; }
  58529. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  58530. if (onLoad === void 0) { onLoad = null; }
  58531. if (onError === void 0) { onError = null; }
  58532. if (buffer === void 0) { buffer = null; }
  58533. if (deleteBuffer === void 0) { deleteBuffer = false; }
  58534. var _this = _super.call(this, scene) || this;
  58535. /**
  58536. * Define an offset on the texture to offset the u coordinates of the UVs
  58537. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  58538. */
  58539. _this.uOffset = 0;
  58540. /**
  58541. * Define an offset on the texture to offset the v coordinates of the UVs
  58542. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  58543. */
  58544. _this.vOffset = 0;
  58545. /**
  58546. * Define an offset on the texture to scale the u coordinates of the UVs
  58547. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  58548. */
  58549. _this.uScale = 1.0;
  58550. /**
  58551. * Define an offset on the texture to scale the v coordinates of the UVs
  58552. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  58553. */
  58554. _this.vScale = 1.0;
  58555. /**
  58556. * Define an offset on the texture to rotate around the u coordinates of the UVs
  58557. * @see http://doc.babylonjs.com/how_to/more_materials
  58558. */
  58559. _this.uAng = 0;
  58560. /**
  58561. * Define an offset on the texture to rotate around the v coordinates of the UVs
  58562. * @see http://doc.babylonjs.com/how_to/more_materials
  58563. */
  58564. _this.vAng = 0;
  58565. /**
  58566. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  58567. * @see http://doc.babylonjs.com/how_to/more_materials
  58568. */
  58569. _this.wAng = 0;
  58570. /**
  58571. * Defines the center of rotation (U)
  58572. */
  58573. _this.uRotationCenter = 0.5;
  58574. /**
  58575. * Defines the center of rotation (V)
  58576. */
  58577. _this.vRotationCenter = 0.5;
  58578. /**
  58579. * Defines the center of rotation (W)
  58580. */
  58581. _this.wRotationCenter = 0.5;
  58582. /** @hidden */
  58583. _this._initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
  58584. /**
  58585. * Observable triggered once the texture has been loaded.
  58586. */
  58587. _this.onLoadObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  58588. _this._isBlocking = true;
  58589. _this.name = url || "";
  58590. _this.url = url;
  58591. _this._noMipmap = noMipmap;
  58592. _this._invertY = invertY;
  58593. _this._initialSamplingMode = samplingMode;
  58594. _this._buffer = buffer;
  58595. _this._deleteBuffer = deleteBuffer;
  58596. if (format) {
  58597. _this._format = format;
  58598. }
  58599. scene = _this.getScene();
  58600. if (!scene) {
  58601. return _this;
  58602. }
  58603. scene.getEngine().onBeforeTextureInitObservable.notifyObservers(_this);
  58604. var load = function () {
  58605. if (_this._texture && _this._texture._invertVScale) {
  58606. _this.vScale = -1;
  58607. }
  58608. if (_this.onLoadObservable.hasObservers()) {
  58609. _this.onLoadObservable.notifyObservers(_this);
  58610. }
  58611. if (onLoad) {
  58612. onLoad();
  58613. }
  58614. if (!_this.isBlocking && scene) {
  58615. scene.resetCachedMaterial();
  58616. }
  58617. };
  58618. if (!_this.url) {
  58619. _this._delayedOnLoad = load;
  58620. _this._delayedOnError = onError;
  58621. return _this;
  58622. }
  58623. _this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode);
  58624. if (!_this._texture) {
  58625. if (!scene.useDelayedTextureLoading) {
  58626. _this._texture = scene.getEngine().createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
  58627. if (deleteBuffer) {
  58628. delete _this._buffer;
  58629. }
  58630. }
  58631. else {
  58632. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58633. _this._delayedOnLoad = load;
  58634. _this._delayedOnError = onError;
  58635. }
  58636. }
  58637. else {
  58638. if (_this._texture.isReady) {
  58639. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(function () { return load(); });
  58640. }
  58641. else {
  58642. _this._texture.onLoadedObservable.add(load);
  58643. }
  58644. }
  58645. return _this;
  58646. }
  58647. Object.defineProperty(Texture.prototype, "noMipmap", {
  58648. /**
  58649. * Are mip maps generated for this texture or not.
  58650. */
  58651. get: function () {
  58652. return this._noMipmap;
  58653. },
  58654. enumerable: true,
  58655. configurable: true
  58656. });
  58657. Object.defineProperty(Texture.prototype, "isBlocking", {
  58658. get: function () {
  58659. return this._isBlocking;
  58660. },
  58661. /**
  58662. * Is the texture preventing material to render while loading.
  58663. * If false, a default texture will be used instead of the loading one during the preparation step.
  58664. */
  58665. set: function (value) {
  58666. this._isBlocking = value;
  58667. },
  58668. enumerable: true,
  58669. configurable: true
  58670. });
  58671. Object.defineProperty(Texture.prototype, "samplingMode", {
  58672. /**
  58673. * Get the current sampling mode associated with the texture.
  58674. */
  58675. get: function () {
  58676. if (!this._texture) {
  58677. return this._initialSamplingMode;
  58678. }
  58679. return this._texture.samplingMode;
  58680. },
  58681. enumerable: true,
  58682. configurable: true
  58683. });
  58684. Object.defineProperty(Texture.prototype, "invertY", {
  58685. /**
  58686. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  58687. */
  58688. get: function () {
  58689. return this._invertY;
  58690. },
  58691. enumerable: true,
  58692. configurable: true
  58693. });
  58694. /**
  58695. * Update the url (and optional buffer) of this texture if url was null during construction.
  58696. * @param url the url of the texture
  58697. * @param buffer the buffer of the texture (defaults to null)
  58698. * @param onLoad callback called when the texture is loaded (defaults to null)
  58699. */
  58700. Texture.prototype.updateURL = function (url, buffer, onLoad) {
  58701. if (buffer === void 0) { buffer = null; }
  58702. if (this.url) {
  58703. this.releaseInternalTexture();
  58704. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  58705. }
  58706. this.url = url;
  58707. this._buffer = buffer;
  58708. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58709. if (onLoad) {
  58710. this._delayedOnLoad = onLoad;
  58711. }
  58712. this.delayLoad();
  58713. };
  58714. /**
  58715. * Finish the loading sequence of a texture flagged as delayed load.
  58716. * @hidden
  58717. */
  58718. Texture.prototype.delayLoad = function () {
  58719. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  58720. return;
  58721. }
  58722. var scene = this.getScene();
  58723. if (!scene) {
  58724. return;
  58725. }
  58726. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  58727. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode);
  58728. if (!this._texture) {
  58729. this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
  58730. if (this._deleteBuffer) {
  58731. delete this._buffer;
  58732. }
  58733. }
  58734. else {
  58735. if (this._delayedOnLoad) {
  58736. if (this._texture.isReady) {
  58737. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(this._delayedOnLoad);
  58738. }
  58739. else {
  58740. this._texture.onLoadedObservable.add(this._delayedOnLoad);
  58741. }
  58742. }
  58743. }
  58744. this._delayedOnLoad = null;
  58745. this._delayedOnError = null;
  58746. };
  58747. Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
  58748. x *= this.uScale;
  58749. y *= this.vScale;
  58750. x -= this.uRotationCenter * this.uScale;
  58751. y -= this.vRotationCenter * this.vScale;
  58752. z -= this.wRotationCenter;
  58753. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
  58754. t.x += this.uRotationCenter * this.uScale + this.uOffset;
  58755. t.y += this.vRotationCenter * this.vScale + this.vOffset;
  58756. t.z += this.wRotationCenter;
  58757. };
  58758. /**
  58759. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  58760. * @returns the transform matrix of the texture.
  58761. */
  58762. Texture.prototype.getTextureMatrix = function () {
  58763. var _this = this;
  58764. if (this.uOffset === this._cachedUOffset &&
  58765. this.vOffset === this._cachedVOffset &&
  58766. this.uScale === this._cachedUScale &&
  58767. this.vScale === this._cachedVScale &&
  58768. this.uAng === this._cachedUAng &&
  58769. this.vAng === this._cachedVAng &&
  58770. this.wAng === this._cachedWAng) {
  58771. return this._cachedTextureMatrix;
  58772. }
  58773. this._cachedUOffset = this.uOffset;
  58774. this._cachedVOffset = this.vOffset;
  58775. this._cachedUScale = this.uScale;
  58776. this._cachedVScale = this.vScale;
  58777. this._cachedUAng = this.uAng;
  58778. this._cachedVAng = this.vAng;
  58779. this._cachedWAng = this.wAng;
  58780. if (!this._cachedTextureMatrix) {
  58781. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  58782. this._rowGenerationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  58783. this._t0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  58784. this._t1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  58785. this._t2 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  58786. }
  58787. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix);
  58788. this._prepareRowForTextureGeneration(0, 0, 0, this._t0);
  58789. this._prepareRowForTextureGeneration(1.0, 0, 0, this._t1);
  58790. this._prepareRowForTextureGeneration(0, 1.0, 0, this._t2);
  58791. this._t1.subtractInPlace(this._t0);
  58792. this._t2.subtractInPlace(this._t0);
  58793. _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);
  58794. var scene = this.getScene();
  58795. if (!scene) {
  58796. return this._cachedTextureMatrix;
  58797. }
  58798. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  58799. return mat.hasTexture(_this);
  58800. });
  58801. return this._cachedTextureMatrix;
  58802. };
  58803. /**
  58804. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  58805. * @returns The reflection texture transform
  58806. */
  58807. Texture.prototype.getReflectionTextureMatrix = function () {
  58808. var _this = this;
  58809. var scene = this.getScene();
  58810. if (!scene) {
  58811. return this._cachedTextureMatrix;
  58812. }
  58813. if (this.uOffset === this._cachedUOffset &&
  58814. this.vOffset === this._cachedVOffset &&
  58815. this.uScale === this._cachedUScale &&
  58816. this.vScale === this._cachedVScale &&
  58817. this.coordinatesMode === this._cachedCoordinatesMode) {
  58818. if (this.coordinatesMode === Texture.PROJECTION_MODE) {
  58819. if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
  58820. return this._cachedTextureMatrix;
  58821. }
  58822. }
  58823. else {
  58824. return this._cachedTextureMatrix;
  58825. }
  58826. }
  58827. if (!this._cachedTextureMatrix) {
  58828. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  58829. }
  58830. if (!this._projectionModeMatrix) {
  58831. this._projectionModeMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  58832. }
  58833. this._cachedUOffset = this.uOffset;
  58834. this._cachedVOffset = this.vOffset;
  58835. this._cachedUScale = this.uScale;
  58836. this._cachedVScale = this.vScale;
  58837. this._cachedCoordinatesMode = this.coordinatesMode;
  58838. switch (this.coordinatesMode) {
  58839. case Texture.PLANAR_MODE:
  58840. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  58841. this._cachedTextureMatrix[0] = this.uScale;
  58842. this._cachedTextureMatrix[5] = this.vScale;
  58843. this._cachedTextureMatrix[12] = this.uOffset;
  58844. this._cachedTextureMatrix[13] = this.vOffset;
  58845. break;
  58846. case Texture.PROJECTION_MODE:
  58847. _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);
  58848. var projectionMatrix = scene.getProjectionMatrix();
  58849. this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
  58850. projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  58851. break;
  58852. default:
  58853. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  58854. break;
  58855. }
  58856. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  58857. return (mat.getActiveTextures().indexOf(_this) !== -1);
  58858. });
  58859. return this._cachedTextureMatrix;
  58860. };
  58861. /**
  58862. * Clones the texture.
  58863. * @returns the cloned texture
  58864. */
  58865. Texture.prototype.clone = function () {
  58866. var _this = this;
  58867. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  58868. return new Texture(_this._texture ? _this._texture.url : null, _this.getScene(), _this._noMipmap, _this._invertY, _this.samplingMode);
  58869. }, this);
  58870. };
  58871. /**
  58872. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  58873. * @returns The JSON representation of the texture
  58874. */
  58875. Texture.prototype.serialize = function () {
  58876. var serializationObject = _super.prototype.serialize.call(this);
  58877. if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
  58878. serializationObject.base64String = this._buffer;
  58879. serializationObject.name = serializationObject.name.replace("data:", "");
  58880. }
  58881. serializationObject.invertY = this._invertY;
  58882. serializationObject.samplingMode = this.samplingMode;
  58883. return serializationObject;
  58884. };
  58885. /**
  58886. * Get the current class name of the texture useful for serialization or dynamic coding.
  58887. * @returns "Texture"
  58888. */
  58889. Texture.prototype.getClassName = function () {
  58890. return "Texture";
  58891. };
  58892. /**
  58893. * Dispose the texture and release its associated resources.
  58894. */
  58895. Texture.prototype.dispose = function () {
  58896. _super.prototype.dispose.call(this);
  58897. this.onLoadObservable.clear();
  58898. this._delayedOnLoad = null;
  58899. this._delayedOnError = null;
  58900. };
  58901. /**
  58902. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  58903. * @param parsedTexture Define the JSON representation of the texture
  58904. * @param scene Define the scene the parsed texture should be instantiated in
  58905. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58906. * @returns The parsed texture if successful
  58907. */
  58908. Texture.Parse = function (parsedTexture, scene, rootUrl) {
  58909. if (parsedTexture.customType) {
  58910. var customTexture = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Instantiate(parsedTexture.customType);
  58911. // Update Sampling Mode
  58912. var parsedCustomTexture = customTexture.Parse(parsedTexture, scene, rootUrl);
  58913. if (parsedTexture.samplingMode && parsedCustomTexture.updateSamplingMode && parsedCustomTexture._samplingMode) {
  58914. if (parsedCustomTexture._samplingMode !== parsedTexture.samplingMode) {
  58915. parsedCustomTexture.updateSamplingMode(parsedTexture.samplingMode);
  58916. }
  58917. }
  58918. return parsedCustomTexture;
  58919. }
  58920. if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
  58921. return Texture._CubeTextureParser(parsedTexture, scene, rootUrl);
  58922. }
  58923. if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
  58924. return null;
  58925. }
  58926. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  58927. var generateMipMaps = true;
  58928. if (parsedTexture.noMipmap) {
  58929. generateMipMaps = false;
  58930. }
  58931. if (parsedTexture.mirrorPlane) {
  58932. var mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  58933. mirrorTexture._waitingRenderList = parsedTexture.renderList;
  58934. mirrorTexture.mirrorPlane = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"].FromArray(parsedTexture.mirrorPlane);
  58935. return mirrorTexture;
  58936. }
  58937. else if (parsedTexture.isRenderTarget) {
  58938. var renderTargetTexture = null;
  58939. if (parsedTexture.isCube) {
  58940. // Search for an existing reflection probe (which contains a cube render target texture)
  58941. if (scene.reflectionProbes) {
  58942. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  58943. var probe = scene.reflectionProbes[index];
  58944. if (probe.name === parsedTexture.name) {
  58945. return probe.cubeTexture;
  58946. }
  58947. }
  58948. }
  58949. }
  58950. else {
  58951. renderTargetTexture = Texture._CreateRenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  58952. renderTargetTexture._waitingRenderList = parsedTexture.renderList;
  58953. }
  58954. return renderTargetTexture;
  58955. }
  58956. else {
  58957. var texture;
  58958. if (parsedTexture.base64String) {
  58959. texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
  58960. }
  58961. else {
  58962. var url = rootUrl + parsedTexture.name;
  58963. if (Texture.UseSerializedUrlIfAny && parsedTexture.url) {
  58964. url = parsedTexture.url;
  58965. }
  58966. texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY);
  58967. }
  58968. return texture;
  58969. }
  58970. }, parsedTexture, scene);
  58971. // Update Sampling Mode
  58972. if (parsedTexture.samplingMode) {
  58973. var sampling = parsedTexture.samplingMode;
  58974. if (texture && texture.samplingMode !== sampling) {
  58975. texture.updateSamplingMode(sampling);
  58976. }
  58977. }
  58978. // Animations
  58979. if (texture && parsedTexture.animations) {
  58980. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  58981. var parsedAnimation = parsedTexture.animations[animationIndex];
  58982. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  58983. if (internalClass) {
  58984. texture.animations.push(internalClass.Parse(parsedAnimation));
  58985. }
  58986. }
  58987. }
  58988. return texture;
  58989. };
  58990. /**
  58991. * Creates a texture from its base 64 representation.
  58992. * @param data Define the base64 payload without the data: prefix
  58993. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  58994. * @param scene Define the scene the texture should belong to
  58995. * @param noMipmap Forces the texture to not create mip map information if true
  58996. * @param invertY define if the texture needs to be inverted on the y axis during loading
  58997. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  58998. * @param onLoad define a callback triggered when the texture has been loaded
  58999. * @param onError define a callback triggered when an error occurred during the loading session
  59000. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  59001. * @returns the created texture
  59002. */
  59003. Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  59004. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  59005. if (onLoad === void 0) { onLoad = null; }
  59006. if (onError === void 0) { onError = null; }
  59007. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  59008. return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);
  59009. };
  59010. /**
  59011. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  59012. * @param data Define the base64 payload without the data: prefix
  59013. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  59014. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  59015. * @param scene Define the scene the texture should belong to
  59016. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  59017. * @param noMipmap Forces the texture to not create mip map information if true
  59018. * @param invertY define if the texture needs to be inverted on the y axis during loading
  59019. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  59020. * @param onLoad define a callback triggered when the texture has been loaded
  59021. * @param onError define a callback triggered when an error occurred during the loading session
  59022. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  59023. * @returns the created texture
  59024. */
  59025. Texture.LoadFromDataString = function (name, buffer, scene, deleteBuffer, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  59026. if (deleteBuffer === void 0) { deleteBuffer = false; }
  59027. if (noMipmap === void 0) { noMipmap = false; }
  59028. if (invertY === void 0) { invertY = true; }
  59029. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  59030. if (onLoad === void 0) { onLoad = null; }
  59031. if (onError === void 0) { onError = null; }
  59032. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  59033. if (name.substr(0, 5) !== "data:") {
  59034. name = "data:" + name;
  59035. }
  59036. return new Texture(name, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format);
  59037. };
  59038. /** @hidden */
  59039. Texture._CubeTextureParser = function (jsonTexture, scene, rootUrl) {
  59040. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("CubeTexture");
  59041. };
  59042. /** @hidden */
  59043. Texture._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  59044. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("MirrorTexture");
  59045. };
  59046. /** @hidden */
  59047. Texture._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  59048. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("RenderTargetTexture");
  59049. };
  59050. /** nearest is mag = nearest and min = nearest and mip = linear */
  59051. Texture.NEAREST_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  59052. /** nearest is mag = nearest and min = nearest and mip = linear */
  59053. 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
  59054. /** Bilinear is mag = linear and min = linear and mip = nearest */
  59055. Texture.BILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  59056. /** Bilinear is mag = linear and min = linear and mip = nearest */
  59057. 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
  59058. /** Trilinear is mag = linear and min = linear and mip = linear */
  59059. Texture.TRILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  59060. /** Trilinear is mag = linear and min = linear and mip = linear */
  59061. 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
  59062. /** mag = nearest and min = nearest and mip = nearest */
  59063. Texture.NEAREST_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  59064. /** mag = nearest and min = linear and mip = nearest */
  59065. Texture.NEAREST_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  59066. /** mag = nearest and min = linear and mip = linear */
  59067. Texture.NEAREST_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  59068. /** mag = nearest and min = linear and mip = none */
  59069. Texture.NEAREST_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR;
  59070. /** mag = nearest and min = nearest and mip = none */
  59071. Texture.NEAREST_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST;
  59072. /** mag = linear and min = nearest and mip = nearest */
  59073. Texture.LINEAR_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  59074. /** mag = linear and min = nearest and mip = linear */
  59075. Texture.LINEAR_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  59076. /** mag = linear and min = linear and mip = none */
  59077. Texture.LINEAR_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR;
  59078. /** mag = linear and min = nearest and mip = none */
  59079. Texture.LINEAR_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST;
  59080. /** Explicit coordinates mode */
  59081. Texture.EXPLICIT_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EXPLICIT_MODE;
  59082. /** Spherical coordinates mode */
  59083. Texture.SPHERICAL_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SPHERICAL_MODE;
  59084. /** Planar coordinates mode */
  59085. Texture.PLANAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PLANAR_MODE;
  59086. /** Cubic coordinates mode */
  59087. Texture.CUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CUBIC_MODE;
  59088. /** Projection coordinates mode */
  59089. Texture.PROJECTION_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PROJECTION_MODE;
  59090. /** Inverse Cubic coordinates mode */
  59091. Texture.SKYBOX_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SKYBOX_MODE;
  59092. /** Inverse Cubic coordinates mode */
  59093. Texture.INVCUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_INVCUBIC_MODE;
  59094. /** Equirectangular coordinates mode */
  59095. Texture.EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  59096. /** Equirectangular Fixed coordinates mode */
  59097. Texture.FIXED_EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  59098. /** Equirectangular Fixed Mirrored coordinates mode */
  59099. Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  59100. /** Texture is not repeating outside of 0..1 UVs */
  59101. Texture.CLAMP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  59102. /** Texture is repeating outside of 0..1 UVs */
  59103. Texture.WRAP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  59104. /** Texture is repeating and mirrored */
  59105. Texture.MIRROR_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  59106. /**
  59107. * 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
  59108. */
  59109. Texture.UseSerializedUrlIfAny = false;
  59110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59112. ], Texture.prototype, "url", void 0);
  59113. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59114. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59115. ], Texture.prototype, "uOffset", void 0);
  59116. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59117. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59118. ], Texture.prototype, "vOffset", void 0);
  59119. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59121. ], Texture.prototype, "uScale", void 0);
  59122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59124. ], Texture.prototype, "vScale", void 0);
  59125. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59126. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59127. ], Texture.prototype, "uAng", void 0);
  59128. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59129. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59130. ], Texture.prototype, "vAng", void 0);
  59131. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59132. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59133. ], Texture.prototype, "wAng", void 0);
  59134. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59135. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59136. ], Texture.prototype, "uRotationCenter", void 0);
  59137. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59138. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59139. ], Texture.prototype, "vRotationCenter", void 0);
  59140. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59141. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59142. ], Texture.prototype, "wRotationCenter", void 0);
  59143. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59144. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59145. ], Texture.prototype, "isBlocking", null);
  59146. return Texture;
  59147. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]));
  59148. // References the dependencies.
  59149. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._TextureParser = Texture.Parse;
  59150. /***/ }),
  59151. /***/ "./Materials/Textures/videoTexture.ts":
  59152. /*!********************************************!*\
  59153. !*** ./Materials/Textures/videoTexture.ts ***!
  59154. \********************************************/
  59155. /*! exports provided: VideoTexture */
  59156. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59157. "use strict";
  59158. __webpack_require__.r(__webpack_exports__);
  59159. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return VideoTexture; });
  59160. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59161. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  59162. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  59163. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  59164. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59165. /**
  59166. * If you want to display a video in your scene, this is the special texture for that.
  59167. * This special texture works similar to other textures, with the exception of a few parameters.
  59168. * @see https://doc.babylonjs.com/how_to/video_texture
  59169. */
  59170. var VideoTexture = /** @class */ (function (_super) {
  59171. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoTexture, _super);
  59172. /**
  59173. * Creates a video texture.
  59174. * If you want to display a video in your scene, this is the special texture for that.
  59175. * This special texture works similar to other textures, with the exception of a few parameters.
  59176. * @see https://doc.babylonjs.com/how_to/video_texture
  59177. * @param name optional name, will detect from video source, if not defined
  59178. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  59179. * @param scene is obviously the current scene.
  59180. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  59181. * @param invertY is false by default but can be used to invert video on Y axis
  59182. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  59183. * @param settings allows finer control over video usage
  59184. */
  59185. function VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings) {
  59186. if (generateMipMaps === void 0) { generateMipMaps = false; }
  59187. if (invertY === void 0) { invertY = false; }
  59188. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  59189. if (settings === void 0) { settings = {
  59190. autoPlay: true,
  59191. loop: true,
  59192. autoUpdateTexture: true,
  59193. }; }
  59194. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  59195. _this._onUserActionRequestedObservable = null;
  59196. _this._stillImageCaptured = false;
  59197. _this._displayingPosterTexture = false;
  59198. _this._createInternalTexture = function () {
  59199. if (_this._texture != null) {
  59200. if (_this._displayingPosterTexture) {
  59201. _this._texture.dispose();
  59202. _this._displayingPosterTexture = false;
  59203. }
  59204. else {
  59205. return;
  59206. }
  59207. }
  59208. if (!_this._engine.needPOTTextures ||
  59209. (_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoWidth) && _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoHeight))) {
  59210. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  59211. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  59212. }
  59213. else {
  59214. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  59215. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  59216. _this._generateMipMaps = false;
  59217. }
  59218. _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this.samplingMode);
  59219. if (!_this.video.autoplay && !_this._settings.poster) {
  59220. var oldHandler_1 = _this.video.onplaying;
  59221. var error_1 = false;
  59222. _this.video.onplaying = function () {
  59223. _this.video.onplaying = oldHandler_1;
  59224. _this._texture.isReady = true;
  59225. _this._updateInternalTexture();
  59226. if (!error_1) {
  59227. _this.video.pause();
  59228. }
  59229. if (_this.onLoadObservable.hasObservers()) {
  59230. _this.onLoadObservable.notifyObservers(_this);
  59231. }
  59232. };
  59233. var playing = _this.video.play();
  59234. if (playing) {
  59235. playing.then(function () {
  59236. // Everything is good.
  59237. })
  59238. .catch(function () {
  59239. error_1 = true;
  59240. // On Chrome for instance, new policies might prevent playing without user interaction.
  59241. if (_this._onUserActionRequestedObservable && _this._onUserActionRequestedObservable.hasObservers()) {
  59242. _this._onUserActionRequestedObservable.notifyObservers(_this);
  59243. }
  59244. });
  59245. }
  59246. else {
  59247. _this.video.onplaying = oldHandler_1;
  59248. _this._texture.isReady = true;
  59249. _this._updateInternalTexture();
  59250. if (_this.onLoadObservable.hasObservers()) {
  59251. _this.onLoadObservable.notifyObservers(_this);
  59252. }
  59253. }
  59254. }
  59255. else {
  59256. _this._texture.isReady = true;
  59257. _this._updateInternalTexture();
  59258. if (_this.onLoadObservable.hasObservers()) {
  59259. _this.onLoadObservable.notifyObservers(_this);
  59260. }
  59261. }
  59262. };
  59263. _this.reset = function () {
  59264. if (_this._texture == null) {
  59265. return;
  59266. }
  59267. if (!_this._displayingPosterTexture) {
  59268. _this._texture.dispose();
  59269. _this._texture = null;
  59270. }
  59271. };
  59272. _this._updateInternalTexture = function () {
  59273. if (_this._texture == null || !_this._texture.isReady) {
  59274. return;
  59275. }
  59276. if (_this.video.readyState < _this.video.HAVE_CURRENT_DATA) {
  59277. return;
  59278. }
  59279. if (_this._displayingPosterTexture) {
  59280. return;
  59281. }
  59282. _this._engine.updateVideoTexture(_this._texture, _this.video, _this._invertY);
  59283. };
  59284. _this._engine = _this.getScene().getEngine();
  59285. _this._generateMipMaps = generateMipMaps;
  59286. _this._initialSamplingMode = samplingMode;
  59287. _this.autoUpdateTexture = settings.autoUpdateTexture;
  59288. _this.name = name || _this._getName(src);
  59289. _this.video = _this._getVideo(src);
  59290. _this._settings = settings;
  59291. if (settings.poster) {
  59292. _this.video.poster = settings.poster;
  59293. }
  59294. if (settings.autoPlay !== undefined) {
  59295. _this.video.autoplay = settings.autoPlay;
  59296. }
  59297. if (settings.loop !== undefined) {
  59298. _this.video.loop = settings.loop;
  59299. }
  59300. _this.video.setAttribute("playsinline", "");
  59301. _this.video.addEventListener("paused", _this._updateInternalTexture);
  59302. _this.video.addEventListener("seeked", _this._updateInternalTexture);
  59303. _this.video.addEventListener("emptied", _this.reset);
  59304. _this._createInternalTextureOnEvent = (settings.poster && !settings.autoPlay) ? "play" : "canplay";
  59305. _this.video.addEventListener(_this._createInternalTextureOnEvent, _this._createInternalTexture);
  59306. var videoHasEnoughData = (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA);
  59307. if (settings.poster &&
  59308. (!settings.autoPlay || !videoHasEnoughData)) {
  59309. _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
  59310. _this._displayingPosterTexture = true;
  59311. }
  59312. else if (videoHasEnoughData) {
  59313. _this._createInternalTexture();
  59314. }
  59315. return _this;
  59316. }
  59317. Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
  59318. /**
  59319. * Event triggerd when a dom action is required by the user to play the video.
  59320. * This happens due to recent changes in browser policies preventing video to auto start.
  59321. */
  59322. get: function () {
  59323. if (!this._onUserActionRequestedObservable) {
  59324. this._onUserActionRequestedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59325. }
  59326. return this._onUserActionRequestedObservable;
  59327. },
  59328. enumerable: true,
  59329. configurable: true
  59330. });
  59331. VideoTexture.prototype._getName = function (src) {
  59332. if (src instanceof HTMLVideoElement) {
  59333. return src.currentSrc;
  59334. }
  59335. if (typeof src === "object") {
  59336. return src.toString();
  59337. }
  59338. return src;
  59339. };
  59340. VideoTexture.prototype._getVideo = function (src) {
  59341. if (src instanceof HTMLVideoElement) {
  59342. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src.currentSrc, src);
  59343. return src;
  59344. }
  59345. var video = document.createElement("video");
  59346. if (typeof src === "string") {
  59347. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src, video);
  59348. video.src = src;
  59349. }
  59350. else {
  59351. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src[0], video);
  59352. src.forEach(function (url) {
  59353. var source = document.createElement("source");
  59354. source.src = url;
  59355. video.appendChild(source);
  59356. });
  59357. }
  59358. return video;
  59359. };
  59360. /**
  59361. * @hidden Internal method to initiate `update`.
  59362. */
  59363. VideoTexture.prototype._rebuild = function () {
  59364. this.update();
  59365. };
  59366. /**
  59367. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  59368. */
  59369. VideoTexture.prototype.update = function () {
  59370. if (!this.autoUpdateTexture) {
  59371. // Expecting user to call `updateTexture` manually
  59372. return;
  59373. }
  59374. this.updateTexture(true);
  59375. };
  59376. /**
  59377. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  59378. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  59379. */
  59380. VideoTexture.prototype.updateTexture = function (isVisible) {
  59381. if (!isVisible) {
  59382. return;
  59383. }
  59384. if (this.video.paused && this._stillImageCaptured) {
  59385. return;
  59386. }
  59387. this._stillImageCaptured = true;
  59388. this._updateInternalTexture();
  59389. };
  59390. /**
  59391. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  59392. * @param url New url.
  59393. */
  59394. VideoTexture.prototype.updateURL = function (url) {
  59395. this.video.src = url;
  59396. };
  59397. /**
  59398. * Dispose the texture and release its associated resources.
  59399. */
  59400. VideoTexture.prototype.dispose = function () {
  59401. _super.prototype.dispose.call(this);
  59402. if (this._onUserActionRequestedObservable) {
  59403. this._onUserActionRequestedObservable.clear();
  59404. this._onUserActionRequestedObservable = null;
  59405. }
  59406. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);
  59407. this.video.removeEventListener("paused", this._updateInternalTexture);
  59408. this.video.removeEventListener("seeked", this._updateInternalTexture);
  59409. this.video.removeEventListener("emptied", this.reset);
  59410. this.video.pause();
  59411. };
  59412. /**
  59413. * Creates a video texture straight from your WebCam video feed.
  59414. * @param scene Define the scene the texture should be created in
  59415. * @param onReady Define a callback to triggered once the texture will be ready
  59416. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  59417. */
  59418. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints) {
  59419. var video = document.createElement("video");
  59420. video.setAttribute('autoplay', '');
  59421. video.setAttribute('muted', '');
  59422. video.setAttribute('playsinline', '');
  59423. var constraintsDeviceId;
  59424. if (constraints && constraints.deviceId) {
  59425. constraintsDeviceId = {
  59426. exact: constraints.deviceId,
  59427. };
  59428. }
  59429. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  59430. if (navigator.mediaDevices) {
  59431. navigator.mediaDevices.getUserMedia({ video: constraints })
  59432. .then(function (stream) {
  59433. if (video.mozSrcObject !== undefined) {
  59434. // hack for Firefox < 19
  59435. video.mozSrcObject = stream;
  59436. }
  59437. else {
  59438. video.srcObject = stream;
  59439. }
  59440. var onPlaying = function () {
  59441. if (onReady) {
  59442. onReady(new VideoTexture("video", video, scene, true, true));
  59443. }
  59444. video.removeEventListener("playing", onPlaying);
  59445. };
  59446. video.addEventListener("playing", onPlaying);
  59447. video.play();
  59448. })
  59449. .catch(function (err) {
  59450. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(err.name);
  59451. });
  59452. }
  59453. else {
  59454. navigator.getUserMedia =
  59455. navigator.getUserMedia ||
  59456. navigator.webkitGetUserMedia ||
  59457. navigator.mozGetUserMedia ||
  59458. navigator.msGetUserMedia;
  59459. if (navigator.getUserMedia) {
  59460. navigator.getUserMedia({
  59461. video: {
  59462. deviceId: constraintsDeviceId,
  59463. width: {
  59464. min: (constraints && constraints.minWidth) || 256,
  59465. max: (constraints && constraints.maxWidth) || 640,
  59466. },
  59467. height: {
  59468. min: (constraints && constraints.minHeight) || 256,
  59469. max: (constraints && constraints.maxHeight) || 480,
  59470. },
  59471. },
  59472. }, function (stream) {
  59473. if (video.mozSrcObject !== undefined) {
  59474. // hack for Firefox < 19
  59475. video.mozSrcObject = stream;
  59476. }
  59477. else {
  59478. video.src = (window.URL && window.URL.createObjectURL(stream)) || stream;
  59479. }
  59480. video.play();
  59481. if (onReady) {
  59482. onReady(new VideoTexture("video", video, scene, true, true));
  59483. }
  59484. }, function (e) {
  59485. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(e.name);
  59486. });
  59487. }
  59488. }
  59489. };
  59490. return VideoTexture;
  59491. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  59492. /***/ }),
  59493. /***/ "./Materials/colorCurves.ts":
  59494. /*!**********************************!*\
  59495. !*** ./Materials/colorCurves.ts ***!
  59496. \**********************************/
  59497. /*! exports provided: ColorCurves */
  59498. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59499. "use strict";
  59500. __webpack_require__.r(__webpack_exports__);
  59501. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return ColorCurves; });
  59502. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59503. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  59504. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  59505. /**
  59506. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59507. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59508. * 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;
  59509. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59510. */
  59511. var ColorCurves = /** @class */ (function () {
  59512. function ColorCurves() {
  59513. this._dirty = true;
  59514. this._tempColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59515. this._globalCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59516. this._highlightsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59517. this._midtonesCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59518. this._shadowsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59519. this._positiveCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59520. this._negativeCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59521. this._globalHue = 30;
  59522. this._globalDensity = 0;
  59523. this._globalSaturation = 0;
  59524. this._globalExposure = 0;
  59525. this._highlightsHue = 30;
  59526. this._highlightsDensity = 0;
  59527. this._highlightsSaturation = 0;
  59528. this._highlightsExposure = 0;
  59529. this._midtonesHue = 30;
  59530. this._midtonesDensity = 0;
  59531. this._midtonesSaturation = 0;
  59532. this._midtonesExposure = 0;
  59533. this._shadowsHue = 30;
  59534. this._shadowsDensity = 0;
  59535. this._shadowsSaturation = 0;
  59536. this._shadowsExposure = 0;
  59537. }
  59538. Object.defineProperty(ColorCurves.prototype, "globalHue", {
  59539. /**
  59540. * Gets the global Hue value.
  59541. * 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).
  59542. */
  59543. get: function () {
  59544. return this._globalHue;
  59545. },
  59546. /**
  59547. * Sets the global Hue value.
  59548. * 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).
  59549. */
  59550. set: function (value) {
  59551. this._globalHue = value;
  59552. this._dirty = true;
  59553. },
  59554. enumerable: true,
  59555. configurable: true
  59556. });
  59557. Object.defineProperty(ColorCurves.prototype, "globalDensity", {
  59558. /**
  59559. * Gets the global Density value.
  59560. * 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.
  59561. * Values less than zero provide a filter of opposite hue.
  59562. */
  59563. get: function () {
  59564. return this._globalDensity;
  59565. },
  59566. /**
  59567. * Sets the global Density value.
  59568. * 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.
  59569. * Values less than zero provide a filter of opposite hue.
  59570. */
  59571. set: function (value) {
  59572. this._globalDensity = value;
  59573. this._dirty = true;
  59574. },
  59575. enumerable: true,
  59576. configurable: true
  59577. });
  59578. Object.defineProperty(ColorCurves.prototype, "globalSaturation", {
  59579. /**
  59580. * Gets the global Saturation value.
  59581. * 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.
  59582. */
  59583. get: function () {
  59584. return this._globalSaturation;
  59585. },
  59586. /**
  59587. * Sets the global Saturation value.
  59588. * 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.
  59589. */
  59590. set: function (value) {
  59591. this._globalSaturation = value;
  59592. this._dirty = true;
  59593. },
  59594. enumerable: true,
  59595. configurable: true
  59596. });
  59597. Object.defineProperty(ColorCurves.prototype, "globalExposure", {
  59598. /**
  59599. * Gets the global Exposure value.
  59600. * 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.
  59601. */
  59602. get: function () {
  59603. return this._globalExposure;
  59604. },
  59605. /**
  59606. * Sets the global Exposure value.
  59607. * 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.
  59608. */
  59609. set: function (value) {
  59610. this._globalExposure = value;
  59611. this._dirty = true;
  59612. },
  59613. enumerable: true,
  59614. configurable: true
  59615. });
  59616. Object.defineProperty(ColorCurves.prototype, "highlightsHue", {
  59617. /**
  59618. * Gets the highlights Hue value.
  59619. * 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).
  59620. */
  59621. get: function () {
  59622. return this._highlightsHue;
  59623. },
  59624. /**
  59625. * Sets the highlights Hue value.
  59626. * 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).
  59627. */
  59628. set: function (value) {
  59629. this._highlightsHue = value;
  59630. this._dirty = true;
  59631. },
  59632. enumerable: true,
  59633. configurable: true
  59634. });
  59635. Object.defineProperty(ColorCurves.prototype, "highlightsDensity", {
  59636. /**
  59637. * Gets the highlights Density value.
  59638. * 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.
  59639. * Values less than zero provide a filter of opposite hue.
  59640. */
  59641. get: function () {
  59642. return this._highlightsDensity;
  59643. },
  59644. /**
  59645. * Sets the highlights Density value.
  59646. * 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.
  59647. * Values less than zero provide a filter of opposite hue.
  59648. */
  59649. set: function (value) {
  59650. this._highlightsDensity = value;
  59651. this._dirty = true;
  59652. },
  59653. enumerable: true,
  59654. configurable: true
  59655. });
  59656. Object.defineProperty(ColorCurves.prototype, "highlightsSaturation", {
  59657. /**
  59658. * Gets the highlights Saturation value.
  59659. * 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.
  59660. */
  59661. get: function () {
  59662. return this._highlightsSaturation;
  59663. },
  59664. /**
  59665. * Sets the highlights Saturation value.
  59666. * 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.
  59667. */
  59668. set: function (value) {
  59669. this._highlightsSaturation = value;
  59670. this._dirty = true;
  59671. },
  59672. enumerable: true,
  59673. configurable: true
  59674. });
  59675. Object.defineProperty(ColorCurves.prototype, "highlightsExposure", {
  59676. /**
  59677. * Gets the highlights Exposure value.
  59678. * 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.
  59679. */
  59680. get: function () {
  59681. return this._highlightsExposure;
  59682. },
  59683. /**
  59684. * Sets the highlights Exposure value.
  59685. * 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.
  59686. */
  59687. set: function (value) {
  59688. this._highlightsExposure = value;
  59689. this._dirty = true;
  59690. },
  59691. enumerable: true,
  59692. configurable: true
  59693. });
  59694. Object.defineProperty(ColorCurves.prototype, "midtonesHue", {
  59695. /**
  59696. * Gets the midtones Hue value.
  59697. * 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).
  59698. */
  59699. get: function () {
  59700. return this._midtonesHue;
  59701. },
  59702. /**
  59703. * Sets the midtones Hue value.
  59704. * 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).
  59705. */
  59706. set: function (value) {
  59707. this._midtonesHue = value;
  59708. this._dirty = true;
  59709. },
  59710. enumerable: true,
  59711. configurable: true
  59712. });
  59713. Object.defineProperty(ColorCurves.prototype, "midtonesDensity", {
  59714. /**
  59715. * Gets the midtones Density value.
  59716. * 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.
  59717. * Values less than zero provide a filter of opposite hue.
  59718. */
  59719. get: function () {
  59720. return this._midtonesDensity;
  59721. },
  59722. /**
  59723. * Sets the midtones Density value.
  59724. * 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.
  59725. * Values less than zero provide a filter of opposite hue.
  59726. */
  59727. set: function (value) {
  59728. this._midtonesDensity = value;
  59729. this._dirty = true;
  59730. },
  59731. enumerable: true,
  59732. configurable: true
  59733. });
  59734. Object.defineProperty(ColorCurves.prototype, "midtonesSaturation", {
  59735. /**
  59736. * Gets the midtones Saturation value.
  59737. * 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.
  59738. */
  59739. get: function () {
  59740. return this._midtonesSaturation;
  59741. },
  59742. /**
  59743. * Sets the midtones Saturation value.
  59744. * 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.
  59745. */
  59746. set: function (value) {
  59747. this._midtonesSaturation = value;
  59748. this._dirty = true;
  59749. },
  59750. enumerable: true,
  59751. configurable: true
  59752. });
  59753. Object.defineProperty(ColorCurves.prototype, "midtonesExposure", {
  59754. /**
  59755. * Gets the midtones Exposure value.
  59756. * 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.
  59757. */
  59758. get: function () {
  59759. return this._midtonesExposure;
  59760. },
  59761. /**
  59762. * Sets the midtones Exposure value.
  59763. * 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.
  59764. */
  59765. set: function (value) {
  59766. this._midtonesExposure = value;
  59767. this._dirty = true;
  59768. },
  59769. enumerable: true,
  59770. configurable: true
  59771. });
  59772. Object.defineProperty(ColorCurves.prototype, "shadowsHue", {
  59773. /**
  59774. * Gets the shadows Hue value.
  59775. * 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).
  59776. */
  59777. get: function () {
  59778. return this._shadowsHue;
  59779. },
  59780. /**
  59781. * Sets the shadows Hue value.
  59782. * 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).
  59783. */
  59784. set: function (value) {
  59785. this._shadowsHue = value;
  59786. this._dirty = true;
  59787. },
  59788. enumerable: true,
  59789. configurable: true
  59790. });
  59791. Object.defineProperty(ColorCurves.prototype, "shadowsDensity", {
  59792. /**
  59793. * Gets the shadows Density value.
  59794. * 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.
  59795. * Values less than zero provide a filter of opposite hue.
  59796. */
  59797. get: function () {
  59798. return this._shadowsDensity;
  59799. },
  59800. /**
  59801. * Sets the shadows Density value.
  59802. * 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.
  59803. * Values less than zero provide a filter of opposite hue.
  59804. */
  59805. set: function (value) {
  59806. this._shadowsDensity = value;
  59807. this._dirty = true;
  59808. },
  59809. enumerable: true,
  59810. configurable: true
  59811. });
  59812. Object.defineProperty(ColorCurves.prototype, "shadowsSaturation", {
  59813. /**
  59814. * Gets the shadows Saturation value.
  59815. * 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.
  59816. */
  59817. get: function () {
  59818. return this._shadowsSaturation;
  59819. },
  59820. /**
  59821. * Sets the shadows Saturation value.
  59822. * 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.
  59823. */
  59824. set: function (value) {
  59825. this._shadowsSaturation = value;
  59826. this._dirty = true;
  59827. },
  59828. enumerable: true,
  59829. configurable: true
  59830. });
  59831. Object.defineProperty(ColorCurves.prototype, "shadowsExposure", {
  59832. /**
  59833. * Gets the shadows Exposure value.
  59834. * 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.
  59835. */
  59836. get: function () {
  59837. return this._shadowsExposure;
  59838. },
  59839. /**
  59840. * Sets the shadows Exposure value.
  59841. * 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.
  59842. */
  59843. set: function (value) {
  59844. this._shadowsExposure = value;
  59845. this._dirty = true;
  59846. },
  59847. enumerable: true,
  59848. configurable: true
  59849. });
  59850. /**
  59851. * Returns the class name
  59852. * @returns The class name
  59853. */
  59854. ColorCurves.prototype.getClassName = function () {
  59855. return "ColorCurves";
  59856. };
  59857. /**
  59858. * Binds the color curves to the shader.
  59859. * @param colorCurves The color curve to bind
  59860. * @param effect The effect to bind to
  59861. * @param positiveUniform The positive uniform shader parameter
  59862. * @param neutralUniform The neutral uniform shader parameter
  59863. * @param negativeUniform The negative uniform shader parameter
  59864. */
  59865. ColorCurves.Bind = function (colorCurves, effect, positiveUniform, neutralUniform, negativeUniform) {
  59866. if (positiveUniform === void 0) { positiveUniform = "vCameraColorCurvePositive"; }
  59867. if (neutralUniform === void 0) { neutralUniform = "vCameraColorCurveNeutral"; }
  59868. if (negativeUniform === void 0) { negativeUniform = "vCameraColorCurveNegative"; }
  59869. if (colorCurves._dirty) {
  59870. colorCurves._dirty = false;
  59871. // Fill in global info.
  59872. colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
  59873. // Compute highlights info.
  59874. colorCurves.getColorGradingDataToRef(colorCurves._highlightsHue, colorCurves._highlightsDensity, colorCurves._highlightsSaturation, colorCurves._highlightsExposure, colorCurves._tempColor);
  59875. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._highlightsCurve);
  59876. // Compute midtones info.
  59877. colorCurves.getColorGradingDataToRef(colorCurves._midtonesHue, colorCurves._midtonesDensity, colorCurves._midtonesSaturation, colorCurves._midtonesExposure, colorCurves._tempColor);
  59878. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._midtonesCurve);
  59879. // Compute shadows info.
  59880. colorCurves.getColorGradingDataToRef(colorCurves._shadowsHue, colorCurves._shadowsDensity, colorCurves._shadowsSaturation, colorCurves._shadowsExposure, colorCurves._tempColor);
  59881. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._shadowsCurve);
  59882. // Compute deltas (neutral is midtones).
  59883. colorCurves._highlightsCurve.subtractToRef(colorCurves._midtonesCurve, colorCurves._positiveCurve);
  59884. colorCurves._midtonesCurve.subtractToRef(colorCurves._shadowsCurve, colorCurves._negativeCurve);
  59885. }
  59886. if (effect) {
  59887. effect.setFloat4(positiveUniform, colorCurves._positiveCurve.r, colorCurves._positiveCurve.g, colorCurves._positiveCurve.b, colorCurves._positiveCurve.a);
  59888. effect.setFloat4(neutralUniform, colorCurves._midtonesCurve.r, colorCurves._midtonesCurve.g, colorCurves._midtonesCurve.b, colorCurves._midtonesCurve.a);
  59889. effect.setFloat4(negativeUniform, colorCurves._negativeCurve.r, colorCurves._negativeCurve.g, colorCurves._negativeCurve.b, colorCurves._negativeCurve.a);
  59890. }
  59891. };
  59892. /**
  59893. * Prepare the list of uniforms associated with the ColorCurves effects.
  59894. * @param uniformsList The list of uniforms used in the effect
  59895. */
  59896. ColorCurves.PrepareUniforms = function (uniformsList) {
  59897. uniformsList.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
  59898. };
  59899. /**
  59900. * Returns color grading data based on a hue, density, saturation and exposure value.
  59901. * @param filterHue The hue of the color filter.
  59902. * @param filterDensity The density of the color filter.
  59903. * @param saturation The saturation.
  59904. * @param exposure The exposure.
  59905. * @param result The result data container.
  59906. */
  59907. ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
  59908. if (hue == null) {
  59909. return;
  59910. }
  59911. hue = ColorCurves.clamp(hue, 0, 360);
  59912. density = ColorCurves.clamp(density, -100, 100);
  59913. saturation = ColorCurves.clamp(saturation, -100, 100);
  59914. exposure = ColorCurves.clamp(exposure, -100, 100);
  59915. // Remap the slider/config filter density with non-linear mapping and also scale by half
  59916. // so that the maximum filter density is only 50% control. This provides fine control
  59917. // for small values and reasonable range.
  59918. density = ColorCurves.applyColorGradingSliderNonlinear(density);
  59919. density *= 0.5;
  59920. exposure = ColorCurves.applyColorGradingSliderNonlinear(exposure);
  59921. if (density < 0) {
  59922. density *= -1;
  59923. hue = (hue + 180) % 360;
  59924. }
  59925. ColorCurves.fromHSBToRef(hue, density, 50 + 0.25 * exposure, result);
  59926. result.scaleToRef(2, result);
  59927. result.a = 1 + 0.01 * saturation;
  59928. };
  59929. /**
  59930. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  59931. * @param value The input slider value in range [-100,100].
  59932. * @returns Adjusted value.
  59933. */
  59934. ColorCurves.applyColorGradingSliderNonlinear = function (value) {
  59935. value /= 100;
  59936. var x = Math.abs(value);
  59937. x = Math.pow(x, 2);
  59938. if (value < 0) {
  59939. x *= -1;
  59940. }
  59941. x *= 100;
  59942. return x;
  59943. };
  59944. /**
  59945. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  59946. * @param hue The hue (H) input.
  59947. * @param saturation The saturation (S) input.
  59948. * @param brightness The brightness (B) input.
  59949. * @result An RGBA color represented as Vector4.
  59950. */
  59951. ColorCurves.fromHSBToRef = function (hue, saturation, brightness, result) {
  59952. var h = ColorCurves.clamp(hue, 0, 360);
  59953. var s = ColorCurves.clamp(saturation / 100, 0, 1);
  59954. var v = ColorCurves.clamp(brightness / 100, 0, 1);
  59955. if (s === 0) {
  59956. result.r = v;
  59957. result.g = v;
  59958. result.b = v;
  59959. }
  59960. else {
  59961. // sector 0 to 5
  59962. h /= 60;
  59963. var i = Math.floor(h);
  59964. // fractional part of h
  59965. var f = h - i;
  59966. var p = v * (1 - s);
  59967. var q = v * (1 - s * f);
  59968. var t = v * (1 - s * (1 - f));
  59969. switch (i) {
  59970. case 0:
  59971. result.r = v;
  59972. result.g = t;
  59973. result.b = p;
  59974. break;
  59975. case 1:
  59976. result.r = q;
  59977. result.g = v;
  59978. result.b = p;
  59979. break;
  59980. case 2:
  59981. result.r = p;
  59982. result.g = v;
  59983. result.b = t;
  59984. break;
  59985. case 3:
  59986. result.r = p;
  59987. result.g = q;
  59988. result.b = v;
  59989. break;
  59990. case 4:
  59991. result.r = t;
  59992. result.g = p;
  59993. result.b = v;
  59994. break;
  59995. default: // case 5:
  59996. result.r = v;
  59997. result.g = p;
  59998. result.b = q;
  59999. break;
  60000. }
  60001. }
  60002. result.a = 1;
  60003. };
  60004. /**
  60005. * Returns a value clamped between min and max
  60006. * @param value The value to clamp
  60007. * @param min The minimum of value
  60008. * @param max The maximum of value
  60009. * @returns The clamped value.
  60010. */
  60011. ColorCurves.clamp = function (value, min, max) {
  60012. return Math.min(Math.max(value, min), max);
  60013. };
  60014. /**
  60015. * Clones the current color curve instance.
  60016. * @return The cloned curves
  60017. */
  60018. ColorCurves.prototype.clone = function () {
  60019. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ColorCurves(); }, this);
  60020. };
  60021. /**
  60022. * Serializes the current color curve instance to a json representation.
  60023. * @return a JSON representation
  60024. */
  60025. ColorCurves.prototype.serialize = function () {
  60026. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  60027. };
  60028. /**
  60029. * Parses the color curve from a json representation.
  60030. * @param source the JSON source to parse
  60031. * @return The parsed curves
  60032. */
  60033. ColorCurves.Parse = function (source) {
  60034. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ColorCurves(); }, source, null, null);
  60035. };
  60036. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60037. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60038. ], ColorCurves.prototype, "_globalHue", void 0);
  60039. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60041. ], ColorCurves.prototype, "_globalDensity", void 0);
  60042. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60043. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60044. ], ColorCurves.prototype, "_globalSaturation", void 0);
  60045. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60046. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60047. ], ColorCurves.prototype, "_globalExposure", void 0);
  60048. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60049. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60050. ], ColorCurves.prototype, "_highlightsHue", void 0);
  60051. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60052. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60053. ], ColorCurves.prototype, "_highlightsDensity", void 0);
  60054. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60055. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60056. ], ColorCurves.prototype, "_highlightsSaturation", void 0);
  60057. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60058. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60059. ], ColorCurves.prototype, "_highlightsExposure", void 0);
  60060. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60061. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60062. ], ColorCurves.prototype, "_midtonesHue", void 0);
  60063. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60064. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60065. ], ColorCurves.prototype, "_midtonesDensity", void 0);
  60066. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60067. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60068. ], ColorCurves.prototype, "_midtonesSaturation", void 0);
  60069. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60070. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60071. ], ColorCurves.prototype, "_midtonesExposure", void 0);
  60072. return ColorCurves;
  60073. }());
  60074. // References the dependencies.
  60075. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ColorCurvesParser = ColorCurves.Parse;
  60076. /***/ }),
  60077. /***/ "./Materials/effect.ts":
  60078. /*!*****************************!*\
  60079. !*** ./Materials/effect.ts ***!
  60080. \*****************************/
  60081. /*! exports provided: EffectFallbacks, EffectCreationOptions, Effect */
  60082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60083. "use strict";
  60084. __webpack_require__.r(__webpack_exports__);
  60085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return EffectFallbacks; });
  60086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return EffectCreationOptions; });
  60087. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return Effect; });
  60088. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  60089. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  60090. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  60091. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  60092. /**
  60093. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  60094. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  60095. */
  60096. var EffectFallbacks = /** @class */ (function () {
  60097. function EffectFallbacks() {
  60098. this._defines = {};
  60099. this._currentRank = 32;
  60100. this._maxRank = -1;
  60101. }
  60102. /**
  60103. * Removes the fallback from the bound mesh.
  60104. */
  60105. EffectFallbacks.prototype.unBindMesh = function () {
  60106. this._mesh = null;
  60107. };
  60108. /**
  60109. * Adds a fallback on the specified property.
  60110. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  60111. * @param define The name of the define in the shader
  60112. */
  60113. EffectFallbacks.prototype.addFallback = function (rank, define) {
  60114. if (!this._defines[rank]) {
  60115. if (rank < this._currentRank) {
  60116. this._currentRank = rank;
  60117. }
  60118. if (rank > this._maxRank) {
  60119. this._maxRank = rank;
  60120. }
  60121. this._defines[rank] = new Array();
  60122. }
  60123. this._defines[rank].push(define);
  60124. };
  60125. /**
  60126. * Sets the mesh to use CPU skinning when needing to fallback.
  60127. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  60128. * @param mesh The mesh to use the fallbacks.
  60129. */
  60130. EffectFallbacks.prototype.addCPUSkinningFallback = function (rank, mesh) {
  60131. this._mesh = mesh;
  60132. if (rank < this._currentRank) {
  60133. this._currentRank = rank;
  60134. }
  60135. if (rank > this._maxRank) {
  60136. this._maxRank = rank;
  60137. }
  60138. };
  60139. Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
  60140. /**
  60141. * Checks to see if more fallbacks are still availible.
  60142. */
  60143. get: function () {
  60144. return this._currentRank <= this._maxRank;
  60145. },
  60146. enumerable: true,
  60147. configurable: true
  60148. });
  60149. /**
  60150. * Removes the defines that shoould be removed when falling back.
  60151. * @param currentDefines defines the current define statements for the shader.
  60152. * @param effect defines the current effect we try to compile
  60153. * @returns The resulting defines with defines of the current rank removed.
  60154. */
  60155. EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
  60156. // First we try to switch to CPU skinning
  60157. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
  60158. this._mesh.computeBonesUsingShaders = false;
  60159. currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
  60160. effect._bonesComputationForcedToCPU = true;
  60161. var scene = this._mesh.getScene();
  60162. for (var index = 0; index < scene.meshes.length; index++) {
  60163. var otherMesh = scene.meshes[index];
  60164. if (!otherMesh.material) {
  60165. continue;
  60166. }
  60167. if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
  60168. continue;
  60169. }
  60170. if (otherMesh.material.getEffect() === effect) {
  60171. otherMesh.computeBonesUsingShaders = false;
  60172. }
  60173. else if (otherMesh.subMeshes) {
  60174. for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
  60175. var subMesh = _a[_i];
  60176. var subMeshEffect = subMesh.effect;
  60177. if (subMeshEffect === effect) {
  60178. otherMesh.computeBonesUsingShaders = false;
  60179. break;
  60180. }
  60181. }
  60182. }
  60183. }
  60184. }
  60185. else {
  60186. var currentFallbacks = this._defines[this._currentRank];
  60187. if (currentFallbacks) {
  60188. for (var index = 0; index < currentFallbacks.length; index++) {
  60189. currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
  60190. }
  60191. }
  60192. this._currentRank++;
  60193. }
  60194. return currentDefines;
  60195. };
  60196. return EffectFallbacks;
  60197. }());
  60198. /**
  60199. * Options to be used when creating an effect.
  60200. */
  60201. var EffectCreationOptions = /** @class */ (function () {
  60202. function EffectCreationOptions() {
  60203. }
  60204. return EffectCreationOptions;
  60205. }());
  60206. /**
  60207. * Effect containing vertex and fragment shader that can be executed on an object.
  60208. */
  60209. var Effect = /** @class */ (function () {
  60210. /**
  60211. * Instantiates an effect.
  60212. * An effect can be used to create/manage/execute vertex and fragment shaders.
  60213. * @param baseName Name of the effect.
  60214. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  60215. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  60216. * @param samplers List of sampler variables that will be passed to the shader.
  60217. * @param engine Engine to be used to render the effect
  60218. * @param defines Define statements to be added to the shader.
  60219. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  60220. * @param onCompiled Callback that will be called when the shader is compiled.
  60221. * @param onError Callback that will be called if an error occurs during shader compilation.
  60222. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  60223. */
  60224. function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {
  60225. if (samplers === void 0) { samplers = null; }
  60226. if (defines === void 0) { defines = null; }
  60227. if (fallbacks === void 0) { fallbacks = null; }
  60228. if (onCompiled === void 0) { onCompiled = null; }
  60229. if (onError === void 0) { onError = null; }
  60230. var _this = this;
  60231. /**
  60232. * Unique ID of the effect.
  60233. */
  60234. this.uniqueId = 0;
  60235. /**
  60236. * Observable that will be called when the shader is compiled.
  60237. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  60238. */
  60239. this.onCompileObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  60240. /**
  60241. * Observable that will be called if an error occurs during shader compilation.
  60242. */
  60243. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  60244. /** @hidden */
  60245. this._bonesComputationForcedToCPU = false;
  60246. this._uniformBuffersNames = {};
  60247. this._isReady = false;
  60248. this._compilationError = "";
  60249. this.name = baseName;
  60250. if (attributesNamesOrOptions.attributes) {
  60251. var options = attributesNamesOrOptions;
  60252. this._engine = uniformsNamesOrEngine;
  60253. this._attributesNames = options.attributes;
  60254. this._uniformsNames = options.uniformsNames.concat(options.samplers);
  60255. this._samplers = options.samplers.slice();
  60256. this.defines = options.defines;
  60257. this.onError = options.onError;
  60258. this.onCompiled = options.onCompiled;
  60259. this._fallbacks = options.fallbacks;
  60260. this._indexParameters = options.indexParameters;
  60261. this._transformFeedbackVaryings = options.transformFeedbackVaryings;
  60262. if (options.uniformBuffersNames) {
  60263. for (var i = 0; i < options.uniformBuffersNames.length; i++) {
  60264. this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;
  60265. }
  60266. }
  60267. }
  60268. else {
  60269. this._engine = engine;
  60270. this.defines = defines;
  60271. this._uniformsNames = uniformsNamesOrEngine.concat(samplers);
  60272. this._samplers = samplers ? samplers.slice() : [];
  60273. this._attributesNames = attributesNamesOrOptions;
  60274. this.onError = onError;
  60275. this.onCompiled = onCompiled;
  60276. this._indexParameters = indexParameters;
  60277. this._fallbacks = fallbacks;
  60278. }
  60279. this.uniqueId = Effect._uniqueIdSeed++;
  60280. var vertexSource;
  60281. var fragmentSource;
  60282. if (baseName.vertexElement) {
  60283. vertexSource = document.getElementById(baseName.vertexElement);
  60284. if (!vertexSource) {
  60285. vertexSource = baseName.vertexElement;
  60286. }
  60287. }
  60288. else {
  60289. vertexSource = baseName.vertex || baseName;
  60290. }
  60291. if (baseName.fragmentElement) {
  60292. fragmentSource = document.getElementById(baseName.fragmentElement);
  60293. if (!fragmentSource) {
  60294. fragmentSource = baseName.fragmentElement;
  60295. }
  60296. }
  60297. else {
  60298. fragmentSource = baseName.fragment || baseName;
  60299. }
  60300. this._loadVertexShader(vertexSource, function (vertexCode) {
  60301. _this._processIncludes(vertexCode, function (vertexCodeWithIncludes) {
  60302. _this._processShaderConversion(vertexCodeWithIncludes, false, function (migratedVertexCode) {
  60303. _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
  60304. _this._processIncludes(fragmentCode, function (fragmentCodeWithIncludes) {
  60305. _this._processShaderConversion(fragmentCodeWithIncludes, true, function (migratedFragmentCode) {
  60306. if (baseName) {
  60307. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  60308. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  60309. _this._vertexSourceCode = "#define SHADER_NAME vertex:" + vertex + "\n" + migratedVertexCode;
  60310. _this._fragmentSourceCode = "#define SHADER_NAME fragment:" + fragment + "\n" + migratedFragmentCode;
  60311. }
  60312. else {
  60313. _this._vertexSourceCode = migratedVertexCode;
  60314. _this._fragmentSourceCode = migratedFragmentCode;
  60315. }
  60316. _this._prepareEffect();
  60317. });
  60318. });
  60319. });
  60320. });
  60321. });
  60322. });
  60323. }
  60324. Object.defineProperty(Effect.prototype, "onBindObservable", {
  60325. /**
  60326. * Observable that will be called when effect is bound.
  60327. */
  60328. get: function () {
  60329. if (!this._onBindObservable) {
  60330. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  60331. }
  60332. return this._onBindObservable;
  60333. },
  60334. enumerable: true,
  60335. configurable: true
  60336. });
  60337. Object.defineProperty(Effect.prototype, "key", {
  60338. /**
  60339. * Unique key for this effect
  60340. */
  60341. get: function () {
  60342. return this._key;
  60343. },
  60344. enumerable: true,
  60345. configurable: true
  60346. });
  60347. /**
  60348. * If the effect has been compiled and prepared.
  60349. * @returns if the effect is compiled and prepared.
  60350. */
  60351. Effect.prototype.isReady = function () {
  60352. if (!this._isReady && this._program && this._program.isParallelCompiled) {
  60353. return this._engine._isProgramCompiled(this._program);
  60354. }
  60355. return this._isReady;
  60356. };
  60357. /**
  60358. * The engine the effect was initialized with.
  60359. * @returns the engine.
  60360. */
  60361. Effect.prototype.getEngine = function () {
  60362. return this._engine;
  60363. };
  60364. /**
  60365. * The compiled webGL program for the effect
  60366. * @returns the webGL program.
  60367. */
  60368. Effect.prototype.getProgram = function () {
  60369. return this._program;
  60370. };
  60371. /**
  60372. * The set of names of attribute variables for the shader.
  60373. * @returns An array of attribute names.
  60374. */
  60375. Effect.prototype.getAttributesNames = function () {
  60376. return this._attributesNames;
  60377. };
  60378. /**
  60379. * Returns the attribute at the given index.
  60380. * @param index The index of the attribute.
  60381. * @returns The location of the attribute.
  60382. */
  60383. Effect.prototype.getAttributeLocation = function (index) {
  60384. return this._attributes[index];
  60385. };
  60386. /**
  60387. * Returns the attribute based on the name of the variable.
  60388. * @param name of the attribute to look up.
  60389. * @returns the attribute location.
  60390. */
  60391. Effect.prototype.getAttributeLocationByName = function (name) {
  60392. var index = this._attributesNames.indexOf(name);
  60393. return this._attributes[index];
  60394. };
  60395. /**
  60396. * The number of attributes.
  60397. * @returns the numnber of attributes.
  60398. */
  60399. Effect.prototype.getAttributesCount = function () {
  60400. return this._attributes.length;
  60401. };
  60402. /**
  60403. * Gets the index of a uniform variable.
  60404. * @param uniformName of the uniform to look up.
  60405. * @returns the index.
  60406. */
  60407. Effect.prototype.getUniformIndex = function (uniformName) {
  60408. return this._uniformsNames.indexOf(uniformName);
  60409. };
  60410. /**
  60411. * Returns the attribute based on the name of the variable.
  60412. * @param uniformName of the uniform to look up.
  60413. * @returns the location of the uniform.
  60414. */
  60415. Effect.prototype.getUniform = function (uniformName) {
  60416. return this._uniforms[this._uniformsNames.indexOf(uniformName)];
  60417. };
  60418. /**
  60419. * Returns an array of sampler variable names
  60420. * @returns The array of sampler variable neames.
  60421. */
  60422. Effect.prototype.getSamplers = function () {
  60423. return this._samplers;
  60424. };
  60425. /**
  60426. * The error from the last compilation.
  60427. * @returns the error string.
  60428. */
  60429. Effect.prototype.getCompilationError = function () {
  60430. return this._compilationError;
  60431. };
  60432. /**
  60433. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  60434. * @param func The callback to be used.
  60435. */
  60436. Effect.prototype.executeWhenCompiled = function (func) {
  60437. var _this = this;
  60438. if (this.isReady()) {
  60439. func(this);
  60440. return;
  60441. }
  60442. this.onCompileObservable.add(function (effect) {
  60443. func(effect);
  60444. });
  60445. if (!this._program || this._program.isParallelCompiled) {
  60446. setTimeout(function () {
  60447. _this._checkIsReady();
  60448. }, 16);
  60449. }
  60450. };
  60451. Effect.prototype._checkIsReady = function () {
  60452. var _this = this;
  60453. if (this.isReady()) {
  60454. return;
  60455. }
  60456. setTimeout(function () {
  60457. _this._checkIsReady();
  60458. }, 16);
  60459. };
  60460. /** @hidden */
  60461. Effect.prototype._loadVertexShader = function (vertex, callback) {
  60462. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  60463. // DOM element ?
  60464. if (vertex instanceof HTMLElement) {
  60465. var vertexCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(vertex);
  60466. callback(vertexCode);
  60467. return;
  60468. }
  60469. }
  60470. // Base64 encoded ?
  60471. if (vertex.substr(0, 7) === "base64:") {
  60472. var vertexBinary = window.atob(vertex.substr(7));
  60473. callback(vertexBinary);
  60474. return;
  60475. }
  60476. // Is in local store ?
  60477. if (Effect.ShadersStore[vertex + "VertexShader"]) {
  60478. callback(Effect.ShadersStore[vertex + "VertexShader"]);
  60479. return;
  60480. }
  60481. var vertexShaderUrl;
  60482. if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
  60483. vertexShaderUrl = vertex;
  60484. }
  60485. else {
  60486. vertexShaderUrl = Effect.ShadersRepository + vertex;
  60487. }
  60488. // Vertex shader
  60489. this._engine._loadFile(vertexShaderUrl + ".vertex.fx", callback);
  60490. };
  60491. /** @hidden */
  60492. Effect.prototype._loadFragmentShader = function (fragment, callback) {
  60493. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  60494. // DOM element ?
  60495. if (fragment instanceof HTMLElement) {
  60496. var fragmentCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(fragment);
  60497. callback(fragmentCode);
  60498. return;
  60499. }
  60500. }
  60501. // Base64 encoded ?
  60502. if (fragment.substr(0, 7) === "base64:") {
  60503. var fragmentBinary = window.atob(fragment.substr(7));
  60504. callback(fragmentBinary);
  60505. return;
  60506. }
  60507. // Is in local store ?
  60508. if (Effect.ShadersStore[fragment + "PixelShader"]) {
  60509. callback(Effect.ShadersStore[fragment + "PixelShader"]);
  60510. return;
  60511. }
  60512. if (Effect.ShadersStore[fragment + "FragmentShader"]) {
  60513. callback(Effect.ShadersStore[fragment + "FragmentShader"]);
  60514. return;
  60515. }
  60516. var fragmentShaderUrl;
  60517. if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
  60518. fragmentShaderUrl = fragment;
  60519. }
  60520. else {
  60521. fragmentShaderUrl = Effect.ShadersRepository + fragment;
  60522. }
  60523. // Fragment shader
  60524. this._engine._loadFile(fragmentShaderUrl + ".fragment.fx", callback);
  60525. };
  60526. /** @hidden */
  60527. Effect.prototype._dumpShadersSource = function (vertexCode, fragmentCode, defines) {
  60528. // Rebuild shaders source code
  60529. var shaderVersion = (this._engine.webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  60530. var prefix = shaderVersion + (defines ? defines + "\n" : "");
  60531. vertexCode = prefix + vertexCode;
  60532. fragmentCode = prefix + fragmentCode;
  60533. // Number lines of shaders source code
  60534. var i = 2;
  60535. var regex = /\n/gm;
  60536. var formattedVertexCode = "\n1\t" + vertexCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  60537. i = 2;
  60538. var formattedFragmentCode = "\n1\t" + fragmentCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  60539. // Dump shaders name and formatted source code
  60540. if (this.name.vertexElement) {
  60541. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
  60542. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
  60543. }
  60544. else if (this.name.vertex) {
  60545. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
  60546. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
  60547. }
  60548. else {
  60549. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name + formattedVertexCode);
  60550. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name + formattedFragmentCode);
  60551. }
  60552. };
  60553. Effect.prototype._processShaderConversion = function (sourceCode, isFragment, callback) {
  60554. var preparedSourceCode = this._processPrecision(sourceCode);
  60555. if (this._engine.webGLVersion == 1) {
  60556. callback(preparedSourceCode);
  60557. return;
  60558. }
  60559. // Already converted
  60560. if (preparedSourceCode.indexOf("#version 3") !== -1) {
  60561. callback(preparedSourceCode.replace("#version 300 es", ""));
  60562. return;
  60563. }
  60564. var hasDrawBuffersExtension = preparedSourceCode.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
  60565. // Remove extensions
  60566. // #extension GL_OES_standard_derivatives : enable
  60567. // #extension GL_EXT_shader_texture_lod : enable
  60568. // #extension GL_EXT_frag_depth : enable
  60569. // #extension GL_EXT_draw_buffers : require
  60570. var regex = /#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  60571. var result = preparedSourceCode.replace(regex, "");
  60572. // Migrate to GLSL v300
  60573. result = result.replace(/varying(?![\n\r])\s/g, isFragment ? "in " : "out ");
  60574. result = result.replace(/attribute[ \t]/g, "in ");
  60575. result = result.replace(/[ \t]attribute/g, " in");
  60576. result = result.replace(/texture2D\s*\(/g, "texture(");
  60577. if (isFragment) {
  60578. result = result.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
  60579. result = result.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
  60580. result = result.replace(/textureCube\s*\(/g, "texture(");
  60581. result = result.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
  60582. result = result.replace(/gl_FragColor/g, "glFragColor");
  60583. result = result.replace(/gl_FragData/g, "glFragData");
  60584. result = result.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "out vec4 glFragColor;\n") + "void main(");
  60585. }
  60586. callback(result);
  60587. };
  60588. Effect.prototype._processIncludes = function (sourceCode, callback) {
  60589. var _this = this;
  60590. var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
  60591. var match = regex.exec(sourceCode);
  60592. var returnValue = new String(sourceCode);
  60593. while (match != null) {
  60594. var includeFile = match[1];
  60595. // Uniform declaration
  60596. if (includeFile.indexOf("__decl__") !== -1) {
  60597. includeFile = includeFile.replace(/__decl__/, "");
  60598. if (this._engine.supportsUniformBuffers) {
  60599. includeFile = includeFile.replace(/Vertex/, "Ubo");
  60600. includeFile = includeFile.replace(/Fragment/, "Ubo");
  60601. }
  60602. includeFile = includeFile + "Declaration";
  60603. }
  60604. if (Effect.IncludesShadersStore[includeFile]) {
  60605. // Substitution
  60606. var includeContent = Effect.IncludesShadersStore[includeFile];
  60607. if (match[2]) {
  60608. var splits = match[3].split(",");
  60609. for (var index = 0; index < splits.length; index += 2) {
  60610. var source = new RegExp(splits[index], "g");
  60611. var dest = splits[index + 1];
  60612. includeContent = includeContent.replace(source, dest);
  60613. }
  60614. }
  60615. if (match[4]) {
  60616. var indexString = match[5];
  60617. if (indexString.indexOf("..") !== -1) {
  60618. var indexSplits = indexString.split("..");
  60619. var minIndex = parseInt(indexSplits[0]);
  60620. var maxIndex = parseInt(indexSplits[1]);
  60621. var sourceIncludeContent = includeContent.slice(0);
  60622. includeContent = "";
  60623. if (isNaN(maxIndex)) {
  60624. maxIndex = this._indexParameters[indexSplits[1]];
  60625. }
  60626. for (var i = minIndex; i < maxIndex; i++) {
  60627. if (!this._engine.supportsUniformBuffers) {
  60628. // Ubo replacement
  60629. sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  60630. return p1 + "{X}";
  60631. });
  60632. }
  60633. includeContent += sourceIncludeContent.replace(/\{X\}/g, i.toString()) + "\n";
  60634. }
  60635. }
  60636. else {
  60637. if (!this._engine.supportsUniformBuffers) {
  60638. // Ubo replacement
  60639. includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  60640. return p1 + "{X}";
  60641. });
  60642. }
  60643. includeContent = includeContent.replace(/\{X\}/g, indexString);
  60644. }
  60645. }
  60646. // Replace
  60647. returnValue = returnValue.replace(match[0], includeContent);
  60648. }
  60649. else {
  60650. var includeShaderUrl = Effect.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
  60651. this._engine._loadFile(includeShaderUrl, function (fileContent) {
  60652. Effect.IncludesShadersStore[includeFile] = fileContent;
  60653. _this._processIncludes(returnValue, callback);
  60654. });
  60655. return;
  60656. }
  60657. match = regex.exec(sourceCode);
  60658. }
  60659. callback(returnValue);
  60660. };
  60661. Effect.prototype._processPrecision = function (source) {
  60662. if (source.indexOf("precision highp float") === -1) {
  60663. if (!this._engine.getCaps().highPrecisionShaderSupported) {
  60664. source = "precision mediump float;\n" + source;
  60665. }
  60666. else {
  60667. source = "precision highp float;\n" + source;
  60668. }
  60669. }
  60670. else {
  60671. if (!this._engine.getCaps().highPrecisionShaderSupported) { // Moving highp to mediump
  60672. source = source.replace("precision highp float", "precision mediump float");
  60673. }
  60674. }
  60675. return source;
  60676. };
  60677. /**
  60678. * Recompiles the webGL program
  60679. * @param vertexSourceCode The source code for the vertex shader.
  60680. * @param fragmentSourceCode The source code for the fragment shader.
  60681. * @param onCompiled Callback called when completed.
  60682. * @param onError Callback called on error.
  60683. * @hidden
  60684. */
  60685. Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
  60686. var _this = this;
  60687. this._isReady = false;
  60688. this._vertexSourceCodeOverride = vertexSourceCode;
  60689. this._fragmentSourceCodeOverride = fragmentSourceCode;
  60690. this.onError = function (effect, error) {
  60691. if (onError) {
  60692. onError(error);
  60693. }
  60694. };
  60695. this.onCompiled = function () {
  60696. var scenes = _this.getEngine().scenes;
  60697. for (var i = 0; i < scenes.length; i++) {
  60698. scenes[i].markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  60699. }
  60700. if (onCompiled) {
  60701. onCompiled(_this._program);
  60702. }
  60703. };
  60704. this._fallbacks = null;
  60705. this._prepareEffect();
  60706. };
  60707. /**
  60708. * Gets the uniform locations of the the specified variable names
  60709. * @param names THe names of the variables to lookup.
  60710. * @returns Array of locations in the same order as variable names.
  60711. */
  60712. Effect.prototype.getSpecificUniformLocations = function (names) {
  60713. var engine = this._engine;
  60714. return engine.getUniforms(this._program, names);
  60715. };
  60716. /**
  60717. * Prepares the effect
  60718. * @hidden
  60719. */
  60720. Effect.prototype._prepareEffect = function () {
  60721. var _this = this;
  60722. var attributesNames = this._attributesNames;
  60723. var defines = this.defines;
  60724. var fallbacks = this._fallbacks;
  60725. this._valueCache = {};
  60726. var previousProgram = this._program;
  60727. try {
  60728. var engine_1 = this._engine;
  60729. if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
  60730. this._program = engine_1.createRawShaderProgram(this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, undefined, this._transformFeedbackVaryings);
  60731. }
  60732. else {
  60733. this._program = engine_1.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines, undefined, this._transformFeedbackVaryings);
  60734. }
  60735. this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
  60736. engine_1._executeWhenProgramIsCompiled(this._program, function () {
  60737. if (engine_1.supportsUniformBuffers) {
  60738. for (var name in _this._uniformBuffersNames) {
  60739. _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
  60740. }
  60741. }
  60742. _this._uniforms = engine_1.getUniforms(_this._program, _this._uniformsNames);
  60743. _this._attributes = engine_1.getAttributes(_this._program, attributesNames);
  60744. var index;
  60745. for (index = 0; index < _this._samplers.length; index++) {
  60746. var sampler = _this.getUniform(_this._samplers[index]);
  60747. if (sampler == null) {
  60748. _this._samplers.splice(index, 1);
  60749. index--;
  60750. }
  60751. }
  60752. engine_1.bindSamplers(_this);
  60753. _this._compilationError = "";
  60754. _this._isReady = true;
  60755. if (_this.onCompiled) {
  60756. _this.onCompiled(_this);
  60757. }
  60758. _this.onCompileObservable.notifyObservers(_this);
  60759. _this.onCompileObservable.clear();
  60760. // Unbind mesh reference in fallbacks
  60761. if (_this._fallbacks) {
  60762. _this._fallbacks.unBindMesh();
  60763. }
  60764. if (previousProgram) {
  60765. _this.getEngine()._deleteProgram(previousProgram);
  60766. }
  60767. });
  60768. if (this._program.isParallelCompiled) {
  60769. this._checkIsReady();
  60770. }
  60771. }
  60772. catch (e) {
  60773. this._compilationError = e.message;
  60774. // Let's go through fallbacks then
  60775. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Unable to compile effect:");
  60776. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Uniforms: " + this._uniformsNames.map(function (uniform) {
  60777. return " " + uniform;
  60778. }));
  60779. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Attributes: " + attributesNames.map(function (attribute) {
  60780. return " " + attribute;
  60781. }));
  60782. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Error: " + this._compilationError);
  60783. if (previousProgram) {
  60784. this._program = previousProgram;
  60785. this._isReady = true;
  60786. if (this.onError) {
  60787. this.onError(this, this._compilationError);
  60788. }
  60789. this.onErrorObservable.notifyObservers(this);
  60790. }
  60791. if (fallbacks && fallbacks.isMoreFallbacks) {
  60792. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Trying next fallback.");
  60793. this.defines = fallbacks.reduce(this.defines, this);
  60794. this._prepareEffect();
  60795. }
  60796. else { // Sorry we did everything we can
  60797. if (this.onError) {
  60798. this.onError(this, this._compilationError);
  60799. }
  60800. this.onErrorObservable.notifyObservers(this);
  60801. this.onErrorObservable.clear();
  60802. // Unbind mesh reference in fallbacks
  60803. if (this._fallbacks) {
  60804. this._fallbacks.unBindMesh();
  60805. }
  60806. }
  60807. }
  60808. };
  60809. Object.defineProperty(Effect.prototype, "isSupported", {
  60810. /**
  60811. * Checks if the effect is supported. (Must be called after compilation)
  60812. */
  60813. get: function () {
  60814. return this._compilationError === "";
  60815. },
  60816. enumerable: true,
  60817. configurable: true
  60818. });
  60819. /**
  60820. * Binds a texture to the engine to be used as output of the shader.
  60821. * @param channel Name of the output variable.
  60822. * @param texture Texture to bind.
  60823. * @hidden
  60824. */
  60825. Effect.prototype._bindTexture = function (channel, texture) {
  60826. this._engine._bindTexture(this._samplers.indexOf(channel), texture);
  60827. };
  60828. /**
  60829. * Sets a texture on the engine to be used in the shader.
  60830. * @param channel Name of the sampler variable.
  60831. * @param texture Texture to set.
  60832. */
  60833. Effect.prototype.setTexture = function (channel, texture) {
  60834. this._engine.setTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  60835. };
  60836. /**
  60837. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  60838. * @param channel Name of the sampler variable.
  60839. * @param texture Texture to set.
  60840. */
  60841. Effect.prototype.setDepthStencilTexture = function (channel, texture) {
  60842. this._engine.setDepthStencilTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  60843. };
  60844. /**
  60845. * Sets an array of textures on the engine to be used in the shader.
  60846. * @param channel Name of the variable.
  60847. * @param textures Textures to set.
  60848. */
  60849. Effect.prototype.setTextureArray = function (channel, textures) {
  60850. if (this._samplers.indexOf(channel + "Ex") === -1) {
  60851. var initialPos = this._samplers.indexOf(channel);
  60852. for (var index = 1; index < textures.length; index++) {
  60853. this._samplers.splice(initialPos + index, 0, channel + "Ex");
  60854. }
  60855. }
  60856. this._engine.setTextureArray(this._samplers.indexOf(channel), this.getUniform(channel), textures);
  60857. };
  60858. /**
  60859. * 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)
  60860. * @param channel Name of the sampler variable.
  60861. * @param postProcess Post process to get the input texture from.
  60862. */
  60863. Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  60864. this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
  60865. };
  60866. /**
  60867. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  60868. * 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)
  60869. * @param channel Name of the sampler variable.
  60870. * @param postProcess Post process to get the output texture from.
  60871. */
  60872. Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  60873. this._engine.setTextureFromPostProcessOutput(this._samplers.indexOf(channel), postProcess);
  60874. };
  60875. /** @hidden */
  60876. Effect.prototype._cacheMatrix = function (uniformName, matrix) {
  60877. var cache = this._valueCache[uniformName];
  60878. var flag = matrix.updateFlag;
  60879. if (cache !== undefined && cache === flag) {
  60880. return false;
  60881. }
  60882. this._valueCache[uniformName] = flag;
  60883. return true;
  60884. };
  60885. /** @hidden */
  60886. Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
  60887. var cache = this._valueCache[uniformName];
  60888. if (!cache) {
  60889. cache = [x, y];
  60890. this._valueCache[uniformName] = cache;
  60891. return true;
  60892. }
  60893. var changed = false;
  60894. if (cache[0] !== x) {
  60895. cache[0] = x;
  60896. changed = true;
  60897. }
  60898. if (cache[1] !== y) {
  60899. cache[1] = y;
  60900. changed = true;
  60901. }
  60902. return changed;
  60903. };
  60904. /** @hidden */
  60905. Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
  60906. var cache = this._valueCache[uniformName];
  60907. if (!cache) {
  60908. cache = [x, y, z];
  60909. this._valueCache[uniformName] = cache;
  60910. return true;
  60911. }
  60912. var changed = false;
  60913. if (cache[0] !== x) {
  60914. cache[0] = x;
  60915. changed = true;
  60916. }
  60917. if (cache[1] !== y) {
  60918. cache[1] = y;
  60919. changed = true;
  60920. }
  60921. if (cache[2] !== z) {
  60922. cache[2] = z;
  60923. changed = true;
  60924. }
  60925. return changed;
  60926. };
  60927. /** @hidden */
  60928. Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
  60929. var cache = this._valueCache[uniformName];
  60930. if (!cache) {
  60931. cache = [x, y, z, w];
  60932. this._valueCache[uniformName] = cache;
  60933. return true;
  60934. }
  60935. var changed = false;
  60936. if (cache[0] !== x) {
  60937. cache[0] = x;
  60938. changed = true;
  60939. }
  60940. if (cache[1] !== y) {
  60941. cache[1] = y;
  60942. changed = true;
  60943. }
  60944. if (cache[2] !== z) {
  60945. cache[2] = z;
  60946. changed = true;
  60947. }
  60948. if (cache[3] !== w) {
  60949. cache[3] = w;
  60950. changed = true;
  60951. }
  60952. return changed;
  60953. };
  60954. /**
  60955. * Binds a buffer to a uniform.
  60956. * @param buffer Buffer to bind.
  60957. * @param name Name of the uniform variable to bind to.
  60958. */
  60959. Effect.prototype.bindUniformBuffer = function (buffer, name) {
  60960. var bufferName = this._uniformBuffersNames[name];
  60961. if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
  60962. return;
  60963. }
  60964. Effect._baseCache[bufferName] = buffer;
  60965. this._engine.bindUniformBufferBase(buffer, bufferName);
  60966. };
  60967. /**
  60968. * Binds block to a uniform.
  60969. * @param blockName Name of the block to bind.
  60970. * @param index Index to bind.
  60971. */
  60972. Effect.prototype.bindUniformBlock = function (blockName, index) {
  60973. this._engine.bindUniformBlock(this._program, blockName, index);
  60974. };
  60975. /**
  60976. * Sets an interger value on a uniform variable.
  60977. * @param uniformName Name of the variable.
  60978. * @param value Value to be set.
  60979. * @returns this effect.
  60980. */
  60981. Effect.prototype.setInt = function (uniformName, value) {
  60982. var cache = this._valueCache[uniformName];
  60983. if (cache !== undefined && cache === value) {
  60984. return this;
  60985. }
  60986. this._valueCache[uniformName] = value;
  60987. this._engine.setInt(this.getUniform(uniformName), value);
  60988. return this;
  60989. };
  60990. /**
  60991. * Sets an int array on a uniform variable.
  60992. * @param uniformName Name of the variable.
  60993. * @param array array to be set.
  60994. * @returns this effect.
  60995. */
  60996. Effect.prototype.setIntArray = function (uniformName, array) {
  60997. this._valueCache[uniformName] = null;
  60998. this._engine.setIntArray(this.getUniform(uniformName), array);
  60999. return this;
  61000. };
  61001. /**
  61002. * 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)
  61003. * @param uniformName Name of the variable.
  61004. * @param array array to be set.
  61005. * @returns this effect.
  61006. */
  61007. Effect.prototype.setIntArray2 = function (uniformName, array) {
  61008. this._valueCache[uniformName] = null;
  61009. this._engine.setIntArray2(this.getUniform(uniformName), array);
  61010. return this;
  61011. };
  61012. /**
  61013. * 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)
  61014. * @param uniformName Name of the variable.
  61015. * @param array array to be set.
  61016. * @returns this effect.
  61017. */
  61018. Effect.prototype.setIntArray3 = function (uniformName, array) {
  61019. this._valueCache[uniformName] = null;
  61020. this._engine.setIntArray3(this.getUniform(uniformName), array);
  61021. return this;
  61022. };
  61023. /**
  61024. * 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)
  61025. * @param uniformName Name of the variable.
  61026. * @param array array to be set.
  61027. * @returns this effect.
  61028. */
  61029. Effect.prototype.setIntArray4 = function (uniformName, array) {
  61030. this._valueCache[uniformName] = null;
  61031. this._engine.setIntArray4(this.getUniform(uniformName), array);
  61032. return this;
  61033. };
  61034. /**
  61035. * Sets an float array on a uniform variable.
  61036. * @param uniformName Name of the variable.
  61037. * @param array array to be set.
  61038. * @returns this effect.
  61039. */
  61040. Effect.prototype.setFloatArray = function (uniformName, array) {
  61041. this._valueCache[uniformName] = null;
  61042. this._engine.setFloatArray(this.getUniform(uniformName), array);
  61043. return this;
  61044. };
  61045. /**
  61046. * 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)
  61047. * @param uniformName Name of the variable.
  61048. * @param array array to be set.
  61049. * @returns this effect.
  61050. */
  61051. Effect.prototype.setFloatArray2 = function (uniformName, array) {
  61052. this._valueCache[uniformName] = null;
  61053. this._engine.setFloatArray2(this.getUniform(uniformName), array);
  61054. return this;
  61055. };
  61056. /**
  61057. * 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)
  61058. * @param uniformName Name of the variable.
  61059. * @param array array to be set.
  61060. * @returns this effect.
  61061. */
  61062. Effect.prototype.setFloatArray3 = function (uniformName, array) {
  61063. this._valueCache[uniformName] = null;
  61064. this._engine.setFloatArray3(this.getUniform(uniformName), array);
  61065. return this;
  61066. };
  61067. /**
  61068. * 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)
  61069. * @param uniformName Name of the variable.
  61070. * @param array array to be set.
  61071. * @returns this effect.
  61072. */
  61073. Effect.prototype.setFloatArray4 = function (uniformName, array) {
  61074. this._valueCache[uniformName] = null;
  61075. this._engine.setFloatArray4(this.getUniform(uniformName), array);
  61076. return this;
  61077. };
  61078. /**
  61079. * Sets an array on a uniform variable.
  61080. * @param uniformName Name of the variable.
  61081. * @param array array to be set.
  61082. * @returns this effect.
  61083. */
  61084. Effect.prototype.setArray = function (uniformName, array) {
  61085. this._valueCache[uniformName] = null;
  61086. this._engine.setArray(this.getUniform(uniformName), array);
  61087. return this;
  61088. };
  61089. /**
  61090. * 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)
  61091. * @param uniformName Name of the variable.
  61092. * @param array array to be set.
  61093. * @returns this effect.
  61094. */
  61095. Effect.prototype.setArray2 = function (uniformName, array) {
  61096. this._valueCache[uniformName] = null;
  61097. this._engine.setArray2(this.getUniform(uniformName), array);
  61098. return this;
  61099. };
  61100. /**
  61101. * 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)
  61102. * @param uniformName Name of the variable.
  61103. * @param array array to be set.
  61104. * @returns this effect.
  61105. */
  61106. Effect.prototype.setArray3 = function (uniformName, array) {
  61107. this._valueCache[uniformName] = null;
  61108. this._engine.setArray3(this.getUniform(uniformName), array);
  61109. return this;
  61110. };
  61111. /**
  61112. * 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)
  61113. * @param uniformName Name of the variable.
  61114. * @param array array to be set.
  61115. * @returns this effect.
  61116. */
  61117. Effect.prototype.setArray4 = function (uniformName, array) {
  61118. this._valueCache[uniformName] = null;
  61119. this._engine.setArray4(this.getUniform(uniformName), array);
  61120. return this;
  61121. };
  61122. /**
  61123. * Sets matrices on a uniform variable.
  61124. * @param uniformName Name of the variable.
  61125. * @param matrices matrices to be set.
  61126. * @returns this effect.
  61127. */
  61128. Effect.prototype.setMatrices = function (uniformName, matrices) {
  61129. if (!matrices) {
  61130. return this;
  61131. }
  61132. this._valueCache[uniformName] = null;
  61133. this._engine.setMatrices(this.getUniform(uniformName), matrices);
  61134. return this;
  61135. };
  61136. /**
  61137. * Sets matrix on a uniform variable.
  61138. * @param uniformName Name of the variable.
  61139. * @param matrix matrix to be set.
  61140. * @returns this effect.
  61141. */
  61142. Effect.prototype.setMatrix = function (uniformName, matrix) {
  61143. if (this._cacheMatrix(uniformName, matrix)) {
  61144. this._engine.setMatrix(this.getUniform(uniformName), matrix);
  61145. }
  61146. return this;
  61147. };
  61148. /**
  61149. * 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)
  61150. * @param uniformName Name of the variable.
  61151. * @param matrix matrix to be set.
  61152. * @returns this effect.
  61153. */
  61154. Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {
  61155. this._valueCache[uniformName] = null;
  61156. this._engine.setMatrix3x3(this.getUniform(uniformName), matrix);
  61157. return this;
  61158. };
  61159. /**
  61160. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  61161. * @param uniformName Name of the variable.
  61162. * @param matrix matrix to be set.
  61163. * @returns this effect.
  61164. */
  61165. Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {
  61166. this._valueCache[uniformName] = null;
  61167. this._engine.setMatrix2x2(this.getUniform(uniformName), matrix);
  61168. return this;
  61169. };
  61170. /**
  61171. * Sets a float on a uniform variable.
  61172. * @param uniformName Name of the variable.
  61173. * @param value value to be set.
  61174. * @returns this effect.
  61175. */
  61176. Effect.prototype.setFloat = function (uniformName, value) {
  61177. var cache = this._valueCache[uniformName];
  61178. if (cache !== undefined && cache === value) {
  61179. return this;
  61180. }
  61181. this._valueCache[uniformName] = value;
  61182. this._engine.setFloat(this.getUniform(uniformName), value);
  61183. return this;
  61184. };
  61185. /**
  61186. * Sets a boolean on a uniform variable.
  61187. * @param uniformName Name of the variable.
  61188. * @param bool value to be set.
  61189. * @returns this effect.
  61190. */
  61191. Effect.prototype.setBool = function (uniformName, bool) {
  61192. var cache = this._valueCache[uniformName];
  61193. if (cache !== undefined && cache === bool) {
  61194. return this;
  61195. }
  61196. this._valueCache[uniformName] = bool;
  61197. this._engine.setBool(this.getUniform(uniformName), bool ? 1 : 0);
  61198. return this;
  61199. };
  61200. /**
  61201. * Sets a Vector2 on a uniform variable.
  61202. * @param uniformName Name of the variable.
  61203. * @param vector2 vector2 to be set.
  61204. * @returns this effect.
  61205. */
  61206. Effect.prototype.setVector2 = function (uniformName, vector2) {
  61207. if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
  61208. this._engine.setFloat2(this.getUniform(uniformName), vector2.x, vector2.y);
  61209. }
  61210. return this;
  61211. };
  61212. /**
  61213. * Sets a float2 on a uniform variable.
  61214. * @param uniformName Name of the variable.
  61215. * @param x First float in float2.
  61216. * @param y Second float in float2.
  61217. * @returns this effect.
  61218. */
  61219. Effect.prototype.setFloat2 = function (uniformName, x, y) {
  61220. if (this._cacheFloat2(uniformName, x, y)) {
  61221. this._engine.setFloat2(this.getUniform(uniformName), x, y);
  61222. }
  61223. return this;
  61224. };
  61225. /**
  61226. * Sets a Vector3 on a uniform variable.
  61227. * @param uniformName Name of the variable.
  61228. * @param vector3 Value to be set.
  61229. * @returns this effect.
  61230. */
  61231. Effect.prototype.setVector3 = function (uniformName, vector3) {
  61232. if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
  61233. this._engine.setFloat3(this.getUniform(uniformName), vector3.x, vector3.y, vector3.z);
  61234. }
  61235. return this;
  61236. };
  61237. /**
  61238. * Sets a float3 on a uniform variable.
  61239. * @param uniformName Name of the variable.
  61240. * @param x First float in float3.
  61241. * @param y Second float in float3.
  61242. * @param z Third float in float3.
  61243. * @returns this effect.
  61244. */
  61245. Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
  61246. if (this._cacheFloat3(uniformName, x, y, z)) {
  61247. this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
  61248. }
  61249. return this;
  61250. };
  61251. /**
  61252. * Sets a Vector4 on a uniform variable.
  61253. * @param uniformName Name of the variable.
  61254. * @param vector4 Value to be set.
  61255. * @returns this effect.
  61256. */
  61257. Effect.prototype.setVector4 = function (uniformName, vector4) {
  61258. if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
  61259. this._engine.setFloat4(this.getUniform(uniformName), vector4.x, vector4.y, vector4.z, vector4.w);
  61260. }
  61261. return this;
  61262. };
  61263. /**
  61264. * Sets a float4 on a uniform variable.
  61265. * @param uniformName Name of the variable.
  61266. * @param x First float in float4.
  61267. * @param y Second float in float4.
  61268. * @param z Third float in float4.
  61269. * @param w Fourth float in float4.
  61270. * @returns this effect.
  61271. */
  61272. Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
  61273. if (this._cacheFloat4(uniformName, x, y, z, w)) {
  61274. this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
  61275. }
  61276. return this;
  61277. };
  61278. /**
  61279. * Sets a Color3 on a uniform variable.
  61280. * @param uniformName Name of the variable.
  61281. * @param color3 Value to be set.
  61282. * @returns this effect.
  61283. */
  61284. Effect.prototype.setColor3 = function (uniformName, color3) {
  61285. if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
  61286. this._engine.setColor3(this.getUniform(uniformName), color3);
  61287. }
  61288. return this;
  61289. };
  61290. /**
  61291. * Sets a Color4 on a uniform variable.
  61292. * @param uniformName Name of the variable.
  61293. * @param color3 Value to be set.
  61294. * @param alpha Alpha value to be set.
  61295. * @returns this effect.
  61296. */
  61297. Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
  61298. if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
  61299. this._engine.setColor4(this.getUniform(uniformName), color3, alpha);
  61300. }
  61301. return this;
  61302. };
  61303. /**
  61304. * Sets a Color4 on a uniform variable
  61305. * @param uniformName defines the name of the variable
  61306. * @param color4 defines the value to be set
  61307. * @returns this effect.
  61308. */
  61309. Effect.prototype.setDirectColor4 = function (uniformName, color4) {
  61310. if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
  61311. this._engine.setDirectColor4(this.getUniform(uniformName), color4);
  61312. }
  61313. return this;
  61314. };
  61315. /**
  61316. * This function will add a new shader to the shader store
  61317. * @param name the name of the shader
  61318. * @param pixelShader optional pixel shader content
  61319. * @param vertexShader optional vertex shader content
  61320. */
  61321. Effect.RegisterShader = function (name, pixelShader, vertexShader) {
  61322. if (pixelShader) {
  61323. Effect.ShadersStore[name + "PixelShader"] = pixelShader;
  61324. }
  61325. if (vertexShader) {
  61326. Effect.ShadersStore[name + "VertexShader"] = vertexShader;
  61327. }
  61328. };
  61329. /**
  61330. * Resets the cache of effects.
  61331. */
  61332. Effect.ResetCache = function () {
  61333. Effect._baseCache = {};
  61334. };
  61335. /**
  61336. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  61337. */
  61338. Effect.ShadersRepository = "src/Shaders/";
  61339. Effect._uniqueIdSeed = 0;
  61340. Effect._baseCache = {};
  61341. /**
  61342. * Store of each shader (The can be looked up using effect.key)
  61343. */
  61344. Effect.ShadersStore = {};
  61345. /**
  61346. * Store of each included file for a shader (The can be looked up using effect.key)
  61347. */
  61348. Effect.IncludesShadersStore = {};
  61349. return Effect;
  61350. }());
  61351. /***/ }),
  61352. /***/ "./Materials/fresnelParameters.ts":
  61353. /*!****************************************!*\
  61354. !*** ./Materials/fresnelParameters.ts ***!
  61355. \****************************************/
  61356. /*! exports provided: FresnelParameters */
  61357. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61358. "use strict";
  61359. __webpack_require__.r(__webpack_exports__);
  61360. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return FresnelParameters; });
  61361. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  61362. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  61363. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  61364. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  61365. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  61366. /**
  61367. * This represents all the required information to add a fresnel effect on a material:
  61368. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  61369. */
  61370. var FresnelParameters = /** @class */ (function () {
  61371. function FresnelParameters() {
  61372. this._isEnabled = true;
  61373. /**
  61374. * Define the color used on edges (grazing angle)
  61375. */
  61376. this.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  61377. /**
  61378. * Define the color used on center
  61379. */
  61380. this.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  61381. /**
  61382. * Define bias applied to computed fresnel term
  61383. */
  61384. this.bias = 0;
  61385. /**
  61386. * Defined the power exponent applied to fresnel term
  61387. */
  61388. this.power = 1;
  61389. }
  61390. Object.defineProperty(FresnelParameters.prototype, "isEnabled", {
  61391. /**
  61392. * Define if the fresnel effect is enable or not.
  61393. */
  61394. get: function () {
  61395. return this._isEnabled;
  61396. },
  61397. set: function (value) {
  61398. if (this._isEnabled === value) {
  61399. return;
  61400. }
  61401. this._isEnabled = value;
  61402. _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);
  61403. },
  61404. enumerable: true,
  61405. configurable: true
  61406. });
  61407. /**
  61408. * Clones the current fresnel and its valuues
  61409. * @returns a clone fresnel configuration
  61410. */
  61411. FresnelParameters.prototype.clone = function () {
  61412. var newFresnelParameters = new FresnelParameters();
  61413. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newFresnelParameters);
  61414. return newFresnelParameters;
  61415. };
  61416. /**
  61417. * Serializes the current fresnel parameters to a JSON representation.
  61418. * @return the JSON serialization
  61419. */
  61420. FresnelParameters.prototype.serialize = function () {
  61421. var serializationObject = {};
  61422. serializationObject.isEnabled = this.isEnabled;
  61423. serializationObject.leftColor = this.leftColor.asArray();
  61424. serializationObject.rightColor = this.rightColor.asArray();
  61425. serializationObject.bias = this.bias;
  61426. serializationObject.power = this.power;
  61427. return serializationObject;
  61428. };
  61429. /**
  61430. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  61431. * @param parsedFresnelParameters Define the JSON representation
  61432. * @returns the parsed parameters
  61433. */
  61434. FresnelParameters.Parse = function (parsedFresnelParameters) {
  61435. var fresnelParameters = new FresnelParameters();
  61436. fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
  61437. fresnelParameters.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.leftColor);
  61438. fresnelParameters.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.rightColor);
  61439. fresnelParameters.bias = parsedFresnelParameters.bias;
  61440. fresnelParameters.power = parsedFresnelParameters.power || 1.0;
  61441. return fresnelParameters;
  61442. };
  61443. return FresnelParameters;
  61444. }());
  61445. // References the dependencies.
  61446. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]._FresnelParametersParser = FresnelParameters.Parse;
  61447. /***/ }),
  61448. /***/ "./Materials/imageProcessingConfiguration.ts":
  61449. /*!***************************************************!*\
  61450. !*** ./Materials/imageProcessingConfiguration.ts ***!
  61451. \***************************************************/
  61452. /*! exports provided: ImageProcessingConfigurationDefines, ImageProcessingConfiguration */
  61453. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61454. "use strict";
  61455. __webpack_require__.r(__webpack_exports__);
  61456. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return ImageProcessingConfigurationDefines; });
  61457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return ImageProcessingConfiguration; });
  61458. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61459. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  61460. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  61461. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  61462. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  61463. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  61464. /* harmony import */ var _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/colorCurves */ "./Materials/colorCurves.ts");
  61465. /**
  61466. * @hidden
  61467. */
  61468. var ImageProcessingConfigurationDefines = /** @class */ (function (_super) {
  61469. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingConfigurationDefines, _super);
  61470. function ImageProcessingConfigurationDefines() {
  61471. var _this = _super.call(this) || this;
  61472. _this.IMAGEPROCESSING = false;
  61473. _this.VIGNETTE = false;
  61474. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  61475. _this.VIGNETTEBLENDMODEOPAQUE = false;
  61476. _this.TONEMAPPING = false;
  61477. _this.TONEMAPPING_ACES = false;
  61478. _this.CONTRAST = false;
  61479. _this.COLORCURVES = false;
  61480. _this.COLORGRADING = false;
  61481. _this.COLORGRADING3D = false;
  61482. _this.SAMPLER3DGREENDEPTH = false;
  61483. _this.SAMPLER3DBGRMAP = false;
  61484. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  61485. _this.EXPOSURE = false;
  61486. _this.rebuild();
  61487. return _this;
  61488. }
  61489. return ImageProcessingConfigurationDefines;
  61490. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__["MaterialDefines"]));
  61491. /**
  61492. * This groups together the common properties used for image processing either in direct forward pass
  61493. * or through post processing effect depending on the use of the image processing pipeline in your scene
  61494. * or not.
  61495. */
  61496. var ImageProcessingConfiguration = /** @class */ (function () {
  61497. function ImageProcessingConfiguration() {
  61498. /**
  61499. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  61500. */
  61501. this.colorCurves = new _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"]();
  61502. this._colorCurvesEnabled = false;
  61503. this._colorGradingEnabled = false;
  61504. this._colorGradingWithGreenDepth = true;
  61505. this._colorGradingBGR = true;
  61506. /** @hidden */
  61507. this._exposure = 1.0;
  61508. this._toneMappingEnabled = false;
  61509. this._toneMappingType = ImageProcessingConfiguration.TONEMAPPING_STANDARD;
  61510. this._contrast = 1.0;
  61511. /**
  61512. * Vignette stretch size.
  61513. */
  61514. this.vignetteStretch = 0;
  61515. /**
  61516. * Vignette centre X Offset.
  61517. */
  61518. this.vignetteCentreX = 0;
  61519. /**
  61520. * Vignette centre Y Offset.
  61521. */
  61522. this.vignetteCentreY = 0;
  61523. /**
  61524. * Vignette weight or intensity of the vignette effect.
  61525. */
  61526. this.vignetteWeight = 1.5;
  61527. /**
  61528. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  61529. * if vignetteEnabled is set to true.
  61530. */
  61531. this.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  61532. /**
  61533. * Camera field of view used by the Vignette effect.
  61534. */
  61535. this.vignetteCameraFov = 0.5;
  61536. this._vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
  61537. this._vignetteEnabled = false;
  61538. this._applyByPostProcess = false;
  61539. this._isEnabled = true;
  61540. /**
  61541. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  61542. */
  61543. this.onUpdateParameters = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  61544. }
  61545. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorCurvesEnabled", {
  61546. /**
  61547. * Gets wether the color curves effect is enabled.
  61548. */
  61549. get: function () {
  61550. return this._colorCurvesEnabled;
  61551. },
  61552. /**
  61553. * Sets wether the color curves effect is enabled.
  61554. */
  61555. set: function (value) {
  61556. if (this._colorCurvesEnabled === value) {
  61557. return;
  61558. }
  61559. this._colorCurvesEnabled = value;
  61560. this._updateParameters();
  61561. },
  61562. enumerable: true,
  61563. configurable: true
  61564. });
  61565. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingTexture", {
  61566. /**
  61567. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  61568. */
  61569. get: function () {
  61570. return this._colorGradingTexture;
  61571. },
  61572. /**
  61573. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  61574. */
  61575. set: function (value) {
  61576. if (this._colorGradingTexture === value) {
  61577. return;
  61578. }
  61579. this._colorGradingTexture = value;
  61580. this._updateParameters();
  61581. },
  61582. enumerable: true,
  61583. configurable: true
  61584. });
  61585. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingEnabled", {
  61586. /**
  61587. * Gets wether the color grading effect is enabled.
  61588. */
  61589. get: function () {
  61590. return this._colorGradingEnabled;
  61591. },
  61592. /**
  61593. * Sets wether the color grading effect is enabled.
  61594. */
  61595. set: function (value) {
  61596. if (this._colorGradingEnabled === value) {
  61597. return;
  61598. }
  61599. this._colorGradingEnabled = value;
  61600. this._updateParameters();
  61601. },
  61602. enumerable: true,
  61603. configurable: true
  61604. });
  61605. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingWithGreenDepth", {
  61606. /**
  61607. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  61608. */
  61609. get: function () {
  61610. return this._colorGradingWithGreenDepth;
  61611. },
  61612. /**
  61613. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  61614. */
  61615. set: function (value) {
  61616. if (this._colorGradingWithGreenDepth === value) {
  61617. return;
  61618. }
  61619. this._colorGradingWithGreenDepth = value;
  61620. this._updateParameters();
  61621. },
  61622. enumerable: true,
  61623. configurable: true
  61624. });
  61625. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingBGR", {
  61626. /**
  61627. * Gets wether the color grading texture contains BGR values.
  61628. */
  61629. get: function () {
  61630. return this._colorGradingBGR;
  61631. },
  61632. /**
  61633. * Sets wether the color grading texture contains BGR values.
  61634. */
  61635. set: function (value) {
  61636. if (this._colorGradingBGR === value) {
  61637. return;
  61638. }
  61639. this._colorGradingBGR = value;
  61640. this._updateParameters();
  61641. },
  61642. enumerable: true,
  61643. configurable: true
  61644. });
  61645. Object.defineProperty(ImageProcessingConfiguration.prototype, "exposure", {
  61646. /**
  61647. * Gets the Exposure used in the effect.
  61648. */
  61649. get: function () {
  61650. return this._exposure;
  61651. },
  61652. /**
  61653. * Sets the Exposure used in the effect.
  61654. */
  61655. set: function (value) {
  61656. if (this._exposure === value) {
  61657. return;
  61658. }
  61659. this._exposure = value;
  61660. this._updateParameters();
  61661. },
  61662. enumerable: true,
  61663. configurable: true
  61664. });
  61665. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingEnabled", {
  61666. /**
  61667. * Gets wether the tone mapping effect is enabled.
  61668. */
  61669. get: function () {
  61670. return this._toneMappingEnabled;
  61671. },
  61672. /**
  61673. * Sets wether the tone mapping effect is enabled.
  61674. */
  61675. set: function (value) {
  61676. if (this._toneMappingEnabled === value) {
  61677. return;
  61678. }
  61679. this._toneMappingEnabled = value;
  61680. this._updateParameters();
  61681. },
  61682. enumerable: true,
  61683. configurable: true
  61684. });
  61685. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingType", {
  61686. /**
  61687. * Gets the type of tone mapping effect.
  61688. */
  61689. get: function () {
  61690. return this._toneMappingType;
  61691. },
  61692. /**
  61693. * Sets the type of tone mapping effect used in BabylonJS.
  61694. */
  61695. set: function (value) {
  61696. if (this._toneMappingType === value) {
  61697. return;
  61698. }
  61699. this._toneMappingType = value;
  61700. this._updateParameters();
  61701. },
  61702. enumerable: true,
  61703. configurable: true
  61704. });
  61705. Object.defineProperty(ImageProcessingConfiguration.prototype, "contrast", {
  61706. /**
  61707. * Gets the contrast used in the effect.
  61708. */
  61709. get: function () {
  61710. return this._contrast;
  61711. },
  61712. /**
  61713. * Sets the contrast used in the effect.
  61714. */
  61715. set: function (value) {
  61716. if (this._contrast === value) {
  61717. return;
  61718. }
  61719. this._contrast = value;
  61720. this._updateParameters();
  61721. },
  61722. enumerable: true,
  61723. configurable: true
  61724. });
  61725. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteBlendMode", {
  61726. /**
  61727. * Gets the vignette blend mode allowing different kind of effect.
  61728. */
  61729. get: function () {
  61730. return this._vignetteBlendMode;
  61731. },
  61732. /**
  61733. * Sets the vignette blend mode allowing different kind of effect.
  61734. */
  61735. set: function (value) {
  61736. if (this._vignetteBlendMode === value) {
  61737. return;
  61738. }
  61739. this._vignetteBlendMode = value;
  61740. this._updateParameters();
  61741. },
  61742. enumerable: true,
  61743. configurable: true
  61744. });
  61745. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteEnabled", {
  61746. /**
  61747. * Gets wether the vignette effect is enabled.
  61748. */
  61749. get: function () {
  61750. return this._vignetteEnabled;
  61751. },
  61752. /**
  61753. * Sets wether the vignette effect is enabled.
  61754. */
  61755. set: function (value) {
  61756. if (this._vignetteEnabled === value) {
  61757. return;
  61758. }
  61759. this._vignetteEnabled = value;
  61760. this._updateParameters();
  61761. },
  61762. enumerable: true,
  61763. configurable: true
  61764. });
  61765. Object.defineProperty(ImageProcessingConfiguration.prototype, "applyByPostProcess", {
  61766. /**
  61767. * Gets wether the image processing is applied through a post process or not.
  61768. */
  61769. get: function () {
  61770. return this._applyByPostProcess;
  61771. },
  61772. /**
  61773. * Sets wether the image processing is applied through a post process or not.
  61774. */
  61775. set: function (value) {
  61776. if (this._applyByPostProcess === value) {
  61777. return;
  61778. }
  61779. this._applyByPostProcess = value;
  61780. this._updateParameters();
  61781. },
  61782. enumerable: true,
  61783. configurable: true
  61784. });
  61785. Object.defineProperty(ImageProcessingConfiguration.prototype, "isEnabled", {
  61786. /**
  61787. * Gets wether the image processing is enabled or not.
  61788. */
  61789. get: function () {
  61790. return this._isEnabled;
  61791. },
  61792. /**
  61793. * Sets wether the image processing is enabled or not.
  61794. */
  61795. set: function (value) {
  61796. if (this._isEnabled === value) {
  61797. return;
  61798. }
  61799. this._isEnabled = value;
  61800. this._updateParameters();
  61801. },
  61802. enumerable: true,
  61803. configurable: true
  61804. });
  61805. /**
  61806. * Method called each time the image processing information changes requires to recompile the effect.
  61807. */
  61808. ImageProcessingConfiguration.prototype._updateParameters = function () {
  61809. this.onUpdateParameters.notifyObservers(this);
  61810. };
  61811. /**
  61812. * Gets the current class name.
  61813. * @return "ImageProcessingConfiguration"
  61814. */
  61815. ImageProcessingConfiguration.prototype.getClassName = function () {
  61816. return "ImageProcessingConfiguration";
  61817. };
  61818. /**
  61819. * Prepare the list of uniforms associated with the Image Processing effects.
  61820. * @param uniforms The list of uniforms used in the effect
  61821. * @param defines the list of defines currently in use
  61822. */
  61823. ImageProcessingConfiguration.PrepareUniforms = function (uniforms, defines) {
  61824. if (defines.EXPOSURE) {
  61825. uniforms.push("exposureLinear");
  61826. }
  61827. if (defines.CONTRAST) {
  61828. uniforms.push("contrast");
  61829. }
  61830. if (defines.COLORGRADING) {
  61831. uniforms.push("colorTransformSettings");
  61832. }
  61833. if (defines.VIGNETTE) {
  61834. uniforms.push("vInverseScreenSize");
  61835. uniforms.push("vignetteSettings1");
  61836. uniforms.push("vignetteSettings2");
  61837. }
  61838. if (defines.COLORCURVES) {
  61839. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].PrepareUniforms(uniforms);
  61840. }
  61841. };
  61842. /**
  61843. * Prepare the list of samplers associated with the Image Processing effects.
  61844. * @param samplersList The list of uniforms used in the effect
  61845. * @param defines the list of defines currently in use
  61846. */
  61847. ImageProcessingConfiguration.PrepareSamplers = function (samplersList, defines) {
  61848. if (defines.COLORGRADING) {
  61849. samplersList.push("txColorTransform");
  61850. }
  61851. };
  61852. /**
  61853. * Prepare the list of defines associated to the shader.
  61854. * @param defines the list of defines to complete
  61855. * @param forPostProcess Define if we are currently in post process mode or not
  61856. */
  61857. ImageProcessingConfiguration.prototype.prepareDefines = function (defines, forPostProcess) {
  61858. if (forPostProcess === void 0) { forPostProcess = false; }
  61859. if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
  61860. defines.VIGNETTE = false;
  61861. defines.TONEMAPPING = false;
  61862. defines.TONEMAPPING_ACES = false;
  61863. defines.CONTRAST = false;
  61864. defines.EXPOSURE = false;
  61865. defines.COLORCURVES = false;
  61866. defines.COLORGRADING = false;
  61867. defines.COLORGRADING3D = false;
  61868. defines.IMAGEPROCESSING = false;
  61869. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  61870. return;
  61871. }
  61872. defines.VIGNETTE = this.vignetteEnabled;
  61873. defines.VIGNETTEBLENDMODEMULTIPLY = (this.vignetteBlendMode === ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY);
  61874. defines.VIGNETTEBLENDMODEOPAQUE = !defines.VIGNETTEBLENDMODEMULTIPLY;
  61875. defines.TONEMAPPING = this.toneMappingEnabled;
  61876. switch (this._toneMappingType) {
  61877. case ImageProcessingConfiguration.TONEMAPPING_ACES:
  61878. defines.TONEMAPPING_ACES = true;
  61879. break;
  61880. default:
  61881. defines.TONEMAPPING_ACES = false;
  61882. break;
  61883. }
  61884. defines.CONTRAST = (this.contrast !== 1.0);
  61885. defines.EXPOSURE = (this.exposure !== 1.0);
  61886. defines.COLORCURVES = (this.colorCurvesEnabled && !!this.colorCurves);
  61887. defines.COLORGRADING = (this.colorGradingEnabled && !!this.colorGradingTexture);
  61888. if (defines.COLORGRADING) {
  61889. defines.COLORGRADING3D = this.colorGradingTexture.is3D;
  61890. }
  61891. else {
  61892. defines.COLORGRADING3D = false;
  61893. }
  61894. defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
  61895. defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
  61896. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
  61897. defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
  61898. };
  61899. /**
  61900. * Returns true if all the image processing information are ready.
  61901. * @returns True if ready, otherwise, false
  61902. */
  61903. ImageProcessingConfiguration.prototype.isReady = function () {
  61904. // Color Grading texure can not be none blocking.
  61905. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
  61906. };
  61907. /**
  61908. * Binds the image processing to the shader.
  61909. * @param effect The effect to bind to
  61910. * @param aspectRatio Define the current aspect ratio of the effect
  61911. */
  61912. ImageProcessingConfiguration.prototype.bind = function (effect, aspectRatio) {
  61913. if (aspectRatio === void 0) { aspectRatio = 1; }
  61914. // Color Curves
  61915. if (this._colorCurvesEnabled && this.colorCurves) {
  61916. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].Bind(this.colorCurves, effect);
  61917. }
  61918. // Vignette
  61919. if (this._vignetteEnabled) {
  61920. var inverseWidth = 1 / effect.getEngine().getRenderWidth();
  61921. var inverseHeight = 1 / effect.getEngine().getRenderHeight();
  61922. effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
  61923. var vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
  61924. var vignetteScaleX = vignetteScaleY * aspectRatio;
  61925. var vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
  61926. vignetteScaleX = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch);
  61927. vignetteScaleY = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch);
  61928. effect.setFloat4("vignetteSettings1", vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY);
  61929. var vignettePower = -2.0 * this.vignetteWeight;
  61930. effect.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower);
  61931. }
  61932. // Exposure
  61933. effect.setFloat("exposureLinear", this.exposure);
  61934. // Contrast
  61935. effect.setFloat("contrast", this.contrast);
  61936. // Color transform settings
  61937. if (this.colorGradingTexture) {
  61938. effect.setTexture("txColorTransform", this.colorGradingTexture);
  61939. var textureSize = this.colorGradingTexture.getSize().height;
  61940. effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale
  61941. 0.5 / textureSize, // textureOffset
  61942. textureSize, // textureSize
  61943. this.colorGradingTexture.level // weight
  61944. );
  61945. }
  61946. };
  61947. /**
  61948. * Clones the current image processing instance.
  61949. * @return The cloned image processing
  61950. */
  61951. ImageProcessingConfiguration.prototype.clone = function () {
  61952. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ImageProcessingConfiguration(); }, this);
  61953. };
  61954. /**
  61955. * Serializes the current image processing instance to a json representation.
  61956. * @return a JSON representation
  61957. */
  61958. ImageProcessingConfiguration.prototype.serialize = function () {
  61959. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  61960. };
  61961. /**
  61962. * Parses the image processing from a json representation.
  61963. * @param source the JSON source to parse
  61964. * @return The parsed image processing
  61965. */
  61966. ImageProcessingConfiguration.Parse = function (source) {
  61967. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ImageProcessingConfiguration(); }, source, null, null);
  61968. };
  61969. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_MULTIPLY", {
  61970. /**
  61971. * Used to apply the vignette as a mix with the pixel color.
  61972. */
  61973. get: function () {
  61974. return this._VIGNETTEMODE_MULTIPLY;
  61975. },
  61976. enumerable: true,
  61977. configurable: true
  61978. });
  61979. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_OPAQUE", {
  61980. /**
  61981. * Used to apply the vignette as a replacement of the pixel color.
  61982. */
  61983. get: function () {
  61984. return this._VIGNETTEMODE_OPAQUE;
  61985. },
  61986. enumerable: true,
  61987. configurable: true
  61988. });
  61989. /**
  61990. * Default tone mapping applied in BabylonJS.
  61991. */
  61992. ImageProcessingConfiguration.TONEMAPPING_STANDARD = 0;
  61993. /**
  61994. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  61995. * to other engines rendering to increase portability.
  61996. */
  61997. ImageProcessingConfiguration.TONEMAPPING_ACES = 1;
  61998. // Static constants associated to the image processing.
  61999. ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY = 0;
  62000. ImageProcessingConfiguration._VIGNETTEMODE_OPAQUE = 1;
  62001. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62002. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColorCurves"])()
  62003. ], ImageProcessingConfiguration.prototype, "colorCurves", void 0);
  62004. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62005. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62006. ], ImageProcessingConfiguration.prototype, "_colorCurvesEnabled", void 0);
  62007. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62008. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("colorGradingTexture")
  62009. ], ImageProcessingConfiguration.prototype, "_colorGradingTexture", void 0);
  62010. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62011. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62012. ], ImageProcessingConfiguration.prototype, "_colorGradingEnabled", void 0);
  62013. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62014. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62015. ], ImageProcessingConfiguration.prototype, "_colorGradingWithGreenDepth", void 0);
  62016. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62017. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62018. ], ImageProcessingConfiguration.prototype, "_colorGradingBGR", void 0);
  62019. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62020. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62021. ], ImageProcessingConfiguration.prototype, "_exposure", void 0);
  62022. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62023. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62024. ], ImageProcessingConfiguration.prototype, "_toneMappingEnabled", void 0);
  62025. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62026. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62027. ], ImageProcessingConfiguration.prototype, "_toneMappingType", void 0);
  62028. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62029. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62030. ], ImageProcessingConfiguration.prototype, "_contrast", void 0);
  62031. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62032. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62033. ], ImageProcessingConfiguration.prototype, "vignetteStretch", void 0);
  62034. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62035. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62036. ], ImageProcessingConfiguration.prototype, "vignetteCentreX", void 0);
  62037. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62038. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62039. ], ImageProcessingConfiguration.prototype, "vignetteCentreY", void 0);
  62040. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62041. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62042. ], ImageProcessingConfiguration.prototype, "vignetteWeight", void 0);
  62043. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62044. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  62045. ], ImageProcessingConfiguration.prototype, "vignetteColor", void 0);
  62046. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62047. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62048. ], ImageProcessingConfiguration.prototype, "vignetteCameraFov", void 0);
  62049. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62050. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62051. ], ImageProcessingConfiguration.prototype, "_vignetteBlendMode", void 0);
  62052. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62053. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62054. ], ImageProcessingConfiguration.prototype, "_vignetteEnabled", void 0);
  62055. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62056. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62057. ], ImageProcessingConfiguration.prototype, "_applyByPostProcess", void 0);
  62058. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62059. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62060. ], ImageProcessingConfiguration.prototype, "_isEnabled", void 0);
  62061. return ImageProcessingConfiguration;
  62062. }());
  62063. // References the dependencies.
  62064. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  62065. /***/ }),
  62066. /***/ "./Materials/index.ts":
  62067. /*!****************************!*\
  62068. !*** ./Materials/index.ts ***!
  62069. \****************************/
  62070. /*! exports provided: ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  62071. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62072. "use strict";
  62073. __webpack_require__.r(__webpack_exports__);
  62074. /* harmony import */ var _Background_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Background/index */ "./Materials/Background/index.ts");
  62075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Background_index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  62076. /* harmony import */ var _colorCurves__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorCurves */ "./Materials/colorCurves.ts");
  62077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _colorCurves__WEBPACK_IMPORTED_MODULE_1__["ColorCurves"]; });
  62078. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  62079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectFallbacks"]; });
  62080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectCreationOptions"]; });
  62081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"]; });
  62082. /* harmony import */ var _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fresnelParameters */ "./Materials/fresnelParameters.ts");
  62083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__["FresnelParameters"]; });
  62084. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  62085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfigurationDefines"]; });
  62086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfiguration"]; });
  62087. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  62088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _material__WEBPACK_IMPORTED_MODULE_5__["Material"]; });
  62089. /* harmony import */ var _materialDefines__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./materialDefines */ "./Materials/materialDefines.ts");
  62090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _materialDefines__WEBPACK_IMPORTED_MODULE_6__["MaterialDefines"]; });
  62091. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  62092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"]; });
  62093. /* harmony import */ var _multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multiMaterial */ "./Materials/multiMaterial.ts");
  62094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"]; });
  62095. /* harmony import */ var _PBR_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./PBR/index */ "./Materials/PBR/index.ts");
  62096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseMaterial"]; });
  62097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseSimpleMaterial"]; });
  62098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterial"]; });
  62099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMetallicRoughnessMaterial"]; });
  62100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRSpecularGlossinessMaterial"]; });
  62101. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  62102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]; });
  62103. /* harmony import */ var _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shaderMaterial */ "./Materials/shaderMaterial.ts");
  62104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__["ShaderMaterial"]; });
  62105. /* harmony import */ var _standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./standardMaterial */ "./Materials/standardMaterial.ts");
  62106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterialDefines"]; });
  62107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]; });
  62108. /* harmony import */ var _Textures_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Textures/index */ "./Materials/Textures/index.ts");
  62109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["BaseTexture"]; });
  62110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CubeTexture"]; });
  62111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HDRCubeTexture"]; });
  62112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["InternalTexture"]; });
  62113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DummyInternalTextureTracker"]; });
  62114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MirrorTexture"]; });
  62115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiRenderTarget"]; });
  62116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  62117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RenderTargetTexture"]; });
  62118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["Texture"]; });
  62119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ColorGradingTexture"]; });
  62120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DynamicTexture"]; });
  62121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTexture"]; });
  62122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawCubeTexture"]; });
  62123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  62124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RefractionTexture"]; });
  62125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["VideoTexture"]; });
  62126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_DDSTextureLoader"]; });
  62127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_ENVTextureLoader"]; });
  62128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_KTXTextureLoader"]; });
  62129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_TGATextureLoader"]; });
  62130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CustomProceduralTexture"]; });
  62131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["NoiseProceduralTexture"]; });
  62132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTextureSceneComponent"]; });
  62133. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  62134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__["UniformBuffer"]; });
  62135. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  62136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _materialFlags__WEBPACK_IMPORTED_MODULE_15__["MaterialFlags"]; });
  62137. /***/ }),
  62138. /***/ "./Materials/material.ts":
  62139. /*!*******************************!*\
  62140. !*** ./Materials/material.ts ***!
  62141. \*******************************/
  62142. /*! exports provided: Material */
  62143. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62144. "use strict";
  62145. __webpack_require__.r(__webpack_exports__);
  62146. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return Material; });
  62147. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  62148. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  62149. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  62150. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  62151. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  62152. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  62153. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  62154. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  62155. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  62156. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  62157. /**
  62158. * Base class for the main features of a material in Babylon.js
  62159. */
  62160. var Material = /** @class */ (function () {
  62161. /**
  62162. * Creates a material instance
  62163. * @param name defines the name of the material
  62164. * @param scene defines the scene to reference
  62165. * @param doNotAdd specifies if the material should be added to the scene
  62166. */
  62167. function Material(name, scene, doNotAdd) {
  62168. /**
  62169. * Gets or sets user defined metadata
  62170. */
  62171. this.metadata = null;
  62172. /**
  62173. * For internal use only. Please do not use.
  62174. */
  62175. this.reservedDataStore = null;
  62176. /**
  62177. * Specifies if the ready state should be checked on each call
  62178. */
  62179. this.checkReadyOnEveryCall = false;
  62180. /**
  62181. * Specifies if the ready state should be checked once
  62182. */
  62183. this.checkReadyOnlyOnce = false;
  62184. /**
  62185. * The state of the material
  62186. */
  62187. this.state = "";
  62188. /**
  62189. * The alpha value of the material
  62190. */
  62191. this._alpha = 1.0;
  62192. /**
  62193. * Specifies if back face culling is enabled
  62194. */
  62195. this._backFaceCulling = true;
  62196. /**
  62197. * Specifies if the material should be serialized
  62198. */
  62199. this.doNotSerialize = false;
  62200. /**
  62201. * @hidden
  62202. */
  62203. this._storeEffectOnSubMeshes = false;
  62204. /**
  62205. * An event triggered when the material is disposed
  62206. */
  62207. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  62208. /**
  62209. * Stores the value of the alpha mode
  62210. */
  62211. this._alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  62212. /**
  62213. * Stores the state of the need depth pre-pass value
  62214. */
  62215. this._needDepthPrePass = false;
  62216. /**
  62217. * Specifies if depth writing should be disabled
  62218. */
  62219. this.disableDepthWrite = false;
  62220. /**
  62221. * Specifies if depth writing should be forced
  62222. */
  62223. this.forceDepthWrite = false;
  62224. /**
  62225. * Specifies if there should be a separate pass for culling
  62226. */
  62227. this.separateCullingPass = false;
  62228. /**
  62229. * Stores the state specifing if fog should be enabled
  62230. */
  62231. this._fogEnabled = true;
  62232. /**
  62233. * Stores the size of points
  62234. */
  62235. this.pointSize = 1.0;
  62236. /**
  62237. * Stores the z offset value
  62238. */
  62239. this.zOffset = 0;
  62240. /**
  62241. * @hidden
  62242. * Specifies if the material was previously ready
  62243. */
  62244. this._wasPreviouslyReady = false;
  62245. /**
  62246. * Stores the fill mode state
  62247. */
  62248. this._fillMode = Material.TriangleFillMode;
  62249. /** @hidden */
  62250. this._indexInSceneMaterialArray = -1;
  62251. this.name = name;
  62252. this.id = name || _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RandomId();
  62253. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  62254. this.uniqueId = this._scene.getUniqueId();
  62255. if (this._scene.useRightHandedSystem) {
  62256. this.sideOrientation = Material.ClockWiseSideOrientation;
  62257. }
  62258. else {
  62259. this.sideOrientation = Material.CounterClockWiseSideOrientation;
  62260. }
  62261. this._uniformBuffer = new _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__["UniformBuffer"](this._scene.getEngine());
  62262. this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
  62263. if (!doNotAdd) {
  62264. this._scene.addMaterial(this);
  62265. }
  62266. if (this._scene.useMaterialMeshMap) {
  62267. this.meshMap = {};
  62268. }
  62269. }
  62270. Object.defineProperty(Material.prototype, "alpha", {
  62271. /**
  62272. * Gets the alpha value of the material
  62273. */
  62274. get: function () {
  62275. return this._alpha;
  62276. },
  62277. /**
  62278. * Sets the alpha value of the material
  62279. */
  62280. set: function (value) {
  62281. if (this._alpha === value) {
  62282. return;
  62283. }
  62284. this._alpha = value;
  62285. this.markAsDirty(Material.MiscDirtyFlag);
  62286. },
  62287. enumerable: true,
  62288. configurable: true
  62289. });
  62290. Object.defineProperty(Material.prototype, "backFaceCulling", {
  62291. /**
  62292. * Gets the back-face culling state
  62293. */
  62294. get: function () {
  62295. return this._backFaceCulling;
  62296. },
  62297. /**
  62298. * Sets the back-face culling state
  62299. */
  62300. set: function (value) {
  62301. if (this._backFaceCulling === value) {
  62302. return;
  62303. }
  62304. this._backFaceCulling = value;
  62305. this.markAsDirty(Material.TextureDirtyFlag);
  62306. },
  62307. enumerable: true,
  62308. configurable: true
  62309. });
  62310. Object.defineProperty(Material.prototype, "hasRenderTargetTextures", {
  62311. /**
  62312. * Gets a boolean indicating that current material needs to register RTT
  62313. */
  62314. get: function () {
  62315. return false;
  62316. },
  62317. enumerable: true,
  62318. configurable: true
  62319. });
  62320. Object.defineProperty(Material.prototype, "onDispose", {
  62321. /**
  62322. * Called during a dispose event
  62323. */
  62324. set: function (callback) {
  62325. if (this._onDisposeObserver) {
  62326. this.onDisposeObservable.remove(this._onDisposeObserver);
  62327. }
  62328. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  62329. },
  62330. enumerable: true,
  62331. configurable: true
  62332. });
  62333. Object.defineProperty(Material.prototype, "onBindObservable", {
  62334. /**
  62335. * An event triggered when the material is bound
  62336. */
  62337. get: function () {
  62338. if (!this._onBindObservable) {
  62339. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  62340. }
  62341. return this._onBindObservable;
  62342. },
  62343. enumerable: true,
  62344. configurable: true
  62345. });
  62346. Object.defineProperty(Material.prototype, "onBind", {
  62347. /**
  62348. * Called during a bind event
  62349. */
  62350. set: function (callback) {
  62351. if (this._onBindObserver) {
  62352. this.onBindObservable.remove(this._onBindObserver);
  62353. }
  62354. this._onBindObserver = this.onBindObservable.add(callback);
  62355. },
  62356. enumerable: true,
  62357. configurable: true
  62358. });
  62359. Object.defineProperty(Material.prototype, "onUnBindObservable", {
  62360. /**
  62361. * An event triggered when the material is unbound
  62362. */
  62363. get: function () {
  62364. if (!this._onUnBindObservable) {
  62365. this._onUnBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  62366. }
  62367. return this._onUnBindObservable;
  62368. },
  62369. enumerable: true,
  62370. configurable: true
  62371. });
  62372. Object.defineProperty(Material.prototype, "alphaMode", {
  62373. /**
  62374. * Gets the value of the alpha mode
  62375. */
  62376. get: function () {
  62377. return this._alphaMode;
  62378. },
  62379. /**
  62380. * Sets the value of the alpha mode.
  62381. *
  62382. * | Value | Type | Description |
  62383. * | --- | --- | --- |
  62384. * | 0 | ALPHA_DISABLE | |
  62385. * | 1 | ALPHA_ADD | |
  62386. * | 2 | ALPHA_COMBINE | |
  62387. * | 3 | ALPHA_SUBTRACT | |
  62388. * | 4 | ALPHA_MULTIPLY | |
  62389. * | 5 | ALPHA_MAXIMIZED | |
  62390. * | 6 | ALPHA_ONEONE | |
  62391. * | 7 | ALPHA_PREMULTIPLIED | |
  62392. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  62393. * | 9 | ALPHA_INTERPOLATE | |
  62394. * | 10 | ALPHA_SCREENMODE | |
  62395. *
  62396. */
  62397. set: function (value) {
  62398. if (this._alphaMode === value) {
  62399. return;
  62400. }
  62401. this._alphaMode = value;
  62402. this.markAsDirty(Material.TextureDirtyFlag);
  62403. },
  62404. enumerable: true,
  62405. configurable: true
  62406. });
  62407. Object.defineProperty(Material.prototype, "needDepthPrePass", {
  62408. /**
  62409. * Gets the depth pre-pass value
  62410. */
  62411. get: function () {
  62412. return this._needDepthPrePass;
  62413. },
  62414. /**
  62415. * Sets the need depth pre-pass value
  62416. */
  62417. set: function (value) {
  62418. if (this._needDepthPrePass === value) {
  62419. return;
  62420. }
  62421. this._needDepthPrePass = value;
  62422. if (this._needDepthPrePass) {
  62423. this.checkReadyOnEveryCall = true;
  62424. }
  62425. },
  62426. enumerable: true,
  62427. configurable: true
  62428. });
  62429. Object.defineProperty(Material.prototype, "fogEnabled", {
  62430. /**
  62431. * Gets the value of the fog enabled state
  62432. */
  62433. get: function () {
  62434. return this._fogEnabled;
  62435. },
  62436. /**
  62437. * Sets the state for enabling fog
  62438. */
  62439. set: function (value) {
  62440. if (this._fogEnabled === value) {
  62441. return;
  62442. }
  62443. this._fogEnabled = value;
  62444. this.markAsDirty(Material.MiscDirtyFlag);
  62445. },
  62446. enumerable: true,
  62447. configurable: true
  62448. });
  62449. Object.defineProperty(Material.prototype, "wireframe", {
  62450. /**
  62451. * Gets a value specifying if wireframe mode is enabled
  62452. */
  62453. get: function () {
  62454. switch (this._fillMode) {
  62455. case Material.WireFrameFillMode:
  62456. case Material.LineListDrawMode:
  62457. case Material.LineLoopDrawMode:
  62458. case Material.LineStripDrawMode:
  62459. return true;
  62460. }
  62461. return this._scene.forceWireframe;
  62462. },
  62463. /**
  62464. * Sets the state of wireframe mode
  62465. */
  62466. set: function (value) {
  62467. this.fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
  62468. },
  62469. enumerable: true,
  62470. configurable: true
  62471. });
  62472. Object.defineProperty(Material.prototype, "pointsCloud", {
  62473. /**
  62474. * Gets the value specifying if point clouds are enabled
  62475. */
  62476. get: function () {
  62477. switch (this._fillMode) {
  62478. case Material.PointFillMode:
  62479. case Material.PointListDrawMode:
  62480. return true;
  62481. }
  62482. return this._scene.forcePointsCloud;
  62483. },
  62484. /**
  62485. * Sets the state of point cloud mode
  62486. */
  62487. set: function (value) {
  62488. this.fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
  62489. },
  62490. enumerable: true,
  62491. configurable: true
  62492. });
  62493. Object.defineProperty(Material.prototype, "fillMode", {
  62494. /**
  62495. * Gets the material fill mode
  62496. */
  62497. get: function () {
  62498. return this._fillMode;
  62499. },
  62500. /**
  62501. * Sets the material fill mode
  62502. */
  62503. set: function (value) {
  62504. if (this._fillMode === value) {
  62505. return;
  62506. }
  62507. this._fillMode = value;
  62508. this.markAsDirty(Material.MiscDirtyFlag);
  62509. },
  62510. enumerable: true,
  62511. configurable: true
  62512. });
  62513. /**
  62514. * Returns a string representation of the current material
  62515. * @param fullDetails defines a boolean indicating which levels of logging is desired
  62516. * @returns a string with material information
  62517. */
  62518. Material.prototype.toString = function (fullDetails) {
  62519. var ret = "Name: " + this.name;
  62520. if (fullDetails) {
  62521. }
  62522. return ret;
  62523. };
  62524. /**
  62525. * Gets the class name of the material
  62526. * @returns a string with the class name of the material
  62527. */
  62528. Material.prototype.getClassName = function () {
  62529. return "Material";
  62530. };
  62531. Object.defineProperty(Material.prototype, "isFrozen", {
  62532. /**
  62533. * Specifies if updates for the material been locked
  62534. */
  62535. get: function () {
  62536. return this.checkReadyOnlyOnce;
  62537. },
  62538. enumerable: true,
  62539. configurable: true
  62540. });
  62541. /**
  62542. * Locks updates for the material
  62543. */
  62544. Material.prototype.freeze = function () {
  62545. this.checkReadyOnlyOnce = true;
  62546. };
  62547. /**
  62548. * Unlocks updates for the material
  62549. */
  62550. Material.prototype.unfreeze = function () {
  62551. this.checkReadyOnlyOnce = false;
  62552. };
  62553. /**
  62554. * Specifies if the material is ready to be used
  62555. * @param mesh defines the mesh to check
  62556. * @param useInstances specifies if instances should be used
  62557. * @returns a boolean indicating if the material is ready to be used
  62558. */
  62559. Material.prototype.isReady = function (mesh, useInstances) {
  62560. return true;
  62561. };
  62562. /**
  62563. * Specifies that the submesh is ready to be used
  62564. * @param mesh defines the mesh to check
  62565. * @param subMesh defines which submesh to check
  62566. * @param useInstances specifies that instances should be used
  62567. * @returns a boolean indicating that the submesh is ready or not
  62568. */
  62569. Material.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  62570. return false;
  62571. };
  62572. /**
  62573. * Returns the material effect
  62574. * @returns the effect associated with the material
  62575. */
  62576. Material.prototype.getEffect = function () {
  62577. return this._effect;
  62578. };
  62579. /**
  62580. * Returns the current scene
  62581. * @returns a Scene
  62582. */
  62583. Material.prototype.getScene = function () {
  62584. return this._scene;
  62585. };
  62586. /**
  62587. * Specifies if the material will require alpha blending
  62588. * @returns a boolean specifying if alpha blending is needed
  62589. */
  62590. Material.prototype.needAlphaBlending = function () {
  62591. return (this.alpha < 1.0);
  62592. };
  62593. /**
  62594. * Specifies if the mesh will require alpha blending
  62595. * @param mesh defines the mesh to check
  62596. * @returns a boolean specifying if alpha blending is needed for the mesh
  62597. */
  62598. Material.prototype.needAlphaBlendingForMesh = function (mesh) {
  62599. return this.needAlphaBlending() || (mesh.visibility < 1.0) || mesh.hasVertexAlpha;
  62600. };
  62601. /**
  62602. * Specifies if this material should be rendered in alpha test mode
  62603. * @returns a boolean specifying if an alpha test is needed.
  62604. */
  62605. Material.prototype.needAlphaTesting = function () {
  62606. return false;
  62607. };
  62608. /**
  62609. * Gets the texture used for the alpha test
  62610. * @returns the texture to use for alpha testing
  62611. */
  62612. Material.prototype.getAlphaTestTexture = function () {
  62613. return null;
  62614. };
  62615. /**
  62616. * Marks the material to indicate that it needs to be re-calculated
  62617. */
  62618. Material.prototype.markDirty = function () {
  62619. this._wasPreviouslyReady = false;
  62620. };
  62621. /** @hidden */
  62622. Material.prototype._preBind = function (effect, overrideOrientation) {
  62623. if (overrideOrientation === void 0) { overrideOrientation = null; }
  62624. var engine = this._scene.getEngine();
  62625. var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
  62626. var reverse = orientation === Material.ClockWiseSideOrientation;
  62627. engine.enableEffect(effect ? effect : this._effect);
  62628. engine.setState(this.backFaceCulling, this.zOffset, false, reverse);
  62629. return reverse;
  62630. };
  62631. /**
  62632. * Binds the material to the mesh
  62633. * @param world defines the world transformation matrix
  62634. * @param mesh defines the mesh to bind the material to
  62635. */
  62636. Material.prototype.bind = function (world, mesh) {
  62637. };
  62638. /**
  62639. * Binds the submesh to the material
  62640. * @param world defines the world transformation matrix
  62641. * @param mesh defines the mesh containing the submesh
  62642. * @param subMesh defines the submesh to bind the material to
  62643. */
  62644. Material.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  62645. };
  62646. /**
  62647. * Binds the world matrix to the material
  62648. * @param world defines the world transformation matrix
  62649. */
  62650. Material.prototype.bindOnlyWorldMatrix = function (world) {
  62651. };
  62652. /**
  62653. * Binds the scene's uniform buffer to the effect.
  62654. * @param effect defines the effect to bind to the scene uniform buffer
  62655. * @param sceneUbo defines the uniform buffer storing scene data
  62656. */
  62657. Material.prototype.bindSceneUniformBuffer = function (effect, sceneUbo) {
  62658. sceneUbo.bindToEffect(effect, "Scene");
  62659. };
  62660. /**
  62661. * Binds the view matrix to the effect
  62662. * @param effect defines the effect to bind the view matrix to
  62663. */
  62664. Material.prototype.bindView = function (effect) {
  62665. if (!this._useUBO) {
  62666. effect.setMatrix("view", this.getScene().getViewMatrix());
  62667. }
  62668. else {
  62669. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  62670. }
  62671. };
  62672. /**
  62673. * Binds the view projection matrix to the effect
  62674. * @param effect defines the effect to bind the view projection matrix to
  62675. */
  62676. Material.prototype.bindViewProjection = function (effect) {
  62677. if (!this._useUBO) {
  62678. effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  62679. }
  62680. else {
  62681. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  62682. }
  62683. };
  62684. /**
  62685. * Specifies if material alpha testing should be turned on for the mesh
  62686. * @param mesh defines the mesh to check
  62687. */
  62688. Material.prototype._shouldTurnAlphaTestOn = function (mesh) {
  62689. return (!this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting());
  62690. };
  62691. /**
  62692. * Processes to execute after binding the material to a mesh
  62693. * @param mesh defines the rendered mesh
  62694. */
  62695. Material.prototype._afterBind = function (mesh) {
  62696. this._scene._cachedMaterial = this;
  62697. if (mesh) {
  62698. this._scene._cachedVisibility = mesh.visibility;
  62699. }
  62700. else {
  62701. this._scene._cachedVisibility = 1;
  62702. }
  62703. if (this._onBindObservable && mesh) {
  62704. this._onBindObservable.notifyObservers(mesh);
  62705. }
  62706. if (this.disableDepthWrite) {
  62707. var engine = this._scene.getEngine();
  62708. this._cachedDepthWriteState = engine.getDepthWrite();
  62709. engine.setDepthWrite(false);
  62710. }
  62711. };
  62712. /**
  62713. * Unbinds the material from the mesh
  62714. */
  62715. Material.prototype.unbind = function () {
  62716. if (this._onUnBindObservable) {
  62717. this._onUnBindObservable.notifyObservers(this);
  62718. }
  62719. if (this.disableDepthWrite) {
  62720. var engine = this._scene.getEngine();
  62721. engine.setDepthWrite(this._cachedDepthWriteState);
  62722. }
  62723. };
  62724. /**
  62725. * Gets the active textures from the material
  62726. * @returns an array of textures
  62727. */
  62728. Material.prototype.getActiveTextures = function () {
  62729. return [];
  62730. };
  62731. /**
  62732. * Specifies if the material uses a texture
  62733. * @param texture defines the texture to check against the material
  62734. * @returns a boolean specifying if the material uses the texture
  62735. */
  62736. Material.prototype.hasTexture = function (texture) {
  62737. return false;
  62738. };
  62739. /**
  62740. * Makes a duplicate of the material, and gives it a new name
  62741. * @param name defines the new name for the duplicated material
  62742. * @returns the cloned material
  62743. */
  62744. Material.prototype.clone = function (name) {
  62745. return null;
  62746. };
  62747. /**
  62748. * Gets the meshes bound to the material
  62749. * @returns an array of meshes bound to the material
  62750. */
  62751. Material.prototype.getBindedMeshes = function () {
  62752. var _this = this;
  62753. if (this.meshMap) {
  62754. var result = new Array();
  62755. for (var meshId in this.meshMap) {
  62756. var mesh = this.meshMap[meshId];
  62757. if (mesh) {
  62758. result.push(mesh);
  62759. }
  62760. }
  62761. return result;
  62762. }
  62763. else {
  62764. var meshes = this._scene.meshes;
  62765. return meshes.filter(function (mesh) { return mesh.material === _this; });
  62766. }
  62767. };
  62768. /**
  62769. * Force shader compilation
  62770. * @param mesh defines the mesh associated with this material
  62771. * @param onCompiled defines a function to execute once the material is compiled
  62772. * @param options defines the options to configure the compilation
  62773. */
  62774. Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
  62775. var _this = this;
  62776. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  62777. var subMesh = new _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__["BaseSubMesh"]();
  62778. var scene = this.getScene();
  62779. var checkReady = function () {
  62780. if (!_this._scene || !_this._scene.getEngine()) {
  62781. return;
  62782. }
  62783. if (subMesh._materialDefines) {
  62784. subMesh._materialDefines._renderId = -1;
  62785. }
  62786. var clipPlaneState = scene.clipPlane;
  62787. if (localOptions.clipPlane) {
  62788. scene.clipPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"](0, 0, 0, 1);
  62789. }
  62790. if (_this._storeEffectOnSubMeshes) {
  62791. if (_this.isReadyForSubMesh(mesh, subMesh)) {
  62792. if (onCompiled) {
  62793. onCompiled(_this);
  62794. }
  62795. }
  62796. else {
  62797. setTimeout(checkReady, 16);
  62798. }
  62799. }
  62800. else {
  62801. if (_this.isReady()) {
  62802. if (onCompiled) {
  62803. onCompiled(_this);
  62804. }
  62805. }
  62806. else {
  62807. setTimeout(checkReady, 16);
  62808. }
  62809. }
  62810. if (localOptions.clipPlane) {
  62811. scene.clipPlane = clipPlaneState;
  62812. }
  62813. };
  62814. checkReady();
  62815. };
  62816. /**
  62817. * Force shader compilation
  62818. * @param mesh defines the mesh that will use this material
  62819. * @param options defines additional options for compiling the shaders
  62820. * @returns a promise that resolves when the compilation completes
  62821. */
  62822. Material.prototype.forceCompilationAsync = function (mesh, options) {
  62823. var _this = this;
  62824. return new Promise(function (resolve) {
  62825. _this.forceCompilation(mesh, function () {
  62826. resolve();
  62827. }, options);
  62828. });
  62829. };
  62830. /**
  62831. * Marks a define in the material to indicate that it needs to be re-computed
  62832. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  62833. */
  62834. Material.prototype.markAsDirty = function (flag) {
  62835. if (this.getScene().blockMaterialDirtyMechanism) {
  62836. return;
  62837. }
  62838. Material._DirtyCallbackArray.length = 0;
  62839. if (flag & Material.TextureDirtyFlag) {
  62840. Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
  62841. }
  62842. if (flag & Material.LightDirtyFlag) {
  62843. Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
  62844. }
  62845. if (flag & Material.FresnelDirtyFlag) {
  62846. Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
  62847. }
  62848. if (flag & Material.AttributesDirtyFlag) {
  62849. Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
  62850. }
  62851. if (flag & Material.MiscDirtyFlag) {
  62852. Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
  62853. }
  62854. if (Material._DirtyCallbackArray.length) {
  62855. this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
  62856. }
  62857. this.getScene().resetCachedMaterial();
  62858. };
  62859. /**
  62860. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  62861. * @param func defines a function which checks material defines against the submeshes
  62862. */
  62863. Material.prototype._markAllSubMeshesAsDirty = function (func) {
  62864. if (this.getScene().blockMaterialDirtyMechanism) {
  62865. return;
  62866. }
  62867. var meshes = this.getScene().meshes;
  62868. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  62869. var mesh = meshes_1[_i];
  62870. if (!mesh.subMeshes) {
  62871. continue;
  62872. }
  62873. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  62874. var subMesh = _b[_a];
  62875. if (subMesh.getMaterial() !== this) {
  62876. continue;
  62877. }
  62878. if (!subMesh._materialDefines) {
  62879. continue;
  62880. }
  62881. func(subMesh._materialDefines);
  62882. }
  62883. }
  62884. };
  62885. /**
  62886. * Indicates that image processing needs to be re-calculated for all submeshes
  62887. */
  62888. Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
  62889. this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
  62890. };
  62891. /**
  62892. * Indicates that textures need to be re-calculated for all submeshes
  62893. */
  62894. Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
  62895. this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
  62896. };
  62897. /**
  62898. * Indicates that fresnel needs to be re-calculated for all submeshes
  62899. */
  62900. Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
  62901. this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
  62902. };
  62903. /**
  62904. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  62905. */
  62906. Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
  62907. this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
  62908. };
  62909. /**
  62910. * Indicates that lights need to be re-calculated for all submeshes
  62911. */
  62912. Material.prototype._markAllSubMeshesAsLightsDirty = function () {
  62913. this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
  62914. };
  62915. /**
  62916. * Indicates that attributes need to be re-calculated for all submeshes
  62917. */
  62918. Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
  62919. this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
  62920. };
  62921. /**
  62922. * Indicates that misc needs to be re-calculated for all submeshes
  62923. */
  62924. Material.prototype._markAllSubMeshesAsMiscDirty = function () {
  62925. this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
  62926. };
  62927. /**
  62928. * Indicates that textures and misc need to be re-calculated for all submeshes
  62929. */
  62930. Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
  62931. this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
  62932. };
  62933. /**
  62934. * Disposes the material
  62935. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  62936. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  62937. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  62938. */
  62939. Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  62940. var scene = this.getScene();
  62941. // Animations
  62942. scene.stopAnimation(this);
  62943. scene.freeProcessedMaterials();
  62944. // Remove from scene
  62945. scene.removeMaterial(this);
  62946. if (notBoundToMesh !== true) {
  62947. // Remove from meshes
  62948. if (this.meshMap) {
  62949. for (var meshId in this.meshMap) {
  62950. var mesh = this.meshMap[meshId];
  62951. if (mesh) {
  62952. mesh.material = null; // will set the entry in the map to undefined
  62953. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  62954. }
  62955. }
  62956. }
  62957. else {
  62958. var meshes = scene.meshes;
  62959. for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
  62960. var mesh = meshes_2[_i];
  62961. if (mesh.material === this) {
  62962. mesh.material = null;
  62963. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  62964. }
  62965. }
  62966. }
  62967. }
  62968. this._uniformBuffer.dispose();
  62969. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  62970. if (forceDisposeEffect && this._effect) {
  62971. if (!this._storeEffectOnSubMeshes) {
  62972. scene.getEngine()._releaseEffect(this._effect);
  62973. }
  62974. this._effect = null;
  62975. }
  62976. // Callback
  62977. this.onDisposeObservable.notifyObservers(this);
  62978. this.onDisposeObservable.clear();
  62979. if (this._onBindObservable) {
  62980. this._onBindObservable.clear();
  62981. }
  62982. if (this._onUnBindObservable) {
  62983. this._onUnBindObservable.clear();
  62984. }
  62985. };
  62986. /** @hidden */
  62987. Material.prototype.releaseVertexArrayObject = function (mesh, forceDisposeEffect) {
  62988. if (mesh.geometry) {
  62989. var geometry = (mesh.geometry);
  62990. var scene = this.getScene();
  62991. if (this._storeEffectOnSubMeshes) {
  62992. for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
  62993. var subMesh = _a[_i];
  62994. geometry._releaseVertexArrayObject(subMesh._materialEffect);
  62995. if (forceDisposeEffect && subMesh._materialEffect) {
  62996. scene.getEngine()._releaseEffect(subMesh._materialEffect);
  62997. }
  62998. }
  62999. }
  63000. else {
  63001. geometry._releaseVertexArrayObject(this._effect);
  63002. }
  63003. }
  63004. };
  63005. /**
  63006. * Serializes this material
  63007. * @returns the serialized material object
  63008. */
  63009. Material.prototype.serialize = function () {
  63010. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  63011. };
  63012. /**
  63013. * Creates a material from parsed material data
  63014. * @param parsedMaterial defines parsed material data
  63015. * @param scene defines the hosting scene
  63016. * @param rootUrl defines the root URL to use to load textures
  63017. * @returns a new material
  63018. */
  63019. Material.Parse = function (parsedMaterial, scene, rootUrl) {
  63020. if (!parsedMaterial.customType) {
  63021. parsedMaterial.customType = "BABYLON.StandardMaterial";
  63022. }
  63023. else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
  63024. parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
  63025. if (!BABYLON.LegacyPBRMaterial) {
  63026. _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.");
  63027. return;
  63028. }
  63029. }
  63030. var materialType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedMaterial.customType);
  63031. return materialType.Parse(parsedMaterial, scene, rootUrl);
  63032. };
  63033. /**
  63034. * Returns the triangle fill mode
  63035. */
  63036. Material.TriangleFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFillMode;
  63037. /**
  63038. * Returns the wireframe mode
  63039. */
  63040. Material.WireFrameFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_WireFrameFillMode;
  63041. /**
  63042. * Returns the point fill mode
  63043. */
  63044. Material.PointFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointFillMode;
  63045. /**
  63046. * Returns the point list draw mode
  63047. */
  63048. Material.PointListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointListDrawMode;
  63049. /**
  63050. * Returns the line list draw mode
  63051. */
  63052. Material.LineListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineListDrawMode;
  63053. /**
  63054. * Returns the line loop draw mode
  63055. */
  63056. Material.LineLoopDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineLoopDrawMode;
  63057. /**
  63058. * Returns the line strip draw mode
  63059. */
  63060. Material.LineStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineStripDrawMode;
  63061. /**
  63062. * Returns the triangle strip draw mode
  63063. */
  63064. Material.TriangleStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleStripDrawMode;
  63065. /**
  63066. * Returns the triangle fan draw mode
  63067. */
  63068. Material.TriangleFanDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFanDrawMode;
  63069. /**
  63070. * Stores the clock-wise side orientation
  63071. */
  63072. Material.ClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_ClockWiseSideOrientation;
  63073. /**
  63074. * Stores the counter clock-wise side orientation
  63075. */
  63076. Material.CounterClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_CounterClockWiseSideOrientation;
  63077. /**
  63078. * The dirty texture flag value
  63079. */
  63080. Material.TextureDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TextureDirtyFlag;
  63081. /**
  63082. * The dirty light flag value
  63083. */
  63084. Material.LightDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LightDirtyFlag;
  63085. /**
  63086. * The dirty fresnel flag value
  63087. */
  63088. Material.FresnelDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_FresnelDirtyFlag;
  63089. /**
  63090. * The dirty attribute flag value
  63091. */
  63092. Material.AttributesDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AttributesDirtyFlag;
  63093. /**
  63094. * The dirty misc flag value
  63095. */
  63096. Material.MiscDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_MiscDirtyFlag;
  63097. /**
  63098. * The all dirty flag value
  63099. */
  63100. Material.AllDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AllDirtyFlag;
  63101. Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
  63102. Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
  63103. Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
  63104. Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
  63105. Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
  63106. Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
  63107. Material._FresnelAndMiscDirtyCallBack = function (defines) {
  63108. Material._FresnelDirtyCallBack(defines);
  63109. Material._MiscDirtyCallBack(defines);
  63110. };
  63111. Material._TextureAndMiscDirtyCallBack = function (defines) {
  63112. Material._TextureDirtyCallBack(defines);
  63113. Material._MiscDirtyCallBack(defines);
  63114. };
  63115. Material._DirtyCallbackArray = [];
  63116. Material._RunDirtyCallBacks = function (defines) {
  63117. for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
  63118. var cb = _a[_i];
  63119. cb(defines);
  63120. }
  63121. };
  63122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63124. ], Material.prototype, "id", void 0);
  63125. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63126. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63127. ], Material.prototype, "uniqueId", void 0);
  63128. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63129. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63130. ], Material.prototype, "name", void 0);
  63131. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63132. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63133. ], Material.prototype, "checkReadyOnEveryCall", void 0);
  63134. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63135. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63136. ], Material.prototype, "checkReadyOnlyOnce", void 0);
  63137. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63138. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63139. ], Material.prototype, "state", void 0);
  63140. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63141. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alpha")
  63142. ], Material.prototype, "_alpha", void 0);
  63143. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63144. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("backFaceCulling")
  63145. ], Material.prototype, "_backFaceCulling", void 0);
  63146. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63147. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63148. ], Material.prototype, "sideOrientation", void 0);
  63149. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63150. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alphaMode")
  63151. ], Material.prototype, "_alphaMode", void 0);
  63152. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63153. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63154. ], Material.prototype, "_needDepthPrePass", void 0);
  63155. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63156. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63157. ], Material.prototype, "disableDepthWrite", void 0);
  63158. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63159. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63160. ], Material.prototype, "forceDepthWrite", void 0);
  63161. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63162. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63163. ], Material.prototype, "separateCullingPass", void 0);
  63164. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63165. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fogEnabled")
  63166. ], Material.prototype, "_fogEnabled", void 0);
  63167. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63168. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63169. ], Material.prototype, "pointSize", void 0);
  63170. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63171. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63172. ], Material.prototype, "zOffset", void 0);
  63173. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63174. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63175. ], Material.prototype, "wireframe", null);
  63176. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63177. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63178. ], Material.prototype, "pointsCloud", null);
  63179. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63180. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63181. ], Material.prototype, "fillMode", null);
  63182. return Material;
  63183. }());
  63184. /***/ }),
  63185. /***/ "./Materials/materialDefines.ts":
  63186. /*!**************************************!*\
  63187. !*** ./Materials/materialDefines.ts ***!
  63188. \**************************************/
  63189. /*! exports provided: MaterialDefines */
  63190. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63191. "use strict";
  63192. __webpack_require__.r(__webpack_exports__);
  63193. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return MaterialDefines; });
  63194. /**
  63195. * Manages the defines for the Material
  63196. */
  63197. var MaterialDefines = /** @class */ (function () {
  63198. function MaterialDefines() {
  63199. this._isDirty = true;
  63200. /** @hidden */
  63201. this._areLightsDirty = true;
  63202. /** @hidden */
  63203. this._areAttributesDirty = true;
  63204. /** @hidden */
  63205. this._areTexturesDirty = true;
  63206. /** @hidden */
  63207. this._areFresnelDirty = true;
  63208. /** @hidden */
  63209. this._areMiscDirty = true;
  63210. /** @hidden */
  63211. this._areImageProcessingDirty = true;
  63212. /** @hidden */
  63213. this._normals = false;
  63214. /** @hidden */
  63215. this._uvs = false;
  63216. /** @hidden */
  63217. this._needNormals = false;
  63218. /** @hidden */
  63219. this._needUVs = false;
  63220. }
  63221. Object.defineProperty(MaterialDefines.prototype, "isDirty", {
  63222. /**
  63223. * Specifies if the material needs to be re-calculated
  63224. */
  63225. get: function () {
  63226. return this._isDirty;
  63227. },
  63228. enumerable: true,
  63229. configurable: true
  63230. });
  63231. /**
  63232. * Marks the material to indicate that it has been re-calculated
  63233. */
  63234. MaterialDefines.prototype.markAsProcessed = function () {
  63235. this._isDirty = false;
  63236. this._areAttributesDirty = false;
  63237. this._areTexturesDirty = false;
  63238. this._areFresnelDirty = false;
  63239. this._areLightsDirty = false;
  63240. this._areMiscDirty = false;
  63241. this._areImageProcessingDirty = false;
  63242. };
  63243. /**
  63244. * Marks the material to indicate that it needs to be re-calculated
  63245. */
  63246. MaterialDefines.prototype.markAsUnprocessed = function () {
  63247. this._isDirty = true;
  63248. };
  63249. /**
  63250. * Marks the material to indicate all of its defines need to be re-calculated
  63251. */
  63252. MaterialDefines.prototype.markAllAsDirty = function () {
  63253. this._areTexturesDirty = true;
  63254. this._areAttributesDirty = true;
  63255. this._areLightsDirty = true;
  63256. this._areFresnelDirty = true;
  63257. this._areMiscDirty = true;
  63258. this._areImageProcessingDirty = true;
  63259. this._isDirty = true;
  63260. };
  63261. /**
  63262. * Marks the material to indicate that image processing needs to be re-calculated
  63263. */
  63264. MaterialDefines.prototype.markAsImageProcessingDirty = function () {
  63265. this._areImageProcessingDirty = true;
  63266. this._isDirty = true;
  63267. };
  63268. /**
  63269. * Marks the material to indicate the lights need to be re-calculated
  63270. */
  63271. MaterialDefines.prototype.markAsLightDirty = function () {
  63272. this._areLightsDirty = true;
  63273. this._isDirty = true;
  63274. };
  63275. /**
  63276. * Marks the attribute state as changed
  63277. */
  63278. MaterialDefines.prototype.markAsAttributesDirty = function () {
  63279. this._areAttributesDirty = true;
  63280. this._isDirty = true;
  63281. };
  63282. /**
  63283. * Marks the texture state as changed
  63284. */
  63285. MaterialDefines.prototype.markAsTexturesDirty = function () {
  63286. this._areTexturesDirty = true;
  63287. this._isDirty = true;
  63288. };
  63289. /**
  63290. * Marks the fresnel state as changed
  63291. */
  63292. MaterialDefines.prototype.markAsFresnelDirty = function () {
  63293. this._areFresnelDirty = true;
  63294. this._isDirty = true;
  63295. };
  63296. /**
  63297. * Marks the misc state as changed
  63298. */
  63299. MaterialDefines.prototype.markAsMiscDirty = function () {
  63300. this._areMiscDirty = true;
  63301. this._isDirty = true;
  63302. };
  63303. /**
  63304. * Rebuilds the material defines
  63305. */
  63306. MaterialDefines.prototype.rebuild = function () {
  63307. if (this._keys) {
  63308. delete this._keys;
  63309. }
  63310. this._keys = [];
  63311. for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
  63312. var key = _a[_i];
  63313. if (key[0] === "_") {
  63314. continue;
  63315. }
  63316. this._keys.push(key);
  63317. }
  63318. };
  63319. /**
  63320. * Specifies if two material defines are equal
  63321. * @param other - A material define instance to compare to
  63322. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  63323. */
  63324. MaterialDefines.prototype.isEqual = function (other) {
  63325. if (this._keys.length !== other._keys.length) {
  63326. return false;
  63327. }
  63328. for (var index = 0; index < this._keys.length; index++) {
  63329. var prop = this._keys[index];
  63330. if (this[prop] !== other[prop]) {
  63331. return false;
  63332. }
  63333. }
  63334. return true;
  63335. };
  63336. /**
  63337. * Clones this instance's defines to another instance
  63338. * @param other - material defines to clone values to
  63339. */
  63340. MaterialDefines.prototype.cloneTo = function (other) {
  63341. if (this._keys.length !== other._keys.length) {
  63342. other._keys = this._keys.slice(0);
  63343. }
  63344. for (var index = 0; index < this._keys.length; index++) {
  63345. var prop = this._keys[index];
  63346. other[prop] = this[prop];
  63347. }
  63348. };
  63349. /**
  63350. * Resets the material define values
  63351. */
  63352. MaterialDefines.prototype.reset = function () {
  63353. for (var index = 0; index < this._keys.length; index++) {
  63354. var prop = this._keys[index];
  63355. var type = typeof this[prop];
  63356. switch (type) {
  63357. case "number":
  63358. this[prop] = 0;
  63359. break;
  63360. case "string":
  63361. this[prop] = "";
  63362. break;
  63363. default:
  63364. this[prop] = false;
  63365. break;
  63366. }
  63367. }
  63368. };
  63369. /**
  63370. * Converts the material define values to a string
  63371. * @returns - String of material define information
  63372. */
  63373. MaterialDefines.prototype.toString = function () {
  63374. var result = "";
  63375. for (var index = 0; index < this._keys.length; index++) {
  63376. var prop = this._keys[index];
  63377. var value = this[prop];
  63378. var type = typeof value;
  63379. switch (type) {
  63380. case "number":
  63381. case "string":
  63382. result += "#define " + prop + " " + value + "\n";
  63383. break;
  63384. default:
  63385. if (value) {
  63386. result += "#define " + prop + "\n";
  63387. }
  63388. break;
  63389. }
  63390. }
  63391. return result;
  63392. };
  63393. return MaterialDefines;
  63394. }());
  63395. /***/ }),
  63396. /***/ "./Materials/materialFlags.ts":
  63397. /*!************************************!*\
  63398. !*** ./Materials/materialFlags.ts ***!
  63399. \************************************/
  63400. /*! exports provided: MaterialFlags */
  63401. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63402. "use strict";
  63403. __webpack_require__.r(__webpack_exports__);
  63404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return MaterialFlags; });
  63405. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  63406. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  63407. /**
  63408. * This groups all the flags used to control the materials channel.
  63409. */
  63410. var MaterialFlags = /** @class */ (function () {
  63411. function MaterialFlags() {
  63412. }
  63413. Object.defineProperty(MaterialFlags, "DiffuseTextureEnabled", {
  63414. /**
  63415. * Are diffuse textures enabled in the application.
  63416. */
  63417. get: function () {
  63418. return this._DiffuseTextureEnabled;
  63419. },
  63420. set: function (value) {
  63421. if (this._DiffuseTextureEnabled === value) {
  63422. return;
  63423. }
  63424. this._DiffuseTextureEnabled = value;
  63425. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63426. },
  63427. enumerable: true,
  63428. configurable: true
  63429. });
  63430. Object.defineProperty(MaterialFlags, "AmbientTextureEnabled", {
  63431. /**
  63432. * Are ambient textures enabled in the application.
  63433. */
  63434. get: function () {
  63435. return this._AmbientTextureEnabled;
  63436. },
  63437. set: function (value) {
  63438. if (this._AmbientTextureEnabled === value) {
  63439. return;
  63440. }
  63441. this._AmbientTextureEnabled = value;
  63442. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63443. },
  63444. enumerable: true,
  63445. configurable: true
  63446. });
  63447. Object.defineProperty(MaterialFlags, "OpacityTextureEnabled", {
  63448. /**
  63449. * Are opacity textures enabled in the application.
  63450. */
  63451. get: function () {
  63452. return this._OpacityTextureEnabled;
  63453. },
  63454. set: function (value) {
  63455. if (this._OpacityTextureEnabled === value) {
  63456. return;
  63457. }
  63458. this._OpacityTextureEnabled = value;
  63459. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63460. },
  63461. enumerable: true,
  63462. configurable: true
  63463. });
  63464. Object.defineProperty(MaterialFlags, "ReflectionTextureEnabled", {
  63465. /**
  63466. * Are reflection textures enabled in the application.
  63467. */
  63468. get: function () {
  63469. return this._ReflectionTextureEnabled;
  63470. },
  63471. set: function (value) {
  63472. if (this._ReflectionTextureEnabled === value) {
  63473. return;
  63474. }
  63475. this._ReflectionTextureEnabled = value;
  63476. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63477. },
  63478. enumerable: true,
  63479. configurable: true
  63480. });
  63481. Object.defineProperty(MaterialFlags, "EmissiveTextureEnabled", {
  63482. /**
  63483. * Are emissive textures enabled in the application.
  63484. */
  63485. get: function () {
  63486. return this._EmissiveTextureEnabled;
  63487. },
  63488. set: function (value) {
  63489. if (this._EmissiveTextureEnabled === value) {
  63490. return;
  63491. }
  63492. this._EmissiveTextureEnabled = value;
  63493. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63494. },
  63495. enumerable: true,
  63496. configurable: true
  63497. });
  63498. Object.defineProperty(MaterialFlags, "SpecularTextureEnabled", {
  63499. /**
  63500. * Are specular textures enabled in the application.
  63501. */
  63502. get: function () {
  63503. return this._SpecularTextureEnabled;
  63504. },
  63505. set: function (value) {
  63506. if (this._SpecularTextureEnabled === value) {
  63507. return;
  63508. }
  63509. this._SpecularTextureEnabled = value;
  63510. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63511. },
  63512. enumerable: true,
  63513. configurable: true
  63514. });
  63515. Object.defineProperty(MaterialFlags, "BumpTextureEnabled", {
  63516. /**
  63517. * Are bump textures enabled in the application.
  63518. */
  63519. get: function () {
  63520. return this._BumpTextureEnabled;
  63521. },
  63522. set: function (value) {
  63523. if (this._BumpTextureEnabled === value) {
  63524. return;
  63525. }
  63526. this._BumpTextureEnabled = value;
  63527. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63528. },
  63529. enumerable: true,
  63530. configurable: true
  63531. });
  63532. Object.defineProperty(MaterialFlags, "LightmapTextureEnabled", {
  63533. /**
  63534. * Are lightmap textures enabled in the application.
  63535. */
  63536. get: function () {
  63537. return this._LightmapTextureEnabled;
  63538. },
  63539. set: function (value) {
  63540. if (this._LightmapTextureEnabled === value) {
  63541. return;
  63542. }
  63543. this._LightmapTextureEnabled = value;
  63544. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63545. },
  63546. enumerable: true,
  63547. configurable: true
  63548. });
  63549. Object.defineProperty(MaterialFlags, "RefractionTextureEnabled", {
  63550. /**
  63551. * Are refraction textures enabled in the application.
  63552. */
  63553. get: function () {
  63554. return this._RefractionTextureEnabled;
  63555. },
  63556. set: function (value) {
  63557. if (this._RefractionTextureEnabled === value) {
  63558. return;
  63559. }
  63560. this._RefractionTextureEnabled = value;
  63561. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63562. },
  63563. enumerable: true,
  63564. configurable: true
  63565. });
  63566. Object.defineProperty(MaterialFlags, "ColorGradingTextureEnabled", {
  63567. /**
  63568. * Are color grading textures enabled in the application.
  63569. */
  63570. get: function () {
  63571. return this._ColorGradingTextureEnabled;
  63572. },
  63573. set: function (value) {
  63574. if (this._ColorGradingTextureEnabled === value) {
  63575. return;
  63576. }
  63577. this._ColorGradingTextureEnabled = value;
  63578. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63579. },
  63580. enumerable: true,
  63581. configurable: true
  63582. });
  63583. Object.defineProperty(MaterialFlags, "FresnelEnabled", {
  63584. /**
  63585. * Are fresnels enabled in the application.
  63586. */
  63587. get: function () {
  63588. return this._FresnelEnabled;
  63589. },
  63590. set: function (value) {
  63591. if (this._FresnelEnabled === value) {
  63592. return;
  63593. }
  63594. this._FresnelEnabled = value;
  63595. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_FresnelDirtyFlag);
  63596. },
  63597. enumerable: true,
  63598. configurable: true
  63599. });
  63600. // Flags used to enable or disable a type of texture for all Standard Materials
  63601. MaterialFlags._DiffuseTextureEnabled = true;
  63602. MaterialFlags._AmbientTextureEnabled = true;
  63603. MaterialFlags._OpacityTextureEnabled = true;
  63604. MaterialFlags._ReflectionTextureEnabled = true;
  63605. MaterialFlags._EmissiveTextureEnabled = true;
  63606. MaterialFlags._SpecularTextureEnabled = true;
  63607. MaterialFlags._BumpTextureEnabled = true;
  63608. MaterialFlags._LightmapTextureEnabled = true;
  63609. MaterialFlags._RefractionTextureEnabled = true;
  63610. MaterialFlags._ColorGradingTextureEnabled = true;
  63611. MaterialFlags._FresnelEnabled = true;
  63612. return MaterialFlags;
  63613. }());
  63614. /***/ }),
  63615. /***/ "./Materials/materialHelper.ts":
  63616. /*!*************************************!*\
  63617. !*** ./Materials/materialHelper.ts ***!
  63618. \*************************************/
  63619. /*! exports provided: MaterialHelper */
  63620. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63621. "use strict";
  63622. __webpack_require__.r(__webpack_exports__);
  63623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return MaterialHelper; });
  63624. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  63625. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  63626. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63627. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  63628. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  63629. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
  63630. /**
  63631. * "Static Class" containing the most commonly used helper while dealing with material for
  63632. * rendering purpose.
  63633. *
  63634. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  63635. *
  63636. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  63637. */
  63638. var MaterialHelper = /** @class */ (function () {
  63639. function MaterialHelper() {
  63640. }
  63641. /**
  63642. * Bind the current view position to an effect.
  63643. * @param effect The effect to be bound
  63644. * @param scene The scene the eyes position is used from
  63645. */
  63646. MaterialHelper.BindEyePosition = function (effect, scene) {
  63647. if (scene._forcedViewPosition) {
  63648. effect.setVector3("vEyePosition", scene._forcedViewPosition);
  63649. return;
  63650. }
  63651. effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  63652. };
  63653. /**
  63654. * Helps preparing the defines values about the UVs in used in the effect.
  63655. * UVs are shared as much as we can accross channels in the shaders.
  63656. * @param texture The texture we are preparing the UVs for
  63657. * @param defines The defines to update
  63658. * @param key The channel key "diffuse", "specular"... used in the shader
  63659. */
  63660. MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
  63661. defines._needUVs = true;
  63662. defines[key] = true;
  63663. if (texture.getTextureMatrix().isIdentityAs3x2()) {
  63664. defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
  63665. if (texture.coordinatesIndex === 0) {
  63666. defines["MAINUV1"] = true;
  63667. }
  63668. else {
  63669. defines["MAINUV2"] = true;
  63670. }
  63671. }
  63672. else {
  63673. defines[key + "DIRECTUV"] = 0;
  63674. }
  63675. };
  63676. /**
  63677. * Binds a texture matrix value to its corrsponding uniform
  63678. * @param texture The texture to bind the matrix for
  63679. * @param uniformBuffer The uniform buffer receivin the data
  63680. * @param key The channel key "diffuse", "specular"... used in the shader
  63681. */
  63682. MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
  63683. var matrix = texture.getTextureMatrix();
  63684. if (!matrix.isIdentityAs3x2()) {
  63685. uniformBuffer.updateMatrix(key + "Matrix", matrix);
  63686. }
  63687. };
  63688. /**
  63689. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  63690. * @param mesh defines the current mesh
  63691. * @param scene defines the current scene
  63692. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  63693. * @param pointsCloud defines if point cloud rendering has to be turned on
  63694. * @param fogEnabled defines if fog has to be turned on
  63695. * @param alphaTest defines if alpha testing has to be turned on
  63696. * @param defines defines the current list of defines
  63697. */
  63698. MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
  63699. if (defines._areMiscDirty) {
  63700. defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
  63701. defines["POINTSIZE"] = pointsCloud;
  63702. defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE && fogEnabled);
  63703. defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
  63704. defines["ALPHATEST"] = alphaTest;
  63705. }
  63706. };
  63707. /**
  63708. * Helper used to prepare the list of defines associated with frame values for shader compilation
  63709. * @param scene defines the current scene
  63710. * @param engine defines the current engine
  63711. * @param defines specifies the list of active defines
  63712. * @param useInstances defines if instances have to be turned on
  63713. * @param useClipPlane defines if clip plane have to be turned on
  63714. */
  63715. MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, useClipPlane) {
  63716. if (useClipPlane === void 0) { useClipPlane = null; }
  63717. var changed = false;
  63718. var useClipPlane1 = false;
  63719. var useClipPlane2 = false;
  63720. var useClipPlane3 = false;
  63721. var useClipPlane4 = false;
  63722. useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
  63723. useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
  63724. useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
  63725. useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
  63726. if (defines["CLIPPLANE"] !== useClipPlane1) {
  63727. defines["CLIPPLANE"] = useClipPlane1;
  63728. changed = true;
  63729. }
  63730. if (defines["CLIPPLANE2"] !== useClipPlane2) {
  63731. defines["CLIPPLANE2"] = useClipPlane2;
  63732. changed = true;
  63733. }
  63734. if (defines["CLIPPLANE3"] !== useClipPlane3) {
  63735. defines["CLIPPLANE3"] = useClipPlane3;
  63736. changed = true;
  63737. }
  63738. if (defines["CLIPPLANE4"] !== useClipPlane4) {
  63739. defines["CLIPPLANE4"] = useClipPlane4;
  63740. changed = true;
  63741. }
  63742. if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
  63743. defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
  63744. changed = true;
  63745. }
  63746. if (defines["INSTANCES"] !== useInstances) {
  63747. defines["INSTANCES"] = useInstances;
  63748. changed = true;
  63749. }
  63750. if (changed) {
  63751. defines.markAsUnprocessed();
  63752. }
  63753. };
  63754. /**
  63755. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  63756. * @param mesh The mesh containing the geometry data we will draw
  63757. * @param defines The defines to update
  63758. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  63759. * @param useBones Precise whether bones should be used or not (override mesh info)
  63760. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  63761. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  63762. * @returns false if defines are considered not dirty and have not been checked
  63763. */
  63764. MaterialHelper.PrepareDefinesForAttributes = function (mesh, defines, useVertexColor, useBones, useMorphTargets, useVertexAlpha) {
  63765. if (useMorphTargets === void 0) { useMorphTargets = false; }
  63766. if (useVertexAlpha === void 0) { useVertexAlpha = true; }
  63767. if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
  63768. return false;
  63769. }
  63770. defines._normals = defines._needNormals;
  63771. defines._uvs = defines._needUVs;
  63772. defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind));
  63773. if (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind)) {
  63774. defines["TANGENT"] = true;
  63775. }
  63776. if (defines._needUVs) {
  63777. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  63778. defines["UV2"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  63779. }
  63780. else {
  63781. defines["UV1"] = false;
  63782. defines["UV2"] = false;
  63783. }
  63784. if (useVertexColor) {
  63785. var hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  63786. defines["VERTEXCOLOR"] = hasVertexColors;
  63787. defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
  63788. }
  63789. if (useBones) {
  63790. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  63791. defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
  63792. var materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
  63793. if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
  63794. defines["BONETEXTURE"] = true;
  63795. }
  63796. else {
  63797. defines["BonesPerMesh"] = (mesh.skeleton.bones.length + 1);
  63798. defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
  63799. }
  63800. }
  63801. else {
  63802. defines["NUM_BONE_INFLUENCERS"] = 0;
  63803. defines["BonesPerMesh"] = 0;
  63804. }
  63805. }
  63806. if (useMorphTargets) {
  63807. var manager = mesh.morphTargetManager;
  63808. if (manager) {
  63809. defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
  63810. defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
  63811. defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
  63812. defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
  63813. }
  63814. else {
  63815. defines["MORPHTARGETS_TANGENT"] = false;
  63816. defines["MORPHTARGETS_NORMAL"] = false;
  63817. defines["MORPHTARGETS"] = false;
  63818. defines["NUM_MORPH_INFLUENCERS"] = 0;
  63819. }
  63820. }
  63821. return true;
  63822. };
  63823. /**
  63824. * Prepares the defines related to the light information passed in parameter
  63825. * @param scene The scene we are intending to draw
  63826. * @param mesh The mesh the effect is compiling for
  63827. * @param defines The defines to update
  63828. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  63829. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  63830. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  63831. * @returns true if normals will be required for the rest of the effect
  63832. */
  63833. MaterialHelper.PrepareDefinesForLights = function (scene, mesh, defines, specularSupported, maxSimultaneousLights, disableLighting) {
  63834. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63835. if (disableLighting === void 0) { disableLighting = false; }
  63836. if (!defines._areLightsDirty) {
  63837. return defines._needNormals;
  63838. }
  63839. var lightIndex = 0;
  63840. var needNormals = false;
  63841. var needRebuild = false;
  63842. var lightmapMode = false;
  63843. var shadowEnabled = false;
  63844. var specularEnabled = false;
  63845. if (scene.lightsEnabled && !disableLighting) {
  63846. for (var _i = 0, _a = mesh._lightSources; _i < _a.length; _i++) {
  63847. var light = _a[_i];
  63848. needNormals = true;
  63849. if (defines["LIGHT" + lightIndex] === undefined) {
  63850. needRebuild = true;
  63851. }
  63852. defines["LIGHT" + lightIndex] = true;
  63853. defines["SPOTLIGHT" + lightIndex] = false;
  63854. defines["HEMILIGHT" + lightIndex] = false;
  63855. defines["POINTLIGHT" + lightIndex] = false;
  63856. defines["DIRLIGHT" + lightIndex] = false;
  63857. light.prepareLightSpecificDefines(defines, lightIndex);
  63858. // FallOff.
  63859. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
  63860. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
  63861. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
  63862. switch (light.falloffType) {
  63863. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_GLTF:
  63864. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
  63865. break;
  63866. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_PHYSICAL:
  63867. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
  63868. break;
  63869. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_STANDARD:
  63870. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
  63871. break;
  63872. }
  63873. // Specular
  63874. if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
  63875. specularEnabled = true;
  63876. }
  63877. // Shadows
  63878. defines["SHADOW" + lightIndex] = false;
  63879. defines["SHADOWPCF" + lightIndex] = false;
  63880. defines["SHADOWPCSS" + lightIndex] = false;
  63881. defines["SHADOWPOISSON" + lightIndex] = false;
  63882. defines["SHADOWESM" + lightIndex] = false;
  63883. defines["SHADOWCUBE" + lightIndex] = false;
  63884. defines["SHADOWLOWQUALITY" + lightIndex] = false;
  63885. defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
  63886. if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
  63887. var shadowGenerator = light.getShadowGenerator();
  63888. if (shadowGenerator) {
  63889. var shadowMap = shadowGenerator.getShadowMap();
  63890. if (shadowMap) {
  63891. if (shadowMap.renderList && shadowMap.renderList.length > 0) {
  63892. shadowEnabled = true;
  63893. shadowGenerator.prepareDefines(defines, lightIndex);
  63894. }
  63895. }
  63896. }
  63897. }
  63898. if (light.lightmapMode != _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_DEFAULT) {
  63899. lightmapMode = true;
  63900. defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
  63901. defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_SHADOWSONLY);
  63902. }
  63903. else {
  63904. defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
  63905. defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
  63906. }
  63907. lightIndex++;
  63908. if (lightIndex === maxSimultaneousLights) {
  63909. break;
  63910. }
  63911. }
  63912. }
  63913. defines["SPECULARTERM"] = specularEnabled;
  63914. defines["SHADOWS"] = shadowEnabled;
  63915. // Resetting all other lights if any
  63916. for (var index = lightIndex; index < maxSimultaneousLights; index++) {
  63917. if (defines["LIGHT" + index] !== undefined) {
  63918. defines["LIGHT" + index] = false;
  63919. defines["HEMILIGHT" + index] = false;
  63920. defines["POINTLIGHT" + index] = false;
  63921. defines["DIRLIGHT" + index] = false;
  63922. defines["SPOTLIGHT" + index] = false;
  63923. defines["SHADOW" + index] = false;
  63924. defines["SHADOWPCF" + index] = false;
  63925. defines["SHADOWPCSS" + index] = false;
  63926. defines["SHADOWPOISSON" + index] = false;
  63927. defines["SHADOWESM" + index] = false;
  63928. defines["SHADOWCUBE" + index] = false;
  63929. defines["SHADOWLOWQUALITY" + index] = false;
  63930. defines["SHADOWMEDIUMQUALITY" + index] = false;
  63931. }
  63932. }
  63933. var caps = scene.getEngine().getCaps();
  63934. if (defines["SHADOWFLOAT"] === undefined) {
  63935. needRebuild = true;
  63936. }
  63937. defines["SHADOWFLOAT"] = shadowEnabled &&
  63938. ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
  63939. (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
  63940. defines["LIGHTMAPEXCLUDED"] = lightmapMode;
  63941. if (needRebuild) {
  63942. defines.rebuild();
  63943. }
  63944. return needNormals;
  63945. };
  63946. /**
  63947. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  63948. * that won t be acctive due to defines being turned off.
  63949. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  63950. * @param samplersList The samplers list
  63951. * @param defines The defines helping in the list generation
  63952. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  63953. */
  63954. MaterialHelper.PrepareUniformsAndSamplersList = function (uniformsListOrOptions, samplersList, defines, maxSimultaneousLights) {
  63955. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63956. var uniformsList;
  63957. var uniformBuffersList = null;
  63958. if (uniformsListOrOptions.uniformsNames) {
  63959. var options = uniformsListOrOptions;
  63960. uniformsList = options.uniformsNames;
  63961. uniformBuffersList = options.uniformBuffersNames;
  63962. samplersList = options.samplers;
  63963. defines = options.defines;
  63964. maxSimultaneousLights = options.maxSimultaneousLights;
  63965. }
  63966. else {
  63967. uniformsList = uniformsListOrOptions;
  63968. if (!samplersList) {
  63969. samplersList = [];
  63970. }
  63971. }
  63972. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  63973. if (!defines["LIGHT" + lightIndex]) {
  63974. break;
  63975. }
  63976. uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
  63977. if (uniformBuffersList) {
  63978. uniformBuffersList.push("Light" + lightIndex);
  63979. }
  63980. samplersList.push("shadowSampler" + lightIndex);
  63981. samplersList.push("depthSampler" + lightIndex);
  63982. if (defines["PROJECTEDLIGHTTEXTURE" + lightIndex]) {
  63983. samplersList.push("projectionLightSampler" + lightIndex);
  63984. uniformsList.push("textureProjectionMatrix" + lightIndex);
  63985. }
  63986. }
  63987. if (defines["NUM_MORPH_INFLUENCERS"]) {
  63988. uniformsList.push("morphTargetInfluences");
  63989. }
  63990. };
  63991. /**
  63992. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  63993. * @param defines The defines to update while falling back
  63994. * @param fallbacks The authorized effect fallbacks
  63995. * @param maxSimultaneousLights The maximum number of lights allowed
  63996. * @param rank the current rank of the Effect
  63997. * @returns The newly affected rank
  63998. */
  63999. MaterialHelper.HandleFallbacksForShadows = function (defines, fallbacks, maxSimultaneousLights, rank) {
  64000. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  64001. if (rank === void 0) { rank = 0; }
  64002. var lightFallbackRank = 0;
  64003. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  64004. if (!defines["LIGHT" + lightIndex]) {
  64005. break;
  64006. }
  64007. if (lightIndex > 0) {
  64008. lightFallbackRank = rank + lightIndex;
  64009. fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
  64010. }
  64011. if (!defines["SHADOWS"]) {
  64012. if (defines["SHADOW" + lightIndex]) {
  64013. fallbacks.addFallback(rank, "SHADOW" + lightIndex);
  64014. }
  64015. if (defines["SHADOWPCF" + lightIndex]) {
  64016. fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
  64017. }
  64018. if (defines["SHADOWPCSS" + lightIndex]) {
  64019. fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
  64020. }
  64021. if (defines["SHADOWPOISSON" + lightIndex]) {
  64022. fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
  64023. }
  64024. if (defines["SHADOWESM" + lightIndex]) {
  64025. fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
  64026. }
  64027. }
  64028. }
  64029. return lightFallbackRank++;
  64030. };
  64031. /**
  64032. * Prepares the list of attributes required for morph targets according to the effect defines.
  64033. * @param attribs The current list of supported attribs
  64034. * @param mesh The mesh to prepare the morph targets attributes for
  64035. * @param defines The current Defines of the effect
  64036. */
  64037. MaterialHelper.PrepareAttributesForMorphTargets = function (attribs, mesh, defines) {
  64038. var influencers = defines["NUM_MORPH_INFLUENCERS"];
  64039. if (influencers > 0 && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine) {
  64040. var maxAttributesCount = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine.getCaps().maxVertexAttribs;
  64041. var manager = mesh.morphTargetManager;
  64042. var normal = manager && manager.supportsNormals && defines["NORMAL"];
  64043. var tangent = manager && manager.supportsTangents && defines["TANGENT"];
  64044. for (var index = 0; index < influencers; index++) {
  64045. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind + index);
  64046. if (normal) {
  64047. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind + index);
  64048. }
  64049. if (tangent) {
  64050. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind + index);
  64051. }
  64052. if (attribs.length > maxAttributesCount) {
  64053. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add more vertex attributes for mesh " + mesh.name);
  64054. }
  64055. }
  64056. }
  64057. };
  64058. /**
  64059. * Prepares the list of attributes required for bones according to the effect defines.
  64060. * @param attribs The current list of supported attribs
  64061. * @param mesh The mesh to prepare the bones attributes for
  64062. * @param defines The current Defines of the effect
  64063. * @param fallbacks The current efffect fallback strategy
  64064. */
  64065. MaterialHelper.PrepareAttributesForBones = function (attribs, mesh, defines, fallbacks) {
  64066. if (defines["NUM_BONE_INFLUENCERS"] > 0) {
  64067. fallbacks.addCPUSkinningFallback(0, mesh);
  64068. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  64069. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  64070. if (defines["NUM_BONE_INFLUENCERS"] > 4) {
  64071. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesExtraKind);
  64072. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsExtraKind);
  64073. }
  64074. }
  64075. };
  64076. /**
  64077. * Prepares the list of attributes required for instances according to the effect defines.
  64078. * @param attribs The current list of supported attribs
  64079. * @param defines The current Defines of the effect
  64080. */
  64081. MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
  64082. if (defines["INSTANCES"]) {
  64083. attribs.push("world0");
  64084. attribs.push("world1");
  64085. attribs.push("world2");
  64086. attribs.push("world3");
  64087. }
  64088. };
  64089. /**
  64090. * Binds the light shadow information to the effect for the given mesh.
  64091. * @param light The light containing the generator
  64092. * @param scene The scene the lights belongs to
  64093. * @param mesh The mesh we are binding the information to render
  64094. * @param lightIndex The light index in the effect used to render the mesh
  64095. * @param effect The effect we are binding the data to
  64096. */
  64097. MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
  64098. if (light.shadowEnabled && mesh.receiveShadows) {
  64099. var shadowGenerator = light.getShadowGenerator();
  64100. if (shadowGenerator) {
  64101. shadowGenerator.bindShadowLight(lightIndex, effect);
  64102. }
  64103. }
  64104. };
  64105. /**
  64106. * Binds the light information to the effect.
  64107. * @param light The light containing the generator
  64108. * @param effect The effect we are binding the data to
  64109. * @param lightIndex The light index in the effect used to render
  64110. */
  64111. MaterialHelper.BindLightProperties = function (light, effect, lightIndex) {
  64112. light.transferToEffect(effect, lightIndex + "");
  64113. };
  64114. /**
  64115. * Binds the lights information from the scene to the effect for the given mesh.
  64116. * @param scene The scene the lights belongs to
  64117. * @param mesh The mesh we are binding the information to render
  64118. * @param effect The effect we are binding the data to
  64119. * @param defines The generated defines for the effect
  64120. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  64121. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  64122. */
  64123. MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
  64124. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  64125. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  64126. var len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
  64127. for (var i = 0; i < len; i++) {
  64128. var light = mesh._lightSources[i];
  64129. var iAsString = i.toString();
  64130. var scaledIntensity = light.getScaledIntensity();
  64131. light._uniformBuffer.bindToEffect(effect, "Light" + i);
  64132. MaterialHelper.BindLightProperties(light, effect, i);
  64133. light.diffuse.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0]);
  64134. light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
  64135. if (defines["SPECULARTERM"]) {
  64136. light.specular.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1]);
  64137. light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1], iAsString);
  64138. }
  64139. // Shadows
  64140. if (scene.shadowsEnabled) {
  64141. this.BindLightShadow(light, mesh, iAsString, effect);
  64142. }
  64143. light._uniformBuffer.update();
  64144. }
  64145. };
  64146. /**
  64147. * Binds the fog information from the scene to the effect for the given mesh.
  64148. * @param scene The scene the lights belongs to
  64149. * @param mesh The mesh we are binding the information to render
  64150. * @param effect The effect we are binding the data to
  64151. * @param linearSpace Defines if the fog effect is applied in linear space
  64152. */
  64153. MaterialHelper.BindFogParameters = function (scene, mesh, effect, linearSpace) {
  64154. if (linearSpace === void 0) { linearSpace = false; }
  64155. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  64156. effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  64157. // Convert fog color to linear space if used in a linear space computed shader.
  64158. if (linearSpace) {
  64159. scene.fogColor.toLinearSpaceToRef(this._tempFogColor);
  64160. effect.setColor3("vFogColor", this._tempFogColor);
  64161. }
  64162. else {
  64163. effect.setColor3("vFogColor", scene.fogColor);
  64164. }
  64165. }
  64166. };
  64167. /**
  64168. * Binds the bones information from the mesh to the effect.
  64169. * @param mesh The mesh we are binding the information to render
  64170. * @param effect The effect we are binding the data to
  64171. */
  64172. MaterialHelper.BindBonesParameters = function (mesh, effect) {
  64173. if (!effect || !mesh) {
  64174. return;
  64175. }
  64176. if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
  64177. mesh.computeBonesUsingShaders = false;
  64178. }
  64179. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  64180. var skeleton = mesh.skeleton;
  64181. if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
  64182. var boneTexture = skeleton.getTransformMatrixTexture();
  64183. effect.setTexture("boneSampler", boneTexture);
  64184. effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  64185. }
  64186. else {
  64187. var matrices = skeleton.getTransformMatrices(mesh);
  64188. if (matrices) {
  64189. effect.setMatrices("mBones", matrices);
  64190. }
  64191. }
  64192. }
  64193. };
  64194. /**
  64195. * Binds the morph targets information from the mesh to the effect.
  64196. * @param abstractMesh The mesh we are binding the information to render
  64197. * @param effect The effect we are binding the data to
  64198. */
  64199. MaterialHelper.BindMorphTargetParameters = function (abstractMesh, effect) {
  64200. var manager = abstractMesh.morphTargetManager;
  64201. if (!abstractMesh || !manager) {
  64202. return;
  64203. }
  64204. effect.setFloatArray("morphTargetInfluences", manager.influences);
  64205. };
  64206. /**
  64207. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  64208. * @param defines The generated defines used in the effect
  64209. * @param effect The effect we are binding the data to
  64210. * @param scene The scene we are willing to render with logarithmic scale for
  64211. */
  64212. MaterialHelper.BindLogDepth = function (defines, effect, scene) {
  64213. if (defines["LOGARITHMICDEPTH"]) {
  64214. effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  64215. }
  64216. };
  64217. /**
  64218. * Binds the clip plane information from the scene to the effect.
  64219. * @param scene The scene the clip plane information are extracted from
  64220. * @param effect The effect we are binding the data to
  64221. */
  64222. MaterialHelper.BindClipPlane = function (effect, scene) {
  64223. if (scene.clipPlane) {
  64224. var clipPlane = scene.clipPlane;
  64225. effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64226. }
  64227. if (scene.clipPlane2) {
  64228. var clipPlane = scene.clipPlane2;
  64229. effect.setFloat4("vClipPlane2", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64230. }
  64231. if (scene.clipPlane3) {
  64232. var clipPlane = scene.clipPlane3;
  64233. effect.setFloat4("vClipPlane3", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64234. }
  64235. if (scene.clipPlane4) {
  64236. var clipPlane = scene.clipPlane4;
  64237. effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64238. }
  64239. };
  64240. MaterialHelper._tempFogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  64241. return MaterialHelper;
  64242. }());
  64243. /***/ }),
  64244. /***/ "./Materials/multiMaterial.ts":
  64245. /*!************************************!*\
  64246. !*** ./Materials/multiMaterial.ts ***!
  64247. \************************************/
  64248. /*! exports provided: MultiMaterial */
  64249. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64250. "use strict";
  64251. __webpack_require__.r(__webpack_exports__);
  64252. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return MultiMaterial; });
  64253. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64254. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  64255. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  64256. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  64257. /**
  64258. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64259. * separate meshes. This can be use to improve performances.
  64260. * @see http://doc.babylonjs.com/how_to/multi_materials
  64261. */
  64262. var MultiMaterial = /** @class */ (function (_super) {
  64263. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiMaterial, _super);
  64264. /**
  64265. * Instantiates a new Multi Material
  64266. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64267. * separate meshes. This can be use to improve performances.
  64268. * @see http://doc.babylonjs.com/how_to/multi_materials
  64269. * @param name Define the name in the scene
  64270. * @param scene Define the scene the material belongs to
  64271. */
  64272. function MultiMaterial(name, scene) {
  64273. var _this = _super.call(this, name, scene, true) || this;
  64274. scene.multiMaterials.push(_this);
  64275. _this.subMaterials = new Array();
  64276. _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
  64277. return _this;
  64278. }
  64279. Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
  64280. /**
  64281. * Gets or Sets the list of Materials used within the multi material.
  64282. * They need to be ordered according to the submeshes order in the associated mesh
  64283. */
  64284. get: function () {
  64285. return this._subMaterials;
  64286. },
  64287. set: function (value) {
  64288. this._subMaterials = value;
  64289. this._hookArray(value);
  64290. },
  64291. enumerable: true,
  64292. configurable: true
  64293. });
  64294. /**
  64295. * Function used to align with Node.getChildren()
  64296. * @returns the list of Materials used within the multi material
  64297. */
  64298. MultiMaterial.prototype.getChildren = function () {
  64299. return this.subMaterials;
  64300. };
  64301. MultiMaterial.prototype._hookArray = function (array) {
  64302. var _this = this;
  64303. var oldPush = array.push;
  64304. array.push = function () {
  64305. var items = [];
  64306. for (var _i = 0; _i < arguments.length; _i++) {
  64307. items[_i] = arguments[_i];
  64308. }
  64309. var result = oldPush.apply(array, items);
  64310. _this._markAllSubMeshesAsTexturesDirty();
  64311. return result;
  64312. };
  64313. var oldSplice = array.splice;
  64314. array.splice = function (index, deleteCount) {
  64315. var deleted = oldSplice.apply(array, [index, deleteCount]);
  64316. _this._markAllSubMeshesAsTexturesDirty();
  64317. return deleted;
  64318. };
  64319. };
  64320. /**
  64321. * Get one of the submaterial by its index in the submaterials array
  64322. * @param index The index to look the sub material at
  64323. * @returns The Material if the index has been defined
  64324. */
  64325. MultiMaterial.prototype.getSubMaterial = function (index) {
  64326. if (index < 0 || index >= this.subMaterials.length) {
  64327. return this.getScene().defaultMaterial;
  64328. }
  64329. return this.subMaterials[index];
  64330. };
  64331. /**
  64332. * Get the list of active textures for the whole sub materials list.
  64333. * @returns All the textures that will be used during the rendering
  64334. */
  64335. MultiMaterial.prototype.getActiveTextures = function () {
  64336. var _a;
  64337. return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
  64338. if (subMaterial) {
  64339. return subMaterial.getActiveTextures();
  64340. }
  64341. else {
  64342. return [];
  64343. }
  64344. }));
  64345. };
  64346. /**
  64347. * Gets the current class name of the material e.g. "MultiMaterial"
  64348. * Mainly use in serialization.
  64349. * @returns the class name
  64350. */
  64351. MultiMaterial.prototype.getClassName = function () {
  64352. return "MultiMaterial";
  64353. };
  64354. /**
  64355. * Checks if the material is ready to render the requested sub mesh
  64356. * @param mesh Define the mesh the submesh belongs to
  64357. * @param subMesh Define the sub mesh to look readyness for
  64358. * @param useInstances Define whether or not the material is used with instances
  64359. * @returns true if ready, otherwise false
  64360. */
  64361. MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  64362. for (var index = 0; index < this.subMaterials.length; index++) {
  64363. var subMaterial = this.subMaterials[index];
  64364. if (subMaterial) {
  64365. if (subMaterial._storeEffectOnSubMeshes) {
  64366. if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
  64367. return false;
  64368. }
  64369. continue;
  64370. }
  64371. if (!subMaterial.isReady(mesh)) {
  64372. return false;
  64373. }
  64374. }
  64375. }
  64376. return true;
  64377. };
  64378. /**
  64379. * Clones the current material and its related sub materials
  64380. * @param name Define the name of the newly cloned material
  64381. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64382. * @returns the cloned material
  64383. */
  64384. MultiMaterial.prototype.clone = function (name, cloneChildren) {
  64385. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  64386. for (var index = 0; index < this.subMaterials.length; index++) {
  64387. var subMaterial = null;
  64388. var current = this.subMaterials[index];
  64389. if (cloneChildren && current) {
  64390. subMaterial = current.clone(name + "-" + current.name);
  64391. }
  64392. else {
  64393. subMaterial = this.subMaterials[index];
  64394. }
  64395. newMultiMaterial.subMaterials.push(subMaterial);
  64396. }
  64397. return newMultiMaterial;
  64398. };
  64399. /**
  64400. * Serializes the materials into a JSON representation.
  64401. * @returns the JSON representation
  64402. */
  64403. MultiMaterial.prototype.serialize = function () {
  64404. var serializationObject = {};
  64405. serializationObject.name = this.name;
  64406. serializationObject.id = this.id;
  64407. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  64408. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  64409. }
  64410. serializationObject.materials = [];
  64411. for (var matIndex = 0; matIndex < this.subMaterials.length; matIndex++) {
  64412. var subMat = this.subMaterials[matIndex];
  64413. if (subMat) {
  64414. serializationObject.materials.push(subMat.id);
  64415. }
  64416. else {
  64417. serializationObject.materials.push(null);
  64418. }
  64419. }
  64420. return serializationObject;
  64421. };
  64422. /**
  64423. * Dispose the material and release its associated resources
  64424. * @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)
  64425. * @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)
  64426. * @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)
  64427. */
  64428. MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, forceDisposeChildren) {
  64429. var scene = this.getScene();
  64430. if (!scene) {
  64431. return;
  64432. }
  64433. if (forceDisposeChildren) {
  64434. for (var index = 0; index < this.subMaterials.length; index++) {
  64435. var subMaterial = this.subMaterials[index];
  64436. if (subMaterial) {
  64437. subMaterial.dispose(forceDisposeEffect, forceDisposeTextures);
  64438. }
  64439. }
  64440. }
  64441. var index = scene.multiMaterials.indexOf(this);
  64442. if (index >= 0) {
  64443. scene.multiMaterials.splice(index, 1);
  64444. }
  64445. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  64446. };
  64447. /**
  64448. * Creates a MultiMaterial from parsed MultiMaterial data.
  64449. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64450. * @param scene defines the hosting scene
  64451. * @returns a new MultiMaterial
  64452. */
  64453. MultiMaterial.ParseMultiMaterial = function (parsedMultiMaterial, scene) {
  64454. var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
  64455. multiMaterial.id = parsedMultiMaterial.id;
  64456. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  64457. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(multiMaterial, parsedMultiMaterial.tags);
  64458. }
  64459. for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
  64460. var subMatId = parsedMultiMaterial.materials[matIndex];
  64461. if (subMatId) {
  64462. multiMaterial.subMaterials.push(scene.getMaterialByID(subMatId));
  64463. }
  64464. else {
  64465. multiMaterial.subMaterials.push(null);
  64466. }
  64467. }
  64468. return multiMaterial;
  64469. };
  64470. return MultiMaterial;
  64471. }(_Materials_material__WEBPACK_IMPORTED_MODULE_1__["Material"]));
  64472. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.MultiMaterial"] = MultiMaterial;
  64473. /***/ }),
  64474. /***/ "./Materials/pushMaterial.ts":
  64475. /*!***********************************!*\
  64476. !*** ./Materials/pushMaterial.ts ***!
  64477. \***********************************/
  64478. /*! exports provided: PushMaterial */
  64479. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64480. "use strict";
  64481. __webpack_require__.r(__webpack_exports__);
  64482. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return PushMaterial; });
  64483. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64484. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64485. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  64486. /**
  64487. * Base class of materials working in push mode in babylon JS
  64488. * @hidden
  64489. */
  64490. var PushMaterial = /** @class */ (function (_super) {
  64491. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PushMaterial, _super);
  64492. function PushMaterial(name, scene) {
  64493. var _this = _super.call(this, name, scene) || this;
  64494. _this._normalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  64495. /**
  64496. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  64497. * This means that the material can keep using a previous shader while a new one is being compiled.
  64498. * This is mostly used when shader parallel compilation is supported (true by default)
  64499. */
  64500. _this.allowShaderHotSwapping = true;
  64501. _this._storeEffectOnSubMeshes = true;
  64502. return _this;
  64503. }
  64504. PushMaterial.prototype.getEffect = function () {
  64505. return this._activeEffect;
  64506. };
  64507. PushMaterial.prototype.isReady = function (mesh, useInstances) {
  64508. if (!mesh) {
  64509. return false;
  64510. }
  64511. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  64512. return true;
  64513. }
  64514. return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
  64515. };
  64516. /**
  64517. * Binds the given world matrix to the active effect
  64518. *
  64519. * @param world the matrix to bind
  64520. */
  64521. PushMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  64522. this._activeEffect.setMatrix("world", world);
  64523. };
  64524. /**
  64525. * Binds the given normal matrix to the active effect
  64526. *
  64527. * @param normalMatrix the matrix to bind
  64528. */
  64529. PushMaterial.prototype.bindOnlyNormalMatrix = function (normalMatrix) {
  64530. this._activeEffect.setMatrix("normalMatrix", normalMatrix);
  64531. };
  64532. PushMaterial.prototype.bind = function (world, mesh) {
  64533. if (!mesh) {
  64534. return;
  64535. }
  64536. this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
  64537. };
  64538. PushMaterial.prototype._afterBind = function (mesh, effect) {
  64539. if (effect === void 0) { effect = null; }
  64540. _super.prototype._afterBind.call(this, mesh);
  64541. this.getScene()._cachedEffect = effect;
  64542. };
  64543. PushMaterial.prototype._mustRebind = function (scene, effect, visibility) {
  64544. if (visibility === void 0) { visibility = 1; }
  64545. return scene.isCachedMaterialInvalid(this, effect, visibility);
  64546. };
  64547. return PushMaterial;
  64548. }(_Materials_material__WEBPACK_IMPORTED_MODULE_2__["Material"]));
  64549. /***/ }),
  64550. /***/ "./Materials/shaderMaterial.ts":
  64551. /*!*************************************!*\
  64552. !*** ./Materials/shaderMaterial.ts ***!
  64553. \*************************************/
  64554. /*! exports provided: ShaderMaterial */
  64555. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64556. "use strict";
  64557. __webpack_require__.r(__webpack_exports__);
  64558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return ShaderMaterial; });
  64559. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64560. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64561. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64562. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  64563. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  64564. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  64565. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  64566. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  64567. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  64568. /**
  64569. * 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.
  64570. *
  64571. * This returned material effects how the mesh will look based on the code in the shaders.
  64572. *
  64573. * @see http://doc.babylonjs.com/how_to/shader_material
  64574. */
  64575. var ShaderMaterial = /** @class */ (function (_super) {
  64576. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderMaterial, _super);
  64577. /**
  64578. * Instantiate a new shader material.
  64579. * 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.
  64580. * This returned material effects how the mesh will look based on the code in the shaders.
  64581. * @see http://doc.babylonjs.com/how_to/shader_material
  64582. * @param name Define the name of the material in the scene
  64583. * @param scene Define the scene the material belongs to
  64584. * @param shaderPath Defines the route to the shader code in one of three ways:
  64585. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  64586. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  64587. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  64588. * @param options Define the options used to create the shader
  64589. */
  64590. function ShaderMaterial(name, scene, shaderPath, options) {
  64591. if (options === void 0) { options = {}; }
  64592. var _this = _super.call(this, name, scene) || this;
  64593. _this._textures = {};
  64594. _this._textureArrays = {};
  64595. _this._floats = {};
  64596. _this._ints = {};
  64597. _this._floatsArrays = {};
  64598. _this._colors3 = {};
  64599. _this._colors3Arrays = {};
  64600. _this._colors4 = {};
  64601. _this._vectors2 = {};
  64602. _this._vectors3 = {};
  64603. _this._vectors4 = {};
  64604. _this._matrices = {};
  64605. _this._matrices3x3 = {};
  64606. _this._matrices2x2 = {};
  64607. _this._vectors2Arrays = {};
  64608. _this._vectors3Arrays = {};
  64609. _this._cachedWorldViewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  64610. _this._shaderPath = shaderPath;
  64611. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ needAlphaBlending: false, needAlphaTesting: false, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, options);
  64612. return _this;
  64613. }
  64614. /**
  64615. * Gets the current class name of the material e.g. "ShaderMaterial"
  64616. * Mainly use in serialization.
  64617. * @returns the class name
  64618. */
  64619. ShaderMaterial.prototype.getClassName = function () {
  64620. return "ShaderMaterial";
  64621. };
  64622. /**
  64623. * Specifies if the material will require alpha blending
  64624. * @returns a boolean specifying if alpha blending is needed
  64625. */
  64626. ShaderMaterial.prototype.needAlphaBlending = function () {
  64627. return (this.alpha < 1.0) || this._options.needAlphaBlending;
  64628. };
  64629. /**
  64630. * Specifies if this material should be rendered in alpha test mode
  64631. * @returns a boolean specifying if an alpha test is needed.
  64632. */
  64633. ShaderMaterial.prototype.needAlphaTesting = function () {
  64634. return this._options.needAlphaTesting;
  64635. };
  64636. ShaderMaterial.prototype._checkUniform = function (uniformName) {
  64637. if (this._options.uniforms.indexOf(uniformName) === -1) {
  64638. this._options.uniforms.push(uniformName);
  64639. }
  64640. };
  64641. /**
  64642. * Set a texture in the shader.
  64643. * @param name Define the name of the uniform samplers as defined in the shader
  64644. * @param texture Define the texture to bind to this sampler
  64645. * @return the material itself allowing "fluent" like uniform updates
  64646. */
  64647. ShaderMaterial.prototype.setTexture = function (name, texture) {
  64648. if (this._options.samplers.indexOf(name) === -1) {
  64649. this._options.samplers.push(name);
  64650. }
  64651. this._textures[name] = texture;
  64652. return this;
  64653. };
  64654. /**
  64655. * Set a texture array in the shader.
  64656. * @param name Define the name of the uniform sampler array as defined in the shader
  64657. * @param textures Define the list of textures to bind to this sampler
  64658. * @return the material itself allowing "fluent" like uniform updates
  64659. */
  64660. ShaderMaterial.prototype.setTextureArray = function (name, textures) {
  64661. if (this._options.samplers.indexOf(name) === -1) {
  64662. this._options.samplers.push(name);
  64663. }
  64664. this._checkUniform(name);
  64665. this._textureArrays[name] = textures;
  64666. return this;
  64667. };
  64668. /**
  64669. * Set a float in the shader.
  64670. * @param name Define the name of the uniform as defined in the shader
  64671. * @param value Define the value to give to the uniform
  64672. * @return the material itself allowing "fluent" like uniform updates
  64673. */
  64674. ShaderMaterial.prototype.setFloat = function (name, value) {
  64675. this._checkUniform(name);
  64676. this._floats[name] = value;
  64677. return this;
  64678. };
  64679. /**
  64680. * Set a int in the shader.
  64681. * @param name Define the name of the uniform as defined in the shader
  64682. * @param value Define the value to give to the uniform
  64683. * @return the material itself allowing "fluent" like uniform updates
  64684. */
  64685. ShaderMaterial.prototype.setInt = function (name, value) {
  64686. this._checkUniform(name);
  64687. this._ints[name] = value;
  64688. return this;
  64689. };
  64690. /**
  64691. * Set an array of floats in the shader.
  64692. * @param name Define the name of the uniform as defined in the shader
  64693. * @param value Define the value to give to the uniform
  64694. * @return the material itself allowing "fluent" like uniform updates
  64695. */
  64696. ShaderMaterial.prototype.setFloats = function (name, value) {
  64697. this._checkUniform(name);
  64698. this._floatsArrays[name] = value;
  64699. return this;
  64700. };
  64701. /**
  64702. * Set a vec3 in the shader from a Color3.
  64703. * @param name Define the name of the uniform as defined in the shader
  64704. * @param value Define the value to give to the uniform
  64705. * @return the material itself allowing "fluent" like uniform updates
  64706. */
  64707. ShaderMaterial.prototype.setColor3 = function (name, value) {
  64708. this._checkUniform(name);
  64709. this._colors3[name] = value;
  64710. return this;
  64711. };
  64712. /**
  64713. * Set a vec3 array in the shader from a Color3 array.
  64714. * @param name Define the name of the uniform as defined in the shader
  64715. * @param value Define the value to give to the uniform
  64716. * @return the material itself allowing "fluent" like uniform updates
  64717. */
  64718. ShaderMaterial.prototype.setColor3Array = function (name, value) {
  64719. this._checkUniform(name);
  64720. this._colors3Arrays[name] = value.reduce(function (arr, color) {
  64721. color.toArray(arr, arr.length);
  64722. return arr;
  64723. }, []);
  64724. return this;
  64725. };
  64726. /**
  64727. * Set a vec4 in the shader from a Color4.
  64728. * @param name Define the name of the uniform as defined in the shader
  64729. * @param value Define the value to give to the uniform
  64730. * @return the material itself allowing "fluent" like uniform updates
  64731. */
  64732. ShaderMaterial.prototype.setColor4 = function (name, value) {
  64733. this._checkUniform(name);
  64734. this._colors4[name] = value;
  64735. return this;
  64736. };
  64737. /**
  64738. * Set a vec2 in the shader from a Vector2.
  64739. * @param name Define the name of the uniform as defined in the shader
  64740. * @param value Define the value to give to the uniform
  64741. * @return the material itself allowing "fluent" like uniform updates
  64742. */
  64743. ShaderMaterial.prototype.setVector2 = function (name, value) {
  64744. this._checkUniform(name);
  64745. this._vectors2[name] = value;
  64746. return this;
  64747. };
  64748. /**
  64749. * Set a vec3 in the shader from a Vector3.
  64750. * @param name Define the name of the uniform as defined in the shader
  64751. * @param value Define the value to give to the uniform
  64752. * @return the material itself allowing "fluent" like uniform updates
  64753. */
  64754. ShaderMaterial.prototype.setVector3 = function (name, value) {
  64755. this._checkUniform(name);
  64756. this._vectors3[name] = value;
  64757. return this;
  64758. };
  64759. /**
  64760. * Set a vec4 in the shader from a Vector4.
  64761. * @param name Define the name of the uniform as defined in the shader
  64762. * @param value Define the value to give to the uniform
  64763. * @return the material itself allowing "fluent" like uniform updates
  64764. */
  64765. ShaderMaterial.prototype.setVector4 = function (name, value) {
  64766. this._checkUniform(name);
  64767. this._vectors4[name] = value;
  64768. return this;
  64769. };
  64770. /**
  64771. * Set a mat4 in the shader from a Matrix.
  64772. * @param name Define the name of the uniform as defined in the shader
  64773. * @param value Define the value to give to the uniform
  64774. * @return the material itself allowing "fluent" like uniform updates
  64775. */
  64776. ShaderMaterial.prototype.setMatrix = function (name, value) {
  64777. this._checkUniform(name);
  64778. this._matrices[name] = value;
  64779. return this;
  64780. };
  64781. /**
  64782. * Set a mat3 in the shader from a Float32Array.
  64783. * @param name Define the name of the uniform as defined in the shader
  64784. * @param value Define the value to give to the uniform
  64785. * @return the material itself allowing "fluent" like uniform updates
  64786. */
  64787. ShaderMaterial.prototype.setMatrix3x3 = function (name, value) {
  64788. this._checkUniform(name);
  64789. this._matrices3x3[name] = value;
  64790. return this;
  64791. };
  64792. /**
  64793. * Set a mat2 in the shader from a Float32Array.
  64794. * @param name Define the name of the uniform as defined in the shader
  64795. * @param value Define the value to give to the uniform
  64796. * @return the material itself allowing "fluent" like uniform updates
  64797. */
  64798. ShaderMaterial.prototype.setMatrix2x2 = function (name, value) {
  64799. this._checkUniform(name);
  64800. this._matrices2x2[name] = value;
  64801. return this;
  64802. };
  64803. /**
  64804. * Set a vec2 array in the shader from a number array.
  64805. * @param name Define the name of the uniform as defined in the shader
  64806. * @param value Define the value to give to the uniform
  64807. * @return the material itself allowing "fluent" like uniform updates
  64808. */
  64809. ShaderMaterial.prototype.setArray2 = function (name, value) {
  64810. this._checkUniform(name);
  64811. this._vectors2Arrays[name] = value;
  64812. return this;
  64813. };
  64814. /**
  64815. * Set a vec3 array in the shader from a number array.
  64816. * @param name Define the name of the uniform as defined in the shader
  64817. * @param value Define the value to give to the uniform
  64818. * @return the material itself allowing "fluent" like uniform updates
  64819. */
  64820. ShaderMaterial.prototype.setArray3 = function (name, value) {
  64821. this._checkUniform(name);
  64822. this._vectors3Arrays[name] = value;
  64823. return this;
  64824. };
  64825. ShaderMaterial.prototype._checkCache = function (mesh, useInstances) {
  64826. if (!mesh) {
  64827. return true;
  64828. }
  64829. if (this._effect && (this._effect.defines.indexOf("#define INSTANCES") !== -1) !== useInstances) {
  64830. return false;
  64831. }
  64832. return false;
  64833. };
  64834. /**
  64835. * Checks if the material is ready to render the requested mesh
  64836. * @param mesh Define the mesh to render
  64837. * @param useInstances Define whether or not the material is used with instances
  64838. * @returns true if ready, otherwise false
  64839. */
  64840. ShaderMaterial.prototype.isReady = function (mesh, useInstances) {
  64841. var scene = this.getScene();
  64842. var engine = scene.getEngine();
  64843. if (!this.checkReadyOnEveryCall) {
  64844. if (this._renderId === scene.getRenderId()) {
  64845. if (this._checkCache(mesh, useInstances)) {
  64846. return true;
  64847. }
  64848. }
  64849. }
  64850. // Instances
  64851. var defines = [];
  64852. var attribs = [];
  64853. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  64854. for (var index = 0; index < this._options.defines.length; index++) {
  64855. defines.push(this._options.defines[index]);
  64856. }
  64857. for (var index = 0; index < this._options.attributes.length; index++) {
  64858. attribs.push(this._options.attributes[index]);
  64859. }
  64860. if (mesh && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  64861. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  64862. defines.push("#define VERTEXCOLOR");
  64863. }
  64864. if (useInstances) {
  64865. defines.push("#define INSTANCES");
  64866. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  64867. }
  64868. // Bones
  64869. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  64870. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  64871. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  64872. if (mesh.numBoneInfluencers > 4) {
  64873. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  64874. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  64875. }
  64876. var skeleton = mesh.skeleton;
  64877. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  64878. fallbacks.addCPUSkinningFallback(0, mesh);
  64879. if (skeleton.isUsingTextureForMatrices) {
  64880. defines.push("#define BONETEXTURE");
  64881. if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
  64882. this._options.uniforms.push("boneTextureWidth");
  64883. }
  64884. if (this._options.samplers.indexOf("boneSampler") === -1) {
  64885. this._options.samplers.push("boneSampler");
  64886. }
  64887. }
  64888. else {
  64889. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  64890. if (this._options.uniforms.indexOf("mBones") === -1) {
  64891. this._options.uniforms.push("mBones");
  64892. }
  64893. }
  64894. }
  64895. else {
  64896. defines.push("#define NUM_BONE_INFLUENCERS 0");
  64897. }
  64898. // Textures
  64899. for (var name in this._textures) {
  64900. if (!this._textures[name].isReady()) {
  64901. return false;
  64902. }
  64903. }
  64904. // Alpha test
  64905. if (mesh && this._shouldTurnAlphaTestOn(mesh)) {
  64906. defines.push("#define ALPHATEST");
  64907. }
  64908. var previousEffect = this._effect;
  64909. var join = defines.join("\n");
  64910. this._effect = engine.createEffect(this._shaderPath, {
  64911. attributes: attribs,
  64912. uniformsNames: this._options.uniforms,
  64913. uniformBuffersNames: this._options.uniformBuffers,
  64914. samplers: this._options.samplers,
  64915. defines: join,
  64916. fallbacks: fallbacks,
  64917. onCompiled: this.onCompiled,
  64918. onError: this.onError
  64919. }, engine);
  64920. if (!this._effect.isReady()) {
  64921. return false;
  64922. }
  64923. if (previousEffect !== this._effect) {
  64924. scene.resetCachedMaterial();
  64925. }
  64926. this._renderId = scene.getRenderId();
  64927. return true;
  64928. };
  64929. /**
  64930. * Binds the world matrix to the material
  64931. * @param world defines the world transformation matrix
  64932. */
  64933. ShaderMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  64934. var scene = this.getScene();
  64935. if (!this._effect) {
  64936. return;
  64937. }
  64938. if (this._options.uniforms.indexOf("world") !== -1) {
  64939. this._effect.setMatrix("world", world);
  64940. }
  64941. if (this._options.uniforms.indexOf("worldView") !== -1) {
  64942. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  64943. this._effect.setMatrix("worldView", this._cachedWorldViewMatrix);
  64944. }
  64945. if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
  64946. this._effect.setMatrix("worldViewProjection", world.multiply(scene.getTransformMatrix()));
  64947. }
  64948. };
  64949. /**
  64950. * Binds the material to the mesh
  64951. * @param world defines the world transformation matrix
  64952. * @param mesh defines the mesh to bind the material to
  64953. */
  64954. ShaderMaterial.prototype.bind = function (world, mesh) {
  64955. // Std values
  64956. this.bindOnlyWorldMatrix(world);
  64957. if (this._effect && this.getScene().getCachedMaterial() !== this) {
  64958. if (this._options.uniforms.indexOf("view") !== -1) {
  64959. this._effect.setMatrix("view", this.getScene().getViewMatrix());
  64960. }
  64961. if (this._options.uniforms.indexOf("projection") !== -1) {
  64962. this._effect.setMatrix("projection", this.getScene().getProjectionMatrix());
  64963. }
  64964. if (this._options.uniforms.indexOf("viewProjection") !== -1) {
  64965. this._effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  64966. }
  64967. // Bones
  64968. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, this._effect);
  64969. var name;
  64970. // Texture
  64971. for (name in this._textures) {
  64972. this._effect.setTexture(name, this._textures[name]);
  64973. }
  64974. // Texture arrays
  64975. for (name in this._textureArrays) {
  64976. this._effect.setTextureArray(name, this._textureArrays[name]);
  64977. }
  64978. // Int
  64979. for (name in this._ints) {
  64980. this._effect.setInt(name, this._ints[name]);
  64981. }
  64982. // Float
  64983. for (name in this._floats) {
  64984. this._effect.setFloat(name, this._floats[name]);
  64985. }
  64986. // Floats
  64987. for (name in this._floatsArrays) {
  64988. this._effect.setArray(name, this._floatsArrays[name]);
  64989. }
  64990. // Color3
  64991. for (name in this._colors3) {
  64992. this._effect.setColor3(name, this._colors3[name]);
  64993. }
  64994. for (name in this._colors3Arrays) {
  64995. this._effect.setArray3(name, this._colors3Arrays[name]);
  64996. }
  64997. // Color4
  64998. for (name in this._colors4) {
  64999. var color = this._colors4[name];
  65000. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  65001. }
  65002. // Vector2
  65003. for (name in this._vectors2) {
  65004. this._effect.setVector2(name, this._vectors2[name]);
  65005. }
  65006. // Vector3
  65007. for (name in this._vectors3) {
  65008. this._effect.setVector3(name, this._vectors3[name]);
  65009. }
  65010. // Vector4
  65011. for (name in this._vectors4) {
  65012. this._effect.setVector4(name, this._vectors4[name]);
  65013. }
  65014. // Matrix
  65015. for (name in this._matrices) {
  65016. this._effect.setMatrix(name, this._matrices[name]);
  65017. }
  65018. // Matrix 3x3
  65019. for (name in this._matrices3x3) {
  65020. this._effect.setMatrix3x3(name, this._matrices3x3[name]);
  65021. }
  65022. // Matrix 2x2
  65023. for (name in this._matrices2x2) {
  65024. this._effect.setMatrix2x2(name, this._matrices2x2[name]);
  65025. }
  65026. // Vector2Array
  65027. for (name in this._vectors2Arrays) {
  65028. this._effect.setArray2(name, this._vectors2Arrays[name]);
  65029. }
  65030. // Vector3Array
  65031. for (name in this._vectors3Arrays) {
  65032. this._effect.setArray3(name, this._vectors3Arrays[name]);
  65033. }
  65034. }
  65035. this._afterBind(mesh);
  65036. };
  65037. /**
  65038. * Gets the active textures from the material
  65039. * @returns an array of textures
  65040. */
  65041. ShaderMaterial.prototype.getActiveTextures = function () {
  65042. var activeTextures = _super.prototype.getActiveTextures.call(this);
  65043. for (var name in this._textures) {
  65044. activeTextures.push(this._textures[name]);
  65045. }
  65046. for (var name in this._textureArrays) {
  65047. var array = this._textureArrays[name];
  65048. for (var index = 0; index < array.length; index++) {
  65049. activeTextures.push(array[index]);
  65050. }
  65051. }
  65052. return activeTextures;
  65053. };
  65054. /**
  65055. * Specifies if the material uses a texture
  65056. * @param texture defines the texture to check against the material
  65057. * @returns a boolean specifying if the material uses the texture
  65058. */
  65059. ShaderMaterial.prototype.hasTexture = function (texture) {
  65060. if (_super.prototype.hasTexture.call(this, texture)) {
  65061. return true;
  65062. }
  65063. for (var name in this._textures) {
  65064. if (this._textures[name] === texture) {
  65065. return true;
  65066. }
  65067. }
  65068. for (var name in this._textureArrays) {
  65069. var array = this._textureArrays[name];
  65070. for (var index = 0; index < array.length; index++) {
  65071. if (array[index] === texture) {
  65072. return true;
  65073. }
  65074. }
  65075. }
  65076. return false;
  65077. };
  65078. /**
  65079. * Makes a duplicate of the material, and gives it a new name
  65080. * @param name defines the new name for the duplicated material
  65081. * @returns the cloned material
  65082. */
  65083. ShaderMaterial.prototype.clone = function (name) {
  65084. var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
  65085. return newShaderMaterial;
  65086. };
  65087. /**
  65088. * Disposes the material
  65089. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  65090. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  65091. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  65092. */
  65093. ShaderMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  65094. if (forceDisposeTextures) {
  65095. var name;
  65096. for (name in this._textures) {
  65097. this._textures[name].dispose();
  65098. }
  65099. for (name in this._textureArrays) {
  65100. var array = this._textureArrays[name];
  65101. for (var index = 0; index < array.length; index++) {
  65102. array[index].dispose();
  65103. }
  65104. }
  65105. }
  65106. this._textures = {};
  65107. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  65108. };
  65109. /**
  65110. * Serializes this material in a JSON representation
  65111. * @returns the serialized material object
  65112. */
  65113. ShaderMaterial.prototype.serialize = function () {
  65114. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  65115. serializationObject.customType = "ShaderMaterial";
  65116. serializationObject.options = this._options;
  65117. serializationObject.shaderPath = this._shaderPath;
  65118. var name;
  65119. // Texture
  65120. serializationObject.textures = {};
  65121. for (name in this._textures) {
  65122. serializationObject.textures[name] = this._textures[name].serialize();
  65123. }
  65124. // Texture arrays
  65125. serializationObject.textureArrays = {};
  65126. for (name in this._textureArrays) {
  65127. serializationObject.textureArrays[name] = [];
  65128. var array = this._textureArrays[name];
  65129. for (var index = 0; index < array.length; index++) {
  65130. serializationObject.textureArrays[name].push(array[index].serialize());
  65131. }
  65132. }
  65133. // Float
  65134. serializationObject.floats = {};
  65135. for (name in this._floats) {
  65136. serializationObject.floats[name] = this._floats[name];
  65137. }
  65138. // Float s
  65139. serializationObject.FloatArrays = {};
  65140. for (name in this._floatsArrays) {
  65141. serializationObject.FloatArrays[name] = this._floatsArrays[name];
  65142. }
  65143. // Color3
  65144. serializationObject.colors3 = {};
  65145. for (name in this._colors3) {
  65146. serializationObject.colors3[name] = this._colors3[name].asArray();
  65147. }
  65148. // Color3 array
  65149. serializationObject.colors3Arrays = {};
  65150. for (name in this._colors3Arrays) {
  65151. serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
  65152. }
  65153. // Color4
  65154. serializationObject.colors4 = {};
  65155. for (name in this._colors4) {
  65156. serializationObject.colors4[name] = this._colors4[name].asArray();
  65157. }
  65158. // Vector2
  65159. serializationObject.vectors2 = {};
  65160. for (name in this._vectors2) {
  65161. serializationObject.vectors2[name] = this._vectors2[name].asArray();
  65162. }
  65163. // Vector3
  65164. serializationObject.vectors3 = {};
  65165. for (name in this._vectors3) {
  65166. serializationObject.vectors3[name] = this._vectors3[name].asArray();
  65167. }
  65168. // Vector4
  65169. serializationObject.vectors4 = {};
  65170. for (name in this._vectors4) {
  65171. serializationObject.vectors4[name] = this._vectors4[name].asArray();
  65172. }
  65173. // Matrix
  65174. serializationObject.matrices = {};
  65175. for (name in this._matrices) {
  65176. serializationObject.matrices[name] = this._matrices[name].asArray();
  65177. }
  65178. // Matrix 3x3
  65179. serializationObject.matrices3x3 = {};
  65180. for (name in this._matrices3x3) {
  65181. serializationObject.matrices3x3[name] = this._matrices3x3[name];
  65182. }
  65183. // Matrix 2x2
  65184. serializationObject.matrices2x2 = {};
  65185. for (name in this._matrices2x2) {
  65186. serializationObject.matrices2x2[name] = this._matrices2x2[name];
  65187. }
  65188. // Vector2Array
  65189. serializationObject.vectors2Arrays = {};
  65190. for (name in this._vectors2Arrays) {
  65191. serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
  65192. }
  65193. // Vector3Array
  65194. serializationObject.vectors3Arrays = {};
  65195. for (name in this._vectors3Arrays) {
  65196. serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
  65197. }
  65198. return serializationObject;
  65199. };
  65200. /**
  65201. * Creates a shader material from parsed shader material data
  65202. * @param source defines the JSON represnetation of the material
  65203. * @param scene defines the hosting scene
  65204. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65205. * @returns a new material
  65206. */
  65207. ShaderMaterial.Parse = function (source, scene, rootUrl) {
  65208. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShaderMaterial(source.name, scene, source.shaderPath, source.options); }, source, scene, rootUrl);
  65209. var name;
  65210. // Texture
  65211. for (name in source.textures) {
  65212. material.setTexture(name, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(source.textures[name], scene, rootUrl));
  65213. }
  65214. // Texture arrays
  65215. for (name in source.textureArrays) {
  65216. var array = source.textureArrays[name];
  65217. var textureArray = new Array();
  65218. for (var index = 0; index < array.length; index++) {
  65219. textureArray.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(array[index], scene, rootUrl));
  65220. }
  65221. material.setTextureArray(name, textureArray);
  65222. }
  65223. // Float
  65224. for (name in source.floats) {
  65225. material.setFloat(name, source.floats[name]);
  65226. }
  65227. // Float s
  65228. for (name in source.floatsArrays) {
  65229. material.setFloats(name, source.floatsArrays[name]);
  65230. }
  65231. // Color3
  65232. for (name in source.colors3) {
  65233. material.setColor3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(source.colors3[name]));
  65234. }
  65235. // Color3 arrays
  65236. for (name in source.colors3Arrays) {
  65237. var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
  65238. if (i % 3 === 0) {
  65239. arr.push([num]);
  65240. }
  65241. else {
  65242. arr[arr.length - 1].push(num);
  65243. }
  65244. return arr;
  65245. }, []).map(function (color) { return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(color); });
  65246. material.setColor3Array(name, colors);
  65247. }
  65248. // Color4
  65249. for (name in source.colors4) {
  65250. material.setColor4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(source.colors4[name]));
  65251. }
  65252. // Vector2
  65253. for (name in source.vectors2) {
  65254. material.setVector2(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"].FromArray(source.vectors2[name]));
  65255. }
  65256. // Vector3
  65257. for (name in source.vectors3) {
  65258. material.setVector3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(source.vectors3[name]));
  65259. }
  65260. // Vector4
  65261. for (name in source.vectors4) {
  65262. material.setVector4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector4"].FromArray(source.vectors4[name]));
  65263. }
  65264. // Matrix
  65265. for (name in source.matrices) {
  65266. material.setMatrix(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(source.matrices[name]));
  65267. }
  65268. // Matrix 3x3
  65269. for (name in source.matrices3x3) {
  65270. material.setMatrix3x3(name, source.matrices3x3[name]);
  65271. }
  65272. // Matrix 2x2
  65273. for (name in source.matrices2x2) {
  65274. material.setMatrix2x2(name, source.matrices2x2[name]);
  65275. }
  65276. // Vector2Array
  65277. for (name in source.vectors2Arrays) {
  65278. material.setArray2(name, source.vectors2Arrays[name]);
  65279. }
  65280. // Vector3Array
  65281. for (name in source.vectors3Arrays) {
  65282. material.setArray3(name, source.vectors3Arrays[name]);
  65283. }
  65284. return material;
  65285. };
  65286. return ShaderMaterial;
  65287. }(_material__WEBPACK_IMPORTED_MODULE_7__["Material"]));
  65288. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.ShaderMaterial"] = ShaderMaterial;
  65289. /***/ }),
  65290. /***/ "./Materials/standardMaterial.ts":
  65291. /*!***************************************!*\
  65292. !*** ./Materials/standardMaterial.ts ***!
  65293. \***************************************/
  65294. /*! exports provided: StandardMaterialDefines, StandardMaterial */
  65295. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65296. "use strict";
  65297. __webpack_require__.r(__webpack_exports__);
  65298. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return StandardMaterialDefines; });
  65299. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return StandardMaterial; });
  65300. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  65301. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  65302. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  65303. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  65304. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  65305. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  65306. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  65307. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  65308. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  65309. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  65310. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  65311. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  65312. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  65313. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  65314. /* harmony import */ var _Shaders_default_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/default.fragment */ "./Shaders/default.fragment.ts");
  65315. /* harmony import */ var _Shaders_default_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/default.vertex */ "./Shaders/default.vertex.ts");
  65316. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  65317. /** @hidden */
  65318. var StandardMaterialDefines = /** @class */ (function (_super) {
  65319. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterialDefines, _super);
  65320. function StandardMaterialDefines() {
  65321. var _this = _super.call(this) || this;
  65322. _this.MAINUV1 = false;
  65323. _this.MAINUV2 = false;
  65324. _this.DIFFUSE = false;
  65325. _this.DIFFUSEDIRECTUV = 0;
  65326. _this.AMBIENT = false;
  65327. _this.AMBIENTDIRECTUV = 0;
  65328. _this.OPACITY = false;
  65329. _this.OPACITYDIRECTUV = 0;
  65330. _this.OPACITYRGB = false;
  65331. _this.REFLECTION = false;
  65332. _this.EMISSIVE = false;
  65333. _this.EMISSIVEDIRECTUV = 0;
  65334. _this.SPECULAR = false;
  65335. _this.SPECULARDIRECTUV = 0;
  65336. _this.BUMP = false;
  65337. _this.BUMPDIRECTUV = 0;
  65338. _this.PARALLAX = false;
  65339. _this.PARALLAXOCCLUSION = false;
  65340. _this.SPECULAROVERALPHA = false;
  65341. _this.CLIPPLANE = false;
  65342. _this.CLIPPLANE2 = false;
  65343. _this.CLIPPLANE3 = false;
  65344. _this.CLIPPLANE4 = false;
  65345. _this.ALPHATEST = false;
  65346. _this.DEPTHPREPASS = false;
  65347. _this.ALPHAFROMDIFFUSE = false;
  65348. _this.POINTSIZE = false;
  65349. _this.FOG = false;
  65350. _this.SPECULARTERM = false;
  65351. _this.DIFFUSEFRESNEL = false;
  65352. _this.OPACITYFRESNEL = false;
  65353. _this.REFLECTIONFRESNEL = false;
  65354. _this.REFRACTIONFRESNEL = false;
  65355. _this.EMISSIVEFRESNEL = false;
  65356. _this.FRESNEL = false;
  65357. _this.NORMAL = false;
  65358. _this.UV1 = false;
  65359. _this.UV2 = false;
  65360. _this.VERTEXCOLOR = false;
  65361. _this.VERTEXALPHA = false;
  65362. _this.NUM_BONE_INFLUENCERS = 0;
  65363. _this.BonesPerMesh = 0;
  65364. _this.BONETEXTURE = false;
  65365. _this.INSTANCES = false;
  65366. _this.GLOSSINESS = false;
  65367. _this.ROUGHNESS = false;
  65368. _this.EMISSIVEASILLUMINATION = false;
  65369. _this.LINKEMISSIVEWITHDIFFUSE = false;
  65370. _this.REFLECTIONFRESNELFROMSPECULAR = false;
  65371. _this.LIGHTMAP = false;
  65372. _this.LIGHTMAPDIRECTUV = 0;
  65373. _this.OBJECTSPACE_NORMALMAP = false;
  65374. _this.USELIGHTMAPASSHADOWMAP = false;
  65375. _this.REFLECTIONMAP_3D = false;
  65376. _this.REFLECTIONMAP_SPHERICAL = false;
  65377. _this.REFLECTIONMAP_PLANAR = false;
  65378. _this.REFLECTIONMAP_CUBIC = false;
  65379. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  65380. _this.REFLECTIONMAP_PROJECTION = false;
  65381. _this.REFLECTIONMAP_SKYBOX = false;
  65382. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  65383. _this.REFLECTIONMAP_EXPLICIT = false;
  65384. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  65385. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  65386. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  65387. _this.INVERTCUBICMAP = false;
  65388. _this.LOGARITHMICDEPTH = false;
  65389. _this.REFRACTION = false;
  65390. _this.REFRACTIONMAP_3D = false;
  65391. _this.REFLECTIONOVERALPHA = false;
  65392. _this.TWOSIDEDLIGHTING = false;
  65393. _this.SHADOWFLOAT = false;
  65394. _this.MORPHTARGETS = false;
  65395. _this.MORPHTARGETS_NORMAL = false;
  65396. _this.MORPHTARGETS_TANGENT = false;
  65397. _this.NUM_MORPH_INFLUENCERS = 0;
  65398. _this.NONUNIFORMSCALING = false; // https://playground.babylonjs.com#V6DWIH
  65399. _this.PREMULTIPLYALPHA = false; // https://playground.babylonjs.com#LNVJJ7
  65400. _this.IMAGEPROCESSING = false;
  65401. _this.VIGNETTE = false;
  65402. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  65403. _this.VIGNETTEBLENDMODEOPAQUE = false;
  65404. _this.TONEMAPPING = false;
  65405. _this.TONEMAPPING_ACES = false;
  65406. _this.CONTRAST = false;
  65407. _this.COLORCURVES = false;
  65408. _this.COLORGRADING = false;
  65409. _this.COLORGRADING3D = false;
  65410. _this.SAMPLER3DGREENDEPTH = false;
  65411. _this.SAMPLER3DBGRMAP = false;
  65412. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  65413. /**
  65414. * If the reflection texture on this material is in linear color space
  65415. * @hidden
  65416. */
  65417. _this.IS_REFLECTION_LINEAR = false;
  65418. /**
  65419. * If the refraction texture on this material is in linear color space
  65420. * @hidden
  65421. */
  65422. _this.IS_REFRACTION_LINEAR = false;
  65423. _this.EXPOSURE = false;
  65424. _this.rebuild();
  65425. return _this;
  65426. }
  65427. StandardMaterialDefines.prototype.setReflectionMode = function (modeToEnable) {
  65428. var modes = [
  65429. "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
  65430. "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
  65431. "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
  65432. "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
  65433. ];
  65434. for (var _i = 0, modes_1 = modes; _i < modes_1.length; _i++) {
  65435. var mode = modes_1[_i];
  65436. this[mode] = (mode === modeToEnable);
  65437. }
  65438. };
  65439. return StandardMaterialDefines;
  65440. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  65441. /**
  65442. * This is the default material used in Babylon. It is the best trade off between quality
  65443. * and performances.
  65444. * @see http://doc.babylonjs.com/babylon101/materials
  65445. */
  65446. var StandardMaterial = /** @class */ (function (_super) {
  65447. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterial, _super);
  65448. /**
  65449. * Instantiates a new standard material.
  65450. * This is the default material used in Babylon. It is the best trade off between quality
  65451. * and performances.
  65452. * @see http://doc.babylonjs.com/babylon101/materials
  65453. * @param name Define the name of the material in the scene
  65454. * @param scene Define the scene the material belong to
  65455. */
  65456. function StandardMaterial(name, scene) {
  65457. var _this = _super.call(this, name, scene) || this;
  65458. /**
  65459. * The color of the material lit by the environmental background lighting.
  65460. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  65461. */
  65462. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  65463. /**
  65464. * The basic color of the material as viewed under a light.
  65465. */
  65466. _this.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  65467. /**
  65468. * Define how the color and intensity of the highlight given by the light in the material.
  65469. */
  65470. _this.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  65471. /**
  65472. * Define the color of the material as if self lit.
  65473. * This will be mixed in the final result even in the absence of light.
  65474. */
  65475. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  65476. /**
  65477. * Defines how sharp are the highlights in the material.
  65478. * The bigger the value the sharper giving a more glossy feeling to the result.
  65479. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  65480. */
  65481. _this.specularPower = 64;
  65482. _this._useAlphaFromDiffuseTexture = false;
  65483. _this._useEmissiveAsIllumination = false;
  65484. _this._linkEmissiveWithDiffuse = false;
  65485. _this._useSpecularOverAlpha = false;
  65486. _this._useReflectionOverAlpha = false;
  65487. _this._disableLighting = false;
  65488. _this._useObjectSpaceNormalMap = false;
  65489. _this._useParallax = false;
  65490. _this._useParallaxOcclusion = false;
  65491. /**
  65492. * 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.
  65493. */
  65494. _this.parallaxScaleBias = 0.05;
  65495. _this._roughness = 0;
  65496. /**
  65497. * In case of refraction, define the value of the indice of refraction.
  65498. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  65499. */
  65500. _this.indexOfRefraction = 0.98;
  65501. /**
  65502. * Invert the refraction texture alongside the y axis.
  65503. * It can be useful with procedural textures or probe for instance.
  65504. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  65505. */
  65506. _this.invertRefractionY = true;
  65507. /**
  65508. * Defines the alpha limits in alpha test mode.
  65509. */
  65510. _this.alphaCutOff = 0.4;
  65511. _this._useLightmapAsShadowmap = false;
  65512. _this._useReflectionFresnelFromSpecular = false;
  65513. _this._useGlossinessFromSpecularMapAlpha = false;
  65514. _this._maxSimultaneousLights = 4;
  65515. _this._invertNormalMapX = false;
  65516. _this._invertNormalMapY = false;
  65517. _this._twoSidedLighting = false;
  65518. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  65519. _this._worldViewProjectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  65520. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  65521. // Setup the default processing configuration to the scene.
  65522. _this._attachImageProcessingConfiguration(null);
  65523. _this.getRenderTargetTextures = function () {
  65524. _this._renderTargets.reset();
  65525. if (StandardMaterial.ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  65526. _this._renderTargets.push(_this._reflectionTexture);
  65527. }
  65528. if (StandardMaterial.RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  65529. _this._renderTargets.push(_this._refractionTexture);
  65530. }
  65531. return _this._renderTargets;
  65532. };
  65533. return _this;
  65534. }
  65535. Object.defineProperty(StandardMaterial.prototype, "imageProcessingConfiguration", {
  65536. /**
  65537. * Gets the image processing configuration used either in this material.
  65538. */
  65539. get: function () {
  65540. return this._imageProcessingConfiguration;
  65541. },
  65542. /**
  65543. * Sets the Default image processing configuration used either in the this material.
  65544. *
  65545. * If sets to null, the scene one is in use.
  65546. */
  65547. set: function (value) {
  65548. this._attachImageProcessingConfiguration(value);
  65549. // Ensure the effect will be rebuilt.
  65550. this._markAllSubMeshesAsTexturesDirty();
  65551. },
  65552. enumerable: true,
  65553. configurable: true
  65554. });
  65555. /**
  65556. * Attaches a new image processing configuration to the Standard Material.
  65557. * @param configuration
  65558. */
  65559. StandardMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  65560. var _this = this;
  65561. if (configuration === this._imageProcessingConfiguration) {
  65562. return;
  65563. }
  65564. // Detaches observer.
  65565. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  65566. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  65567. }
  65568. // Pick the scene configuration if needed.
  65569. if (!configuration) {
  65570. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  65571. }
  65572. else {
  65573. this._imageProcessingConfiguration = configuration;
  65574. }
  65575. // Attaches observer.
  65576. if (this._imageProcessingConfiguration) {
  65577. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  65578. _this._markAllSubMeshesAsImageProcessingDirty();
  65579. });
  65580. }
  65581. };
  65582. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurvesEnabled", {
  65583. /**
  65584. * Gets wether the color curves effect is enabled.
  65585. */
  65586. get: function () {
  65587. return this.imageProcessingConfiguration.colorCurvesEnabled;
  65588. },
  65589. /**
  65590. * Sets wether the color curves effect is enabled.
  65591. */
  65592. set: function (value) {
  65593. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  65594. },
  65595. enumerable: true,
  65596. configurable: true
  65597. });
  65598. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingEnabled", {
  65599. /**
  65600. * Gets wether the color grading effect is enabled.
  65601. */
  65602. get: function () {
  65603. return this.imageProcessingConfiguration.colorGradingEnabled;
  65604. },
  65605. /**
  65606. * Gets wether the color grading effect is enabled.
  65607. */
  65608. set: function (value) {
  65609. this.imageProcessingConfiguration.colorGradingEnabled = value;
  65610. },
  65611. enumerable: true,
  65612. configurable: true
  65613. });
  65614. Object.defineProperty(StandardMaterial.prototype, "cameraToneMappingEnabled", {
  65615. /**
  65616. * Gets wether tonemapping is enabled or not.
  65617. */
  65618. get: function () {
  65619. return this._imageProcessingConfiguration.toneMappingEnabled;
  65620. },
  65621. /**
  65622. * Sets wether tonemapping is enabled or not
  65623. */
  65624. set: function (value) {
  65625. this._imageProcessingConfiguration.toneMappingEnabled = value;
  65626. },
  65627. enumerable: true,
  65628. configurable: true
  65629. });
  65630. Object.defineProperty(StandardMaterial.prototype, "cameraExposure", {
  65631. /**
  65632. * The camera exposure used on this material.
  65633. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  65634. * This corresponds to a photographic exposure.
  65635. */
  65636. get: function () {
  65637. return this._imageProcessingConfiguration.exposure;
  65638. },
  65639. /**
  65640. * The camera exposure used on this material.
  65641. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  65642. * This corresponds to a photographic exposure.
  65643. */
  65644. set: function (value) {
  65645. this._imageProcessingConfiguration.exposure = value;
  65646. },
  65647. enumerable: true,
  65648. configurable: true
  65649. });
  65650. Object.defineProperty(StandardMaterial.prototype, "cameraContrast", {
  65651. /**
  65652. * Gets The camera contrast used on this material.
  65653. */
  65654. get: function () {
  65655. return this._imageProcessingConfiguration.contrast;
  65656. },
  65657. /**
  65658. * Sets The camera contrast used on this material.
  65659. */
  65660. set: function (value) {
  65661. this._imageProcessingConfiguration.contrast = value;
  65662. },
  65663. enumerable: true,
  65664. configurable: true
  65665. });
  65666. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingTexture", {
  65667. /**
  65668. * Gets the Color Grading 2D Lookup Texture.
  65669. */
  65670. get: function () {
  65671. return this._imageProcessingConfiguration.colorGradingTexture;
  65672. },
  65673. /**
  65674. * Sets the Color Grading 2D Lookup Texture.
  65675. */
  65676. set: function (value) {
  65677. this._imageProcessingConfiguration.colorGradingTexture = value;
  65678. },
  65679. enumerable: true,
  65680. configurable: true
  65681. });
  65682. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurves", {
  65683. /**
  65684. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  65685. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  65686. * 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;
  65687. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  65688. */
  65689. get: function () {
  65690. return this._imageProcessingConfiguration.colorCurves;
  65691. },
  65692. /**
  65693. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  65694. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  65695. * 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;
  65696. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  65697. */
  65698. set: function (value) {
  65699. this._imageProcessingConfiguration.colorCurves = value;
  65700. },
  65701. enumerable: true,
  65702. configurable: true
  65703. });
  65704. Object.defineProperty(StandardMaterial.prototype, "hasRenderTargetTextures", {
  65705. /**
  65706. * Gets a boolean indicating that current material needs to register RTT
  65707. */
  65708. get: function () {
  65709. if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  65710. return true;
  65711. }
  65712. if (StandardMaterial.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  65713. return true;
  65714. }
  65715. return false;
  65716. },
  65717. enumerable: true,
  65718. configurable: true
  65719. });
  65720. /**
  65721. * Gets the current class name of the material e.g. "StandardMaterial"
  65722. * Mainly use in serialization.
  65723. * @returns the class name
  65724. */
  65725. StandardMaterial.prototype.getClassName = function () {
  65726. return "StandardMaterial";
  65727. };
  65728. Object.defineProperty(StandardMaterial.prototype, "useLogarithmicDepth", {
  65729. /**
  65730. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  65731. * You can try switching to logarithmic depth.
  65732. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  65733. */
  65734. get: function () {
  65735. return this._useLogarithmicDepth;
  65736. },
  65737. set: function (value) {
  65738. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  65739. this._markAllSubMeshesAsMiscDirty();
  65740. },
  65741. enumerable: true,
  65742. configurable: true
  65743. });
  65744. /**
  65745. * Specifies if the material will require alpha blending
  65746. * @returns a boolean specifying if alpha blending is needed
  65747. */
  65748. StandardMaterial.prototype.needAlphaBlending = function () {
  65749. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
  65750. };
  65751. /**
  65752. * Specifies if this material should be rendered in alpha test mode
  65753. * @returns a boolean specifying if an alpha test is needed.
  65754. */
  65755. StandardMaterial.prototype.needAlphaTesting = function () {
  65756. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
  65757. };
  65758. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  65759. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
  65760. };
  65761. /**
  65762. * Get the texture used for alpha test purpose.
  65763. * @returns the diffuse texture in case of the standard material.
  65764. */
  65765. StandardMaterial.prototype.getAlphaTestTexture = function () {
  65766. return this._diffuseTexture;
  65767. };
  65768. /**
  65769. * Get if the submesh is ready to be used and all its information available.
  65770. * Child classes can use it to update shaders
  65771. * @param mesh defines the mesh to check
  65772. * @param subMesh defines which submesh to check
  65773. * @param useInstances specifies that instances should be used
  65774. * @returns a boolean indicating that the submesh is ready or not
  65775. */
  65776. StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  65777. if (useInstances === void 0) { useInstances = false; }
  65778. if (subMesh.effect && this.isFrozen) {
  65779. if (this._wasPreviouslyReady) {
  65780. return true;
  65781. }
  65782. }
  65783. if (!subMesh._materialDefines) {
  65784. subMesh._materialDefines = new StandardMaterialDefines();
  65785. }
  65786. var scene = this.getScene();
  65787. var defines = subMesh._materialDefines;
  65788. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  65789. if (defines._renderId === scene.getRenderId()) {
  65790. return true;
  65791. }
  65792. }
  65793. var engine = scene.getEngine();
  65794. // Lights
  65795. defines._needNormals = _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  65796. // Textures
  65797. if (defines._areTexturesDirty) {
  65798. defines._needUVs = false;
  65799. defines.MAINUV1 = false;
  65800. defines.MAINUV2 = false;
  65801. if (scene.texturesEnabled) {
  65802. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  65803. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  65804. return false;
  65805. }
  65806. else {
  65807. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  65808. }
  65809. }
  65810. else {
  65811. defines.DIFFUSE = false;
  65812. }
  65813. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  65814. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  65815. return false;
  65816. }
  65817. else {
  65818. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  65819. }
  65820. }
  65821. else {
  65822. defines.AMBIENT = false;
  65823. }
  65824. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  65825. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  65826. return false;
  65827. }
  65828. else {
  65829. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  65830. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  65831. }
  65832. }
  65833. else {
  65834. defines.OPACITY = false;
  65835. }
  65836. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  65837. if (!this._reflectionTexture.isReadyOrNotBlocking()) {
  65838. return false;
  65839. }
  65840. else {
  65841. defines._needNormals = true;
  65842. defines.REFLECTION = true;
  65843. defines.ROUGHNESS = (this._roughness > 0);
  65844. defines.REFLECTIONOVERALPHA = this._useReflectionOverAlpha;
  65845. defines.INVERTCUBICMAP = (this._reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE);
  65846. defines.REFLECTIONMAP_3D = this._reflectionTexture.isCube;
  65847. switch (this._reflectionTexture.coordinatesMode) {
  65848. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  65849. defines.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  65850. break;
  65851. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  65852. defines.setReflectionMode("REFLECTIONMAP_PLANAR");
  65853. break;
  65854. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  65855. defines.setReflectionMode("REFLECTIONMAP_PROJECTION");
  65856. break;
  65857. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  65858. defines.setReflectionMode("REFLECTIONMAP_SKYBOX");
  65859. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !this._reflectionTexture.getReflectionTextureMatrix().isIdentity();
  65860. break;
  65861. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  65862. defines.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  65863. break;
  65864. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  65865. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  65866. break;
  65867. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  65868. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  65869. break;
  65870. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  65871. defines.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  65872. break;
  65873. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  65874. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  65875. default:
  65876. defines.setReflectionMode("REFLECTIONMAP_CUBIC");
  65877. break;
  65878. }
  65879. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = this._reflectionTexture.boundingBoxSize ? true : false;
  65880. }
  65881. }
  65882. else {
  65883. defines.REFLECTION = false;
  65884. }
  65885. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  65886. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  65887. return false;
  65888. }
  65889. else {
  65890. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  65891. }
  65892. }
  65893. else {
  65894. defines.EMISSIVE = false;
  65895. }
  65896. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  65897. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  65898. return false;
  65899. }
  65900. else {
  65901. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  65902. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  65903. }
  65904. }
  65905. else {
  65906. defines.LIGHTMAP = false;
  65907. }
  65908. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  65909. if (!this._specularTexture.isReadyOrNotBlocking()) {
  65910. return false;
  65911. }
  65912. else {
  65913. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._specularTexture, defines, "SPECULAR");
  65914. defines.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  65915. }
  65916. }
  65917. else {
  65918. defines.SPECULAR = false;
  65919. }
  65920. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
  65921. // Bump texure can not be not blocking.
  65922. if (!this._bumpTexture.isReady()) {
  65923. return false;
  65924. }
  65925. else {
  65926. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  65927. defines.PARALLAX = this._useParallax;
  65928. defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  65929. }
  65930. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  65931. }
  65932. else {
  65933. defines.BUMP = false;
  65934. }
  65935. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  65936. if (!this._refractionTexture.isReadyOrNotBlocking()) {
  65937. return false;
  65938. }
  65939. else {
  65940. defines._needUVs = true;
  65941. defines.REFRACTION = true;
  65942. defines.REFRACTIONMAP_3D = this._refractionTexture.isCube;
  65943. }
  65944. }
  65945. else {
  65946. defines.REFRACTION = false;
  65947. }
  65948. defines.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
  65949. }
  65950. else {
  65951. defines.DIFFUSE = false;
  65952. defines.AMBIENT = false;
  65953. defines.OPACITY = false;
  65954. defines.REFLECTION = false;
  65955. defines.EMISSIVE = false;
  65956. defines.LIGHTMAP = false;
  65957. defines.BUMP = false;
  65958. defines.REFRACTION = false;
  65959. }
  65960. defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
  65961. defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
  65962. defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
  65963. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  65964. 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);
  65965. }
  65966. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  65967. if (!this._imageProcessingConfiguration.isReady()) {
  65968. return false;
  65969. }
  65970. this._imageProcessingConfiguration.prepareDefines(defines);
  65971. defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
  65972. defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
  65973. }
  65974. if (defines._areFresnelDirty) {
  65975. if (StandardMaterial.FresnelEnabled) {
  65976. // Fresnel
  65977. if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
  65978. this._emissiveFresnelParameters || this._refractionFresnelParameters ||
  65979. this._reflectionFresnelParameters) {
  65980. defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
  65981. defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
  65982. defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
  65983. defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
  65984. defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
  65985. defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
  65986. defines._needNormals = true;
  65987. defines.FRESNEL = true;
  65988. }
  65989. }
  65990. else {
  65991. defines.FRESNEL = false;
  65992. }
  65993. }
  65994. // Misc.
  65995. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  65996. // Attribs
  65997. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true);
  65998. // Values that need to be evaluated on every frame
  65999. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  66000. // Get correct effect
  66001. if (defines.isDirty) {
  66002. defines.markAsProcessed();
  66003. // Fallbacks
  66004. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_7__["EffectFallbacks"]();
  66005. if (defines.REFLECTION) {
  66006. fallbacks.addFallback(0, "REFLECTION");
  66007. }
  66008. if (defines.SPECULAR) {
  66009. fallbacks.addFallback(0, "SPECULAR");
  66010. }
  66011. if (defines.BUMP) {
  66012. fallbacks.addFallback(0, "BUMP");
  66013. }
  66014. if (defines.PARALLAX) {
  66015. fallbacks.addFallback(1, "PARALLAX");
  66016. }
  66017. if (defines.PARALLAXOCCLUSION) {
  66018. fallbacks.addFallback(0, "PARALLAXOCCLUSION");
  66019. }
  66020. if (defines.SPECULAROVERALPHA) {
  66021. fallbacks.addFallback(0, "SPECULAROVERALPHA");
  66022. }
  66023. if (defines.FOG) {
  66024. fallbacks.addFallback(1, "FOG");
  66025. }
  66026. if (defines.POINTSIZE) {
  66027. fallbacks.addFallback(0, "POINTSIZE");
  66028. }
  66029. if (defines.LOGARITHMICDEPTH) {
  66030. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  66031. }
  66032. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  66033. if (defines.SPECULARTERM) {
  66034. fallbacks.addFallback(0, "SPECULARTERM");
  66035. }
  66036. if (defines.DIFFUSEFRESNEL) {
  66037. fallbacks.addFallback(1, "DIFFUSEFRESNEL");
  66038. }
  66039. if (defines.OPACITYFRESNEL) {
  66040. fallbacks.addFallback(2, "OPACITYFRESNEL");
  66041. }
  66042. if (defines.REFLECTIONFRESNEL) {
  66043. fallbacks.addFallback(3, "REFLECTIONFRESNEL");
  66044. }
  66045. if (defines.EMISSIVEFRESNEL) {
  66046. fallbacks.addFallback(4, "EMISSIVEFRESNEL");
  66047. }
  66048. if (defines.FRESNEL) {
  66049. fallbacks.addFallback(4, "FRESNEL");
  66050. }
  66051. //Attributes
  66052. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  66053. if (defines.NORMAL) {
  66054. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  66055. }
  66056. if (defines.UV1) {
  66057. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  66058. }
  66059. if (defines.UV2) {
  66060. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  66061. }
  66062. if (defines.VERTEXCOLOR) {
  66063. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind);
  66064. }
  66065. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  66066. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  66067. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  66068. var shaderName = "default";
  66069. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
  66070. "vFogInfos", "vFogColor", "pointSize",
  66071. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  66072. "mBones",
  66073. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
  66074. "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
  66075. "vReflectionPosition", "vReflectionSize",
  66076. "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"
  66077. ];
  66078. var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler",
  66079. "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
  66080. "refractionCubeSampler", "refraction2DSampler", "boneSampler"];
  66081. var uniformBuffers = ["Material", "Scene"];
  66082. if (_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"]) {
  66083. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  66084. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  66085. }
  66086. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareUniformsAndSamplersList({
  66087. uniformsNames: uniforms,
  66088. uniformBuffersNames: uniformBuffers,
  66089. samplers: samplers,
  66090. defines: defines,
  66091. maxSimultaneousLights: this._maxSimultaneousLights
  66092. });
  66093. if (this.customShaderNameResolve) {
  66094. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  66095. }
  66096. var join = defines.toString();
  66097. var previousEffect = subMesh.effect;
  66098. var effect = scene.getEngine().createEffect(shaderName, {
  66099. attributes: attribs,
  66100. uniformsNames: uniforms,
  66101. uniformBuffersNames: uniformBuffers,
  66102. samplers: samplers,
  66103. defines: join,
  66104. fallbacks: fallbacks,
  66105. onCompiled: this.onCompiled,
  66106. onError: this.onError,
  66107. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  66108. }, engine);
  66109. if (effect) {
  66110. // Use previous effect while new one is compiling
  66111. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  66112. effect = previousEffect;
  66113. defines.markAsUnprocessed();
  66114. }
  66115. else {
  66116. scene.resetCachedMaterial();
  66117. subMesh.setEffect(effect, defines);
  66118. this.buildUniformLayout();
  66119. }
  66120. }
  66121. }
  66122. if (!subMesh.effect || !subMesh.effect.isReady()) {
  66123. return false;
  66124. }
  66125. defines._renderId = scene.getRenderId();
  66126. this._wasPreviouslyReady = true;
  66127. return true;
  66128. };
  66129. /**
  66130. * Builds the material UBO layouts.
  66131. * Used internally during the effect preparation.
  66132. */
  66133. StandardMaterial.prototype.buildUniformLayout = function () {
  66134. // Order is important !
  66135. this._uniformBuffer.addUniform("diffuseLeftColor", 4);
  66136. this._uniformBuffer.addUniform("diffuseRightColor", 4);
  66137. this._uniformBuffer.addUniform("opacityParts", 4);
  66138. this._uniformBuffer.addUniform("reflectionLeftColor", 4);
  66139. this._uniformBuffer.addUniform("reflectionRightColor", 4);
  66140. this._uniformBuffer.addUniform("refractionLeftColor", 4);
  66141. this._uniformBuffer.addUniform("refractionRightColor", 4);
  66142. this._uniformBuffer.addUniform("emissiveLeftColor", 4);
  66143. this._uniformBuffer.addUniform("emissiveRightColor", 4);
  66144. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  66145. this._uniformBuffer.addUniform("vAmbientInfos", 2);
  66146. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  66147. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  66148. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  66149. this._uniformBuffer.addUniform("vReflectionSize", 3);
  66150. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  66151. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  66152. this._uniformBuffer.addUniform("vSpecularInfos", 2);
  66153. this._uniformBuffer.addUniform("vBumpInfos", 3);
  66154. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  66155. this._uniformBuffer.addUniform("ambientMatrix", 16);
  66156. this._uniformBuffer.addUniform("opacityMatrix", 16);
  66157. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  66158. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  66159. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  66160. this._uniformBuffer.addUniform("specularMatrix", 16);
  66161. this._uniformBuffer.addUniform("bumpMatrix", 16);
  66162. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  66163. this._uniformBuffer.addUniform("refractionMatrix", 16);
  66164. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  66165. this._uniformBuffer.addUniform("vSpecularColor", 4);
  66166. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  66167. this._uniformBuffer.addUniform("vDiffuseColor", 4);
  66168. this._uniformBuffer.addUniform("pointSize", 1);
  66169. this._uniformBuffer.create();
  66170. };
  66171. /**
  66172. * Unbinds the material from the mesh
  66173. */
  66174. StandardMaterial.prototype.unbind = function () {
  66175. if (this._activeEffect) {
  66176. var needFlag = false;
  66177. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  66178. this._activeEffect.setTexture("reflection2DSampler", null);
  66179. needFlag = true;
  66180. }
  66181. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  66182. this._activeEffect.setTexture("refraction2DSampler", null);
  66183. needFlag = true;
  66184. }
  66185. if (needFlag) {
  66186. this._markAllSubMeshesAsTexturesDirty();
  66187. }
  66188. }
  66189. _super.prototype.unbind.call(this);
  66190. };
  66191. /**
  66192. * Binds the submesh to this material by preparing the effect and shader to draw
  66193. * @param world defines the world transformation matrix
  66194. * @param mesh defines the mesh containing the submesh
  66195. * @param subMesh defines the submesh to bind the material to
  66196. */
  66197. StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  66198. var scene = this.getScene();
  66199. var defines = subMesh._materialDefines;
  66200. if (!defines) {
  66201. return;
  66202. }
  66203. var effect = subMesh.effect;
  66204. if (!effect) {
  66205. return;
  66206. }
  66207. this._activeEffect = effect;
  66208. // Matrices
  66209. this.bindOnlyWorldMatrix(world);
  66210. // Normal Matrix
  66211. if (defines.OBJECTSPACE_NORMALMAP) {
  66212. world.toNormalMatrix(this._normalMatrix);
  66213. this.bindOnlyNormalMatrix(this._normalMatrix);
  66214. }
  66215. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  66216. // Bones
  66217. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindBonesParameters(mesh, effect);
  66218. if (mustRebind) {
  66219. this._uniformBuffer.bindToEffect(effect, "Material");
  66220. this.bindViewProjection(effect);
  66221. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  66222. if (StandardMaterial.FresnelEnabled && defines.FRESNEL) {
  66223. // Fresnel
  66224. if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
  66225. this._uniformBuffer.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
  66226. this._uniformBuffer.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
  66227. }
  66228. if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
  66229. 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);
  66230. }
  66231. if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
  66232. this._uniformBuffer.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
  66233. this._uniformBuffer.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
  66234. }
  66235. if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
  66236. this._uniformBuffer.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power);
  66237. this._uniformBuffer.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias);
  66238. }
  66239. if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
  66240. this._uniformBuffer.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
  66241. this._uniformBuffer.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
  66242. }
  66243. }
  66244. // Textures
  66245. if (scene.texturesEnabled) {
  66246. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  66247. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  66248. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  66249. if (this._diffuseTexture.hasAlpha) {
  66250. effect.setFloat("alphaCutOff", this.alphaCutOff);
  66251. }
  66252. }
  66253. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  66254. this._uniformBuffer.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level);
  66255. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  66256. }
  66257. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  66258. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  66259. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  66260. }
  66261. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  66262. this._uniformBuffer.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness);
  66263. this._uniformBuffer.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix());
  66264. if (this._reflectionTexture.boundingBoxSize) {
  66265. var cubeTexture = this._reflectionTexture;
  66266. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  66267. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  66268. }
  66269. }
  66270. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  66271. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  66272. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  66273. }
  66274. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  66275. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  66276. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  66277. }
  66278. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  66279. this._uniformBuffer.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level);
  66280. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._specularTexture, this._uniformBuffer, "specular");
  66281. }
  66282. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  66283. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
  66284. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  66285. if (scene._mirroredCameraPosition) {
  66286. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  66287. }
  66288. else {
  66289. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  66290. }
  66291. }
  66292. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  66293. var depth = 1.0;
  66294. if (!this._refractionTexture.isCube) {
  66295. this._uniformBuffer.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix());
  66296. if (this._refractionTexture.depth) {
  66297. depth = this._refractionTexture.depth;
  66298. }
  66299. }
  66300. this._uniformBuffer.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
  66301. }
  66302. }
  66303. // Point size
  66304. if (this.pointsCloud) {
  66305. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  66306. }
  66307. if (defines.SPECULARTERM) {
  66308. this._uniformBuffer.updateColor4("vSpecularColor", this.specularColor, this.specularPower);
  66309. }
  66310. this._uniformBuffer.updateColor3("vEmissiveColor", StandardMaterial.EmissiveTextureEnabled ? this.emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].BlackReadOnly);
  66311. // Diffuse
  66312. this._uniformBuffer.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  66313. }
  66314. // Textures
  66315. if (scene.texturesEnabled) {
  66316. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  66317. effect.setTexture("diffuseSampler", this._diffuseTexture);
  66318. }
  66319. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  66320. effect.setTexture("ambientSampler", this._ambientTexture);
  66321. }
  66322. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  66323. effect.setTexture("opacitySampler", this._opacityTexture);
  66324. }
  66325. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  66326. if (this._reflectionTexture.isCube) {
  66327. effect.setTexture("reflectionCubeSampler", this._reflectionTexture);
  66328. }
  66329. else {
  66330. effect.setTexture("reflection2DSampler", this._reflectionTexture);
  66331. }
  66332. }
  66333. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  66334. effect.setTexture("emissiveSampler", this._emissiveTexture);
  66335. }
  66336. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  66337. effect.setTexture("lightmapSampler", this._lightmapTexture);
  66338. }
  66339. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  66340. effect.setTexture("specularSampler", this._specularTexture);
  66341. }
  66342. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  66343. effect.setTexture("bumpSampler", this._bumpTexture);
  66344. }
  66345. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  66346. var depth = 1.0;
  66347. if (this._refractionTexture.isCube) {
  66348. effect.setTexture("refractionCubeSampler", this._refractionTexture);
  66349. }
  66350. else {
  66351. effect.setTexture("refraction2DSampler", this._refractionTexture);
  66352. }
  66353. }
  66354. }
  66355. // Clip plane
  66356. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindClipPlane(effect, scene);
  66357. // Colors
  66358. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  66359. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindEyePosition(effect, scene);
  66360. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  66361. }
  66362. if (mustRebind || !this.isFrozen) {
  66363. // Lights
  66364. if (scene.lightsEnabled && !this._disableLighting) {
  66365. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLights(scene, mesh, effect, defines, this._maxSimultaneousLights);
  66366. }
  66367. // View
  66368. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
  66369. this.bindView(effect);
  66370. }
  66371. // Fog
  66372. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindFogParameters(scene, mesh, effect);
  66373. // Morph targets
  66374. if (defines.NUM_MORPH_INFLUENCERS) {
  66375. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  66376. }
  66377. // Log. depth
  66378. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
  66379. // image processing
  66380. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  66381. this._imageProcessingConfiguration.bind(this._activeEffect);
  66382. }
  66383. }
  66384. this._uniformBuffer.update();
  66385. this._afterBind(mesh, this._activeEffect);
  66386. };
  66387. /**
  66388. * Get the list of animatables in the material.
  66389. * @returns the list of animatables object used in the material
  66390. */
  66391. StandardMaterial.prototype.getAnimatables = function () {
  66392. var results = [];
  66393. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  66394. results.push(this._diffuseTexture);
  66395. }
  66396. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  66397. results.push(this._ambientTexture);
  66398. }
  66399. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  66400. results.push(this._opacityTexture);
  66401. }
  66402. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  66403. results.push(this._reflectionTexture);
  66404. }
  66405. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  66406. results.push(this._emissiveTexture);
  66407. }
  66408. if (this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0) {
  66409. results.push(this._specularTexture);
  66410. }
  66411. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  66412. results.push(this._bumpTexture);
  66413. }
  66414. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  66415. results.push(this._lightmapTexture);
  66416. }
  66417. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  66418. results.push(this._refractionTexture);
  66419. }
  66420. return results;
  66421. };
  66422. /**
  66423. * Gets the active textures from the material
  66424. * @returns an array of textures
  66425. */
  66426. StandardMaterial.prototype.getActiveTextures = function () {
  66427. var activeTextures = _super.prototype.getActiveTextures.call(this);
  66428. if (this._diffuseTexture) {
  66429. activeTextures.push(this._diffuseTexture);
  66430. }
  66431. if (this._ambientTexture) {
  66432. activeTextures.push(this._ambientTexture);
  66433. }
  66434. if (this._opacityTexture) {
  66435. activeTextures.push(this._opacityTexture);
  66436. }
  66437. if (this._reflectionTexture) {
  66438. activeTextures.push(this._reflectionTexture);
  66439. }
  66440. if (this._emissiveTexture) {
  66441. activeTextures.push(this._emissiveTexture);
  66442. }
  66443. if (this._specularTexture) {
  66444. activeTextures.push(this._specularTexture);
  66445. }
  66446. if (this._bumpTexture) {
  66447. activeTextures.push(this._bumpTexture);
  66448. }
  66449. if (this._lightmapTexture) {
  66450. activeTextures.push(this._lightmapTexture);
  66451. }
  66452. if (this._refractionTexture) {
  66453. activeTextures.push(this._refractionTexture);
  66454. }
  66455. return activeTextures;
  66456. };
  66457. /**
  66458. * Specifies if the material uses a texture
  66459. * @param texture defines the texture to check against the material
  66460. * @returns a boolean specifying if the material uses the texture
  66461. */
  66462. StandardMaterial.prototype.hasTexture = function (texture) {
  66463. if (_super.prototype.hasTexture.call(this, texture)) {
  66464. return true;
  66465. }
  66466. if (this._diffuseTexture === texture) {
  66467. return true;
  66468. }
  66469. if (this._ambientTexture === texture) {
  66470. return true;
  66471. }
  66472. if (this._opacityTexture === texture) {
  66473. return true;
  66474. }
  66475. if (this._reflectionTexture === texture) {
  66476. return true;
  66477. }
  66478. if (this._emissiveTexture === texture) {
  66479. return true;
  66480. }
  66481. if (this._specularTexture === texture) {
  66482. return true;
  66483. }
  66484. if (this._bumpTexture === texture) {
  66485. return true;
  66486. }
  66487. if (this._lightmapTexture === texture) {
  66488. return true;
  66489. }
  66490. if (this._refractionTexture === texture) {
  66491. return true;
  66492. }
  66493. return false;
  66494. };
  66495. /**
  66496. * Disposes the material
  66497. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  66498. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  66499. */
  66500. StandardMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  66501. if (forceDisposeTextures) {
  66502. if (this._diffuseTexture) {
  66503. this._diffuseTexture.dispose();
  66504. }
  66505. if (this._ambientTexture) {
  66506. this._ambientTexture.dispose();
  66507. }
  66508. if (this._opacityTexture) {
  66509. this._opacityTexture.dispose();
  66510. }
  66511. if (this._reflectionTexture) {
  66512. this._reflectionTexture.dispose();
  66513. }
  66514. if (this._emissiveTexture) {
  66515. this._emissiveTexture.dispose();
  66516. }
  66517. if (this._specularTexture) {
  66518. this._specularTexture.dispose();
  66519. }
  66520. if (this._bumpTexture) {
  66521. this._bumpTexture.dispose();
  66522. }
  66523. if (this._lightmapTexture) {
  66524. this._lightmapTexture.dispose();
  66525. }
  66526. if (this._refractionTexture) {
  66527. this._refractionTexture.dispose();
  66528. }
  66529. }
  66530. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  66531. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  66532. }
  66533. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  66534. };
  66535. /**
  66536. * Makes a duplicate of the material, and gives it a new name
  66537. * @param name defines the new name for the duplicated material
  66538. * @returns the cloned material
  66539. */
  66540. StandardMaterial.prototype.clone = function (name) {
  66541. var _this = this;
  66542. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new StandardMaterial(name, _this.getScene()); }, this);
  66543. result.name = name;
  66544. result.id = name;
  66545. return result;
  66546. };
  66547. /**
  66548. * Serializes this material in a JSON representation
  66549. * @returns the serialized material object
  66550. */
  66551. StandardMaterial.prototype.serialize = function () {
  66552. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  66553. };
  66554. /**
  66555. * Creates a standard material from parsed material data
  66556. * @param source defines the JSON representation of the material
  66557. * @param scene defines the hosting scene
  66558. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66559. * @returns a new standard material
  66560. */
  66561. StandardMaterial.Parse = function (source, scene, rootUrl) {
  66562. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardMaterial(source.name, scene); }, source, scene, rootUrl);
  66563. };
  66564. Object.defineProperty(StandardMaterial, "DiffuseTextureEnabled", {
  66565. // Flags used to enable or disable a type of texture for all Standard Materials
  66566. /**
  66567. * Are diffuse textures enabled in the application.
  66568. */
  66569. get: function () {
  66570. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled;
  66571. },
  66572. set: function (value) {
  66573. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled = value;
  66574. },
  66575. enumerable: true,
  66576. configurable: true
  66577. });
  66578. Object.defineProperty(StandardMaterial, "AmbientTextureEnabled", {
  66579. /**
  66580. * Are ambient textures enabled in the application.
  66581. */
  66582. get: function () {
  66583. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled;
  66584. },
  66585. set: function (value) {
  66586. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled = value;
  66587. },
  66588. enumerable: true,
  66589. configurable: true
  66590. });
  66591. Object.defineProperty(StandardMaterial, "OpacityTextureEnabled", {
  66592. /**
  66593. * Are opacity textures enabled in the application.
  66594. */
  66595. get: function () {
  66596. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled;
  66597. },
  66598. set: function (value) {
  66599. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled = value;
  66600. },
  66601. enumerable: true,
  66602. configurable: true
  66603. });
  66604. Object.defineProperty(StandardMaterial, "ReflectionTextureEnabled", {
  66605. /**
  66606. * Are reflection textures enabled in the application.
  66607. */
  66608. get: function () {
  66609. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled;
  66610. },
  66611. set: function (value) {
  66612. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled = value;
  66613. },
  66614. enumerable: true,
  66615. configurable: true
  66616. });
  66617. Object.defineProperty(StandardMaterial, "EmissiveTextureEnabled", {
  66618. /**
  66619. * Are emissive textures enabled in the application.
  66620. */
  66621. get: function () {
  66622. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled;
  66623. },
  66624. set: function (value) {
  66625. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled = value;
  66626. },
  66627. enumerable: true,
  66628. configurable: true
  66629. });
  66630. Object.defineProperty(StandardMaterial, "SpecularTextureEnabled", {
  66631. /**
  66632. * Are specular textures enabled in the application.
  66633. */
  66634. get: function () {
  66635. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled;
  66636. },
  66637. set: function (value) {
  66638. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled = value;
  66639. },
  66640. enumerable: true,
  66641. configurable: true
  66642. });
  66643. Object.defineProperty(StandardMaterial, "BumpTextureEnabled", {
  66644. /**
  66645. * Are bump textures enabled in the application.
  66646. */
  66647. get: function () {
  66648. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled;
  66649. },
  66650. set: function (value) {
  66651. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled = value;
  66652. },
  66653. enumerable: true,
  66654. configurable: true
  66655. });
  66656. Object.defineProperty(StandardMaterial, "LightmapTextureEnabled", {
  66657. /**
  66658. * Are lightmap textures enabled in the application.
  66659. */
  66660. get: function () {
  66661. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled;
  66662. },
  66663. set: function (value) {
  66664. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled = value;
  66665. },
  66666. enumerable: true,
  66667. configurable: true
  66668. });
  66669. Object.defineProperty(StandardMaterial, "RefractionTextureEnabled", {
  66670. /**
  66671. * Are refraction textures enabled in the application.
  66672. */
  66673. get: function () {
  66674. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled;
  66675. },
  66676. set: function (value) {
  66677. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled = value;
  66678. },
  66679. enumerable: true,
  66680. configurable: true
  66681. });
  66682. Object.defineProperty(StandardMaterial, "ColorGradingTextureEnabled", {
  66683. /**
  66684. * Are color grading textures enabled in the application.
  66685. */
  66686. get: function () {
  66687. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled;
  66688. },
  66689. set: function (value) {
  66690. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled = value;
  66691. },
  66692. enumerable: true,
  66693. configurable: true
  66694. });
  66695. Object.defineProperty(StandardMaterial, "FresnelEnabled", {
  66696. /**
  66697. * Are fresnels enabled in the application.
  66698. */
  66699. get: function () {
  66700. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled;
  66701. },
  66702. set: function (value) {
  66703. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled = value;
  66704. },
  66705. enumerable: true,
  66706. configurable: true
  66707. });
  66708. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66709. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
  66710. ], StandardMaterial.prototype, "_diffuseTexture", void 0);
  66711. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66712. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  66713. ], StandardMaterial.prototype, "diffuseTexture", void 0);
  66714. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66715. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("ambientTexture")
  66716. ], StandardMaterial.prototype, "_ambientTexture", void 0);
  66717. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66718. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66719. ], StandardMaterial.prototype, "ambientTexture", void 0);
  66720. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66721. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
  66722. ], StandardMaterial.prototype, "_opacityTexture", void 0);
  66723. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66724. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  66725. ], StandardMaterial.prototype, "opacityTexture", void 0);
  66726. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66727. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("reflectionTexture")
  66728. ], StandardMaterial.prototype, "_reflectionTexture", void 0);
  66729. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66730. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66731. ], StandardMaterial.prototype, "reflectionTexture", void 0);
  66732. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66733. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("emissiveTexture")
  66734. ], StandardMaterial.prototype, "_emissiveTexture", void 0);
  66735. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66736. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66737. ], StandardMaterial.prototype, "emissiveTexture", void 0);
  66738. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66739. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("specularTexture")
  66740. ], StandardMaterial.prototype, "_specularTexture", void 0);
  66741. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66742. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66743. ], StandardMaterial.prototype, "specularTexture", void 0);
  66744. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66745. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
  66746. ], StandardMaterial.prototype, "_bumpTexture", void 0);
  66747. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66748. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66749. ], StandardMaterial.prototype, "bumpTexture", void 0);
  66750. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66751. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lightmapTexture")
  66752. ], StandardMaterial.prototype, "_lightmapTexture", void 0);
  66753. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66754. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66755. ], StandardMaterial.prototype, "lightmapTexture", void 0);
  66756. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66757. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("refractionTexture")
  66758. ], StandardMaterial.prototype, "_refractionTexture", void 0);
  66759. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66760. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66761. ], StandardMaterial.prototype, "refractionTexture", void 0);
  66762. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66763. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient")
  66764. ], StandardMaterial.prototype, "ambientColor", void 0);
  66765. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66766. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
  66767. ], StandardMaterial.prototype, "diffuseColor", void 0);
  66768. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66769. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular")
  66770. ], StandardMaterial.prototype, "specularColor", void 0);
  66771. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66772. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive")
  66773. ], StandardMaterial.prototype, "emissiveColor", void 0);
  66774. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66775. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66776. ], StandardMaterial.prototype, "specularPower", void 0);
  66777. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66778. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useAlphaFromDiffuseTexture")
  66779. ], StandardMaterial.prototype, "_useAlphaFromDiffuseTexture", void 0);
  66780. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66781. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66782. ], StandardMaterial.prototype, "useAlphaFromDiffuseTexture", void 0);
  66783. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66784. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useEmissiveAsIllumination")
  66785. ], StandardMaterial.prototype, "_useEmissiveAsIllumination", void 0);
  66786. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66787. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66788. ], StandardMaterial.prototype, "useEmissiveAsIllumination", void 0);
  66789. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66790. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("linkEmissiveWithDiffuse")
  66791. ], StandardMaterial.prototype, "_linkEmissiveWithDiffuse", void 0);
  66792. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66793. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66794. ], StandardMaterial.prototype, "linkEmissiveWithDiffuse", void 0);
  66795. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66796. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useSpecularOverAlpha")
  66797. ], StandardMaterial.prototype, "_useSpecularOverAlpha", void 0);
  66798. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66799. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66800. ], StandardMaterial.prototype, "useSpecularOverAlpha", void 0);
  66801. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66802. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionOverAlpha")
  66803. ], StandardMaterial.prototype, "_useReflectionOverAlpha", void 0);
  66804. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66805. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66806. ], StandardMaterial.prototype, "useReflectionOverAlpha", void 0);
  66807. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66808. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  66809. ], StandardMaterial.prototype, "_disableLighting", void 0);
  66810. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66811. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  66812. ], StandardMaterial.prototype, "disableLighting", void 0);
  66813. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66814. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useObjectSpaceNormalMap")
  66815. ], StandardMaterial.prototype, "_useObjectSpaceNormalMap", void 0);
  66816. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66817. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66818. ], StandardMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  66819. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66820. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallax")
  66821. ], StandardMaterial.prototype, "_useParallax", void 0);
  66822. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66823. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66824. ], StandardMaterial.prototype, "useParallax", void 0);
  66825. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66826. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallaxOcclusion")
  66827. ], StandardMaterial.prototype, "_useParallaxOcclusion", void 0);
  66828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66830. ], StandardMaterial.prototype, "useParallaxOcclusion", void 0);
  66831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66833. ], StandardMaterial.prototype, "parallaxScaleBias", void 0);
  66834. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66835. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("roughness")
  66836. ], StandardMaterial.prototype, "_roughness", void 0);
  66837. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66838. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66839. ], StandardMaterial.prototype, "roughness", void 0);
  66840. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66841. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66842. ], StandardMaterial.prototype, "indexOfRefraction", void 0);
  66843. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66844. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66845. ], StandardMaterial.prototype, "invertRefractionY", void 0);
  66846. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66847. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66848. ], StandardMaterial.prototype, "alphaCutOff", void 0);
  66849. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66850. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useLightmapAsShadowmap")
  66851. ], StandardMaterial.prototype, "_useLightmapAsShadowmap", void 0);
  66852. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66853. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66854. ], StandardMaterial.prototype, "useLightmapAsShadowmap", void 0);
  66855. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66856. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("diffuseFresnelParameters")
  66857. ], StandardMaterial.prototype, "_diffuseFresnelParameters", void 0);
  66858. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66859. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66860. ], StandardMaterial.prototype, "diffuseFresnelParameters", void 0);
  66861. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66862. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("opacityFresnelParameters")
  66863. ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
  66864. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66865. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelAndMiscDirty")
  66866. ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
  66867. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66868. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("reflectionFresnelParameters")
  66869. ], StandardMaterial.prototype, "_reflectionFresnelParameters", void 0);
  66870. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66871. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66872. ], StandardMaterial.prototype, "reflectionFresnelParameters", void 0);
  66873. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66874. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("refractionFresnelParameters")
  66875. ], StandardMaterial.prototype, "_refractionFresnelParameters", void 0);
  66876. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66877. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66878. ], StandardMaterial.prototype, "refractionFresnelParameters", void 0);
  66879. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66880. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("emissiveFresnelParameters")
  66881. ], StandardMaterial.prototype, "_emissiveFresnelParameters", void 0);
  66882. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66883. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66884. ], StandardMaterial.prototype, "emissiveFresnelParameters", void 0);
  66885. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66886. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionFresnelFromSpecular")
  66887. ], StandardMaterial.prototype, "_useReflectionFresnelFromSpecular", void 0);
  66888. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66889. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66890. ], StandardMaterial.prototype, "useReflectionFresnelFromSpecular", void 0);
  66891. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66892. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useGlossinessFromSpecularMapAlpha")
  66893. ], StandardMaterial.prototype, "_useGlossinessFromSpecularMapAlpha", void 0);
  66894. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66895. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66896. ], StandardMaterial.prototype, "useGlossinessFromSpecularMapAlpha", void 0);
  66897. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66898. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  66899. ], StandardMaterial.prototype, "_maxSimultaneousLights", void 0);
  66900. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66901. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  66902. ], StandardMaterial.prototype, "maxSimultaneousLights", void 0);
  66903. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66904. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapX")
  66905. ], StandardMaterial.prototype, "_invertNormalMapX", void 0);
  66906. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66907. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66908. ], StandardMaterial.prototype, "invertNormalMapX", void 0);
  66909. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66910. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapY")
  66911. ], StandardMaterial.prototype, "_invertNormalMapY", void 0);
  66912. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66913. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66914. ], StandardMaterial.prototype, "invertNormalMapY", void 0);
  66915. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66916. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("twoSidedLighting")
  66917. ], StandardMaterial.prototype, "_twoSidedLighting", void 0);
  66918. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66919. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66920. ], StandardMaterial.prototype, "twoSidedLighting", void 0);
  66921. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66922. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66923. ], StandardMaterial.prototype, "useLogarithmicDepth", null);
  66924. return StandardMaterial;
  66925. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  66926. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
  66927. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].DefaultMaterialFactory = function (scene) {
  66928. return new StandardMaterial("default material", scene);
  66929. };
  66930. /***/ }),
  66931. /***/ "./Materials/uniformBuffer.ts":
  66932. /*!************************************!*\
  66933. !*** ./Materials/uniformBuffer.ts ***!
  66934. \************************************/
  66935. /*! exports provided: UniformBuffer */
  66936. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66937. "use strict";
  66938. __webpack_require__.r(__webpack_exports__);
  66939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return UniformBuffer; });
  66940. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  66941. /**
  66942. * Uniform buffer objects.
  66943. *
  66944. * Handles blocks of uniform on the GPU.
  66945. *
  66946. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  66947. *
  66948. * For more information, please refer to :
  66949. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  66950. */
  66951. var UniformBuffer = /** @class */ (function () {
  66952. /**
  66953. * Instantiates a new Uniform buffer objects.
  66954. *
  66955. * Handles blocks of uniform on the GPU.
  66956. *
  66957. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  66958. *
  66959. * For more information, please refer to :
  66960. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  66961. * @param engine Define the engine the buffer is associated with
  66962. * @param data Define the data contained in the buffer
  66963. * @param dynamic Define if the buffer is updatable
  66964. */
  66965. function UniformBuffer(engine, data, dynamic) {
  66966. this._engine = engine;
  66967. this._noUBO = !engine.supportsUniformBuffers;
  66968. this._dynamic = dynamic;
  66969. this._data = data || [];
  66970. this._uniformLocations = {};
  66971. this._uniformSizes = {};
  66972. this._uniformLocationPointer = 0;
  66973. this._needSync = false;
  66974. if (this._noUBO) {
  66975. this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
  66976. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
  66977. this.updateFloat = this._updateFloatForEffect;
  66978. this.updateFloat2 = this._updateFloat2ForEffect;
  66979. this.updateFloat3 = this._updateFloat3ForEffect;
  66980. this.updateFloat4 = this._updateFloat4ForEffect;
  66981. this.updateMatrix = this._updateMatrixForEffect;
  66982. this.updateVector3 = this._updateVector3ForEffect;
  66983. this.updateVector4 = this._updateVector4ForEffect;
  66984. this.updateColor3 = this._updateColor3ForEffect;
  66985. this.updateColor4 = this._updateColor4ForEffect;
  66986. }
  66987. else {
  66988. this._engine._uniformBuffers.push(this);
  66989. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
  66990. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
  66991. this.updateFloat = this._updateFloatForUniform;
  66992. this.updateFloat2 = this._updateFloat2ForUniform;
  66993. this.updateFloat3 = this._updateFloat3ForUniform;
  66994. this.updateFloat4 = this._updateFloat4ForUniform;
  66995. this.updateMatrix = this._updateMatrixForUniform;
  66996. this.updateVector3 = this._updateVector3ForUniform;
  66997. this.updateVector4 = this._updateVector4ForUniform;
  66998. this.updateColor3 = this._updateColor3ForUniform;
  66999. this.updateColor4 = this._updateColor4ForUniform;
  67000. }
  67001. }
  67002. Object.defineProperty(UniformBuffer.prototype, "useUbo", {
  67003. /**
  67004. * Indicates if the buffer is using the WebGL2 UBO implementation,
  67005. * or just falling back on setUniformXXX calls.
  67006. */
  67007. get: function () {
  67008. return !this._noUBO;
  67009. },
  67010. enumerable: true,
  67011. configurable: true
  67012. });
  67013. Object.defineProperty(UniformBuffer.prototype, "isSync", {
  67014. /**
  67015. * Indicates if the WebGL underlying uniform buffer is in sync
  67016. * with the javascript cache data.
  67017. */
  67018. get: function () {
  67019. return !this._needSync;
  67020. },
  67021. enumerable: true,
  67022. configurable: true
  67023. });
  67024. /**
  67025. * Indicates if the WebGL underlying uniform buffer is dynamic.
  67026. * Also, a dynamic UniformBuffer will disable cache verification and always
  67027. * update the underlying WebGL uniform buffer to the GPU.
  67028. * @returns if Dynamic, otherwise false
  67029. */
  67030. UniformBuffer.prototype.isDynamic = function () {
  67031. return this._dynamic !== undefined;
  67032. };
  67033. /**
  67034. * The data cache on JS side.
  67035. * @returns the underlying data as a float array
  67036. */
  67037. UniformBuffer.prototype.getData = function () {
  67038. return this._bufferData;
  67039. };
  67040. /**
  67041. * The underlying WebGL Uniform buffer.
  67042. * @returns the webgl buffer
  67043. */
  67044. UniformBuffer.prototype.getBuffer = function () {
  67045. return this._buffer;
  67046. };
  67047. /**
  67048. * std140 layout specifies how to align data within an UBO structure.
  67049. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  67050. * for specs.
  67051. */
  67052. UniformBuffer.prototype._fillAlignment = function (size) {
  67053. // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components
  67054. // and 4x4 matrices
  67055. // TODO : change if other types are used
  67056. var alignment;
  67057. if (size <= 2) {
  67058. alignment = size;
  67059. }
  67060. else {
  67061. alignment = 4;
  67062. }
  67063. if ((this._uniformLocationPointer % alignment) !== 0) {
  67064. var oldPointer = this._uniformLocationPointer;
  67065. this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);
  67066. var diff = this._uniformLocationPointer - oldPointer;
  67067. for (var i = 0; i < diff; i++) {
  67068. this._data.push(0);
  67069. }
  67070. }
  67071. };
  67072. /**
  67073. * Adds an uniform in the buffer.
  67074. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  67075. * for the layout to be correct !
  67076. * @param name Name of the uniform, as used in the uniform block in the shader.
  67077. * @param size Data size, or data directly.
  67078. */
  67079. UniformBuffer.prototype.addUniform = function (name, size) {
  67080. if (this._noUBO) {
  67081. return;
  67082. }
  67083. if (this._uniformLocations[name] !== undefined) {
  67084. // Already existing uniform
  67085. return;
  67086. }
  67087. // This function must be called in the order of the shader layout !
  67088. // size can be the size of the uniform, or data directly
  67089. var data;
  67090. if (size instanceof Array) {
  67091. data = size;
  67092. size = data.length;
  67093. }
  67094. else {
  67095. size = size;
  67096. data = [];
  67097. // Fill with zeros
  67098. for (var i = 0; i < size; i++) {
  67099. data.push(0);
  67100. }
  67101. }
  67102. this._fillAlignment(size);
  67103. this._uniformSizes[name] = size;
  67104. this._uniformLocations[name] = this._uniformLocationPointer;
  67105. this._uniformLocationPointer += size;
  67106. for (var i = 0; i < size; i++) {
  67107. this._data.push(data[i]);
  67108. }
  67109. this._needSync = true;
  67110. };
  67111. /**
  67112. * Adds a Matrix 4x4 to the uniform buffer.
  67113. * @param name Name of the uniform, as used in the uniform block in the shader.
  67114. * @param mat A 4x4 matrix.
  67115. */
  67116. UniformBuffer.prototype.addMatrix = function (name, mat) {
  67117. this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
  67118. };
  67119. /**
  67120. * Adds a vec2 to the uniform buffer.
  67121. * @param name Name of the uniform, as used in the uniform block in the shader.
  67122. * @param x Define the x component value of the vec2
  67123. * @param y Define the y component value of the vec2
  67124. */
  67125. UniformBuffer.prototype.addFloat2 = function (name, x, y) {
  67126. var temp = [x, y];
  67127. this.addUniform(name, temp);
  67128. };
  67129. /**
  67130. * Adds a vec3 to the uniform buffer.
  67131. * @param name Name of the uniform, as used in the uniform block in the shader.
  67132. * @param x Define the x component value of the vec3
  67133. * @param y Define the y component value of the vec3
  67134. * @param z Define the z component value of the vec3
  67135. */
  67136. UniformBuffer.prototype.addFloat3 = function (name, x, y, z) {
  67137. var temp = [x, y, z];
  67138. this.addUniform(name, temp);
  67139. };
  67140. /**
  67141. * Adds a vec3 to the uniform buffer.
  67142. * @param name Name of the uniform, as used in the uniform block in the shader.
  67143. * @param color Define the vec3 from a Color
  67144. */
  67145. UniformBuffer.prototype.addColor3 = function (name, color) {
  67146. var temp = new Array();
  67147. color.toArray(temp);
  67148. this.addUniform(name, temp);
  67149. };
  67150. /**
  67151. * Adds a vec4 to the uniform buffer.
  67152. * @param name Name of the uniform, as used in the uniform block in the shader.
  67153. * @param color Define the rgb components from a Color
  67154. * @param alpha Define the a component of the vec4
  67155. */
  67156. UniformBuffer.prototype.addColor4 = function (name, color, alpha) {
  67157. var temp = new Array();
  67158. color.toArray(temp);
  67159. temp.push(alpha);
  67160. this.addUniform(name, temp);
  67161. };
  67162. /**
  67163. * Adds a vec3 to the uniform buffer.
  67164. * @param name Name of the uniform, as used in the uniform block in the shader.
  67165. * @param vector Define the vec3 components from a Vector
  67166. */
  67167. UniformBuffer.prototype.addVector3 = function (name, vector) {
  67168. var temp = new Array();
  67169. vector.toArray(temp);
  67170. this.addUniform(name, temp);
  67171. };
  67172. /**
  67173. * Adds a Matrix 3x3 to the uniform buffer.
  67174. * @param name Name of the uniform, as used in the uniform block in the shader.
  67175. */
  67176. UniformBuffer.prototype.addMatrix3x3 = function (name) {
  67177. this.addUniform(name, 12);
  67178. };
  67179. /**
  67180. * Adds a Matrix 2x2 to the uniform buffer.
  67181. * @param name Name of the uniform, as used in the uniform block in the shader.
  67182. */
  67183. UniformBuffer.prototype.addMatrix2x2 = function (name) {
  67184. this.addUniform(name, 8);
  67185. };
  67186. /**
  67187. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  67188. */
  67189. UniformBuffer.prototype.create = function () {
  67190. if (this._noUBO) {
  67191. return;
  67192. }
  67193. if (this._buffer) {
  67194. return; // nothing to do
  67195. }
  67196. // See spec, alignment must be filled as a vec4
  67197. this._fillAlignment(4);
  67198. this._bufferData = new Float32Array(this._data);
  67199. this._rebuild();
  67200. this._needSync = true;
  67201. };
  67202. /** @hidden */
  67203. UniformBuffer.prototype._rebuild = function () {
  67204. if (this._noUBO) {
  67205. return;
  67206. }
  67207. if (this._dynamic) {
  67208. this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
  67209. }
  67210. else {
  67211. this._buffer = this._engine.createUniformBuffer(this._bufferData);
  67212. }
  67213. };
  67214. /**
  67215. * Updates the WebGL Uniform Buffer on the GPU.
  67216. * If the `dynamic` flag is set to true, no cache comparison is done.
  67217. * Otherwise, the buffer will be updated only if the cache differs.
  67218. */
  67219. UniformBuffer.prototype.update = function () {
  67220. if (!this._buffer) {
  67221. this.create();
  67222. return;
  67223. }
  67224. if (!this._dynamic && !this._needSync) {
  67225. return;
  67226. }
  67227. this._engine.updateUniformBuffer(this._buffer, this._bufferData);
  67228. this._needSync = false;
  67229. };
  67230. /**
  67231. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  67232. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  67233. * @param data Define the flattened data
  67234. * @param size Define the size of the data.
  67235. */
  67236. UniformBuffer.prototype.updateUniform = function (uniformName, data, size) {
  67237. var location = this._uniformLocations[uniformName];
  67238. if (location === undefined) {
  67239. if (this._buffer) {
  67240. // Cannot add an uniform if the buffer is already created
  67241. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add an uniform after UBO has been created.");
  67242. return;
  67243. }
  67244. this.addUniform(uniformName, size);
  67245. location = this._uniformLocations[uniformName];
  67246. }
  67247. if (!this._buffer) {
  67248. this.create();
  67249. }
  67250. if (!this._dynamic) {
  67251. // Cache for static uniform buffers
  67252. var changed = false;
  67253. for (var i = 0; i < size; i++) {
  67254. if (this._bufferData[location + i] !== data[i]) {
  67255. changed = true;
  67256. this._bufferData[location + i] = data[i];
  67257. }
  67258. }
  67259. this._needSync = this._needSync || changed;
  67260. }
  67261. else {
  67262. // No cache for dynamic
  67263. for (var i = 0; i < size; i++) {
  67264. this._bufferData[location + i] = data[i];
  67265. }
  67266. }
  67267. };
  67268. // Update methods
  67269. UniformBuffer.prototype._updateMatrix3x3ForUniform = function (name, matrix) {
  67270. // To match std140, matrix must be realigned
  67271. for (var i = 0; i < 3; i++) {
  67272. UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
  67273. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 3 + 1];
  67274. UniformBuffer._tempBuffer[i * 4 + 2] = matrix[i * 3 + 2];
  67275. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  67276. }
  67277. this.updateUniform(name, UniformBuffer._tempBuffer, 12);
  67278. };
  67279. UniformBuffer.prototype._updateMatrix3x3ForEffect = function (name, matrix) {
  67280. this._currentEffect.setMatrix3x3(name, matrix);
  67281. };
  67282. UniformBuffer.prototype._updateMatrix2x2ForEffect = function (name, matrix) {
  67283. this._currentEffect.setMatrix2x2(name, matrix);
  67284. };
  67285. UniformBuffer.prototype._updateMatrix2x2ForUniform = function (name, matrix) {
  67286. // To match std140, matrix must be realigned
  67287. for (var i = 0; i < 2; i++) {
  67288. UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
  67289. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 2 + 1];
  67290. UniformBuffer._tempBuffer[i * 4 + 2] = 0.0;
  67291. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  67292. }
  67293. this.updateUniform(name, UniformBuffer._tempBuffer, 8);
  67294. };
  67295. UniformBuffer.prototype._updateFloatForEffect = function (name, x) {
  67296. this._currentEffect.setFloat(name, x);
  67297. };
  67298. UniformBuffer.prototype._updateFloatForUniform = function (name, x) {
  67299. UniformBuffer._tempBuffer[0] = x;
  67300. this.updateUniform(name, UniformBuffer._tempBuffer, 1);
  67301. };
  67302. UniformBuffer.prototype._updateFloat2ForEffect = function (name, x, y, suffix) {
  67303. if (suffix === void 0) { suffix = ""; }
  67304. this._currentEffect.setFloat2(name + suffix, x, y);
  67305. };
  67306. UniformBuffer.prototype._updateFloat2ForUniform = function (name, x, y) {
  67307. UniformBuffer._tempBuffer[0] = x;
  67308. UniformBuffer._tempBuffer[1] = y;
  67309. this.updateUniform(name, UniformBuffer._tempBuffer, 2);
  67310. };
  67311. UniformBuffer.prototype._updateFloat3ForEffect = function (name, x, y, z, suffix) {
  67312. if (suffix === void 0) { suffix = ""; }
  67313. this._currentEffect.setFloat3(name + suffix, x, y, z);
  67314. };
  67315. UniformBuffer.prototype._updateFloat3ForUniform = function (name, x, y, z) {
  67316. UniformBuffer._tempBuffer[0] = x;
  67317. UniformBuffer._tempBuffer[1] = y;
  67318. UniformBuffer._tempBuffer[2] = z;
  67319. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  67320. };
  67321. UniformBuffer.prototype._updateFloat4ForEffect = function (name, x, y, z, w, suffix) {
  67322. if (suffix === void 0) { suffix = ""; }
  67323. this._currentEffect.setFloat4(name + suffix, x, y, z, w);
  67324. };
  67325. UniformBuffer.prototype._updateFloat4ForUniform = function (name, x, y, z, w) {
  67326. UniformBuffer._tempBuffer[0] = x;
  67327. UniformBuffer._tempBuffer[1] = y;
  67328. UniformBuffer._tempBuffer[2] = z;
  67329. UniformBuffer._tempBuffer[3] = w;
  67330. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  67331. };
  67332. UniformBuffer.prototype._updateMatrixForEffect = function (name, mat) {
  67333. this._currentEffect.setMatrix(name, mat);
  67334. };
  67335. UniformBuffer.prototype._updateMatrixForUniform = function (name, mat) {
  67336. this.updateUniform(name, mat.toArray(), 16);
  67337. };
  67338. UniformBuffer.prototype._updateVector3ForEffect = function (name, vector) {
  67339. this._currentEffect.setVector3(name, vector);
  67340. };
  67341. UniformBuffer.prototype._updateVector3ForUniform = function (name, vector) {
  67342. vector.toArray(UniformBuffer._tempBuffer);
  67343. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  67344. };
  67345. UniformBuffer.prototype._updateVector4ForEffect = function (name, vector) {
  67346. this._currentEffect.setVector4(name, vector);
  67347. };
  67348. UniformBuffer.prototype._updateVector4ForUniform = function (name, vector) {
  67349. vector.toArray(UniformBuffer._tempBuffer);
  67350. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  67351. };
  67352. UniformBuffer.prototype._updateColor3ForEffect = function (name, color, suffix) {
  67353. if (suffix === void 0) { suffix = ""; }
  67354. this._currentEffect.setColor3(name + suffix, color);
  67355. };
  67356. UniformBuffer.prototype._updateColor3ForUniform = function (name, color) {
  67357. color.toArray(UniformBuffer._tempBuffer);
  67358. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  67359. };
  67360. UniformBuffer.prototype._updateColor4ForEffect = function (name, color, alpha, suffix) {
  67361. if (suffix === void 0) { suffix = ""; }
  67362. this._currentEffect.setColor4(name + suffix, color, alpha);
  67363. };
  67364. UniformBuffer.prototype._updateColor4ForUniform = function (name, color, alpha) {
  67365. color.toArray(UniformBuffer._tempBuffer);
  67366. UniformBuffer._tempBuffer[3] = alpha;
  67367. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  67368. };
  67369. /**
  67370. * Sets a sampler uniform on the effect.
  67371. * @param name Define the name of the sampler.
  67372. * @param texture Define the texture to set in the sampler
  67373. */
  67374. UniformBuffer.prototype.setTexture = function (name, texture) {
  67375. this._currentEffect.setTexture(name, texture);
  67376. };
  67377. /**
  67378. * Directly updates the value of the uniform in the cache AND on the GPU.
  67379. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  67380. * @param data Define the flattened data
  67381. */
  67382. UniformBuffer.prototype.updateUniformDirectly = function (uniformName, data) {
  67383. this.updateUniform(uniformName, data, data.length);
  67384. this.update();
  67385. };
  67386. /**
  67387. * Binds this uniform buffer to an effect.
  67388. * @param effect Define the effect to bind the buffer to
  67389. * @param name Name of the uniform block in the shader.
  67390. */
  67391. UniformBuffer.prototype.bindToEffect = function (effect, name) {
  67392. this._currentEffect = effect;
  67393. if (this._noUBO || !this._buffer) {
  67394. return;
  67395. }
  67396. effect.bindUniformBuffer(this._buffer, name);
  67397. };
  67398. /**
  67399. * Disposes the uniform buffer.
  67400. */
  67401. UniformBuffer.prototype.dispose = function () {
  67402. if (this._noUBO) {
  67403. return;
  67404. }
  67405. var uniformBuffers = this._engine._uniformBuffers;
  67406. var index = uniformBuffers.indexOf(this);
  67407. if (index !== -1) {
  67408. uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];
  67409. uniformBuffers.pop();
  67410. }
  67411. if (!this._buffer) {
  67412. return;
  67413. }
  67414. if (this._engine._releaseBuffer(this._buffer)) {
  67415. this._buffer = null;
  67416. }
  67417. };
  67418. // Pool for avoiding memory leaks
  67419. UniformBuffer._MAX_UNIFORM_SIZE = 256;
  67420. UniformBuffer._tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
  67421. return UniformBuffer;
  67422. }());
  67423. /***/ }),
  67424. /***/ "./Maths/index.ts":
  67425. /*!************************!*\
  67426. !*** ./Maths/index.ts ***!
  67427. \************************/
  67428. /*! 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 */
  67429. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67430. "use strict";
  67431. __webpack_require__.r(__webpack_exports__);
  67432. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  67433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  67434. /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ "./Maths/math.ts");
  67435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]; });
  67436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]; });
  67437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; });
  67438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  67439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  67440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]; });
  67441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]; });
  67442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]; });
  67443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Size"]; });
  67444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]; });
  67445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]; });
  67446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Plane"]; });
  67447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Viewport"]; });
  67448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Frustum"]; });
  67449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Space"]; });
  67450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Axis"]; });
  67451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"]; });
  67452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Orientation"]; });
  67453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Angle"]; });
  67454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Arc2"]; });
  67455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path2"]; });
  67456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path3D"]; });
  67457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Curve3"]; });
  67458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalVertex"]; });
  67459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalTextureVertex"]; });
  67460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Tmp"]; });
  67461. /* harmony import */ var _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  67462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"]; });
  67463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]; });
  67464. /***/ }),
  67465. /***/ "./Maths/math.scalar.ts":
  67466. /*!******************************!*\
  67467. !*** ./Maths/math.scalar.ts ***!
  67468. \******************************/
  67469. /*! exports provided: Scalar */
  67470. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67471. "use strict";
  67472. __webpack_require__.r(__webpack_exports__);
  67473. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return Scalar; });
  67474. /**
  67475. * Scalar computation library
  67476. */
  67477. var Scalar = /** @class */ (function () {
  67478. function Scalar() {
  67479. }
  67480. /**
  67481. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67482. * @param a number
  67483. * @param b number
  67484. * @param epsilon (default = 1.401298E-45)
  67485. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67486. */
  67487. Scalar.WithinEpsilon = function (a, b, epsilon) {
  67488. if (epsilon === void 0) { epsilon = 1.401298E-45; }
  67489. var num = a - b;
  67490. return -epsilon <= num && num <= epsilon;
  67491. };
  67492. /**
  67493. * Returns a string : the upper case translation of the number i to hexadecimal.
  67494. * @param i number
  67495. * @returns the upper case translation of the number i to hexadecimal.
  67496. */
  67497. Scalar.ToHex = function (i) {
  67498. var str = i.toString(16);
  67499. if (i <= 15) {
  67500. return ("0" + str).toUpperCase();
  67501. }
  67502. return str.toUpperCase();
  67503. };
  67504. /**
  67505. * Returns -1 if value is negative and +1 is value is positive.
  67506. * @param value the value
  67507. * @returns the value itself if it's equal to zero.
  67508. */
  67509. Scalar.Sign = function (value) {
  67510. value = +value; // convert to a number
  67511. if (value === 0 || isNaN(value)) {
  67512. return value;
  67513. }
  67514. return value > 0 ? 1 : -1;
  67515. };
  67516. /**
  67517. * Returns the value itself if it's between min and max.
  67518. * Returns min if the value is lower than min.
  67519. * Returns max if the value is greater than max.
  67520. * @param value the value to clmap
  67521. * @param min the min value to clamp to (default: 0)
  67522. * @param max the max value to clamp to (default: 1)
  67523. * @returns the clamped value
  67524. */
  67525. Scalar.Clamp = function (value, min, max) {
  67526. if (min === void 0) { min = 0; }
  67527. if (max === void 0) { max = 1; }
  67528. return Math.min(max, Math.max(min, value));
  67529. };
  67530. /**
  67531. * the log2 of value.
  67532. * @param value the value to compute log2 of
  67533. * @returns the log2 of value.
  67534. */
  67535. Scalar.Log2 = function (value) {
  67536. return Math.log(value) * Math.LOG2E;
  67537. };
  67538. /**
  67539. * Loops the value, so that it is never larger than length and never smaller than 0.
  67540. *
  67541. * This is similar to the modulo operator but it works with floating point numbers.
  67542. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  67543. * With t = 5 and length = 2.5, the result would be 0.0.
  67544. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  67545. * @param value the value
  67546. * @param length the length
  67547. * @returns the looped value
  67548. */
  67549. Scalar.Repeat = function (value, length) {
  67550. return value - Math.floor(value / length) * length;
  67551. };
  67552. /**
  67553. * Normalize the value between 0.0 and 1.0 using min and max values
  67554. * @param value value to normalize
  67555. * @param min max to normalize between
  67556. * @param max min to normalize between
  67557. * @returns the normalized value
  67558. */
  67559. Scalar.Normalize = function (value, min, max) {
  67560. return (value - min) / (max - min);
  67561. };
  67562. /**
  67563. * Denormalize the value from 0.0 and 1.0 using min and max values
  67564. * @param normalized value to denormalize
  67565. * @param min max to denormalize between
  67566. * @param max min to denormalize between
  67567. * @returns the denormalized value
  67568. */
  67569. Scalar.Denormalize = function (normalized, min, max) {
  67570. return (normalized * (max - min) + min);
  67571. };
  67572. /**
  67573. * Calculates the shortest difference between two given angles given in degrees.
  67574. * @param current current angle in degrees
  67575. * @param target target angle in degrees
  67576. * @returns the delta
  67577. */
  67578. Scalar.DeltaAngle = function (current, target) {
  67579. var num = Scalar.Repeat(target - current, 360.0);
  67580. if (num > 180.0) {
  67581. num -= 360.0;
  67582. }
  67583. return num;
  67584. };
  67585. /**
  67586. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  67587. * @param tx value
  67588. * @param length length
  67589. * @returns The returned value will move back and forth between 0 and length
  67590. */
  67591. Scalar.PingPong = function (tx, length) {
  67592. var t = Scalar.Repeat(tx, length * 2.0);
  67593. return length - Math.abs(t - length);
  67594. };
  67595. /**
  67596. * Interpolates between min and max with smoothing at the limits.
  67597. *
  67598. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  67599. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  67600. * @param from from
  67601. * @param to to
  67602. * @param tx value
  67603. * @returns the smooth stepped value
  67604. */
  67605. Scalar.SmoothStep = function (from, to, tx) {
  67606. var t = Scalar.Clamp(tx);
  67607. t = -2.0 * t * t * t + 3.0 * t * t;
  67608. return to * t + from * (1.0 - t);
  67609. };
  67610. /**
  67611. * Moves a value current towards target.
  67612. *
  67613. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  67614. * Negative values of maxDelta pushes the value away from target.
  67615. * @param current current value
  67616. * @param target target value
  67617. * @param maxDelta max distance to move
  67618. * @returns resulting value
  67619. */
  67620. Scalar.MoveTowards = function (current, target, maxDelta) {
  67621. var result = 0;
  67622. if (Math.abs(target - current) <= maxDelta) {
  67623. result = target;
  67624. }
  67625. else {
  67626. result = current + Scalar.Sign(target - current) * maxDelta;
  67627. }
  67628. return result;
  67629. };
  67630. /**
  67631. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67632. *
  67633. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  67634. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  67635. * @param current current value
  67636. * @param target target value
  67637. * @param maxDelta max distance to move
  67638. * @returns resulting angle
  67639. */
  67640. Scalar.MoveTowardsAngle = function (current, target, maxDelta) {
  67641. var num = Scalar.DeltaAngle(current, target);
  67642. var result = 0;
  67643. if (-maxDelta < num && num < maxDelta) {
  67644. result = target;
  67645. }
  67646. else {
  67647. target = current + num;
  67648. result = Scalar.MoveTowards(current, target, maxDelta);
  67649. }
  67650. return result;
  67651. };
  67652. /**
  67653. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  67654. * @param start start value
  67655. * @param end target value
  67656. * @param amount amount to lerp between
  67657. * @returns the lerped value
  67658. */
  67659. Scalar.Lerp = function (start, end, amount) {
  67660. return start + ((end - start) * amount);
  67661. };
  67662. /**
  67663. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67664. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  67665. * @param start start value
  67666. * @param end target value
  67667. * @param amount amount to lerp between
  67668. * @returns the lerped value
  67669. */
  67670. Scalar.LerpAngle = function (start, end, amount) {
  67671. var num = Scalar.Repeat(end - start, 360.0);
  67672. if (num > 180.0) {
  67673. num -= 360.0;
  67674. }
  67675. return start + num * Scalar.Clamp(amount);
  67676. };
  67677. /**
  67678. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  67679. * @param a start value
  67680. * @param b target value
  67681. * @param value value between a and b
  67682. * @returns the inverseLerp value
  67683. */
  67684. Scalar.InverseLerp = function (a, b, value) {
  67685. var result = 0;
  67686. if (a != b) {
  67687. result = Scalar.Clamp((value - a) / (b - a));
  67688. }
  67689. else {
  67690. result = 0.0;
  67691. }
  67692. return result;
  67693. };
  67694. /**
  67695. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  67696. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  67697. * @param value1 spline value
  67698. * @param tangent1 spline value
  67699. * @param value2 spline value
  67700. * @param tangent2 spline value
  67701. * @param amount input value
  67702. * @returns hermite result
  67703. */
  67704. Scalar.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  67705. var squared = amount * amount;
  67706. var cubed = amount * squared;
  67707. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  67708. var part2 = (-2.0 * cubed) + (3.0 * squared);
  67709. var part3 = (cubed - (2.0 * squared)) + amount;
  67710. var part4 = cubed - squared;
  67711. return (((value1 * part1) + (value2 * part2)) + (tangent1 * part3)) + (tangent2 * part4);
  67712. };
  67713. /**
  67714. * Returns a random float number between and min and max values
  67715. * @param min min value of random
  67716. * @param max max value of random
  67717. * @returns random value
  67718. */
  67719. Scalar.RandomRange = function (min, max) {
  67720. if (min === max) {
  67721. return min;
  67722. }
  67723. return ((Math.random() * (max - min)) + min);
  67724. };
  67725. /**
  67726. * This function returns percentage of a number in a given range.
  67727. *
  67728. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67729. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67730. * @param number to convert to percentage
  67731. * @param min min range
  67732. * @param max max range
  67733. * @returns the percentage
  67734. */
  67735. Scalar.RangeToPercent = function (number, min, max) {
  67736. return ((number - min) / (max - min));
  67737. };
  67738. /**
  67739. * This function returns number that corresponds to the percentage in a given range.
  67740. *
  67741. * PercentToRange(0.34,0,100) will return 34.
  67742. * @param percent to convert to number
  67743. * @param min min range
  67744. * @param max max range
  67745. * @returns the number
  67746. */
  67747. Scalar.PercentToRange = function (percent, min, max) {
  67748. return ((max - min) * percent + min);
  67749. };
  67750. /**
  67751. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67752. * @param angle The angle to normalize in radian.
  67753. * @return The converted angle.
  67754. */
  67755. Scalar.NormalizeRadians = function (angle) {
  67756. // More precise but slower version kept for reference.
  67757. // angle = angle % Tools.TwoPi;
  67758. // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
  67759. //if (angle > Math.PI) {
  67760. // angle -= Tools.TwoPi;
  67761. //}
  67762. angle -= (Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi));
  67763. return angle;
  67764. };
  67765. /**
  67766. * Two pi constants convenient for computation.
  67767. */
  67768. Scalar.TwoPi = Math.PI * 2;
  67769. return Scalar;
  67770. }());
  67771. /***/ }),
  67772. /***/ "./Maths/math.ts":
  67773. /*!***********************!*\
  67774. !*** ./Maths/math.ts ***!
  67775. \***********************/
  67776. /*! 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 */
  67777. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67778. "use strict";
  67779. __webpack_require__.r(__webpack_exports__);
  67780. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return ToGammaSpace; });
  67781. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return ToLinearSpace; });
  67782. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return Epsilon; });
  67783. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return Color3; });
  67784. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return Color4; });
  67785. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return Vector2; });
  67786. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return Vector3; });
  67787. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return Vector4; });
  67788. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return Size; });
  67789. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return Quaternion; });
  67790. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
  67791. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return Plane; });
  67792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return Viewport; });
  67793. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return Frustum; });
  67794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return Space; });
  67795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return Axis; });
  67796. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return BezierCurve; });
  67797. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return Orientation; });
  67798. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return Angle; });
  67799. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return Arc2; });
  67800. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return Path2; });
  67801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return Path3D; });
  67802. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return Curve3; });
  67803. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return PositionNormalVertex; });
  67804. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return PositionNormalTextureVertex; });
  67805. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return Tmp; });
  67806. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  67807. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  67808. /**
  67809. * Constant used to convert a value to gamma space
  67810. * @ignorenaming
  67811. */
  67812. var ToGammaSpace = 1 / 2.2;
  67813. /**
  67814. * Constant used to convert a value to linear space
  67815. * @ignorenaming
  67816. */
  67817. var ToLinearSpace = 2.2;
  67818. /**
  67819. * Constant used to define the minimal number value in Babylon.js
  67820. * @ignorenaming
  67821. */
  67822. var Epsilon = 0.001;
  67823. /**
  67824. * Class used to hold a RBG color
  67825. */
  67826. var Color3 = /** @class */ (function () {
  67827. /**
  67828. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  67829. * @param r defines the red component (between 0 and 1, default is 0)
  67830. * @param g defines the green component (between 0 and 1, default is 0)
  67831. * @param b defines the blue component (between 0 and 1, default is 0)
  67832. */
  67833. function Color3(
  67834. /**
  67835. * Defines the red component (between 0 and 1, default is 0)
  67836. */
  67837. r,
  67838. /**
  67839. * Defines the green component (between 0 and 1, default is 0)
  67840. */
  67841. g,
  67842. /**
  67843. * Defines the blue component (between 0 and 1, default is 0)
  67844. */
  67845. b) {
  67846. if (r === void 0) { r = 0; }
  67847. if (g === void 0) { g = 0; }
  67848. if (b === void 0) { b = 0; }
  67849. this.r = r;
  67850. this.g = g;
  67851. this.b = b;
  67852. }
  67853. /**
  67854. * Creates a string with the Color3 current values
  67855. * @returns the string representation of the Color3 object
  67856. */
  67857. Color3.prototype.toString = function () {
  67858. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
  67859. };
  67860. /**
  67861. * Returns the string "Color3"
  67862. * @returns "Color3"
  67863. */
  67864. Color3.prototype.getClassName = function () {
  67865. return "Color3";
  67866. };
  67867. /**
  67868. * Compute the Color3 hash code
  67869. * @returns an unique number that can be used to hash Color3 objects
  67870. */
  67871. Color3.prototype.getHashCode = function () {
  67872. var hash = this.r || 0;
  67873. hash = (hash * 397) ^ (this.g || 0);
  67874. hash = (hash * 397) ^ (this.b || 0);
  67875. return hash;
  67876. };
  67877. // Operators
  67878. /**
  67879. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  67880. * @param array defines the array where to store the r,g,b components
  67881. * @param index defines an optional index in the target array to define where to start storing values
  67882. * @returns the current Color3 object
  67883. */
  67884. Color3.prototype.toArray = function (array, index) {
  67885. if (index === void 0) { index = 0; }
  67886. array[index] = this.r;
  67887. array[index + 1] = this.g;
  67888. array[index + 2] = this.b;
  67889. return this;
  67890. };
  67891. /**
  67892. * Returns a new Color4 object from the current Color3 and the given alpha
  67893. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  67894. * @returns a new Color4 object
  67895. */
  67896. Color3.prototype.toColor4 = function (alpha) {
  67897. if (alpha === void 0) { alpha = 1; }
  67898. return new Color4(this.r, this.g, this.b, alpha);
  67899. };
  67900. /**
  67901. * Returns a new array populated with 3 numeric elements : red, green and blue values
  67902. * @returns the new array
  67903. */
  67904. Color3.prototype.asArray = function () {
  67905. var result = new Array();
  67906. this.toArray(result, 0);
  67907. return result;
  67908. };
  67909. /**
  67910. * Returns the luminance value
  67911. * @returns a float value
  67912. */
  67913. Color3.prototype.toLuminance = function () {
  67914. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  67915. };
  67916. /**
  67917. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  67918. * @param otherColor defines the second operand
  67919. * @returns the new Color3 object
  67920. */
  67921. Color3.prototype.multiply = function (otherColor) {
  67922. return new Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
  67923. };
  67924. /**
  67925. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  67926. * @param otherColor defines the second operand
  67927. * @param result defines the Color3 object where to store the result
  67928. * @returns the current Color3
  67929. */
  67930. Color3.prototype.multiplyToRef = function (otherColor, result) {
  67931. result.r = this.r * otherColor.r;
  67932. result.g = this.g * otherColor.g;
  67933. result.b = this.b * otherColor.b;
  67934. return this;
  67935. };
  67936. /**
  67937. * Determines equality between Color3 objects
  67938. * @param otherColor defines the second operand
  67939. * @returns true if the rgb values are equal to the given ones
  67940. */
  67941. Color3.prototype.equals = function (otherColor) {
  67942. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
  67943. };
  67944. /**
  67945. * Determines equality between the current Color3 object and a set of r,b,g values
  67946. * @param r defines the red component to check
  67947. * @param g defines the green component to check
  67948. * @param b defines the blue component to check
  67949. * @returns true if the rgb values are equal to the given ones
  67950. */
  67951. Color3.prototype.equalsFloats = function (r, g, b) {
  67952. return this.r === r && this.g === g && this.b === b;
  67953. };
  67954. /**
  67955. * Multiplies in place each rgb value by scale
  67956. * @param scale defines the scaling factor
  67957. * @returns the updated Color3
  67958. */
  67959. Color3.prototype.scale = function (scale) {
  67960. return new Color3(this.r * scale, this.g * scale, this.b * scale);
  67961. };
  67962. /**
  67963. * Multiplies the rgb values by scale and stores the result into "result"
  67964. * @param scale defines the scaling factor
  67965. * @param result defines the Color3 object where to store the result
  67966. * @returns the unmodified current Color3
  67967. */
  67968. Color3.prototype.scaleToRef = function (scale, result) {
  67969. result.r = this.r * scale;
  67970. result.g = this.g * scale;
  67971. result.b = this.b * scale;
  67972. return this;
  67973. };
  67974. /**
  67975. * Scale the current Color3 values by a factor and add the result to a given Color3
  67976. * @param scale defines the scale factor
  67977. * @param result defines color to store the result into
  67978. * @returns the unmodified current Color3
  67979. */
  67980. Color3.prototype.scaleAndAddToRef = function (scale, result) {
  67981. result.r += this.r * scale;
  67982. result.g += this.g * scale;
  67983. result.b += this.b * scale;
  67984. return this;
  67985. };
  67986. /**
  67987. * Clamps the rgb values by the min and max values and stores the result into "result"
  67988. * @param min defines minimum clamping value (default is 0)
  67989. * @param max defines maximum clamping value (default is 1)
  67990. * @param result defines color to store the result into
  67991. * @returns the original Color3
  67992. */
  67993. Color3.prototype.clampToRef = function (min, max, result) {
  67994. if (min === void 0) { min = 0; }
  67995. if (max === void 0) { max = 1; }
  67996. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  67997. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  67998. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  67999. return this;
  68000. };
  68001. /**
  68002. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  68003. * @param otherColor defines the second operand
  68004. * @returns the new Color3
  68005. */
  68006. Color3.prototype.add = function (otherColor) {
  68007. return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
  68008. };
  68009. /**
  68010. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  68011. * @param otherColor defines the second operand
  68012. * @param result defines Color3 object to store the result into
  68013. * @returns the unmodified current Color3
  68014. */
  68015. Color3.prototype.addToRef = function (otherColor, result) {
  68016. result.r = this.r + otherColor.r;
  68017. result.g = this.g + otherColor.g;
  68018. result.b = this.b + otherColor.b;
  68019. return this;
  68020. };
  68021. /**
  68022. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  68023. * @param otherColor defines the second operand
  68024. * @returns the new Color3
  68025. */
  68026. Color3.prototype.subtract = function (otherColor) {
  68027. return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
  68028. };
  68029. /**
  68030. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  68031. * @param otherColor defines the second operand
  68032. * @param result defines Color3 object to store the result into
  68033. * @returns the unmodified current Color3
  68034. */
  68035. Color3.prototype.subtractToRef = function (otherColor, result) {
  68036. result.r = this.r - otherColor.r;
  68037. result.g = this.g - otherColor.g;
  68038. result.b = this.b - otherColor.b;
  68039. return this;
  68040. };
  68041. /**
  68042. * Copy the current object
  68043. * @returns a new Color3 copied the current one
  68044. */
  68045. Color3.prototype.clone = function () {
  68046. return new Color3(this.r, this.g, this.b);
  68047. };
  68048. /**
  68049. * Copies the rgb values from the source in the current Color3
  68050. * @param source defines the source Color3 object
  68051. * @returns the updated Color3 object
  68052. */
  68053. Color3.prototype.copyFrom = function (source) {
  68054. this.r = source.r;
  68055. this.g = source.g;
  68056. this.b = source.b;
  68057. return this;
  68058. };
  68059. /**
  68060. * Updates the Color3 rgb values from the given floats
  68061. * @param r defines the red component to read from
  68062. * @param g defines the green component to read from
  68063. * @param b defines the blue component to read from
  68064. * @returns the current Color3 object
  68065. */
  68066. Color3.prototype.copyFromFloats = function (r, g, b) {
  68067. this.r = r;
  68068. this.g = g;
  68069. this.b = b;
  68070. return this;
  68071. };
  68072. /**
  68073. * Updates the Color3 rgb values from the given floats
  68074. * @param r defines the red component to read from
  68075. * @param g defines the green component to read from
  68076. * @param b defines the blue component to read from
  68077. * @returns the current Color3 object
  68078. */
  68079. Color3.prototype.set = function (r, g, b) {
  68080. return this.copyFromFloats(r, g, b);
  68081. };
  68082. /**
  68083. * Compute the Color3 hexadecimal code as a string
  68084. * @returns a string containing the hexadecimal representation of the Color3 object
  68085. */
  68086. Color3.prototype.toHexString = function () {
  68087. var intR = (this.r * 255) | 0;
  68088. var intG = (this.g * 255) | 0;
  68089. var intB = (this.b * 255) | 0;
  68090. 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);
  68091. };
  68092. /**
  68093. * Computes a new Color3 converted from the current one to linear space
  68094. * @returns a new Color3 object
  68095. */
  68096. Color3.prototype.toLinearSpace = function () {
  68097. var convertedColor = new Color3();
  68098. this.toLinearSpaceToRef(convertedColor);
  68099. return convertedColor;
  68100. };
  68101. /**
  68102. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  68103. * @param convertedColor defines the Color3 object where to store the linear space version
  68104. * @returns the unmodified Color3
  68105. */
  68106. Color3.prototype.toLinearSpaceToRef = function (convertedColor) {
  68107. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  68108. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  68109. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  68110. return this;
  68111. };
  68112. /**
  68113. * Computes a new Color3 converted from the current one to gamma space
  68114. * @returns a new Color3 object
  68115. */
  68116. Color3.prototype.toGammaSpace = function () {
  68117. var convertedColor = new Color3();
  68118. this.toGammaSpaceToRef(convertedColor);
  68119. return convertedColor;
  68120. };
  68121. /**
  68122. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  68123. * @param convertedColor defines the Color3 object where to store the gamma space version
  68124. * @returns the unmodified Color3
  68125. */
  68126. Color3.prototype.toGammaSpaceToRef = function (convertedColor) {
  68127. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  68128. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  68129. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  68130. return this;
  68131. };
  68132. /**
  68133. * Creates a new Color3 from the string containing valid hexadecimal values
  68134. * @param hex defines a string containing valid hexadecimal values
  68135. * @returns a new Color3 object
  68136. */
  68137. Color3.FromHexString = function (hex) {
  68138. if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
  68139. return new Color3(0, 0, 0);
  68140. }
  68141. var r = parseInt(hex.substring(1, 3), 16);
  68142. var g = parseInt(hex.substring(3, 5), 16);
  68143. var b = parseInt(hex.substring(5, 7), 16);
  68144. return Color3.FromInts(r, g, b);
  68145. };
  68146. /**
  68147. * Creates a new Vector3 from the starting index of the given array
  68148. * @param array defines the source array
  68149. * @param offset defines an offset in the source array
  68150. * @returns a new Color3 object
  68151. */
  68152. Color3.FromArray = function (array, offset) {
  68153. if (offset === void 0) { offset = 0; }
  68154. return new Color3(array[offset], array[offset + 1], array[offset + 2]);
  68155. };
  68156. /**
  68157. * Creates a new Color3 from integer values (< 256)
  68158. * @param r defines the red component to read from (value between 0 and 255)
  68159. * @param g defines the green component to read from (value between 0 and 255)
  68160. * @param b defines the blue component to read from (value between 0 and 255)
  68161. * @returns a new Color3 object
  68162. */
  68163. Color3.FromInts = function (r, g, b) {
  68164. return new Color3(r / 255.0, g / 255.0, b / 255.0);
  68165. };
  68166. /**
  68167. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68168. * @param start defines the start Color3 value
  68169. * @param end defines the end Color3 value
  68170. * @param amount defines the gradient value between start and end
  68171. * @returns a new Color3 object
  68172. */
  68173. Color3.Lerp = function (start, end, amount) {
  68174. var result = new Color3(0.0, 0.0, 0.0);
  68175. Color3.LerpToRef(start, end, amount, result);
  68176. return result;
  68177. };
  68178. /**
  68179. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68180. * @param left defines the start value
  68181. * @param right defines the end value
  68182. * @param amount defines the gradient factor
  68183. * @param result defines the Color3 object where to store the result
  68184. */
  68185. Color3.LerpToRef = function (left, right, amount, result) {
  68186. result.r = left.r + ((right.r - left.r) * amount);
  68187. result.g = left.g + ((right.g - left.g) * amount);
  68188. result.b = left.b + ((right.b - left.b) * amount);
  68189. };
  68190. /**
  68191. * Returns a Color3 value containing a red color
  68192. * @returns a new Color3 object
  68193. */
  68194. Color3.Red = function () { return new Color3(1, 0, 0); };
  68195. /**
  68196. * Returns a Color3 value containing a green color
  68197. * @returns a new Color3 object
  68198. */
  68199. Color3.Green = function () { return new Color3(0, 1, 0); };
  68200. /**
  68201. * Returns a Color3 value containing a blue color
  68202. * @returns a new Color3 object
  68203. */
  68204. Color3.Blue = function () { return new Color3(0, 0, 1); };
  68205. /**
  68206. * Returns a Color3 value containing a black color
  68207. * @returns a new Color3 object
  68208. */
  68209. Color3.Black = function () { return new Color3(0, 0, 0); };
  68210. Object.defineProperty(Color3, "BlackReadOnly", {
  68211. /**
  68212. * Gets a Color3 value containing a black color that must not be updated
  68213. */
  68214. get: function () {
  68215. return Color3._BlackReadOnly;
  68216. },
  68217. enumerable: true,
  68218. configurable: true
  68219. });
  68220. /**
  68221. * Returns a Color3 value containing a white color
  68222. * @returns a new Color3 object
  68223. */
  68224. Color3.White = function () { return new Color3(1, 1, 1); };
  68225. /**
  68226. * Returns a Color3 value containing a purple color
  68227. * @returns a new Color3 object
  68228. */
  68229. Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
  68230. /**
  68231. * Returns a Color3 value containing a magenta color
  68232. * @returns a new Color3 object
  68233. */
  68234. Color3.Magenta = function () { return new Color3(1, 0, 1); };
  68235. /**
  68236. * Returns a Color3 value containing a yellow color
  68237. * @returns a new Color3 object
  68238. */
  68239. Color3.Yellow = function () { return new Color3(1, 1, 0); };
  68240. /**
  68241. * Returns a Color3 value containing a gray color
  68242. * @returns a new Color3 object
  68243. */
  68244. Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
  68245. /**
  68246. * Returns a Color3 value containing a teal color
  68247. * @returns a new Color3 object
  68248. */
  68249. Color3.Teal = function () { return new Color3(0, 1.0, 1.0); };
  68250. /**
  68251. * Returns a Color3 value containing a random color
  68252. * @returns a new Color3 object
  68253. */
  68254. Color3.Random = function () { return new Color3(Math.random(), Math.random(), Math.random()); };
  68255. // Statics
  68256. Color3._BlackReadOnly = Color3.Black();
  68257. return Color3;
  68258. }());
  68259. /**
  68260. * Class used to hold a RBGA color
  68261. */
  68262. var Color4 = /** @class */ (function () {
  68263. /**
  68264. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  68265. * @param r defines the red component (between 0 and 1, default is 0)
  68266. * @param g defines the green component (between 0 and 1, default is 0)
  68267. * @param b defines the blue component (between 0 and 1, default is 0)
  68268. * @param a defines the alpha component (between 0 and 1, default is 1)
  68269. */
  68270. function Color4(
  68271. /**
  68272. * Defines the red component (between 0 and 1, default is 0)
  68273. */
  68274. r,
  68275. /**
  68276. * Defines the green component (between 0 and 1, default is 0)
  68277. */
  68278. g,
  68279. /**
  68280. * Defines the blue component (between 0 and 1, default is 0)
  68281. */
  68282. b,
  68283. /**
  68284. * Defines the alpha component (between 0 and 1, default is 1)
  68285. */
  68286. a) {
  68287. if (r === void 0) { r = 0; }
  68288. if (g === void 0) { g = 0; }
  68289. if (b === void 0) { b = 0; }
  68290. if (a === void 0) { a = 1; }
  68291. this.r = r;
  68292. this.g = g;
  68293. this.b = b;
  68294. this.a = a;
  68295. }
  68296. // Operators
  68297. /**
  68298. * Adds in place the given Color4 values to the current Color4 object
  68299. * @param right defines the second operand
  68300. * @returns the current updated Color4 object
  68301. */
  68302. Color4.prototype.addInPlace = function (right) {
  68303. this.r += right.r;
  68304. this.g += right.g;
  68305. this.b += right.b;
  68306. this.a += right.a;
  68307. return this;
  68308. };
  68309. /**
  68310. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  68311. * @returns the new array
  68312. */
  68313. Color4.prototype.asArray = function () {
  68314. var result = new Array();
  68315. this.toArray(result, 0);
  68316. return result;
  68317. };
  68318. /**
  68319. * Stores from the starting index in the given array the Color4 successive values
  68320. * @param array defines the array where to store the r,g,b components
  68321. * @param index defines an optional index in the target array to define where to start storing values
  68322. * @returns the current Color4 object
  68323. */
  68324. Color4.prototype.toArray = function (array, index) {
  68325. if (index === void 0) { index = 0; }
  68326. array[index] = this.r;
  68327. array[index + 1] = this.g;
  68328. array[index + 2] = this.b;
  68329. array[index + 3] = this.a;
  68330. return this;
  68331. };
  68332. /**
  68333. * Determines equality between Color4 objects
  68334. * @param otherColor defines the second operand
  68335. * @returns true if the rgba values are equal to the given ones
  68336. */
  68337. Color4.prototype.equals = function (otherColor) {
  68338. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.a === otherColor.a;
  68339. };
  68340. /**
  68341. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  68342. * @param right defines the second operand
  68343. * @returns a new Color4 object
  68344. */
  68345. Color4.prototype.add = function (right) {
  68346. return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
  68347. };
  68348. /**
  68349. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  68350. * @param right defines the second operand
  68351. * @returns a new Color4 object
  68352. */
  68353. Color4.prototype.subtract = function (right) {
  68354. return new Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
  68355. };
  68356. /**
  68357. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  68358. * @param right defines the second operand
  68359. * @param result defines the Color4 object where to store the result
  68360. * @returns the current Color4 object
  68361. */
  68362. Color4.prototype.subtractToRef = function (right, result) {
  68363. result.r = this.r - right.r;
  68364. result.g = this.g - right.g;
  68365. result.b = this.b - right.b;
  68366. result.a = this.a - right.a;
  68367. return this;
  68368. };
  68369. /**
  68370. * Creates a new Color4 with the current Color4 values multiplied by scale
  68371. * @param scale defines the scaling factor to apply
  68372. * @returns a new Color4 object
  68373. */
  68374. Color4.prototype.scale = function (scale) {
  68375. return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
  68376. };
  68377. /**
  68378. * Multiplies the current Color4 values by scale and stores the result in "result"
  68379. * @param scale defines the scaling factor to apply
  68380. * @param result defines the Color4 object where to store the result
  68381. * @returns the current unmodified Color4
  68382. */
  68383. Color4.prototype.scaleToRef = function (scale, result) {
  68384. result.r = this.r * scale;
  68385. result.g = this.g * scale;
  68386. result.b = this.b * scale;
  68387. result.a = this.a * scale;
  68388. return this;
  68389. };
  68390. /**
  68391. * Scale the current Color4 values by a factor and add the result to a given Color4
  68392. * @param scale defines the scale factor
  68393. * @param result defines the Color4 object where to store the result
  68394. * @returns the unmodified current Color4
  68395. */
  68396. Color4.prototype.scaleAndAddToRef = function (scale, result) {
  68397. result.r += this.r * scale;
  68398. result.g += this.g * scale;
  68399. result.b += this.b * scale;
  68400. result.a += this.a * scale;
  68401. return this;
  68402. };
  68403. /**
  68404. * Clamps the rgb values by the min and max values and stores the result into "result"
  68405. * @param min defines minimum clamping value (default is 0)
  68406. * @param max defines maximum clamping value (default is 1)
  68407. * @param result defines color to store the result into.
  68408. * @returns the cuurent Color4
  68409. */
  68410. Color4.prototype.clampToRef = function (min, max, result) {
  68411. if (min === void 0) { min = 0; }
  68412. if (max === void 0) { max = 1; }
  68413. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  68414. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  68415. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  68416. result.a = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.a, min, max);
  68417. return this;
  68418. };
  68419. /**
  68420. * Multipy an Color4 value by another and return a new Color4 object
  68421. * @param color defines the Color4 value to multiply by
  68422. * @returns a new Color4 object
  68423. */
  68424. Color4.prototype.multiply = function (color) {
  68425. return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
  68426. };
  68427. /**
  68428. * Multipy a Color4 value by another and push the result in a reference value
  68429. * @param color defines the Color4 value to multiply by
  68430. * @param result defines the Color4 to fill the result in
  68431. * @returns the result Color4
  68432. */
  68433. Color4.prototype.multiplyToRef = function (color, result) {
  68434. result.r = this.r * color.r;
  68435. result.g = this.g * color.g;
  68436. result.b = this.b * color.b;
  68437. result.a = this.a * color.a;
  68438. return result;
  68439. };
  68440. /**
  68441. * Creates a string with the Color4 current values
  68442. * @returns the string representation of the Color4 object
  68443. */
  68444. Color4.prototype.toString = function () {
  68445. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
  68446. };
  68447. /**
  68448. * Returns the string "Color4"
  68449. * @returns "Color4"
  68450. */
  68451. Color4.prototype.getClassName = function () {
  68452. return "Color4";
  68453. };
  68454. /**
  68455. * Compute the Color4 hash code
  68456. * @returns an unique number that can be used to hash Color4 objects
  68457. */
  68458. Color4.prototype.getHashCode = function () {
  68459. var hash = this.r || 0;
  68460. hash = (hash * 397) ^ (this.g || 0);
  68461. hash = (hash * 397) ^ (this.b || 0);
  68462. hash = (hash * 397) ^ (this.a || 0);
  68463. return hash;
  68464. };
  68465. /**
  68466. * Creates a new Color4 copied from the current one
  68467. * @returns a new Color4 object
  68468. */
  68469. Color4.prototype.clone = function () {
  68470. return new Color4(this.r, this.g, this.b, this.a);
  68471. };
  68472. /**
  68473. * Copies the given Color4 values into the current one
  68474. * @param source defines the source Color4 object
  68475. * @returns the current updated Color4 object
  68476. */
  68477. Color4.prototype.copyFrom = function (source) {
  68478. this.r = source.r;
  68479. this.g = source.g;
  68480. this.b = source.b;
  68481. this.a = source.a;
  68482. return this;
  68483. };
  68484. /**
  68485. * Copies the given float values into the current one
  68486. * @param r defines the red component to read from
  68487. * @param g defines the green component to read from
  68488. * @param b defines the blue component to read from
  68489. * @param a defines the alpha component to read from
  68490. * @returns the current updated Color4 object
  68491. */
  68492. Color4.prototype.copyFromFloats = function (r, g, b, a) {
  68493. this.r = r;
  68494. this.g = g;
  68495. this.b = b;
  68496. this.a = a;
  68497. return this;
  68498. };
  68499. /**
  68500. * Copies the given float values into the current one
  68501. * @param r defines the red component to read from
  68502. * @param g defines the green component to read from
  68503. * @param b defines the blue component to read from
  68504. * @param a defines the alpha component to read from
  68505. * @returns the current updated Color4 object
  68506. */
  68507. Color4.prototype.set = function (r, g, b, a) {
  68508. return this.copyFromFloats(r, g, b, a);
  68509. };
  68510. /**
  68511. * Compute the Color4 hexadecimal code as a string
  68512. * @returns a string containing the hexadecimal representation of the Color4 object
  68513. */
  68514. Color4.prototype.toHexString = function () {
  68515. var intR = (this.r * 255) | 0;
  68516. var intG = (this.g * 255) | 0;
  68517. var intB = (this.b * 255) | 0;
  68518. var intA = (this.a * 255) | 0;
  68519. 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);
  68520. };
  68521. /**
  68522. * Computes a new Color4 converted from the current one to linear space
  68523. * @returns a new Color4 object
  68524. */
  68525. Color4.prototype.toLinearSpace = function () {
  68526. var convertedColor = new Color4();
  68527. this.toLinearSpaceToRef(convertedColor);
  68528. return convertedColor;
  68529. };
  68530. /**
  68531. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  68532. * @param convertedColor defines the Color4 object where to store the linear space version
  68533. * @returns the unmodified Color4
  68534. */
  68535. Color4.prototype.toLinearSpaceToRef = function (convertedColor) {
  68536. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  68537. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  68538. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  68539. convertedColor.a = this.a;
  68540. return this;
  68541. };
  68542. /**
  68543. * Computes a new Color4 converted from the current one to gamma space
  68544. * @returns a new Color4 object
  68545. */
  68546. Color4.prototype.toGammaSpace = function () {
  68547. var convertedColor = new Color4();
  68548. this.toGammaSpaceToRef(convertedColor);
  68549. return convertedColor;
  68550. };
  68551. /**
  68552. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  68553. * @param convertedColor defines the Color4 object where to store the gamma space version
  68554. * @returns the unmodified Color4
  68555. */
  68556. Color4.prototype.toGammaSpaceToRef = function (convertedColor) {
  68557. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  68558. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  68559. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  68560. convertedColor.a = this.a;
  68561. return this;
  68562. };
  68563. // Statics
  68564. /**
  68565. * Creates a new Color4 from the string containing valid hexadecimal values
  68566. * @param hex defines a string containing valid hexadecimal values
  68567. * @returns a new Color4 object
  68568. */
  68569. Color4.FromHexString = function (hex) {
  68570. if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
  68571. return new Color4(0.0, 0.0, 0.0, 0.0);
  68572. }
  68573. var r = parseInt(hex.substring(1, 3), 16);
  68574. var g = parseInt(hex.substring(3, 5), 16);
  68575. var b = parseInt(hex.substring(5, 7), 16);
  68576. var a = parseInt(hex.substring(7, 9), 16);
  68577. return Color4.FromInts(r, g, b, a);
  68578. };
  68579. /**
  68580. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  68581. * @param left defines the start value
  68582. * @param right defines the end value
  68583. * @param amount defines the gradient factor
  68584. * @returns a new Color4 object
  68585. */
  68586. Color4.Lerp = function (left, right, amount) {
  68587. var result = new Color4(0.0, 0.0, 0.0, 0.0);
  68588. Color4.LerpToRef(left, right, amount, result);
  68589. return result;
  68590. };
  68591. /**
  68592. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  68593. * @param left defines the start value
  68594. * @param right defines the end value
  68595. * @param amount defines the gradient factor
  68596. * @param result defines the Color4 object where to store data
  68597. */
  68598. Color4.LerpToRef = function (left, right, amount, result) {
  68599. result.r = left.r + (right.r - left.r) * amount;
  68600. result.g = left.g + (right.g - left.g) * amount;
  68601. result.b = left.b + (right.b - left.b) * amount;
  68602. result.a = left.a + (right.a - left.a) * amount;
  68603. };
  68604. /**
  68605. * Creates a new Color4 from a Color3 and an alpha value
  68606. * @param color3 defines the source Color3 to read from
  68607. * @param alpha defines the alpha component (1.0 by default)
  68608. * @returns a new Color4 object
  68609. */
  68610. Color4.FromColor3 = function (color3, alpha) {
  68611. if (alpha === void 0) { alpha = 1.0; }
  68612. return new Color4(color3.r, color3.g, color3.b, alpha);
  68613. };
  68614. /**
  68615. * Creates a new Color4 from the starting index element of the given array
  68616. * @param array defines the source array to read from
  68617. * @param offset defines the offset in the source array
  68618. * @returns a new Color4 object
  68619. */
  68620. Color4.FromArray = function (array, offset) {
  68621. if (offset === void 0) { offset = 0; }
  68622. return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  68623. };
  68624. /**
  68625. * Creates a new Color3 from integer values (< 256)
  68626. * @param r defines the red component to read from (value between 0 and 255)
  68627. * @param g defines the green component to read from (value between 0 and 255)
  68628. * @param b defines the blue component to read from (value between 0 and 255)
  68629. * @param a defines the alpha component to read from (value between 0 and 255)
  68630. * @returns a new Color3 object
  68631. */
  68632. Color4.FromInts = function (r, g, b, a) {
  68633. return new Color4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  68634. };
  68635. /**
  68636. * Check the content of a given array and convert it to an array containing RGBA data
  68637. * If the original array was already containing count * 4 values then it is returned directly
  68638. * @param colors defines the array to check
  68639. * @param count defines the number of RGBA data to expect
  68640. * @returns an array containing count * 4 values (RGBA)
  68641. */
  68642. Color4.CheckColors4 = function (colors, count) {
  68643. // Check if color3 was used
  68644. if (colors.length === count * 3) {
  68645. var colors4 = [];
  68646. for (var index = 0; index < colors.length; index += 3) {
  68647. var newIndex = (index / 3) * 4;
  68648. colors4[newIndex] = colors[index];
  68649. colors4[newIndex + 1] = colors[index + 1];
  68650. colors4[newIndex + 2] = colors[index + 2];
  68651. colors4[newIndex + 3] = 1.0;
  68652. }
  68653. return colors4;
  68654. }
  68655. return colors;
  68656. };
  68657. return Color4;
  68658. }());
  68659. /**
  68660. * Class representing a vector containing 2 coordinates
  68661. */
  68662. var Vector2 = /** @class */ (function () {
  68663. /**
  68664. * Creates a new Vector2 from the given x and y coordinates
  68665. * @param x defines the first coordinate
  68666. * @param y defines the second coordinate
  68667. */
  68668. function Vector2(
  68669. /** defines the first coordinate */
  68670. x,
  68671. /** defines the second coordinate */
  68672. y) {
  68673. if (x === void 0) { x = 0; }
  68674. if (y === void 0) { y = 0; }
  68675. this.x = x;
  68676. this.y = y;
  68677. }
  68678. /**
  68679. * Gets a string with the Vector2 coordinates
  68680. * @returns a string with the Vector2 coordinates
  68681. */
  68682. Vector2.prototype.toString = function () {
  68683. return "{X: " + this.x + " Y:" + this.y + "}";
  68684. };
  68685. /**
  68686. * Gets class name
  68687. * @returns the string "Vector2"
  68688. */
  68689. Vector2.prototype.getClassName = function () {
  68690. return "Vector2";
  68691. };
  68692. /**
  68693. * Gets current vector hash code
  68694. * @returns the Vector2 hash code as a number
  68695. */
  68696. Vector2.prototype.getHashCode = function () {
  68697. var hash = this.x || 0;
  68698. hash = (hash * 397) ^ (this.y || 0);
  68699. return hash;
  68700. };
  68701. // Operators
  68702. /**
  68703. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  68704. * @param array defines the source array
  68705. * @param index defines the offset in source array
  68706. * @returns the current Vector2
  68707. */
  68708. Vector2.prototype.toArray = function (array, index) {
  68709. if (index === void 0) { index = 0; }
  68710. array[index] = this.x;
  68711. array[index + 1] = this.y;
  68712. return this;
  68713. };
  68714. /**
  68715. * Copy the current vector to an array
  68716. * @returns a new array with 2 elements: the Vector2 coordinates.
  68717. */
  68718. Vector2.prototype.asArray = function () {
  68719. var result = new Array();
  68720. this.toArray(result, 0);
  68721. return result;
  68722. };
  68723. /**
  68724. * Sets the Vector2 coordinates with the given Vector2 coordinates
  68725. * @param source defines the source Vector2
  68726. * @returns the current updated Vector2
  68727. */
  68728. Vector2.prototype.copyFrom = function (source) {
  68729. this.x = source.x;
  68730. this.y = source.y;
  68731. return this;
  68732. };
  68733. /**
  68734. * Sets the Vector2 coordinates with the given floats
  68735. * @param x defines the first coordinate
  68736. * @param y defines the second coordinate
  68737. * @returns the current updated Vector2
  68738. */
  68739. Vector2.prototype.copyFromFloats = function (x, y) {
  68740. this.x = x;
  68741. this.y = y;
  68742. return this;
  68743. };
  68744. /**
  68745. * Sets the Vector2 coordinates with the given floats
  68746. * @param x defines the first coordinate
  68747. * @param y defines the second coordinate
  68748. * @returns the current updated Vector2
  68749. */
  68750. Vector2.prototype.set = function (x, y) {
  68751. return this.copyFromFloats(x, y);
  68752. };
  68753. /**
  68754. * Add another vector with the current one
  68755. * @param otherVector defines the other vector
  68756. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  68757. */
  68758. Vector2.prototype.add = function (otherVector) {
  68759. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  68760. };
  68761. /**
  68762. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  68763. * @param otherVector defines the other vector
  68764. * @param result defines the target vector
  68765. * @returns the unmodified current Vector2
  68766. */
  68767. Vector2.prototype.addToRef = function (otherVector, result) {
  68768. result.x = this.x + otherVector.x;
  68769. result.y = this.y + otherVector.y;
  68770. return this;
  68771. };
  68772. /**
  68773. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  68774. * @param otherVector defines the other vector
  68775. * @returns the current updated Vector2
  68776. */
  68777. Vector2.prototype.addInPlace = function (otherVector) {
  68778. this.x += otherVector.x;
  68779. this.y += otherVector.y;
  68780. return this;
  68781. };
  68782. /**
  68783. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  68784. * @param otherVector defines the other vector
  68785. * @returns a new Vector2
  68786. */
  68787. Vector2.prototype.addVector3 = function (otherVector) {
  68788. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  68789. };
  68790. /**
  68791. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  68792. * @param otherVector defines the other vector
  68793. * @returns a new Vector2
  68794. */
  68795. Vector2.prototype.subtract = function (otherVector) {
  68796. return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
  68797. };
  68798. /**
  68799. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  68800. * @param otherVector defines the other vector
  68801. * @param result defines the target vector
  68802. * @returns the unmodified current Vector2
  68803. */
  68804. Vector2.prototype.subtractToRef = function (otherVector, result) {
  68805. result.x = this.x - otherVector.x;
  68806. result.y = this.y - otherVector.y;
  68807. return this;
  68808. };
  68809. /**
  68810. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  68811. * @param otherVector defines the other vector
  68812. * @returns the current updated Vector2
  68813. */
  68814. Vector2.prototype.subtractInPlace = function (otherVector) {
  68815. this.x -= otherVector.x;
  68816. this.y -= otherVector.y;
  68817. return this;
  68818. };
  68819. /**
  68820. * Multiplies in place the current Vector2 coordinates by the given ones
  68821. * @param otherVector defines the other vector
  68822. * @returns the current updated Vector2
  68823. */
  68824. Vector2.prototype.multiplyInPlace = function (otherVector) {
  68825. this.x *= otherVector.x;
  68826. this.y *= otherVector.y;
  68827. return this;
  68828. };
  68829. /**
  68830. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  68831. * @param otherVector defines the other vector
  68832. * @returns a new Vector2
  68833. */
  68834. Vector2.prototype.multiply = function (otherVector) {
  68835. return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
  68836. };
  68837. /**
  68838. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  68839. * @param otherVector defines the other vector
  68840. * @param result defines the target vector
  68841. * @returns the unmodified current Vector2
  68842. */
  68843. Vector2.prototype.multiplyToRef = function (otherVector, result) {
  68844. result.x = this.x * otherVector.x;
  68845. result.y = this.y * otherVector.y;
  68846. return this;
  68847. };
  68848. /**
  68849. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  68850. * @param x defines the first coordinate
  68851. * @param y defines the second coordinate
  68852. * @returns a new Vector2
  68853. */
  68854. Vector2.prototype.multiplyByFloats = function (x, y) {
  68855. return new Vector2(this.x * x, this.y * y);
  68856. };
  68857. /**
  68858. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  68859. * @param otherVector defines the other vector
  68860. * @returns a new Vector2
  68861. */
  68862. Vector2.prototype.divide = function (otherVector) {
  68863. return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
  68864. };
  68865. /**
  68866. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  68867. * @param otherVector defines the other vector
  68868. * @param result defines the target vector
  68869. * @returns the unmodified current Vector2
  68870. */
  68871. Vector2.prototype.divideToRef = function (otherVector, result) {
  68872. result.x = this.x / otherVector.x;
  68873. result.y = this.y / otherVector.y;
  68874. return this;
  68875. };
  68876. /**
  68877. * Divides the current Vector2 coordinates by the given ones
  68878. * @param otherVector defines the other vector
  68879. * @returns the current updated Vector2
  68880. */
  68881. Vector2.prototype.divideInPlace = function (otherVector) {
  68882. return this.divideToRef(otherVector, this);
  68883. };
  68884. /**
  68885. * Gets a new Vector2 with current Vector2 negated coordinates
  68886. * @returns a new Vector2
  68887. */
  68888. Vector2.prototype.negate = function () {
  68889. return new Vector2(-this.x, -this.y);
  68890. };
  68891. /**
  68892. * Multiply the Vector2 coordinates by scale
  68893. * @param scale defines the scaling factor
  68894. * @returns the current updated Vector2
  68895. */
  68896. Vector2.prototype.scaleInPlace = function (scale) {
  68897. this.x *= scale;
  68898. this.y *= scale;
  68899. return this;
  68900. };
  68901. /**
  68902. * Returns a new Vector2 scaled by "scale" from the current Vector2
  68903. * @param scale defines the scaling factor
  68904. * @returns a new Vector2
  68905. */
  68906. Vector2.prototype.scale = function (scale) {
  68907. var result = new Vector2(0, 0);
  68908. this.scaleToRef(scale, result);
  68909. return result;
  68910. };
  68911. /**
  68912. * Scale the current Vector2 values by a factor to a given Vector2
  68913. * @param scale defines the scale factor
  68914. * @param result defines the Vector2 object where to store the result
  68915. * @returns the unmodified current Vector2
  68916. */
  68917. Vector2.prototype.scaleToRef = function (scale, result) {
  68918. result.x = this.x * scale;
  68919. result.y = this.y * scale;
  68920. return this;
  68921. };
  68922. /**
  68923. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  68924. * @param scale defines the scale factor
  68925. * @param result defines the Vector2 object where to store the result
  68926. * @returns the unmodified current Vector2
  68927. */
  68928. Vector2.prototype.scaleAndAddToRef = function (scale, result) {
  68929. result.x += this.x * scale;
  68930. result.y += this.y * scale;
  68931. return this;
  68932. };
  68933. /**
  68934. * Gets a boolean if two vectors are equals
  68935. * @param otherVector defines the other vector
  68936. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  68937. */
  68938. Vector2.prototype.equals = function (otherVector) {
  68939. return otherVector && this.x === otherVector.x && this.y === otherVector.y;
  68940. };
  68941. /**
  68942. * Gets a boolean if two vectors are equals (using an epsilon value)
  68943. * @param otherVector defines the other vector
  68944. * @param epsilon defines the minimal distance to consider equality
  68945. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  68946. */
  68947. Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  68948. if (epsilon === void 0) { epsilon = Epsilon; }
  68949. 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);
  68950. };
  68951. /**
  68952. * Gets a new Vector2 from current Vector2 floored values
  68953. * @returns a new Vector2
  68954. */
  68955. Vector2.prototype.floor = function () {
  68956. return new Vector2(Math.floor(this.x), Math.floor(this.y));
  68957. };
  68958. /**
  68959. * Gets a new Vector2 from current Vector2 floored values
  68960. * @returns a new Vector2
  68961. */
  68962. Vector2.prototype.fract = function () {
  68963. return new Vector2(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
  68964. };
  68965. // Properties
  68966. /**
  68967. * Gets the length of the vector
  68968. * @returns the vector length (float)
  68969. */
  68970. Vector2.prototype.length = function () {
  68971. return Math.sqrt(this.x * this.x + this.y * this.y);
  68972. };
  68973. /**
  68974. * Gets the vector squared length
  68975. * @returns the vector squared length (float)
  68976. */
  68977. Vector2.prototype.lengthSquared = function () {
  68978. return (this.x * this.x + this.y * this.y);
  68979. };
  68980. // Methods
  68981. /**
  68982. * Normalize the vector
  68983. * @returns the current updated Vector2
  68984. */
  68985. Vector2.prototype.normalize = function () {
  68986. var len = this.length();
  68987. if (len === 0) {
  68988. return this;
  68989. }
  68990. var num = 1.0 / len;
  68991. this.x *= num;
  68992. this.y *= num;
  68993. return this;
  68994. };
  68995. /**
  68996. * Gets a new Vector2 copied from the Vector2
  68997. * @returns a new Vector2
  68998. */
  68999. Vector2.prototype.clone = function () {
  69000. return new Vector2(this.x, this.y);
  69001. };
  69002. // Statics
  69003. /**
  69004. * Gets a new Vector2(0, 0)
  69005. * @returns a new Vector2
  69006. */
  69007. Vector2.Zero = function () {
  69008. return new Vector2(0, 0);
  69009. };
  69010. /**
  69011. * Gets a new Vector2(1, 1)
  69012. * @returns a new Vector2
  69013. */
  69014. Vector2.One = function () {
  69015. return new Vector2(1, 1);
  69016. };
  69017. /**
  69018. * Gets a new Vector2 set from the given index element of the given array
  69019. * @param array defines the data source
  69020. * @param offset defines the offset in the data source
  69021. * @returns a new Vector2
  69022. */
  69023. Vector2.FromArray = function (array, offset) {
  69024. if (offset === void 0) { offset = 0; }
  69025. return new Vector2(array[offset], array[offset + 1]);
  69026. };
  69027. /**
  69028. * Sets "result" from the given index element of the given array
  69029. * @param array defines the data source
  69030. * @param offset defines the offset in the data source
  69031. * @param result defines the target vector
  69032. */
  69033. Vector2.FromArrayToRef = function (array, offset, result) {
  69034. result.x = array[offset];
  69035. result.y = array[offset + 1];
  69036. };
  69037. /**
  69038. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  69039. * @param value1 defines 1st point of control
  69040. * @param value2 defines 2nd point of control
  69041. * @param value3 defines 3rd point of control
  69042. * @param value4 defines 4th point of control
  69043. * @param amount defines the interpolation factor
  69044. * @returns a new Vector2
  69045. */
  69046. Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
  69047. var squared = amount * amount;
  69048. var cubed = amount * squared;
  69049. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  69050. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  69051. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  69052. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  69053. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  69054. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  69055. return new Vector2(x, y);
  69056. };
  69057. /**
  69058. * 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".
  69059. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  69060. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  69061. * @param value defines the value to clamp
  69062. * @param min defines the lower limit
  69063. * @param max defines the upper limit
  69064. * @returns a new Vector2
  69065. */
  69066. Vector2.Clamp = function (value, min, max) {
  69067. var x = value.x;
  69068. x = (x > max.x) ? max.x : x;
  69069. x = (x < min.x) ? min.x : x;
  69070. var y = value.y;
  69071. y = (y > max.y) ? max.y : y;
  69072. y = (y < min.y) ? min.y : y;
  69073. return new Vector2(x, y);
  69074. };
  69075. /**
  69076. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  69077. * @param value1 defines the 1st control point
  69078. * @param tangent1 defines the outgoing tangent
  69079. * @param value2 defines the 2nd control point
  69080. * @param tangent2 defines the incoming tangent
  69081. * @param amount defines the interpolation factor
  69082. * @returns a new Vector2
  69083. */
  69084. Vector2.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  69085. var squared = amount * amount;
  69086. var cubed = amount * squared;
  69087. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  69088. var part2 = (-2.0 * cubed) + (3.0 * squared);
  69089. var part3 = (cubed - (2.0 * squared)) + amount;
  69090. var part4 = cubed - squared;
  69091. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  69092. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  69093. return new Vector2(x, y);
  69094. };
  69095. /**
  69096. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  69097. * @param start defines the start vector
  69098. * @param end defines the end vector
  69099. * @param amount defines the interpolation factor
  69100. * @returns a new Vector2
  69101. */
  69102. Vector2.Lerp = function (start, end, amount) {
  69103. var x = start.x + ((end.x - start.x) * amount);
  69104. var y = start.y + ((end.y - start.y) * amount);
  69105. return new Vector2(x, y);
  69106. };
  69107. /**
  69108. * Gets the dot product of the vector "left" and the vector "right"
  69109. * @param left defines first vector
  69110. * @param right defines second vector
  69111. * @returns the dot product (float)
  69112. */
  69113. Vector2.Dot = function (left, right) {
  69114. return left.x * right.x + left.y * right.y;
  69115. };
  69116. /**
  69117. * Returns a new Vector2 equal to the normalized given vector
  69118. * @param vector defines the vector to normalize
  69119. * @returns a new Vector2
  69120. */
  69121. Vector2.Normalize = function (vector) {
  69122. var newVector = vector.clone();
  69123. newVector.normalize();
  69124. return newVector;
  69125. };
  69126. /**
  69127. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  69128. * @param left defines 1st vector
  69129. * @param right defines 2nd vector
  69130. * @returns a new Vector2
  69131. */
  69132. Vector2.Minimize = function (left, right) {
  69133. var x = (left.x < right.x) ? left.x : right.x;
  69134. var y = (left.y < right.y) ? left.y : right.y;
  69135. return new Vector2(x, y);
  69136. };
  69137. /**
  69138. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  69139. * @param left defines 1st vector
  69140. * @param right defines 2nd vector
  69141. * @returns a new Vector2
  69142. */
  69143. Vector2.Maximize = function (left, right) {
  69144. var x = (left.x > right.x) ? left.x : right.x;
  69145. var y = (left.y > right.y) ? left.y : right.y;
  69146. return new Vector2(x, y);
  69147. };
  69148. /**
  69149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  69150. * @param vector defines the vector to transform
  69151. * @param transformation defines the matrix to apply
  69152. * @returns a new Vector2
  69153. */
  69154. Vector2.Transform = function (vector, transformation) {
  69155. var r = Vector2.Zero();
  69156. Vector2.TransformToRef(vector, transformation, r);
  69157. return r;
  69158. };
  69159. /**
  69160. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  69161. * @param vector defines the vector to transform
  69162. * @param transformation defines the matrix to apply
  69163. * @param result defines the target vector
  69164. */
  69165. Vector2.TransformToRef = function (vector, transformation, result) {
  69166. var m = transformation.m;
  69167. var x = (vector.x * m[0]) + (vector.y * m[4]) + m[12];
  69168. var y = (vector.x * m[1]) + (vector.y * m[5]) + m[13];
  69169. result.x = x;
  69170. result.y = y;
  69171. };
  69172. /**
  69173. * Determines if a given vector is included in a triangle
  69174. * @param p defines the vector to test
  69175. * @param p0 defines 1st triangle point
  69176. * @param p1 defines 2nd triangle point
  69177. * @param p2 defines 3rd triangle point
  69178. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  69179. */
  69180. Vector2.PointInTriangle = function (p, p0, p1, p2) {
  69181. var a = 1 / 2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
  69182. var sign = a < 0 ? -1 : 1;
  69183. var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
  69184. var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;
  69185. return s > 0 && t > 0 && (s + t) < 2 * a * sign;
  69186. };
  69187. /**
  69188. * Gets the distance between the vectors "value1" and "value2"
  69189. * @param value1 defines first vector
  69190. * @param value2 defines second vector
  69191. * @returns the distance between vectors
  69192. */
  69193. Vector2.Distance = function (value1, value2) {
  69194. return Math.sqrt(Vector2.DistanceSquared(value1, value2));
  69195. };
  69196. /**
  69197. * Returns the squared distance between the vectors "value1" and "value2"
  69198. * @param value1 defines first vector
  69199. * @param value2 defines second vector
  69200. * @returns the squared distance between vectors
  69201. */
  69202. Vector2.DistanceSquared = function (value1, value2) {
  69203. var x = value1.x - value2.x;
  69204. var y = value1.y - value2.y;
  69205. return (x * x) + (y * y);
  69206. };
  69207. /**
  69208. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  69209. * @param value1 defines first vector
  69210. * @param value2 defines second vector
  69211. * @returns a new Vector2
  69212. */
  69213. Vector2.Center = function (value1, value2) {
  69214. var center = value1.add(value2);
  69215. center.scaleInPlace(0.5);
  69216. return center;
  69217. };
  69218. /**
  69219. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  69220. * @param p defines the middle point
  69221. * @param segA defines one point of the segment
  69222. * @param segB defines the other point of the segment
  69223. * @returns the shortest distance
  69224. */
  69225. Vector2.DistanceOfPointFromSegment = function (p, segA, segB) {
  69226. var l2 = Vector2.DistanceSquared(segA, segB);
  69227. if (l2 === 0.0) {
  69228. return Vector2.Distance(p, segA);
  69229. }
  69230. var v = segB.subtract(segA);
  69231. var t = Math.max(0, Math.min(1, Vector2.Dot(p.subtract(segA), v) / l2));
  69232. var proj = segA.add(v.multiplyByFloats(t, t));
  69233. return Vector2.Distance(p, proj);
  69234. };
  69235. return Vector2;
  69236. }());
  69237. /**
  69238. * Classed used to store (x,y,z) vector representation
  69239. * A Vector3 is the main object used in 3D geometry
  69240. * It can represent etiher the coordinates of a point the space, either a direction
  69241. * Reminder: js uses a left handed forward facing system
  69242. */
  69243. var Vector3 = /** @class */ (function () {
  69244. /**
  69245. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  69246. * @param x defines the first coordinates (on X axis)
  69247. * @param y defines the second coordinates (on Y axis)
  69248. * @param z defines the third coordinates (on Z axis)
  69249. */
  69250. function Vector3(
  69251. /**
  69252. * Defines the first coordinates (on X axis)
  69253. */
  69254. x,
  69255. /**
  69256. * Defines the second coordinates (on Y axis)
  69257. */
  69258. y,
  69259. /**
  69260. * Defines the third coordinates (on Z axis)
  69261. */
  69262. z) {
  69263. if (x === void 0) { x = 0; }
  69264. if (y === void 0) { y = 0; }
  69265. if (z === void 0) { z = 0; }
  69266. this.x = x;
  69267. this.y = y;
  69268. this.z = z;
  69269. }
  69270. /**
  69271. * Creates a string representation of the Vector3
  69272. * @returns a string with the Vector3 coordinates.
  69273. */
  69274. Vector3.prototype.toString = function () {
  69275. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
  69276. };
  69277. /**
  69278. * Gets the class name
  69279. * @returns the string "Vector3"
  69280. */
  69281. Vector3.prototype.getClassName = function () {
  69282. return "Vector3";
  69283. };
  69284. /**
  69285. * Creates the Vector3 hash code
  69286. * @returns a number which tends to be unique between Vector3 instances
  69287. */
  69288. Vector3.prototype.getHashCode = function () {
  69289. var hash = this.x || 0;
  69290. hash = (hash * 397) ^ (this.y || 0);
  69291. hash = (hash * 397) ^ (this.z || 0);
  69292. return hash;
  69293. };
  69294. // Operators
  69295. /**
  69296. * Creates an array containing three elements : the coordinates of the Vector3
  69297. * @returns a new array of numbers
  69298. */
  69299. Vector3.prototype.asArray = function () {
  69300. var result = [];
  69301. this.toArray(result, 0);
  69302. return result;
  69303. };
  69304. /**
  69305. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  69306. * @param array defines the destination array
  69307. * @param index defines the offset in the destination array
  69308. * @returns the current Vector3
  69309. */
  69310. Vector3.prototype.toArray = function (array, index) {
  69311. if (index === void 0) { index = 0; }
  69312. array[index] = this.x;
  69313. array[index + 1] = this.y;
  69314. array[index + 2] = this.z;
  69315. return this;
  69316. };
  69317. /**
  69318. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  69319. * @returns a new Quaternion object, computed from the Vector3 coordinates
  69320. */
  69321. Vector3.prototype.toQuaternion = function () {
  69322. return Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
  69323. };
  69324. /**
  69325. * Adds the given vector to the current Vector3
  69326. * @param otherVector defines the second operand
  69327. * @returns the current updated Vector3
  69328. */
  69329. Vector3.prototype.addInPlace = function (otherVector) {
  69330. return this.addInPlaceFromFloats(otherVector.x, otherVector.y, otherVector.z);
  69331. };
  69332. /**
  69333. * Adds the given coordinates to the current Vector3
  69334. * @param x defines the x coordinate of the operand
  69335. * @param y defines the y coordinate of the operand
  69336. * @param z defines the z coordinate of the operand
  69337. * @returns the current updated Vector3
  69338. */
  69339. Vector3.prototype.addInPlaceFromFloats = function (x, y, z) {
  69340. this.x += x;
  69341. this.y += y;
  69342. this.z += z;
  69343. return this;
  69344. };
  69345. /**
  69346. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  69347. * @param otherVector defines the second operand
  69348. * @returns the resulting Vector3
  69349. */
  69350. Vector3.prototype.add = function (otherVector) {
  69351. return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  69352. };
  69353. /**
  69354. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  69355. * @param otherVector defines the second operand
  69356. * @param result defines the Vector3 object where to store the result
  69357. * @returns the current Vector3
  69358. */
  69359. Vector3.prototype.addToRef = function (otherVector, result) {
  69360. return result.copyFromFloats(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  69361. };
  69362. /**
  69363. * Subtract the given vector from the current Vector3
  69364. * @param otherVector defines the second operand
  69365. * @returns the current updated Vector3
  69366. */
  69367. Vector3.prototype.subtractInPlace = function (otherVector) {
  69368. this.x -= otherVector.x;
  69369. this.y -= otherVector.y;
  69370. this.z -= otherVector.z;
  69371. return this;
  69372. };
  69373. /**
  69374. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  69375. * @param otherVector defines the second operand
  69376. * @returns the resulting Vector3
  69377. */
  69378. Vector3.prototype.subtract = function (otherVector) {
  69379. return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
  69380. };
  69381. /**
  69382. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  69383. * @param otherVector defines the second operand
  69384. * @param result defines the Vector3 object where to store the result
  69385. * @returns the current Vector3
  69386. */
  69387. Vector3.prototype.subtractToRef = function (otherVector, result) {
  69388. return this.subtractFromFloatsToRef(otherVector.x, otherVector.y, otherVector.z, result);
  69389. };
  69390. /**
  69391. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  69392. * @param x defines the x coordinate of the operand
  69393. * @param y defines the y coordinate of the operand
  69394. * @param z defines the z coordinate of the operand
  69395. * @returns the resulting Vector3
  69396. */
  69397. Vector3.prototype.subtractFromFloats = function (x, y, z) {
  69398. return new Vector3(this.x - x, this.y - y, this.z - z);
  69399. };
  69400. /**
  69401. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  69402. * @param x defines the x coordinate of the operand
  69403. * @param y defines the y coordinate of the operand
  69404. * @param z defines the z coordinate of the operand
  69405. * @param result defines the Vector3 object where to store the result
  69406. * @returns the current Vector3
  69407. */
  69408. Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
  69409. return result.copyFromFloats(this.x - x, this.y - y, this.z - z);
  69410. };
  69411. /**
  69412. * Gets a new Vector3 set with the current Vector3 negated coordinates
  69413. * @returns a new Vector3
  69414. */
  69415. Vector3.prototype.negate = function () {
  69416. return new Vector3(-this.x, -this.y, -this.z);
  69417. };
  69418. /**
  69419. * Multiplies the Vector3 coordinates by the float "scale"
  69420. * @param scale defines the multiplier factor
  69421. * @returns the current updated Vector3
  69422. */
  69423. Vector3.prototype.scaleInPlace = function (scale) {
  69424. this.x *= scale;
  69425. this.y *= scale;
  69426. this.z *= scale;
  69427. return this;
  69428. };
  69429. /**
  69430. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  69431. * @param scale defines the multiplier factor
  69432. * @returns a new Vector3
  69433. */
  69434. Vector3.prototype.scale = function (scale) {
  69435. return new Vector3(this.x * scale, this.y * scale, this.z * scale);
  69436. };
  69437. /**
  69438. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  69439. * @param scale defines the multiplier factor
  69440. * @param result defines the Vector3 object where to store the result
  69441. * @returns the current Vector3
  69442. */
  69443. Vector3.prototype.scaleToRef = function (scale, result) {
  69444. return result.copyFromFloats(this.x * scale, this.y * scale, this.z * scale);
  69445. };
  69446. /**
  69447. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  69448. * @param scale defines the scale factor
  69449. * @param result defines the Vector3 object where to store the result
  69450. * @returns the unmodified current Vector3
  69451. */
  69452. Vector3.prototype.scaleAndAddToRef = function (scale, result) {
  69453. return result.addInPlaceFromFloats(this.x * scale, this.y * scale, this.z * scale);
  69454. };
  69455. /**
  69456. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  69457. * @param otherVector defines the second operand
  69458. * @returns true if both vectors are equals
  69459. */
  69460. Vector3.prototype.equals = function (otherVector) {
  69461. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
  69462. };
  69463. /**
  69464. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  69465. * @param otherVector defines the second operand
  69466. * @param epsilon defines the minimal distance to define values as equals
  69467. * @returns true if both vectors are distant less than epsilon
  69468. */
  69469. Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  69470. if (epsilon === void 0) { epsilon = Epsilon; }
  69471. 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);
  69472. };
  69473. /**
  69474. * Returns true if the current Vector3 coordinates equals the given floats
  69475. * @param x defines the x coordinate of the operand
  69476. * @param y defines the y coordinate of the operand
  69477. * @param z defines the z coordinate of the operand
  69478. * @returns true if both vectors are equals
  69479. */
  69480. Vector3.prototype.equalsToFloats = function (x, y, z) {
  69481. return this.x === x && this.y === y && this.z === z;
  69482. };
  69483. /**
  69484. * Multiplies the current Vector3 coordinates by the given ones
  69485. * @param otherVector defines the second operand
  69486. * @returns the current updated Vector3
  69487. */
  69488. Vector3.prototype.multiplyInPlace = function (otherVector) {
  69489. this.x *= otherVector.x;
  69490. this.y *= otherVector.y;
  69491. this.z *= otherVector.z;
  69492. return this;
  69493. };
  69494. /**
  69495. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  69496. * @param otherVector defines the second operand
  69497. * @returns the new Vector3
  69498. */
  69499. Vector3.prototype.multiply = function (otherVector) {
  69500. return this.multiplyByFloats(otherVector.x, otherVector.y, otherVector.z);
  69501. };
  69502. /**
  69503. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  69504. * @param otherVector defines the second operand
  69505. * @param result defines the Vector3 object where to store the result
  69506. * @returns the current Vector3
  69507. */
  69508. Vector3.prototype.multiplyToRef = function (otherVector, result) {
  69509. return result.copyFromFloats(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
  69510. };
  69511. /**
  69512. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  69513. * @param x defines the x coordinate of the operand
  69514. * @param y defines the y coordinate of the operand
  69515. * @param z defines the z coordinate of the operand
  69516. * @returns the new Vector3
  69517. */
  69518. Vector3.prototype.multiplyByFloats = function (x, y, z) {
  69519. return new Vector3(this.x * x, this.y * y, this.z * z);
  69520. };
  69521. /**
  69522. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  69523. * @param otherVector defines the second operand
  69524. * @returns the new Vector3
  69525. */
  69526. Vector3.prototype.divide = function (otherVector) {
  69527. return new Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  69528. };
  69529. /**
  69530. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  69531. * @param otherVector defines the second operand
  69532. * @param result defines the Vector3 object where to store the result
  69533. * @returns the current Vector3
  69534. */
  69535. Vector3.prototype.divideToRef = function (otherVector, result) {
  69536. return result.copyFromFloats(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  69537. };
  69538. /**
  69539. * Divides the current Vector3 coordinates by the given ones.
  69540. * @param otherVector defines the second operand
  69541. * @returns the current updated Vector3
  69542. */
  69543. Vector3.prototype.divideInPlace = function (otherVector) {
  69544. return this.divideToRef(otherVector, this);
  69545. };
  69546. /**
  69547. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  69548. * @param other defines the second operand
  69549. * @returns the current updated Vector3
  69550. */
  69551. Vector3.prototype.minimizeInPlace = function (other) {
  69552. return this.minimizeInPlaceFromFloats(other.x, other.y, other.z);
  69553. };
  69554. /**
  69555. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  69556. * @param other defines the second operand
  69557. * @returns the current updated Vector3
  69558. */
  69559. Vector3.prototype.maximizeInPlace = function (other) {
  69560. return this.maximizeInPlaceFromFloats(other.x, other.y, other.z);
  69561. };
  69562. /**
  69563. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  69564. * @param x defines the x coordinate of the operand
  69565. * @param y defines the y coordinate of the operand
  69566. * @param z defines the z coordinate of the operand
  69567. * @returns the current updated Vector3
  69568. */
  69569. Vector3.prototype.minimizeInPlaceFromFloats = function (x, y, z) {
  69570. if (x < this.x) {
  69571. this.x = x;
  69572. }
  69573. if (y < this.y) {
  69574. this.y = y;
  69575. }
  69576. if (z < this.z) {
  69577. this.z = z;
  69578. }
  69579. return this;
  69580. };
  69581. /**
  69582. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  69583. * @param x defines the x coordinate of the operand
  69584. * @param y defines the y coordinate of the operand
  69585. * @param z defines the z coordinate of the operand
  69586. * @returns the current updated Vector3
  69587. */
  69588. Vector3.prototype.maximizeInPlaceFromFloats = function (x, y, z) {
  69589. if (x > this.x) {
  69590. this.x = x;
  69591. }
  69592. if (y > this.y) {
  69593. this.y = y;
  69594. }
  69595. if (z > this.z) {
  69596. this.z = z;
  69597. }
  69598. return this;
  69599. };
  69600. /**
  69601. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  69602. * Check if is non uniform within a certain amount of decimal places to account for this
  69603. * @param epsilon the amount the values can differ
  69604. * @returns if the the vector is non uniform to a certain number of decimal places
  69605. */
  69606. Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
  69607. var absX = Math.abs(this.x);
  69608. var absY = Math.abs(this.y);
  69609. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absY, epsilon)) {
  69610. return true;
  69611. }
  69612. var absZ = Math.abs(this.z);
  69613. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absZ, epsilon)) {
  69614. return true;
  69615. }
  69616. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absY, absZ, epsilon)) {
  69617. return true;
  69618. }
  69619. return false;
  69620. };
  69621. Object.defineProperty(Vector3.prototype, "isNonUniform", {
  69622. /**
  69623. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  69624. */
  69625. get: function () {
  69626. var absX = Math.abs(this.x);
  69627. var absY = Math.abs(this.y);
  69628. if (absX !== absY) {
  69629. return true;
  69630. }
  69631. var absZ = Math.abs(this.z);
  69632. if (absX !== absZ) {
  69633. return true;
  69634. }
  69635. if (absY !== absZ) {
  69636. return true;
  69637. }
  69638. return false;
  69639. },
  69640. enumerable: true,
  69641. configurable: true
  69642. });
  69643. /**
  69644. * Gets a new Vector3 from current Vector3 floored values
  69645. * @returns a new Vector3
  69646. */
  69647. Vector3.prototype.floor = function () {
  69648. return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
  69649. };
  69650. /**
  69651. * Gets a new Vector3 from current Vector3 floored values
  69652. * @returns a new Vector3
  69653. */
  69654. Vector3.prototype.fract = function () {
  69655. return new Vector3(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z));
  69656. };
  69657. // Properties
  69658. /**
  69659. * Gets the length of the Vector3
  69660. * @returns the length of the Vecto3
  69661. */
  69662. Vector3.prototype.length = function () {
  69663. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  69664. };
  69665. /**
  69666. * Gets the squared length of the Vector3
  69667. * @returns squared length of the Vector3
  69668. */
  69669. Vector3.prototype.lengthSquared = function () {
  69670. return (this.x * this.x + this.y * this.y + this.z * this.z);
  69671. };
  69672. /**
  69673. * Normalize the current Vector3.
  69674. * Please note that this is an in place operation.
  69675. * @returns the current updated Vector3
  69676. */
  69677. Vector3.prototype.normalize = function () {
  69678. return this.normalizeFromLength(this.length());
  69679. };
  69680. /**
  69681. * Reorders the x y z properties of the vector in place
  69682. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  69683. * @returns the current updated vector
  69684. */
  69685. Vector3.prototype.reorderInPlace = function (order) {
  69686. var _this = this;
  69687. order = order.toLowerCase();
  69688. if (order === "xyz") {
  69689. return this;
  69690. }
  69691. MathTmp.Vector3[0].copyFrom(this);
  69692. ["x", "y", "z"].forEach(function (val, i) {
  69693. _this[val] = MathTmp.Vector3[0][order[i]];
  69694. });
  69695. return this;
  69696. };
  69697. /**
  69698. * Rotates the vector around 0,0,0 by a quaternion
  69699. * @param quaternion the rotation quaternion
  69700. * @param result vector to store the result
  69701. * @returns the resulting vector
  69702. */
  69703. Vector3.prototype.rotateByQuaternionToRef = function (quaternion, result) {
  69704. quaternion.toRotationMatrix(MathTmp.Matrix[0]);
  69705. Vector3.TransformCoordinatesToRef(this, MathTmp.Matrix[0], result);
  69706. return result;
  69707. };
  69708. /**
  69709. * Rotates a vector around a given point
  69710. * @param quaternion the rotation quaternion
  69711. * @param point the point to rotate around
  69712. * @param result vector to store the result
  69713. * @returns the resulting vector
  69714. */
  69715. Vector3.prototype.rotateByQuaternionAroundPointToRef = function (quaternion, point, result) {
  69716. this.subtractToRef(point, MathTmp.Vector3[0]);
  69717. MathTmp.Vector3[0].rotateByQuaternionToRef(quaternion, MathTmp.Vector3[0]);
  69718. point.addToRef(MathTmp.Vector3[0], result);
  69719. return result;
  69720. };
  69721. /**
  69722. * Normalize the current Vector3 with the given input length.
  69723. * Please note that this is an in place operation.
  69724. * @param len the length of the vector
  69725. * @returns the current updated Vector3
  69726. */
  69727. Vector3.prototype.normalizeFromLength = function (len) {
  69728. if (len === 0 || len === 1.0) {
  69729. return this;
  69730. }
  69731. return this.scaleInPlace(1.0 / len);
  69732. };
  69733. /**
  69734. * Normalize the current Vector3 to a new vector
  69735. * @returns the new Vector3
  69736. */
  69737. Vector3.prototype.normalizeToNew = function () {
  69738. var normalized = new Vector3(0, 0, 0);
  69739. this.normalizeToRef(normalized);
  69740. return normalized;
  69741. };
  69742. /**
  69743. * Normalize the current Vector3 to the reference
  69744. * @param reference define the Vector3 to update
  69745. * @returns the updated Vector3
  69746. */
  69747. Vector3.prototype.normalizeToRef = function (reference) {
  69748. var len = this.length();
  69749. if (len === 0 || len === 1.0) {
  69750. return reference.copyFromFloats(this.x, this.y, this.z);
  69751. }
  69752. return this.scaleToRef(1.0 / len, reference);
  69753. };
  69754. /**
  69755. * Creates a new Vector3 copied from the current Vector3
  69756. * @returns the new Vector3
  69757. */
  69758. Vector3.prototype.clone = function () {
  69759. return new Vector3(this.x, this.y, this.z);
  69760. };
  69761. /**
  69762. * Copies the given vector coordinates to the current Vector3 ones
  69763. * @param source defines the source Vector3
  69764. * @returns the current updated Vector3
  69765. */
  69766. Vector3.prototype.copyFrom = function (source) {
  69767. return this.copyFromFloats(source.x, source.y, source.z);
  69768. };
  69769. /**
  69770. * Copies the given floats to the current Vector3 coordinates
  69771. * @param x defines the x coordinate of the operand
  69772. * @param y defines the y coordinate of the operand
  69773. * @param z defines the z coordinate of the operand
  69774. * @returns the current updated Vector3
  69775. */
  69776. Vector3.prototype.copyFromFloats = function (x, y, z) {
  69777. this.x = x;
  69778. this.y = y;
  69779. this.z = z;
  69780. return this;
  69781. };
  69782. /**
  69783. * Copies the given floats to the current Vector3 coordinates
  69784. * @param x defines the x coordinate of the operand
  69785. * @param y defines the y coordinate of the operand
  69786. * @param z defines the z coordinate of the operand
  69787. * @returns the current updated Vector3
  69788. */
  69789. Vector3.prototype.set = function (x, y, z) {
  69790. return this.copyFromFloats(x, y, z);
  69791. };
  69792. /**
  69793. * Copies the given float to the current Vector3 coordinates
  69794. * @param v defines the x, y and z coordinates of the operand
  69795. * @returns the current updated Vector3
  69796. */
  69797. Vector3.prototype.setAll = function (v) {
  69798. this.x = this.y = this.z = v;
  69799. return this;
  69800. };
  69801. // Statics
  69802. /**
  69803. * Get the clip factor between two vectors
  69804. * @param vector0 defines the first operand
  69805. * @param vector1 defines the second operand
  69806. * @param axis defines the axis to use
  69807. * @param size defines the size along the axis
  69808. * @returns the clip factor
  69809. */
  69810. Vector3.GetClipFactor = function (vector0, vector1, axis, size) {
  69811. var d0 = Vector3.Dot(vector0, axis) - size;
  69812. var d1 = Vector3.Dot(vector1, axis) - size;
  69813. var s = d0 / (d0 - d1);
  69814. return s;
  69815. };
  69816. /**
  69817. * Get angle between two vectors
  69818. * @param vector0 angle between vector0 and vector1
  69819. * @param vector1 angle between vector0 and vector1
  69820. * @param normal direction of the normal
  69821. * @return the angle between vector0 and vector1
  69822. */
  69823. Vector3.GetAngleBetweenVectors = function (vector0, vector1, normal) {
  69824. var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
  69825. var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
  69826. var dot = Vector3.Dot(v0, v1);
  69827. var n = MathTmp.Vector3[3];
  69828. Vector3.CrossToRef(v0, v1, n);
  69829. if (Vector3.Dot(n, normal) > 0) {
  69830. return Math.acos(dot);
  69831. }
  69832. return -Math.acos(dot);
  69833. };
  69834. /**
  69835. * Returns a new Vector3 set from the index "offset" of the given array
  69836. * @param array defines the source array
  69837. * @param offset defines the offset in the source array
  69838. * @returns the new Vector3
  69839. */
  69840. Vector3.FromArray = function (array, offset) {
  69841. if (offset === void 0) { offset = 0; }
  69842. return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
  69843. };
  69844. /**
  69845. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  69846. * This function is deprecated. Use FromArray instead
  69847. * @param array defines the source array
  69848. * @param offset defines the offset in the source array
  69849. * @returns the new Vector3
  69850. */
  69851. Vector3.FromFloatArray = function (array, offset) {
  69852. return Vector3.FromArray(array, offset);
  69853. };
  69854. /**
  69855. * Sets the given vector "result" with the element values from the index "offset" of the given array
  69856. * @param array defines the source array
  69857. * @param offset defines the offset in the source array
  69858. * @param result defines the Vector3 where to store the result
  69859. */
  69860. Vector3.FromArrayToRef = function (array, offset, result) {
  69861. result.x = array[offset];
  69862. result.y = array[offset + 1];
  69863. result.z = array[offset + 2];
  69864. };
  69865. /**
  69866. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  69867. * This function is deprecated. Use FromArrayToRef instead.
  69868. * @param array defines the source array
  69869. * @param offset defines the offset in the source array
  69870. * @param result defines the Vector3 where to store the result
  69871. */
  69872. Vector3.FromFloatArrayToRef = function (array, offset, result) {
  69873. return Vector3.FromArrayToRef(array, offset, result);
  69874. };
  69875. /**
  69876. * Sets the given vector "result" with the given floats.
  69877. * @param x defines the x coordinate of the source
  69878. * @param y defines the y coordinate of the source
  69879. * @param z defines the z coordinate of the source
  69880. * @param result defines the Vector3 where to store the result
  69881. */
  69882. Vector3.FromFloatsToRef = function (x, y, z, result) {
  69883. result.copyFromFloats(x, y, z);
  69884. };
  69885. /**
  69886. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  69887. * @returns a new empty Vector3
  69888. */
  69889. Vector3.Zero = function () {
  69890. return new Vector3(0.0, 0.0, 0.0);
  69891. };
  69892. /**
  69893. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  69894. * @returns a new unit Vector3
  69895. */
  69896. Vector3.One = function () {
  69897. return new Vector3(1.0, 1.0, 1.0);
  69898. };
  69899. /**
  69900. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  69901. * @returns a new up Vector3
  69902. */
  69903. Vector3.Up = function () {
  69904. return new Vector3(0.0, 1.0, 0.0);
  69905. };
  69906. Object.defineProperty(Vector3, "UpReadOnly", {
  69907. /**
  69908. * Gets a up Vector3 that must not be updated
  69909. */
  69910. get: function () {
  69911. return Vector3._UpReadOnly;
  69912. },
  69913. enumerable: true,
  69914. configurable: true
  69915. });
  69916. /**
  69917. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  69918. * @returns a new down Vector3
  69919. */
  69920. Vector3.Down = function () {
  69921. return new Vector3(0.0, -1.0, 0.0);
  69922. };
  69923. /**
  69924. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  69925. * @returns a new forward Vector3
  69926. */
  69927. Vector3.Forward = function () {
  69928. return new Vector3(0.0, 0.0, 1.0);
  69929. };
  69930. /**
  69931. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  69932. * @returns a new forward Vector3
  69933. */
  69934. Vector3.Backward = function () {
  69935. return new Vector3(0.0, 0.0, -1.0);
  69936. };
  69937. /**
  69938. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  69939. * @returns a new right Vector3
  69940. */
  69941. Vector3.Right = function () {
  69942. return new Vector3(1.0, 0.0, 0.0);
  69943. };
  69944. /**
  69945. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  69946. * @returns a new left Vector3
  69947. */
  69948. Vector3.Left = function () {
  69949. return new Vector3(-1.0, 0.0, 0.0);
  69950. };
  69951. /**
  69952. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  69953. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69954. * @param vector defines the Vector3 to transform
  69955. * @param transformation defines the transformation matrix
  69956. * @returns the transformed Vector3
  69957. */
  69958. Vector3.TransformCoordinates = function (vector, transformation) {
  69959. var result = Vector3.Zero();
  69960. Vector3.TransformCoordinatesToRef(vector, transformation, result);
  69961. return result;
  69962. };
  69963. /**
  69964. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  69965. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69966. * @param vector defines the Vector3 to transform
  69967. * @param transformation defines the transformation matrix
  69968. * @param result defines the Vector3 where to store the result
  69969. */
  69970. Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
  69971. Vector3.TransformCoordinatesFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  69972. };
  69973. /**
  69974. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  69975. * This method computes tranformed coordinates only, not transformed direction vectors
  69976. * @param x define the x coordinate of the source vector
  69977. * @param y define the y coordinate of the source vector
  69978. * @param z define the z coordinate of the source vector
  69979. * @param transformation defines the transformation matrix
  69980. * @param result defines the Vector3 where to store the result
  69981. */
  69982. Vector3.TransformCoordinatesFromFloatsToRef = function (x, y, z, transformation, result) {
  69983. var m = transformation.m;
  69984. var rx = x * m[0] + y * m[4] + z * m[8] + m[12];
  69985. var ry = x * m[1] + y * m[5] + z * m[9] + m[13];
  69986. var rz = x * m[2] + y * m[6] + z * m[10] + m[14];
  69987. var rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
  69988. result.x = rx * rw;
  69989. result.y = ry * rw;
  69990. result.z = rz * rw;
  69991. };
  69992. /**
  69993. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  69994. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69995. * @param vector defines the Vector3 to transform
  69996. * @param transformation defines the transformation matrix
  69997. * @returns the new Vector3
  69998. */
  69999. Vector3.TransformNormal = function (vector, transformation) {
  70000. var result = Vector3.Zero();
  70001. Vector3.TransformNormalToRef(vector, transformation, result);
  70002. return result;
  70003. };
  70004. /**
  70005. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70006. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70007. * @param vector defines the Vector3 to transform
  70008. * @param transformation defines the transformation matrix
  70009. * @param result defines the Vector3 where to store the result
  70010. */
  70011. Vector3.TransformNormalToRef = function (vector, transformation, result) {
  70012. this.TransformNormalFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  70013. };
  70014. /**
  70015. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70016. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70017. * @param x define the x coordinate of the source vector
  70018. * @param y define the y coordinate of the source vector
  70019. * @param z define the z coordinate of the source vector
  70020. * @param transformation defines the transformation matrix
  70021. * @param result defines the Vector3 where to store the result
  70022. */
  70023. Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
  70024. var m = transformation.m;
  70025. result.x = x * m[0] + y * m[4] + z * m[8];
  70026. result.y = x * m[1] + y * m[5] + z * m[9];
  70027. result.z = x * m[2] + y * m[6] + z * m[10];
  70028. };
  70029. /**
  70030. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70031. * @param value1 defines the first control point
  70032. * @param value2 defines the second control point
  70033. * @param value3 defines the third control point
  70034. * @param value4 defines the fourth control point
  70035. * @param amount defines the amount on the spline to use
  70036. * @returns the new Vector3
  70037. */
  70038. Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
  70039. var squared = amount * amount;
  70040. var cubed = amount * squared;
  70041. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  70042. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  70043. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  70044. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  70045. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  70046. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  70047. var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
  70048. (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
  70049. ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
  70050. return new Vector3(x, y, z);
  70051. };
  70052. /**
  70053. * 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"
  70054. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70055. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70056. * @param value defines the current value
  70057. * @param min defines the lower range value
  70058. * @param max defines the upper range value
  70059. * @returns the new Vector3
  70060. */
  70061. Vector3.Clamp = function (value, min, max) {
  70062. var v = new Vector3();
  70063. Vector3.ClampToRef(value, min, max, v);
  70064. return v;
  70065. };
  70066. /**
  70067. * 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"
  70068. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70069. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70070. * @param value defines the current value
  70071. * @param min defines the lower range value
  70072. * @param max defines the upper range value
  70073. * @param result defines the Vector3 where to store the result
  70074. */
  70075. Vector3.ClampToRef = function (value, min, max, result) {
  70076. var x = value.x;
  70077. x = (x > max.x) ? max.x : x;
  70078. x = (x < min.x) ? min.x : x;
  70079. var y = value.y;
  70080. y = (y > max.y) ? max.y : y;
  70081. y = (y < min.y) ? min.y : y;
  70082. var z = value.z;
  70083. z = (z > max.z) ? max.z : z;
  70084. z = (z < min.z) ? min.z : z;
  70085. result.copyFromFloats(x, y, z);
  70086. };
  70087. /**
  70088. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70089. * @param value1 defines the first control point
  70090. * @param tangent1 defines the first tangent vector
  70091. * @param value2 defines the second control point
  70092. * @param tangent2 defines the second tangent vector
  70093. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70094. * @returns the new Vector3
  70095. */
  70096. Vector3.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  70097. var squared = amount * amount;
  70098. var cubed = amount * squared;
  70099. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  70100. var part2 = (-2.0 * cubed) + (3.0 * squared);
  70101. var part3 = (cubed - (2.0 * squared)) + amount;
  70102. var part4 = cubed - squared;
  70103. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  70104. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  70105. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  70106. return new Vector3(x, y, z);
  70107. };
  70108. /**
  70109. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70110. * @param start defines the start value
  70111. * @param end defines the end value
  70112. * @param amount max defines amount between both (between 0 and 1)
  70113. * @returns the new Vector3
  70114. */
  70115. Vector3.Lerp = function (start, end, amount) {
  70116. var result = new Vector3(0, 0, 0);
  70117. Vector3.LerpToRef(start, end, amount, result);
  70118. return result;
  70119. };
  70120. /**
  70121. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70122. * @param start defines the start value
  70123. * @param end defines the end value
  70124. * @param amount max defines amount between both (between 0 and 1)
  70125. * @param result defines the Vector3 where to store the result
  70126. */
  70127. Vector3.LerpToRef = function (start, end, amount, result) {
  70128. result.x = start.x + ((end.x - start.x) * amount);
  70129. result.y = start.y + ((end.y - start.y) * amount);
  70130. result.z = start.z + ((end.z - start.z) * amount);
  70131. };
  70132. /**
  70133. * Returns the dot product (float) between the vectors "left" and "right"
  70134. * @param left defines the left operand
  70135. * @param right defines the right operand
  70136. * @returns the dot product
  70137. */
  70138. Vector3.Dot = function (left, right) {
  70139. return (left.x * right.x + left.y * right.y + left.z * right.z);
  70140. };
  70141. /**
  70142. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  70143. * The cross product is then orthogonal to both "left" and "right"
  70144. * @param left defines the left operand
  70145. * @param right defines the right operand
  70146. * @returns the cross product
  70147. */
  70148. Vector3.Cross = function (left, right) {
  70149. var result = Vector3.Zero();
  70150. Vector3.CrossToRef(left, right, result);
  70151. return result;
  70152. };
  70153. /**
  70154. * Sets the given vector "result" with the cross product of "left" and "right"
  70155. * The cross product is then orthogonal to both "left" and "right"
  70156. * @param left defines the left operand
  70157. * @param right defines the right operand
  70158. * @param result defines the Vector3 where to store the result
  70159. */
  70160. Vector3.CrossToRef = function (left, right, result) {
  70161. var x = left.y * right.z - left.z * right.y;
  70162. var y = left.z * right.x - left.x * right.z;
  70163. var z = left.x * right.y - left.y * right.x;
  70164. result.copyFromFloats(x, y, z);
  70165. };
  70166. /**
  70167. * Returns a new Vector3 as the normalization of the given vector
  70168. * @param vector defines the Vector3 to normalize
  70169. * @returns the new Vector3
  70170. */
  70171. Vector3.Normalize = function (vector) {
  70172. var result = Vector3.Zero();
  70173. Vector3.NormalizeToRef(vector, result);
  70174. return result;
  70175. };
  70176. /**
  70177. * Sets the given vector "result" with the normalization of the given first vector
  70178. * @param vector defines the Vector3 to normalize
  70179. * @param result defines the Vector3 where to store the result
  70180. */
  70181. Vector3.NormalizeToRef = function (vector, result) {
  70182. vector.normalizeToRef(result);
  70183. };
  70184. /**
  70185. * Project a Vector3 onto screen space
  70186. * @param vector defines the Vector3 to project
  70187. * @param world defines the world matrix to use
  70188. * @param transform defines the transform (view x projection) matrix to use
  70189. * @param viewport defines the screen viewport to use
  70190. * @returns the new Vector3
  70191. */
  70192. Vector3.Project = function (vector, world, transform, viewport) {
  70193. var cw = viewport.width;
  70194. var ch = viewport.height;
  70195. var cx = viewport.x;
  70196. var cy = viewport.y;
  70197. var viewportMatrix = MathTmp.Matrix[1];
  70198. 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);
  70199. var matrix = MathTmp.Matrix[0];
  70200. world.multiplyToRef(transform, matrix);
  70201. matrix.multiplyToRef(viewportMatrix, matrix);
  70202. return Vector3.TransformCoordinates(vector, matrix);
  70203. };
  70204. /** @hidden */
  70205. Vector3._UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
  70206. Vector3.TransformCoordinatesToRef(source, matrix, result);
  70207. var m = matrix.m;
  70208. var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
  70209. if (_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(num, 1.0)) {
  70210. result.scaleInPlace(1.0 / num);
  70211. }
  70212. };
  70213. /**
  70214. * Unproject from screen space to object space
  70215. * @param source defines the screen space Vector3 to use
  70216. * @param viewportWidth defines the current width of the viewport
  70217. * @param viewportHeight defines the current height of the viewport
  70218. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70219. * @param transform defines the transform (view x projection) matrix to use
  70220. * @returns the new Vector3
  70221. */
  70222. Vector3.UnprojectFromTransform = function (source, viewportWidth, viewportHeight, world, transform) {
  70223. var matrix = MathTmp.Matrix[0];
  70224. world.multiplyToRef(transform, matrix);
  70225. matrix.invert();
  70226. source.x = source.x / viewportWidth * 2 - 1;
  70227. source.y = -(source.y / viewportHeight * 2 - 1);
  70228. var vector = new Vector3();
  70229. Vector3._UnprojectFromInvertedMatrixToRef(source, matrix, vector);
  70230. return vector;
  70231. };
  70232. /**
  70233. * Unproject from screen space to object space
  70234. * @param source defines the screen space Vector3 to use
  70235. * @param viewportWidth defines the current width of the viewport
  70236. * @param viewportHeight defines the current height of the viewport
  70237. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70238. * @param view defines the view matrix to use
  70239. * @param projection defines the projection matrix to use
  70240. * @returns the new Vector3
  70241. */
  70242. Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
  70243. var result = Vector3.Zero();
  70244. Vector3.UnprojectToRef(source, viewportWidth, viewportHeight, world, view, projection, result);
  70245. return result;
  70246. };
  70247. /**
  70248. * Unproject from screen space to object space
  70249. * @param source defines the screen space Vector3 to use
  70250. * @param viewportWidth defines the current width of the viewport
  70251. * @param viewportHeight defines the current height of the viewport
  70252. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70253. * @param view defines the view matrix to use
  70254. * @param projection defines the projection matrix to use
  70255. * @param result defines the Vector3 where to store the result
  70256. */
  70257. Vector3.UnprojectToRef = function (source, viewportWidth, viewportHeight, world, view, projection, result) {
  70258. Vector3.UnprojectFloatsToRef(source.x, source.y, source.z, viewportWidth, viewportHeight, world, view, projection, result);
  70259. };
  70260. /**
  70261. * Unproject from screen space to object space
  70262. * @param sourceX defines the screen space x coordinate to use
  70263. * @param sourceY defines the screen space y coordinate to use
  70264. * @param sourceZ defines the screen space z coordinate to use
  70265. * @param viewportWidth defines the current width of the viewport
  70266. * @param viewportHeight defines the current height of the viewport
  70267. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70268. * @param view defines the view matrix to use
  70269. * @param projection defines the projection matrix to use
  70270. * @param result defines the Vector3 where to store the result
  70271. */
  70272. Vector3.UnprojectFloatsToRef = function (sourceX, sourceY, sourceZ, viewportWidth, viewportHeight, world, view, projection, result) {
  70273. var matrix = MathTmp.Matrix[0];
  70274. world.multiplyToRef(view, matrix);
  70275. matrix.multiplyToRef(projection, matrix);
  70276. matrix.invert();
  70277. var screenSource = MathTmp.Vector3[0];
  70278. screenSource.x = sourceX / viewportWidth * 2 - 1;
  70279. screenSource.y = -(sourceY / viewportHeight * 2 - 1);
  70280. screenSource.z = 2 * sourceZ - 1.0;
  70281. Vector3._UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
  70282. };
  70283. /**
  70284. * Gets the minimal coordinate values between two Vector3
  70285. * @param left defines the first operand
  70286. * @param right defines the second operand
  70287. * @returns the new Vector3
  70288. */
  70289. Vector3.Minimize = function (left, right) {
  70290. var min = left.clone();
  70291. min.minimizeInPlace(right);
  70292. return min;
  70293. };
  70294. /**
  70295. * Gets the maximal coordinate values between two Vector3
  70296. * @param left defines the first operand
  70297. * @param right defines the second operand
  70298. * @returns the new Vector3
  70299. */
  70300. Vector3.Maximize = function (left, right) {
  70301. var max = left.clone();
  70302. max.maximizeInPlace(right);
  70303. return max;
  70304. };
  70305. /**
  70306. * Returns the distance between the vectors "value1" and "value2"
  70307. * @param value1 defines the first operand
  70308. * @param value2 defines the second operand
  70309. * @returns the distance
  70310. */
  70311. Vector3.Distance = function (value1, value2) {
  70312. return Math.sqrt(Vector3.DistanceSquared(value1, value2));
  70313. };
  70314. /**
  70315. * Returns the squared distance between the vectors "value1" and "value2"
  70316. * @param value1 defines the first operand
  70317. * @param value2 defines the second operand
  70318. * @returns the squared distance
  70319. */
  70320. Vector3.DistanceSquared = function (value1, value2) {
  70321. var x = value1.x - value2.x;
  70322. var y = value1.y - value2.y;
  70323. var z = value1.z - value2.z;
  70324. return (x * x) + (y * y) + (z * z);
  70325. };
  70326. /**
  70327. * Returns a new Vector3 located at the center between "value1" and "value2"
  70328. * @param value1 defines the first operand
  70329. * @param value2 defines the second operand
  70330. * @returns the new Vector3
  70331. */
  70332. Vector3.Center = function (value1, value2) {
  70333. var center = value1.add(value2);
  70334. center.scaleInPlace(0.5);
  70335. return center;
  70336. };
  70337. /**
  70338. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  70339. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  70340. * to something in order to rotate it from its local system to the given target system
  70341. * Note: axis1, axis2 and axis3 are normalized during this operation
  70342. * @param axis1 defines the first axis
  70343. * @param axis2 defines the second axis
  70344. * @param axis3 defines the third axis
  70345. * @returns a new Vector3
  70346. */
  70347. Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
  70348. var rotation = Vector3.Zero();
  70349. Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
  70350. return rotation;
  70351. };
  70352. /**
  70353. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  70354. * @param axis1 defines the first axis
  70355. * @param axis2 defines the second axis
  70356. * @param axis3 defines the third axis
  70357. * @param ref defines the Vector3 where to store the result
  70358. */
  70359. Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
  70360. var quat = MathTmp.Quaternion[0];
  70361. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  70362. quat.toEulerAnglesToRef(ref);
  70363. };
  70364. Vector3._UpReadOnly = Vector3.Up();
  70365. return Vector3;
  70366. }());
  70367. /**
  70368. * Vector4 class created for EulerAngle class conversion to Quaternion
  70369. */
  70370. var Vector4 = /** @class */ (function () {
  70371. /**
  70372. * Creates a Vector4 object from the given floats.
  70373. * @param x x value of the vector
  70374. * @param y y value of the vector
  70375. * @param z z value of the vector
  70376. * @param w w value of the vector
  70377. */
  70378. function Vector4(
  70379. /** x value of the vector */
  70380. x,
  70381. /** y value of the vector */
  70382. y,
  70383. /** z value of the vector */
  70384. z,
  70385. /** w value of the vector */
  70386. w) {
  70387. this.x = x;
  70388. this.y = y;
  70389. this.z = z;
  70390. this.w = w;
  70391. }
  70392. /**
  70393. * Returns the string with the Vector4 coordinates.
  70394. * @returns a string containing all the vector values
  70395. */
  70396. Vector4.prototype.toString = function () {
  70397. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  70398. };
  70399. /**
  70400. * Returns the string "Vector4".
  70401. * @returns "Vector4"
  70402. */
  70403. Vector4.prototype.getClassName = function () {
  70404. return "Vector4";
  70405. };
  70406. /**
  70407. * Returns the Vector4 hash code.
  70408. * @returns a unique hash code
  70409. */
  70410. Vector4.prototype.getHashCode = function () {
  70411. var hash = this.x || 0;
  70412. hash = (hash * 397) ^ (this.y || 0);
  70413. hash = (hash * 397) ^ (this.z || 0);
  70414. hash = (hash * 397) ^ (this.w || 0);
  70415. return hash;
  70416. };
  70417. // Operators
  70418. /**
  70419. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  70420. * @returns the resulting array
  70421. */
  70422. Vector4.prototype.asArray = function () {
  70423. var result = new Array();
  70424. this.toArray(result, 0);
  70425. return result;
  70426. };
  70427. /**
  70428. * Populates the given array from the given index with the Vector4 coordinates.
  70429. * @param array array to populate
  70430. * @param index index of the array to start at (default: 0)
  70431. * @returns the Vector4.
  70432. */
  70433. Vector4.prototype.toArray = function (array, index) {
  70434. if (index === undefined) {
  70435. index = 0;
  70436. }
  70437. array[index] = this.x;
  70438. array[index + 1] = this.y;
  70439. array[index + 2] = this.z;
  70440. array[index + 3] = this.w;
  70441. return this;
  70442. };
  70443. /**
  70444. * Adds the given vector to the current Vector4.
  70445. * @param otherVector the vector to add
  70446. * @returns the updated Vector4.
  70447. */
  70448. Vector4.prototype.addInPlace = function (otherVector) {
  70449. this.x += otherVector.x;
  70450. this.y += otherVector.y;
  70451. this.z += otherVector.z;
  70452. this.w += otherVector.w;
  70453. return this;
  70454. };
  70455. /**
  70456. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  70457. * @param otherVector the vector to add
  70458. * @returns the resulting vector
  70459. */
  70460. Vector4.prototype.add = function (otherVector) {
  70461. return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
  70462. };
  70463. /**
  70464. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  70465. * @param otherVector the vector to add
  70466. * @param result the vector to store the result
  70467. * @returns the current Vector4.
  70468. */
  70469. Vector4.prototype.addToRef = function (otherVector, result) {
  70470. result.x = this.x + otherVector.x;
  70471. result.y = this.y + otherVector.y;
  70472. result.z = this.z + otherVector.z;
  70473. result.w = this.w + otherVector.w;
  70474. return this;
  70475. };
  70476. /**
  70477. * Subtract in place the given vector from the current Vector4.
  70478. * @param otherVector the vector to subtract
  70479. * @returns the updated Vector4.
  70480. */
  70481. Vector4.prototype.subtractInPlace = function (otherVector) {
  70482. this.x -= otherVector.x;
  70483. this.y -= otherVector.y;
  70484. this.z -= otherVector.z;
  70485. this.w -= otherVector.w;
  70486. return this;
  70487. };
  70488. /**
  70489. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  70490. * @param otherVector the vector to add
  70491. * @returns the new vector with the result
  70492. */
  70493. Vector4.prototype.subtract = function (otherVector) {
  70494. return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
  70495. };
  70496. /**
  70497. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  70498. * @param otherVector the vector to subtract
  70499. * @param result the vector to store the result
  70500. * @returns the current Vector4.
  70501. */
  70502. Vector4.prototype.subtractToRef = function (otherVector, result) {
  70503. result.x = this.x - otherVector.x;
  70504. result.y = this.y - otherVector.y;
  70505. result.z = this.z - otherVector.z;
  70506. result.w = this.w - otherVector.w;
  70507. return this;
  70508. };
  70509. /**
  70510. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70511. */
  70512. /**
  70513. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70514. * @param x value to subtract
  70515. * @param y value to subtract
  70516. * @param z value to subtract
  70517. * @param w value to subtract
  70518. * @returns new vector containing the result
  70519. */
  70520. Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
  70521. return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
  70522. };
  70523. /**
  70524. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70525. * @param x value to subtract
  70526. * @param y value to subtract
  70527. * @param z value to subtract
  70528. * @param w value to subtract
  70529. * @param result the vector to store the result in
  70530. * @returns the current Vector4.
  70531. */
  70532. Vector4.prototype.subtractFromFloatsToRef = function (x, y, z, w, result) {
  70533. result.x = this.x - x;
  70534. result.y = this.y - y;
  70535. result.z = this.z - z;
  70536. result.w = this.w - w;
  70537. return this;
  70538. };
  70539. /**
  70540. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  70541. * @returns a new vector with the negated values
  70542. */
  70543. Vector4.prototype.negate = function () {
  70544. return new Vector4(-this.x, -this.y, -this.z, -this.w);
  70545. };
  70546. /**
  70547. * Multiplies the current Vector4 coordinates by scale (float).
  70548. * @param scale the number to scale with
  70549. * @returns the updated Vector4.
  70550. */
  70551. Vector4.prototype.scaleInPlace = function (scale) {
  70552. this.x *= scale;
  70553. this.y *= scale;
  70554. this.z *= scale;
  70555. this.w *= scale;
  70556. return this;
  70557. };
  70558. /**
  70559. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  70560. * @param scale the number to scale with
  70561. * @returns a new vector with the result
  70562. */
  70563. Vector4.prototype.scale = function (scale) {
  70564. return new Vector4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
  70565. };
  70566. /**
  70567. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  70568. * @param scale the number to scale with
  70569. * @param result a vector to store the result in
  70570. * @returns the current Vector4.
  70571. */
  70572. Vector4.prototype.scaleToRef = function (scale, result) {
  70573. result.x = this.x * scale;
  70574. result.y = this.y * scale;
  70575. result.z = this.z * scale;
  70576. result.w = this.w * scale;
  70577. return this;
  70578. };
  70579. /**
  70580. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  70581. * @param scale defines the scale factor
  70582. * @param result defines the Vector4 object where to store the result
  70583. * @returns the unmodified current Vector4
  70584. */
  70585. Vector4.prototype.scaleAndAddToRef = function (scale, result) {
  70586. result.x += this.x * scale;
  70587. result.y += this.y * scale;
  70588. result.z += this.z * scale;
  70589. result.w += this.w * scale;
  70590. return this;
  70591. };
  70592. /**
  70593. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  70594. * @param otherVector the vector to compare against
  70595. * @returns true if they are equal
  70596. */
  70597. Vector4.prototype.equals = function (otherVector) {
  70598. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
  70599. };
  70600. /**
  70601. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  70602. * @param otherVector vector to compare against
  70603. * @param epsilon (Default: very small number)
  70604. * @returns true if they are equal
  70605. */
  70606. Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  70607. if (epsilon === void 0) { epsilon = Epsilon; }
  70608. return otherVector
  70609. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon)
  70610. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon)
  70611. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon)
  70612. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.w, otherVector.w, epsilon);
  70613. };
  70614. /**
  70615. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  70616. * @param x x value to compare against
  70617. * @param y y value to compare against
  70618. * @param z z value to compare against
  70619. * @param w w value to compare against
  70620. * @returns true if equal
  70621. */
  70622. Vector4.prototype.equalsToFloats = function (x, y, z, w) {
  70623. return this.x === x && this.y === y && this.z === z && this.w === w;
  70624. };
  70625. /**
  70626. * Multiplies in place the current Vector4 by the given one.
  70627. * @param otherVector vector to multiple with
  70628. * @returns the updated Vector4.
  70629. */
  70630. Vector4.prototype.multiplyInPlace = function (otherVector) {
  70631. this.x *= otherVector.x;
  70632. this.y *= otherVector.y;
  70633. this.z *= otherVector.z;
  70634. this.w *= otherVector.w;
  70635. return this;
  70636. };
  70637. /**
  70638. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  70639. * @param otherVector vector to multiple with
  70640. * @returns resulting new vector
  70641. */
  70642. Vector4.prototype.multiply = function (otherVector) {
  70643. return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
  70644. };
  70645. /**
  70646. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  70647. * @param otherVector vector to multiple with
  70648. * @param result vector to store the result
  70649. * @returns the current Vector4.
  70650. */
  70651. Vector4.prototype.multiplyToRef = function (otherVector, result) {
  70652. result.x = this.x * otherVector.x;
  70653. result.y = this.y * otherVector.y;
  70654. result.z = this.z * otherVector.z;
  70655. result.w = this.w * otherVector.w;
  70656. return this;
  70657. };
  70658. /**
  70659. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  70660. * @param x x value multiply with
  70661. * @param y y value multiply with
  70662. * @param z z value multiply with
  70663. * @param w w value multiply with
  70664. * @returns resulting new vector
  70665. */
  70666. Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
  70667. return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
  70668. };
  70669. /**
  70670. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  70671. * @param otherVector vector to devide with
  70672. * @returns resulting new vector
  70673. */
  70674. Vector4.prototype.divide = function (otherVector) {
  70675. return new Vector4(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z, this.w / otherVector.w);
  70676. };
  70677. /**
  70678. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  70679. * @param otherVector vector to devide with
  70680. * @param result vector to store the result
  70681. * @returns the current Vector4.
  70682. */
  70683. Vector4.prototype.divideToRef = function (otherVector, result) {
  70684. result.x = this.x / otherVector.x;
  70685. result.y = this.y / otherVector.y;
  70686. result.z = this.z / otherVector.z;
  70687. result.w = this.w / otherVector.w;
  70688. return this;
  70689. };
  70690. /**
  70691. * Divides the current Vector3 coordinates by the given ones.
  70692. * @param otherVector vector to devide with
  70693. * @returns the updated Vector3.
  70694. */
  70695. Vector4.prototype.divideInPlace = function (otherVector) {
  70696. return this.divideToRef(otherVector, this);
  70697. };
  70698. /**
  70699. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  70700. * @param other defines the second operand
  70701. * @returns the current updated Vector4
  70702. */
  70703. Vector4.prototype.minimizeInPlace = function (other) {
  70704. if (other.x < this.x) {
  70705. this.x = other.x;
  70706. }
  70707. if (other.y < this.y) {
  70708. this.y = other.y;
  70709. }
  70710. if (other.z < this.z) {
  70711. this.z = other.z;
  70712. }
  70713. if (other.w < this.w) {
  70714. this.w = other.w;
  70715. }
  70716. return this;
  70717. };
  70718. /**
  70719. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  70720. * @param other defines the second operand
  70721. * @returns the current updated Vector4
  70722. */
  70723. Vector4.prototype.maximizeInPlace = function (other) {
  70724. if (other.x > this.x) {
  70725. this.x = other.x;
  70726. }
  70727. if (other.y > this.y) {
  70728. this.y = other.y;
  70729. }
  70730. if (other.z > this.z) {
  70731. this.z = other.z;
  70732. }
  70733. if (other.w > this.w) {
  70734. this.w = other.w;
  70735. }
  70736. return this;
  70737. };
  70738. /**
  70739. * Gets a new Vector4 from current Vector4 floored values
  70740. * @returns a new Vector4
  70741. */
  70742. Vector4.prototype.floor = function () {
  70743. return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
  70744. };
  70745. /**
  70746. * Gets a new Vector4 from current Vector3 floored values
  70747. * @returns a new Vector4
  70748. */
  70749. Vector4.prototype.fract = function () {
  70750. 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));
  70751. };
  70752. // Properties
  70753. /**
  70754. * Returns the Vector4 length (float).
  70755. * @returns the length
  70756. */
  70757. Vector4.prototype.length = function () {
  70758. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  70759. };
  70760. /**
  70761. * Returns the Vector4 squared length (float).
  70762. * @returns the length squared
  70763. */
  70764. Vector4.prototype.lengthSquared = function () {
  70765. return (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  70766. };
  70767. // Methods
  70768. /**
  70769. * Normalizes in place the Vector4.
  70770. * @returns the updated Vector4.
  70771. */
  70772. Vector4.prototype.normalize = function () {
  70773. var len = this.length();
  70774. if (len === 0) {
  70775. return this;
  70776. }
  70777. return this.scaleInPlace(1.0 / len);
  70778. };
  70779. /**
  70780. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70781. * @returns this converted to a new vector3
  70782. */
  70783. Vector4.prototype.toVector3 = function () {
  70784. return new Vector3(this.x, this.y, this.z);
  70785. };
  70786. /**
  70787. * Returns a new Vector4 copied from the current one.
  70788. * @returns the new cloned vector
  70789. */
  70790. Vector4.prototype.clone = function () {
  70791. return new Vector4(this.x, this.y, this.z, this.w);
  70792. };
  70793. /**
  70794. * Updates the current Vector4 with the given one coordinates.
  70795. * @param source the source vector to copy from
  70796. * @returns the updated Vector4.
  70797. */
  70798. Vector4.prototype.copyFrom = function (source) {
  70799. this.x = source.x;
  70800. this.y = source.y;
  70801. this.z = source.z;
  70802. this.w = source.w;
  70803. return this;
  70804. };
  70805. /**
  70806. * Updates the current Vector4 coordinates with the given floats.
  70807. * @param x float to copy from
  70808. * @param y float to copy from
  70809. * @param z float to copy from
  70810. * @param w float to copy from
  70811. * @returns the updated Vector4.
  70812. */
  70813. Vector4.prototype.copyFromFloats = function (x, y, z, w) {
  70814. this.x = x;
  70815. this.y = y;
  70816. this.z = z;
  70817. this.w = w;
  70818. return this;
  70819. };
  70820. /**
  70821. * Updates the current Vector4 coordinates with the given floats.
  70822. * @param x float to set from
  70823. * @param y float to set from
  70824. * @param z float to set from
  70825. * @param w float to set from
  70826. * @returns the updated Vector4.
  70827. */
  70828. Vector4.prototype.set = function (x, y, z, w) {
  70829. return this.copyFromFloats(x, y, z, w);
  70830. };
  70831. /**
  70832. * Copies the given float to the current Vector3 coordinates
  70833. * @param v defines the x, y, z and w coordinates of the operand
  70834. * @returns the current updated Vector3
  70835. */
  70836. Vector4.prototype.setAll = function (v) {
  70837. this.x = this.y = this.z = this.w = v;
  70838. return this;
  70839. };
  70840. // Statics
  70841. /**
  70842. * Returns a new Vector4 set from the starting index of the given array.
  70843. * @param array the array to pull values from
  70844. * @param offset the offset into the array to start at
  70845. * @returns the new vector
  70846. */
  70847. Vector4.FromArray = function (array, offset) {
  70848. if (!offset) {
  70849. offset = 0;
  70850. }
  70851. return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  70852. };
  70853. /**
  70854. * Updates the given vector "result" from the starting index of the given array.
  70855. * @param array the array to pull values from
  70856. * @param offset the offset into the array to start at
  70857. * @param result the vector to store the result in
  70858. */
  70859. Vector4.FromArrayToRef = function (array, offset, result) {
  70860. result.x = array[offset];
  70861. result.y = array[offset + 1];
  70862. result.z = array[offset + 2];
  70863. result.w = array[offset + 3];
  70864. };
  70865. /**
  70866. * Updates the given vector "result" from the starting index of the given Float32Array.
  70867. * @param array the array to pull values from
  70868. * @param offset the offset into the array to start at
  70869. * @param result the vector to store the result in
  70870. */
  70871. Vector4.FromFloatArrayToRef = function (array, offset, result) {
  70872. Vector4.FromArrayToRef(array, offset, result);
  70873. };
  70874. /**
  70875. * Updates the given vector "result" coordinates from the given floats.
  70876. * @param x float to set from
  70877. * @param y float to set from
  70878. * @param z float to set from
  70879. * @param w float to set from
  70880. * @param result the vector to the floats in
  70881. */
  70882. Vector4.FromFloatsToRef = function (x, y, z, w, result) {
  70883. result.x = x;
  70884. result.y = y;
  70885. result.z = z;
  70886. result.w = w;
  70887. };
  70888. /**
  70889. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70890. * @returns the new vector
  70891. */
  70892. Vector4.Zero = function () {
  70893. return new Vector4(0.0, 0.0, 0.0, 0.0);
  70894. };
  70895. /**
  70896. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70897. * @returns the new vector
  70898. */
  70899. Vector4.One = function () {
  70900. return new Vector4(1.0, 1.0, 1.0, 1.0);
  70901. };
  70902. /**
  70903. * Returns a new normalized Vector4 from the given one.
  70904. * @param vector the vector to normalize
  70905. * @returns the vector
  70906. */
  70907. Vector4.Normalize = function (vector) {
  70908. var result = Vector4.Zero();
  70909. Vector4.NormalizeToRef(vector, result);
  70910. return result;
  70911. };
  70912. /**
  70913. * Updates the given vector "result" from the normalization of the given one.
  70914. * @param vector the vector to normalize
  70915. * @param result the vector to store the result in
  70916. */
  70917. Vector4.NormalizeToRef = function (vector, result) {
  70918. result.copyFrom(vector);
  70919. result.normalize();
  70920. };
  70921. /**
  70922. * Returns a vector with the minimum values from the left and right vectors
  70923. * @param left left vector to minimize
  70924. * @param right right vector to minimize
  70925. * @returns a new vector with the minimum of the left and right vector values
  70926. */
  70927. Vector4.Minimize = function (left, right) {
  70928. var min = left.clone();
  70929. min.minimizeInPlace(right);
  70930. return min;
  70931. };
  70932. /**
  70933. * Returns a vector with the maximum values from the left and right vectors
  70934. * @param left left vector to maximize
  70935. * @param right right vector to maximize
  70936. * @returns a new vector with the maximum of the left and right vector values
  70937. */
  70938. Vector4.Maximize = function (left, right) {
  70939. var max = left.clone();
  70940. max.maximizeInPlace(right);
  70941. return max;
  70942. };
  70943. /**
  70944. * Returns the distance (float) between the vectors "value1" and "value2".
  70945. * @param value1 value to calulate the distance between
  70946. * @param value2 value to calulate the distance between
  70947. * @return the distance between the two vectors
  70948. */
  70949. Vector4.Distance = function (value1, value2) {
  70950. return Math.sqrt(Vector4.DistanceSquared(value1, value2));
  70951. };
  70952. /**
  70953. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70954. * @param value1 value to calulate the distance between
  70955. * @param value2 value to calulate the distance between
  70956. * @return the distance between the two vectors squared
  70957. */
  70958. Vector4.DistanceSquared = function (value1, value2) {
  70959. var x = value1.x - value2.x;
  70960. var y = value1.y - value2.y;
  70961. var z = value1.z - value2.z;
  70962. var w = value1.w - value2.w;
  70963. return (x * x) + (y * y) + (z * z) + (w * w);
  70964. };
  70965. /**
  70966. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70967. * @param value1 value to calulate the center between
  70968. * @param value2 value to calulate the center between
  70969. * @return the center between the two vectors
  70970. */
  70971. Vector4.Center = function (value1, value2) {
  70972. var center = value1.add(value2);
  70973. center.scaleInPlace(0.5);
  70974. return center;
  70975. };
  70976. /**
  70977. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70978. * This methods computes transformed normalized direction vectors only.
  70979. * @param vector the vector to transform
  70980. * @param transformation the transformation matrix to apply
  70981. * @returns the new vector
  70982. */
  70983. Vector4.TransformNormal = function (vector, transformation) {
  70984. var result = Vector4.Zero();
  70985. Vector4.TransformNormalToRef(vector, transformation, result);
  70986. return result;
  70987. };
  70988. /**
  70989. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70990. * This methods computes transformed normalized direction vectors only.
  70991. * @param vector the vector to transform
  70992. * @param transformation the transformation matrix to apply
  70993. * @param result the vector to store the result in
  70994. */
  70995. Vector4.TransformNormalToRef = function (vector, transformation, result) {
  70996. var m = transformation.m;
  70997. var x = (vector.x * m[0]) + (vector.y * m[4]) + (vector.z * m[8]);
  70998. var y = (vector.x * m[1]) + (vector.y * m[5]) + (vector.z * m[9]);
  70999. var z = (vector.x * m[2]) + (vector.y * m[6]) + (vector.z * m[10]);
  71000. result.x = x;
  71001. result.y = y;
  71002. result.z = z;
  71003. result.w = vector.w;
  71004. };
  71005. /**
  71006. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  71007. * This methods computes transformed normalized direction vectors only.
  71008. * @param x value to transform
  71009. * @param y value to transform
  71010. * @param z value to transform
  71011. * @param w value to transform
  71012. * @param transformation the transformation matrix to apply
  71013. * @param result the vector to store the results in
  71014. */
  71015. Vector4.TransformNormalFromFloatsToRef = function (x, y, z, w, transformation, result) {
  71016. var m = transformation.m;
  71017. result.x = (x * m[0]) + (y * m[4]) + (z * m[8]);
  71018. result.y = (x * m[1]) + (y * m[5]) + (z * m[9]);
  71019. result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
  71020. result.w = w;
  71021. };
  71022. /**
  71023. * Creates a new Vector4 from a Vector3
  71024. * @param source defines the source data
  71025. * @param w defines the 4th component (default is 0)
  71026. * @returns a new Vector4
  71027. */
  71028. Vector4.FromVector3 = function (source, w) {
  71029. if (w === void 0) { w = 0; }
  71030. return new Vector4(source.x, source.y, source.z, w);
  71031. };
  71032. return Vector4;
  71033. }());
  71034. /**
  71035. * Size containing widht and height
  71036. */
  71037. var Size = /** @class */ (function () {
  71038. /**
  71039. * Creates a Size object from the given width and height (floats).
  71040. * @param width width of the new size
  71041. * @param height height of the new size
  71042. */
  71043. function Size(width, height) {
  71044. this.width = width;
  71045. this.height = height;
  71046. }
  71047. /**
  71048. * Returns a string with the Size width and height
  71049. * @returns a string with the Size width and height
  71050. */
  71051. Size.prototype.toString = function () {
  71052. return "{W: " + this.width + ", H: " + this.height + "}";
  71053. };
  71054. /**
  71055. * "Size"
  71056. * @returns the string "Size"
  71057. */
  71058. Size.prototype.getClassName = function () {
  71059. return "Size";
  71060. };
  71061. /**
  71062. * Returns the Size hash code.
  71063. * @returns a hash code for a unique width and height
  71064. */
  71065. Size.prototype.getHashCode = function () {
  71066. var hash = this.width || 0;
  71067. hash = (hash * 397) ^ (this.height || 0);
  71068. return hash;
  71069. };
  71070. /**
  71071. * Updates the current size from the given one.
  71072. * @param src the given size
  71073. */
  71074. Size.prototype.copyFrom = function (src) {
  71075. this.width = src.width;
  71076. this.height = src.height;
  71077. };
  71078. /**
  71079. * Updates in place the current Size from the given floats.
  71080. * @param width width of the new size
  71081. * @param height height of the new size
  71082. * @returns the updated Size.
  71083. */
  71084. Size.prototype.copyFromFloats = function (width, height) {
  71085. this.width = width;
  71086. this.height = height;
  71087. return this;
  71088. };
  71089. /**
  71090. * Updates in place the current Size from the given floats.
  71091. * @param width width to set
  71092. * @param height height to set
  71093. * @returns the updated Size.
  71094. */
  71095. Size.prototype.set = function (width, height) {
  71096. return this.copyFromFloats(width, height);
  71097. };
  71098. /**
  71099. * Multiplies the width and height by numbers
  71100. * @param w factor to multiple the width by
  71101. * @param h factor to multiple the height by
  71102. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  71103. */
  71104. Size.prototype.multiplyByFloats = function (w, h) {
  71105. return new Size(this.width * w, this.height * h);
  71106. };
  71107. /**
  71108. * Clones the size
  71109. * @returns a new Size copied from the given one.
  71110. */
  71111. Size.prototype.clone = function () {
  71112. return new Size(this.width, this.height);
  71113. };
  71114. /**
  71115. * True if the current Size and the given one width and height are strictly equal.
  71116. * @param other the other size to compare against
  71117. * @returns True if the current Size and the given one width and height are strictly equal.
  71118. */
  71119. Size.prototype.equals = function (other) {
  71120. if (!other) {
  71121. return false;
  71122. }
  71123. return (this.width === other.width) && (this.height === other.height);
  71124. };
  71125. Object.defineProperty(Size.prototype, "surface", {
  71126. /**
  71127. * The surface of the Size : width * height (float).
  71128. */
  71129. get: function () {
  71130. return this.width * this.height;
  71131. },
  71132. enumerable: true,
  71133. configurable: true
  71134. });
  71135. /**
  71136. * Create a new size of zero
  71137. * @returns a new Size set to (0.0, 0.0)
  71138. */
  71139. Size.Zero = function () {
  71140. return new Size(0.0, 0.0);
  71141. };
  71142. /**
  71143. * Sums the width and height of two sizes
  71144. * @param otherSize size to add to this size
  71145. * @returns a new Size set as the addition result of the current Size and the given one.
  71146. */
  71147. Size.prototype.add = function (otherSize) {
  71148. var r = new Size(this.width + otherSize.width, this.height + otherSize.height);
  71149. return r;
  71150. };
  71151. /**
  71152. * Subtracts the width and height of two
  71153. * @param otherSize size to subtract to this size
  71154. * @returns a new Size set as the subtraction result of the given one from the current Size.
  71155. */
  71156. Size.prototype.subtract = function (otherSize) {
  71157. var r = new Size(this.width - otherSize.width, this.height - otherSize.height);
  71158. return r;
  71159. };
  71160. /**
  71161. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  71162. * @param start starting size to lerp between
  71163. * @param end end size to lerp between
  71164. * @param amount amount to lerp between the start and end values
  71165. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  71166. */
  71167. Size.Lerp = function (start, end, amount) {
  71168. var w = start.width + ((end.width - start.width) * amount);
  71169. var h = start.height + ((end.height - start.height) * amount);
  71170. return new Size(w, h);
  71171. };
  71172. return Size;
  71173. }());
  71174. /**
  71175. * Class used to store quaternion data
  71176. * @see https://en.wikipedia.org/wiki/Quaternion
  71177. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  71178. */
  71179. var Quaternion = /** @class */ (function () {
  71180. /**
  71181. * Creates a new Quaternion from the given floats
  71182. * @param x defines the first component (0 by default)
  71183. * @param y defines the second component (0 by default)
  71184. * @param z defines the third component (0 by default)
  71185. * @param w defines the fourth component (1.0 by default)
  71186. */
  71187. function Quaternion(
  71188. /** defines the first component (0 by default) */
  71189. x,
  71190. /** defines the second component (0 by default) */
  71191. y,
  71192. /** defines the third component (0 by default) */
  71193. z,
  71194. /** defines the fourth component (1.0 by default) */
  71195. w) {
  71196. if (x === void 0) { x = 0.0; }
  71197. if (y === void 0) { y = 0.0; }
  71198. if (z === void 0) { z = 0.0; }
  71199. if (w === void 0) { w = 1.0; }
  71200. this.x = x;
  71201. this.y = y;
  71202. this.z = z;
  71203. this.w = w;
  71204. }
  71205. /**
  71206. * Gets a string representation for the current quaternion
  71207. * @returns a string with the Quaternion coordinates
  71208. */
  71209. Quaternion.prototype.toString = function () {
  71210. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  71211. };
  71212. /**
  71213. * Gets the class name of the quaternion
  71214. * @returns the string "Quaternion"
  71215. */
  71216. Quaternion.prototype.getClassName = function () {
  71217. return "Quaternion";
  71218. };
  71219. /**
  71220. * Gets a hash code for this quaternion
  71221. * @returns the quaternion hash code
  71222. */
  71223. Quaternion.prototype.getHashCode = function () {
  71224. var hash = this.x || 0;
  71225. hash = (hash * 397) ^ (this.y || 0);
  71226. hash = (hash * 397) ^ (this.z || 0);
  71227. hash = (hash * 397) ^ (this.w || 0);
  71228. return hash;
  71229. };
  71230. /**
  71231. * Copy the quaternion to an array
  71232. * @returns a new array populated with 4 elements from the quaternion coordinates
  71233. */
  71234. Quaternion.prototype.asArray = function () {
  71235. return [this.x, this.y, this.z, this.w];
  71236. };
  71237. /**
  71238. * Check if two quaternions are equals
  71239. * @param otherQuaternion defines the second operand
  71240. * @return true if the current quaternion and the given one coordinates are strictly equals
  71241. */
  71242. Quaternion.prototype.equals = function (otherQuaternion) {
  71243. return otherQuaternion && this.x === otherQuaternion.x && this.y === otherQuaternion.y && this.z === otherQuaternion.z && this.w === otherQuaternion.w;
  71244. };
  71245. /**
  71246. * Clone the current quaternion
  71247. * @returns a new quaternion copied from the current one
  71248. */
  71249. Quaternion.prototype.clone = function () {
  71250. return new Quaternion(this.x, this.y, this.z, this.w);
  71251. };
  71252. /**
  71253. * Copy a quaternion to the current one
  71254. * @param other defines the other quaternion
  71255. * @returns the updated current quaternion
  71256. */
  71257. Quaternion.prototype.copyFrom = function (other) {
  71258. this.x = other.x;
  71259. this.y = other.y;
  71260. this.z = other.z;
  71261. this.w = other.w;
  71262. return this;
  71263. };
  71264. /**
  71265. * Updates the current quaternion with the given float coordinates
  71266. * @param x defines the x coordinate
  71267. * @param y defines the y coordinate
  71268. * @param z defines the z coordinate
  71269. * @param w defines the w coordinate
  71270. * @returns the updated current quaternion
  71271. */
  71272. Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
  71273. this.x = x;
  71274. this.y = y;
  71275. this.z = z;
  71276. this.w = w;
  71277. return this;
  71278. };
  71279. /**
  71280. * Updates the current quaternion from the given float coordinates
  71281. * @param x defines the x coordinate
  71282. * @param y defines the y coordinate
  71283. * @param z defines the z coordinate
  71284. * @param w defines the w coordinate
  71285. * @returns the updated current quaternion
  71286. */
  71287. Quaternion.prototype.set = function (x, y, z, w) {
  71288. return this.copyFromFloats(x, y, z, w);
  71289. };
  71290. /**
  71291. * Adds two quaternions
  71292. * @param other defines the second operand
  71293. * @returns a new quaternion as the addition result of the given one and the current quaternion
  71294. */
  71295. Quaternion.prototype.add = function (other) {
  71296. return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
  71297. };
  71298. /**
  71299. * Add a quaternion to the current one
  71300. * @param other defines the quaternion to add
  71301. * @returns the current quaternion
  71302. */
  71303. Quaternion.prototype.addInPlace = function (other) {
  71304. this.x += other.x;
  71305. this.y += other.y;
  71306. this.z += other.z;
  71307. this.w += other.w;
  71308. return this;
  71309. };
  71310. /**
  71311. * Subtract two quaternions
  71312. * @param other defines the second operand
  71313. * @returns a new quaternion as the subtraction result of the given one from the current one
  71314. */
  71315. Quaternion.prototype.subtract = function (other) {
  71316. return new Quaternion(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w);
  71317. };
  71318. /**
  71319. * Multiplies the current quaternion by a scale factor
  71320. * @param value defines the scale factor
  71321. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  71322. */
  71323. Quaternion.prototype.scale = function (value) {
  71324. return new Quaternion(this.x * value, this.y * value, this.z * value, this.w * value);
  71325. };
  71326. /**
  71327. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  71328. * @param scale defines the scale factor
  71329. * @param result defines the Quaternion object where to store the result
  71330. * @returns the unmodified current quaternion
  71331. */
  71332. Quaternion.prototype.scaleToRef = function (scale, result) {
  71333. result.x = this.x * scale;
  71334. result.y = this.y * scale;
  71335. result.z = this.z * scale;
  71336. result.w = this.w * scale;
  71337. return this;
  71338. };
  71339. /**
  71340. * Multiplies in place the current quaternion by a scale factor
  71341. * @param value defines the scale factor
  71342. * @returns the current modified quaternion
  71343. */
  71344. Quaternion.prototype.scaleInPlace = function (value) {
  71345. this.x *= value;
  71346. this.y *= value;
  71347. this.z *= value;
  71348. this.w *= value;
  71349. return this;
  71350. };
  71351. /**
  71352. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71353. * @param scale defines the scale factor
  71354. * @param result defines the Quaternion object where to store the result
  71355. * @returns the unmodified current quaternion
  71356. */
  71357. Quaternion.prototype.scaleAndAddToRef = function (scale, result) {
  71358. result.x += this.x * scale;
  71359. result.y += this.y * scale;
  71360. result.z += this.z * scale;
  71361. result.w += this.w * scale;
  71362. return this;
  71363. };
  71364. /**
  71365. * Multiplies two quaternions
  71366. * @param q1 defines the second operand
  71367. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71368. */
  71369. Quaternion.prototype.multiply = function (q1) {
  71370. var result = new Quaternion(0, 0, 0, 1.0);
  71371. this.multiplyToRef(q1, result);
  71372. return result;
  71373. };
  71374. /**
  71375. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71376. * @param q1 defines the second operand
  71377. * @param result defines the target quaternion
  71378. * @returns the current quaternion
  71379. */
  71380. Quaternion.prototype.multiplyToRef = function (q1, result) {
  71381. var x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x;
  71382. var y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
  71383. var z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
  71384. var w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
  71385. result.copyFromFloats(x, y, z, w);
  71386. return this;
  71387. };
  71388. /**
  71389. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71390. * @param q1 defines the second operand
  71391. * @returns the currentupdated quaternion
  71392. */
  71393. Quaternion.prototype.multiplyInPlace = function (q1) {
  71394. this.multiplyToRef(q1, this);
  71395. return this;
  71396. };
  71397. /**
  71398. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71399. * @param ref defines the target quaternion
  71400. * @returns the current quaternion
  71401. */
  71402. Quaternion.prototype.conjugateToRef = function (ref) {
  71403. ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
  71404. return this;
  71405. };
  71406. /**
  71407. * Conjugates in place (1-q) the current quaternion
  71408. * @returns the current updated quaternion
  71409. */
  71410. Quaternion.prototype.conjugateInPlace = function () {
  71411. this.x *= -1;
  71412. this.y *= -1;
  71413. this.z *= -1;
  71414. return this;
  71415. };
  71416. /**
  71417. * Conjugates in place (1-q) the current quaternion
  71418. * @returns a new quaternion
  71419. */
  71420. Quaternion.prototype.conjugate = function () {
  71421. var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
  71422. return result;
  71423. };
  71424. /**
  71425. * Gets length of current quaternion
  71426. * @returns the quaternion length (float)
  71427. */
  71428. Quaternion.prototype.length = function () {
  71429. return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
  71430. };
  71431. /**
  71432. * Normalize in place the current quaternion
  71433. * @returns the current updated quaternion
  71434. */
  71435. Quaternion.prototype.normalize = function () {
  71436. var length = 1.0 / this.length();
  71437. this.x *= length;
  71438. this.y *= length;
  71439. this.z *= length;
  71440. this.w *= length;
  71441. return this;
  71442. };
  71443. /**
  71444. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71445. * @param order is a reserved parameter and is ignore for now
  71446. * @returns a new Vector3 containing the Euler angles
  71447. */
  71448. Quaternion.prototype.toEulerAngles = function (order) {
  71449. if (order === void 0) { order = "YZX"; }
  71450. var result = Vector3.Zero();
  71451. this.toEulerAnglesToRef(result);
  71452. return result;
  71453. };
  71454. /**
  71455. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71456. * @param result defines the vector which will be filled with the Euler angles
  71457. * @param order is a reserved parameter and is ignore for now
  71458. * @returns the current unchanged quaternion
  71459. */
  71460. Quaternion.prototype.toEulerAnglesToRef = function (result) {
  71461. var qz = this.z;
  71462. var qx = this.x;
  71463. var qy = this.y;
  71464. var qw = this.w;
  71465. var sqw = qw * qw;
  71466. var sqz = qz * qz;
  71467. var sqx = qx * qx;
  71468. var sqy = qy * qy;
  71469. var zAxisY = qy * qz - qx * qw;
  71470. var limit = .4999999;
  71471. if (zAxisY < -limit) {
  71472. result.y = 2 * Math.atan2(qy, qw);
  71473. result.x = Math.PI / 2;
  71474. result.z = 0;
  71475. }
  71476. else if (zAxisY > limit) {
  71477. result.y = 2 * Math.atan2(qy, qw);
  71478. result.x = -Math.PI / 2;
  71479. result.z = 0;
  71480. }
  71481. else {
  71482. result.z = Math.atan2(2.0 * (qx * qy + qz * qw), (-sqz - sqx + sqy + sqw));
  71483. result.x = Math.asin(-2.0 * (qz * qy - qx * qw));
  71484. result.y = Math.atan2(2.0 * (qz * qx + qy * qw), (sqz - sqx - sqy + sqw));
  71485. }
  71486. return this;
  71487. };
  71488. /**
  71489. * Updates the given rotation matrix with the current quaternion values
  71490. * @param result defines the target matrix
  71491. * @returns the current unchanged quaternion
  71492. */
  71493. Quaternion.prototype.toRotationMatrix = function (result) {
  71494. Matrix.FromQuaternionToRef(this, result);
  71495. return this;
  71496. };
  71497. /**
  71498. * Updates the current quaternion from the given rotation matrix values
  71499. * @param matrix defines the source matrix
  71500. * @returns the current updated quaternion
  71501. */
  71502. Quaternion.prototype.fromRotationMatrix = function (matrix) {
  71503. Quaternion.FromRotationMatrixToRef(matrix, this);
  71504. return this;
  71505. };
  71506. // Statics
  71507. /**
  71508. * Creates a new quaternion from a rotation matrix
  71509. * @param matrix defines the source matrix
  71510. * @returns a new quaternion created from the given rotation matrix values
  71511. */
  71512. Quaternion.FromRotationMatrix = function (matrix) {
  71513. var result = new Quaternion();
  71514. Quaternion.FromRotationMatrixToRef(matrix, result);
  71515. return result;
  71516. };
  71517. /**
  71518. * Updates the given quaternion with the given rotation matrix values
  71519. * @param matrix defines the source matrix
  71520. * @param result defines the target quaternion
  71521. */
  71522. Quaternion.FromRotationMatrixToRef = function (matrix, result) {
  71523. var data = matrix.m;
  71524. var m11 = data[0], m12 = data[4], m13 = data[8];
  71525. var m21 = data[1], m22 = data[5], m23 = data[9];
  71526. var m31 = data[2], m32 = data[6], m33 = data[10];
  71527. var trace = m11 + m22 + m33;
  71528. var s;
  71529. if (trace > 0) {
  71530. s = 0.5 / Math.sqrt(trace + 1.0);
  71531. result.w = 0.25 / s;
  71532. result.x = (m32 - m23) * s;
  71533. result.y = (m13 - m31) * s;
  71534. result.z = (m21 - m12) * s;
  71535. }
  71536. else if (m11 > m22 && m11 > m33) {
  71537. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  71538. result.w = (m32 - m23) / s;
  71539. result.x = 0.25 * s;
  71540. result.y = (m12 + m21) / s;
  71541. result.z = (m13 + m31) / s;
  71542. }
  71543. else if (m22 > m33) {
  71544. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  71545. result.w = (m13 - m31) / s;
  71546. result.x = (m12 + m21) / s;
  71547. result.y = 0.25 * s;
  71548. result.z = (m23 + m32) / s;
  71549. }
  71550. else {
  71551. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  71552. result.w = (m21 - m12) / s;
  71553. result.x = (m13 + m31) / s;
  71554. result.y = (m23 + m32) / s;
  71555. result.z = 0.25 * s;
  71556. }
  71557. };
  71558. /**
  71559. * Returns the dot product (float) between the quaternions "left" and "right"
  71560. * @param left defines the left operand
  71561. * @param right defines the right operand
  71562. * @returns the dot product
  71563. */
  71564. Quaternion.Dot = function (left, right) {
  71565. return (left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w);
  71566. };
  71567. /**
  71568. * Checks if the two quaternions are close to each other
  71569. * @param quat0 defines the first quaternion to check
  71570. * @param quat1 defines the second quaternion to check
  71571. * @returns true if the two quaternions are close to each other
  71572. */
  71573. Quaternion.AreClose = function (quat0, quat1) {
  71574. var dot = Quaternion.Dot(quat0, quat1);
  71575. return dot >= 0;
  71576. };
  71577. /**
  71578. * Creates an empty quaternion
  71579. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71580. */
  71581. Quaternion.Zero = function () {
  71582. return new Quaternion(0.0, 0.0, 0.0, 0.0);
  71583. };
  71584. /**
  71585. * Inverse a given quaternion
  71586. * @param q defines the source quaternion
  71587. * @returns a new quaternion as the inverted current quaternion
  71588. */
  71589. Quaternion.Inverse = function (q) {
  71590. return new Quaternion(-q.x, -q.y, -q.z, q.w);
  71591. };
  71592. /**
  71593. * Inverse a given quaternion
  71594. * @param q defines the source quaternion
  71595. * @param result the quaternion the result will be stored in
  71596. * @returns the result quaternion
  71597. */
  71598. Quaternion.InverseToRef = function (q, result) {
  71599. result.set(-q.x, -q.y, -q.z, q.w);
  71600. return result;
  71601. };
  71602. /**
  71603. * Creates an identity quaternion
  71604. * @returns the identity quaternion
  71605. */
  71606. Quaternion.Identity = function () {
  71607. return new Quaternion(0.0, 0.0, 0.0, 1.0);
  71608. };
  71609. /**
  71610. * Gets a boolean indicating if the given quaternion is identity
  71611. * @param quaternion defines the quaternion to check
  71612. * @returns true if the quaternion is identity
  71613. */
  71614. Quaternion.IsIdentity = function (quaternion) {
  71615. return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;
  71616. };
  71617. /**
  71618. * Creates a quaternion from a rotation around an axis
  71619. * @param axis defines the axis to use
  71620. * @param angle defines the angle to use
  71621. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71622. */
  71623. Quaternion.RotationAxis = function (axis, angle) {
  71624. return Quaternion.RotationAxisToRef(axis, angle, new Quaternion());
  71625. };
  71626. /**
  71627. * Creates a rotation around an axis and stores it into the given quaternion
  71628. * @param axis defines the axis to use
  71629. * @param angle defines the angle to use
  71630. * @param result defines the target quaternion
  71631. * @returns the target quaternion
  71632. */
  71633. Quaternion.RotationAxisToRef = function (axis, angle, result) {
  71634. var sin = Math.sin(angle / 2);
  71635. axis.normalize();
  71636. result.w = Math.cos(angle / 2);
  71637. result.x = axis.x * sin;
  71638. result.y = axis.y * sin;
  71639. result.z = axis.z * sin;
  71640. return result;
  71641. };
  71642. /**
  71643. * Creates a new quaternion from data stored into an array
  71644. * @param array defines the data source
  71645. * @param offset defines the offset in the source array where the data starts
  71646. * @returns a new quaternion
  71647. */
  71648. Quaternion.FromArray = function (array, offset) {
  71649. if (!offset) {
  71650. offset = 0;
  71651. }
  71652. return new Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  71653. };
  71654. /**
  71655. * Create a quaternion from Euler rotation angles
  71656. * @param x Pitch
  71657. * @param y Yaw
  71658. * @param z Roll
  71659. * @returns the new Quaternion
  71660. */
  71661. Quaternion.FromEulerAngles = function (x, y, z) {
  71662. var q = new Quaternion();
  71663. Quaternion.RotationYawPitchRollToRef(y, x, z, q);
  71664. return q;
  71665. };
  71666. /**
  71667. * Updates a quaternion from Euler rotation angles
  71668. * @param x Pitch
  71669. * @param y Yaw
  71670. * @param z Roll
  71671. * @param result the quaternion to store the result
  71672. * @returns the updated quaternion
  71673. */
  71674. Quaternion.FromEulerAnglesToRef = function (x, y, z, result) {
  71675. Quaternion.RotationYawPitchRollToRef(y, x, z, result);
  71676. return result;
  71677. };
  71678. /**
  71679. * Create a quaternion from Euler rotation vector
  71680. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71681. * @returns the new Quaternion
  71682. */
  71683. Quaternion.FromEulerVector = function (vec) {
  71684. var q = new Quaternion();
  71685. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, q);
  71686. return q;
  71687. };
  71688. /**
  71689. * Updates a quaternion from Euler rotation vector
  71690. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71691. * @param result the quaternion to store the result
  71692. * @returns the updated quaternion
  71693. */
  71694. Quaternion.FromEulerVectorToRef = function (vec, result) {
  71695. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
  71696. return result;
  71697. };
  71698. /**
  71699. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71700. * @param yaw defines the rotation around Y axis
  71701. * @param pitch defines the rotation around X axis
  71702. * @param roll defines the rotation around Z axis
  71703. * @returns the new quaternion
  71704. */
  71705. Quaternion.RotationYawPitchRoll = function (yaw, pitch, roll) {
  71706. var q = new Quaternion();
  71707. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, q);
  71708. return q;
  71709. };
  71710. /**
  71711. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71712. * @param yaw defines the rotation around Y axis
  71713. * @param pitch defines the rotation around X axis
  71714. * @param roll defines the rotation around Z axis
  71715. * @param result defines the target quaternion
  71716. */
  71717. Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  71718. // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
  71719. var halfRoll = roll * 0.5;
  71720. var halfPitch = pitch * 0.5;
  71721. var halfYaw = yaw * 0.5;
  71722. var sinRoll = Math.sin(halfRoll);
  71723. var cosRoll = Math.cos(halfRoll);
  71724. var sinPitch = Math.sin(halfPitch);
  71725. var cosPitch = Math.cos(halfPitch);
  71726. var sinYaw = Math.sin(halfYaw);
  71727. var cosYaw = Math.cos(halfYaw);
  71728. result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
  71729. result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
  71730. result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
  71731. result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
  71732. };
  71733. /**
  71734. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71735. * @param alpha defines the rotation around first axis
  71736. * @param beta defines the rotation around second axis
  71737. * @param gamma defines the rotation around third axis
  71738. * @returns the new quaternion
  71739. */
  71740. Quaternion.RotationAlphaBetaGamma = function (alpha, beta, gamma) {
  71741. var result = new Quaternion();
  71742. Quaternion.RotationAlphaBetaGammaToRef(alpha, beta, gamma, result);
  71743. return result;
  71744. };
  71745. /**
  71746. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71747. * @param alpha defines the rotation around first axis
  71748. * @param beta defines the rotation around second axis
  71749. * @param gamma defines the rotation around third axis
  71750. * @param result defines the target quaternion
  71751. */
  71752. Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
  71753. // Produces a quaternion from Euler angles in the z-x-z orientation
  71754. var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
  71755. var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
  71756. var halfBeta = beta * 0.5;
  71757. result.x = Math.cos(halfGammaMinusAlpha) * Math.sin(halfBeta);
  71758. result.y = Math.sin(halfGammaMinusAlpha) * Math.sin(halfBeta);
  71759. result.z = Math.sin(halfGammaPlusAlpha) * Math.cos(halfBeta);
  71760. result.w = Math.cos(halfGammaPlusAlpha) * Math.cos(halfBeta);
  71761. };
  71762. /**
  71763. * 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)
  71764. * @param axis1 defines the first axis
  71765. * @param axis2 defines the second axis
  71766. * @param axis3 defines the third axis
  71767. * @returns the new quaternion
  71768. */
  71769. Quaternion.RotationQuaternionFromAxis = function (axis1, axis2, axis3) {
  71770. var quat = new Quaternion(0.0, 0.0, 0.0, 0.0);
  71771. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  71772. return quat;
  71773. };
  71774. /**
  71775. * 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
  71776. * @param axis1 defines the first axis
  71777. * @param axis2 defines the second axis
  71778. * @param axis3 defines the third axis
  71779. * @param ref defines the target quaternion
  71780. */
  71781. Quaternion.RotationQuaternionFromAxisToRef = function (axis1, axis2, axis3, ref) {
  71782. var rotMat = MathTmp.Matrix[0];
  71783. Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
  71784. Quaternion.FromRotationMatrixToRef(rotMat, ref);
  71785. };
  71786. /**
  71787. * Interpolates between two quaternions
  71788. * @param left defines first quaternion
  71789. * @param right defines second quaternion
  71790. * @param amount defines the gradient to use
  71791. * @returns the new interpolated quaternion
  71792. */
  71793. Quaternion.Slerp = function (left, right, amount) {
  71794. var result = Quaternion.Identity();
  71795. Quaternion.SlerpToRef(left, right, amount, result);
  71796. return result;
  71797. };
  71798. /**
  71799. * Interpolates between two quaternions and stores it into a target quaternion
  71800. * @param left defines first quaternion
  71801. * @param right defines second quaternion
  71802. * @param amount defines the gradient to use
  71803. * @param result defines the target quaternion
  71804. */
  71805. Quaternion.SlerpToRef = function (left, right, amount, result) {
  71806. var num2;
  71807. var num3;
  71808. var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w);
  71809. var flag = false;
  71810. if (num4 < 0) {
  71811. flag = true;
  71812. num4 = -num4;
  71813. }
  71814. if (num4 > 0.999999) {
  71815. num3 = 1 - amount;
  71816. num2 = flag ? -amount : amount;
  71817. }
  71818. else {
  71819. var num5 = Math.acos(num4);
  71820. var num6 = (1.0 / Math.sin(num5));
  71821. num3 = (Math.sin((1.0 - amount) * num5)) * num6;
  71822. num2 = flag ? ((-Math.sin(amount * num5)) * num6) : ((Math.sin(amount * num5)) * num6);
  71823. }
  71824. result.x = (num3 * left.x) + (num2 * right.x);
  71825. result.y = (num3 * left.y) + (num2 * right.y);
  71826. result.z = (num3 * left.z) + (num2 * right.z);
  71827. result.w = (num3 * left.w) + (num2 * right.w);
  71828. };
  71829. /**
  71830. * Interpolate between two quaternions using Hermite interpolation
  71831. * @param value1 defines first quaternion
  71832. * @param tangent1 defines the incoming tangent
  71833. * @param value2 defines second quaternion
  71834. * @param tangent2 defines the outgoing tangent
  71835. * @param amount defines the target quaternion
  71836. * @returns the new interpolated quaternion
  71837. */
  71838. Quaternion.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  71839. var squared = amount * amount;
  71840. var cubed = amount * squared;
  71841. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  71842. var part2 = (-2.0 * cubed) + (3.0 * squared);
  71843. var part3 = (cubed - (2.0 * squared)) + amount;
  71844. var part4 = cubed - squared;
  71845. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  71846. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  71847. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  71848. var w = (((value1.w * part1) + (value2.w * part2)) + (tangent1.w * part3)) + (tangent2.w * part4);
  71849. return new Quaternion(x, y, z, w);
  71850. };
  71851. return Quaternion;
  71852. }());
  71853. /**
  71854. * Class used to store matrix data (4x4)
  71855. */
  71856. var Matrix = /** @class */ (function () {
  71857. /**
  71858. * Creates an empty matrix (filled with zeros)
  71859. */
  71860. function Matrix() {
  71861. this._isIdentity = false;
  71862. this._isIdentityDirty = true;
  71863. this._isIdentity3x2 = true;
  71864. this._isIdentity3x2Dirty = true;
  71865. this._m = new Float32Array(16);
  71866. this._updateIdentityStatus(false);
  71867. }
  71868. Object.defineProperty(Matrix.prototype, "m", {
  71869. /**
  71870. * Gets the internal data of the matrix
  71871. */
  71872. get: function () { return this._m; },
  71873. enumerable: true,
  71874. configurable: true
  71875. });
  71876. /** @hidden */
  71877. Matrix.prototype._markAsUpdated = function () {
  71878. this.updateFlag = Matrix._updateFlagSeed++;
  71879. this._isIdentity = false;
  71880. this._isIdentity3x2 = false;
  71881. this._isIdentityDirty = true;
  71882. this._isIdentity3x2Dirty = true;
  71883. };
  71884. /** @hidden */
  71885. Matrix.prototype._updateIdentityStatus = function (isIdentity, isIdentityDirty, isIdentity3x2, isIdentity3x2Dirty) {
  71886. if (isIdentityDirty === void 0) { isIdentityDirty = false; }
  71887. if (isIdentity3x2 === void 0) { isIdentity3x2 = false; }
  71888. if (isIdentity3x2Dirty === void 0) { isIdentity3x2Dirty = true; }
  71889. this.updateFlag = Matrix._updateFlagSeed++;
  71890. this._isIdentity = isIdentity;
  71891. this._isIdentity3x2 = isIdentity || isIdentity3x2;
  71892. this._isIdentityDirty = this._isIdentity ? false : isIdentityDirty;
  71893. this._isIdentity3x2Dirty = this._isIdentity3x2 ? false : isIdentity3x2Dirty;
  71894. };
  71895. // Properties
  71896. /**
  71897. * Check if the current matrix is identity
  71898. * @returns true is the matrix is the identity matrix
  71899. */
  71900. Matrix.prototype.isIdentity = function () {
  71901. if (this._isIdentityDirty) {
  71902. this._isIdentityDirty = false;
  71903. var m = this._m;
  71904. this._isIdentity = (m[0] === 1.0 && m[1] === 0.0 && m[2] === 0.0 && m[3] === 0.0 &&
  71905. m[4] === 0.0 && m[5] === 1.0 && m[6] === 0.0 && m[7] === 0.0 &&
  71906. m[8] === 0.0 && m[9] === 0.0 && m[10] === 1.0 && m[11] === 0.0 &&
  71907. m[12] === 0.0 && m[13] === 0.0 && m[14] === 0.0 && m[15] === 1.0);
  71908. }
  71909. return this._isIdentity;
  71910. };
  71911. /**
  71912. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71913. * @returns true is the matrix is the identity matrix
  71914. */
  71915. Matrix.prototype.isIdentityAs3x2 = function () {
  71916. if (this._isIdentity3x2Dirty) {
  71917. this._isIdentity3x2Dirty = false;
  71918. if (this._m[0] !== 1.0 || this._m[5] !== 1.0 || this._m[15] !== 1.0) {
  71919. this._isIdentity3x2 = false;
  71920. }
  71921. else if (this._m[1] !== 0.0 || this._m[2] !== 0.0 || this._m[3] !== 0.0 ||
  71922. this._m[4] !== 0.0 || this._m[6] !== 0.0 || this._m[7] !== 0.0 ||
  71923. this._m[8] !== 0.0 || this._m[9] !== 0.0 || this._m[10] !== 0.0 || this._m[11] !== 0.0 ||
  71924. this._m[12] !== 0.0 || this._m[13] !== 0.0 || this._m[14] !== 0.0) {
  71925. this._isIdentity3x2 = false;
  71926. }
  71927. else {
  71928. this._isIdentity3x2 = true;
  71929. }
  71930. }
  71931. return this._isIdentity3x2;
  71932. };
  71933. /**
  71934. * Gets the determinant of the matrix
  71935. * @returns the matrix determinant
  71936. */
  71937. Matrix.prototype.determinant = function () {
  71938. if (this._isIdentity === true) {
  71939. return 1;
  71940. }
  71941. var m = this._m;
  71942. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  71943. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  71944. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  71945. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  71946. // https://en.wikipedia.org/wiki/Laplace_expansion
  71947. // to compute the deterrminant of a 4x4 Matrix we compute the cofactors of any row or column,
  71948. // then we multiply each Cofactor by its corresponding matrix value and sum them all to get the determinant
  71949. // Cofactor(i, j) = sign(i,j) * det(Minor(i, j))
  71950. // where
  71951. // - sign(i,j) = (i+j) % 2 === 0 ? 1 : -1
  71952. // - Minor(i, j) is the 3x3 matrix we get by removing row i and column j from current Matrix
  71953. //
  71954. // Here we do that for the 1st row.
  71955. var det_22_33 = m22 * m33 - m32 * m23;
  71956. var det_21_33 = m21 * m33 - m31 * m23;
  71957. var det_21_32 = m21 * m32 - m31 * m22;
  71958. var det_20_33 = m20 * m33 - m30 * m23;
  71959. var det_20_32 = m20 * m32 - m22 * m30;
  71960. var det_20_31 = m20 * m31 - m30 * m21;
  71961. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  71962. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  71963. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  71964. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  71965. return m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  71966. };
  71967. // Methods
  71968. /**
  71969. * Returns the matrix as a Float32Array
  71970. * @returns the matrix underlying array
  71971. */
  71972. Matrix.prototype.toArray = function () {
  71973. return this._m;
  71974. };
  71975. /**
  71976. * Returns the matrix as a Float32Array
  71977. * @returns the matrix underlying array.
  71978. */
  71979. Matrix.prototype.asArray = function () {
  71980. return this._m;
  71981. };
  71982. /**
  71983. * Inverts the current matrix in place
  71984. * @returns the current inverted matrix
  71985. */
  71986. Matrix.prototype.invert = function () {
  71987. this.invertToRef(this);
  71988. return this;
  71989. };
  71990. /**
  71991. * Sets all the matrix elements to zero
  71992. * @returns the current matrix
  71993. */
  71994. Matrix.prototype.reset = function () {
  71995. 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);
  71996. this._updateIdentityStatus(false);
  71997. return this;
  71998. };
  71999. /**
  72000. * Adds the current matrix with a second one
  72001. * @param other defines the matrix to add
  72002. * @returns a new matrix as the addition of the current matrix and the given one
  72003. */
  72004. Matrix.prototype.add = function (other) {
  72005. var result = new Matrix();
  72006. this.addToRef(other, result);
  72007. return result;
  72008. };
  72009. /**
  72010. * Sets the given matrix "result" to the addition of the current matrix and the given one
  72011. * @param other defines the matrix to add
  72012. * @param result defines the target matrix
  72013. * @returns the current matrix
  72014. */
  72015. Matrix.prototype.addToRef = function (other, result) {
  72016. var m = this._m;
  72017. var resultM = result._m;
  72018. var otherM = other.m;
  72019. for (var index = 0; index < 16; index++) {
  72020. resultM[index] = m[index] + otherM[index];
  72021. }
  72022. result._markAsUpdated();
  72023. return this;
  72024. };
  72025. /**
  72026. * Adds in place the given matrix to the current matrix
  72027. * @param other defines the second operand
  72028. * @returns the current updated matrix
  72029. */
  72030. Matrix.prototype.addToSelf = function (other) {
  72031. var m = this._m;
  72032. var otherM = other.m;
  72033. for (var index = 0; index < 16; index++) {
  72034. m[index] += otherM[index];
  72035. }
  72036. this._markAsUpdated();
  72037. return this;
  72038. };
  72039. /**
  72040. * Sets the given matrix to the current inverted Matrix
  72041. * @param other defines the target matrix
  72042. * @returns the unmodified current matrix
  72043. */
  72044. Matrix.prototype.invertToRef = function (other) {
  72045. if (this._isIdentity === true) {
  72046. Matrix.IdentityToRef(other);
  72047. return this;
  72048. }
  72049. // the inverse of a Matrix is the transpose of cofactor matrix divided by the determinant
  72050. var m = this._m;
  72051. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  72052. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  72053. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  72054. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  72055. var det_22_33 = m22 * m33 - m32 * m23;
  72056. var det_21_33 = m21 * m33 - m31 * m23;
  72057. var det_21_32 = m21 * m32 - m31 * m22;
  72058. var det_20_33 = m20 * m33 - m30 * m23;
  72059. var det_20_32 = m20 * m32 - m22 * m30;
  72060. var det_20_31 = m20 * m31 - m30 * m21;
  72061. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  72062. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  72063. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  72064. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  72065. var det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  72066. if (det === 0) {
  72067. // not invertible
  72068. other.copyFrom(this);
  72069. return this;
  72070. }
  72071. var detInv = 1 / det;
  72072. var det_12_33 = m12 * m33 - m32 * m13;
  72073. var det_11_33 = m11 * m33 - m31 * m13;
  72074. var det_11_32 = m11 * m32 - m31 * m12;
  72075. var det_10_33 = m10 * m33 - m30 * m13;
  72076. var det_10_32 = m10 * m32 - m30 * m12;
  72077. var det_10_31 = m10 * m31 - m30 * m11;
  72078. var det_12_23 = m12 * m23 - m22 * m13;
  72079. var det_11_23 = m11 * m23 - m21 * m13;
  72080. var det_11_22 = m11 * m22 - m21 * m12;
  72081. var det_10_23 = m10 * m23 - m20 * m13;
  72082. var det_10_22 = m10 * m22 - m20 * m12;
  72083. var det_10_21 = m10 * m21 - m20 * m11;
  72084. var cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);
  72085. var cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);
  72086. var cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);
  72087. var cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);
  72088. var cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);
  72089. var cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);
  72090. var cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);
  72091. var cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);
  72092. var cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);
  72093. var cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);
  72094. var cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);
  72095. var cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);
  72096. 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);
  72097. return this;
  72098. };
  72099. /**
  72100. * add a value at the specified position in the current Matrix
  72101. * @param index the index of the value within the matrix. between 0 and 15.
  72102. * @param value the value to be added
  72103. * @returns the current updated matrix
  72104. */
  72105. Matrix.prototype.addAtIndex = function (index, value) {
  72106. this._m[index] += value;
  72107. this._markAsUpdated();
  72108. return this;
  72109. };
  72110. /**
  72111. * mutiply the specified position in the current Matrix by a value
  72112. * @param index the index of the value within the matrix. between 0 and 15.
  72113. * @param value the value to be added
  72114. * @returns the current updated matrix
  72115. */
  72116. Matrix.prototype.multiplyAtIndex = function (index, value) {
  72117. this._m[index] *= value;
  72118. this._markAsUpdated();
  72119. return this;
  72120. };
  72121. /**
  72122. * Inserts the translation vector (using 3 floats) in the current matrix
  72123. * @param x defines the 1st component of the translation
  72124. * @param y defines the 2nd component of the translation
  72125. * @param z defines the 3rd component of the translation
  72126. * @returns the current updated matrix
  72127. */
  72128. Matrix.prototype.setTranslationFromFloats = function (x, y, z) {
  72129. this._m[12] = x;
  72130. this._m[13] = y;
  72131. this._m[14] = z;
  72132. this._markAsUpdated();
  72133. return this;
  72134. };
  72135. /**
  72136. * Inserts the translation vector in the current matrix
  72137. * @param vector3 defines the translation to insert
  72138. * @returns the current updated matrix
  72139. */
  72140. Matrix.prototype.setTranslation = function (vector3) {
  72141. return this.setTranslationFromFloats(vector3.x, vector3.y, vector3.z);
  72142. };
  72143. /**
  72144. * Gets the translation value of the current matrix
  72145. * @returns a new Vector3 as the extracted translation from the matrix
  72146. */
  72147. Matrix.prototype.getTranslation = function () {
  72148. return new Vector3(this._m[12], this._m[13], this._m[14]);
  72149. };
  72150. /**
  72151. * Fill a Vector3 with the extracted translation from the matrix
  72152. * @param result defines the Vector3 where to store the translation
  72153. * @returns the current matrix
  72154. */
  72155. Matrix.prototype.getTranslationToRef = function (result) {
  72156. result.x = this._m[12];
  72157. result.y = this._m[13];
  72158. result.z = this._m[14];
  72159. return this;
  72160. };
  72161. /**
  72162. * Remove rotation and scaling part from the matrix
  72163. * @returns the updated matrix
  72164. */
  72165. Matrix.prototype.removeRotationAndScaling = function () {
  72166. var m = this.m;
  72167. 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);
  72168. this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
  72169. return this;
  72170. };
  72171. /**
  72172. * Multiply two matrices
  72173. * @param other defines the second operand
  72174. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  72175. */
  72176. Matrix.prototype.multiply = function (other) {
  72177. var result = new Matrix();
  72178. this.multiplyToRef(other, result);
  72179. return result;
  72180. };
  72181. /**
  72182. * Copy the current matrix from the given one
  72183. * @param other defines the source matrix
  72184. * @returns the current updated matrix
  72185. */
  72186. Matrix.prototype.copyFrom = function (other) {
  72187. other.copyToArray(this._m);
  72188. var o = other;
  72189. this._updateIdentityStatus(o._isIdentity, o._isIdentityDirty, o._isIdentity3x2, o._isIdentity3x2Dirty);
  72190. return this;
  72191. };
  72192. /**
  72193. * Populates the given array from the starting index with the current matrix values
  72194. * @param array defines the target array
  72195. * @param offset defines the offset in the target array where to start storing values
  72196. * @returns the current matrix
  72197. */
  72198. Matrix.prototype.copyToArray = function (array, offset) {
  72199. if (offset === void 0) { offset = 0; }
  72200. for (var index = 0; index < 16; index++) {
  72201. array[offset + index] = this._m[index];
  72202. }
  72203. return this;
  72204. };
  72205. /**
  72206. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72207. * @param other defines the second operand
  72208. * @param result defines the matrix where to store the multiplication
  72209. * @returns the current matrix
  72210. */
  72211. Matrix.prototype.multiplyToRef = function (other, result) {
  72212. if (this._isIdentity) {
  72213. result.copyFrom(other);
  72214. return this;
  72215. }
  72216. if (other._isIdentity) {
  72217. result.copyFrom(this);
  72218. return this;
  72219. }
  72220. this.multiplyToArray(other, result._m, 0);
  72221. result._markAsUpdated();
  72222. return this;
  72223. };
  72224. /**
  72225. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72226. * @param other defines the second operand
  72227. * @param result defines the array where to store the multiplication
  72228. * @param offset defines the offset in the target array where to start storing values
  72229. * @returns the current matrix
  72230. */
  72231. Matrix.prototype.multiplyToArray = function (other, result, offset) {
  72232. var m = this._m;
  72233. var otherM = other.m;
  72234. var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
  72235. var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
  72236. var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
  72237. var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
  72238. var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
  72239. var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
  72240. var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
  72241. var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
  72242. result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
  72243. result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
  72244. result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
  72245. result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
  72246. result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
  72247. result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
  72248. result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
  72249. result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
  72250. result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
  72251. result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
  72252. result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
  72253. result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
  72254. result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
  72255. result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
  72256. result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
  72257. result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
  72258. return this;
  72259. };
  72260. /**
  72261. * Check equality between this matrix and a second one
  72262. * @param value defines the second matrix to compare
  72263. * @returns true is the current matrix and the given one values are strictly equal
  72264. */
  72265. Matrix.prototype.equals = function (value) {
  72266. var other = value;
  72267. if (!other) {
  72268. return false;
  72269. }
  72270. if (this._isIdentity || other._isIdentity) {
  72271. if (!this._isIdentityDirty && !other._isIdentityDirty) {
  72272. return this._isIdentity && other._isIdentity;
  72273. }
  72274. }
  72275. var m = this.m;
  72276. var om = other.m;
  72277. return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&
  72278. m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&
  72279. m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&
  72280. m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);
  72281. };
  72282. /**
  72283. * Clone the current matrix
  72284. * @returns a new matrix from the current matrix
  72285. */
  72286. Matrix.prototype.clone = function () {
  72287. var matrix = new Matrix();
  72288. matrix.copyFrom(this);
  72289. return matrix;
  72290. };
  72291. /**
  72292. * Returns the name of the current matrix class
  72293. * @returns the string "Matrix"
  72294. */
  72295. Matrix.prototype.getClassName = function () {
  72296. return "Matrix";
  72297. };
  72298. /**
  72299. * Gets the hash code of the current matrix
  72300. * @returns the hash code
  72301. */
  72302. Matrix.prototype.getHashCode = function () {
  72303. var hash = this._m[0] || 0;
  72304. for (var i = 1; i < 16; i++) {
  72305. hash = (hash * 397) ^ (this._m[i] || 0);
  72306. }
  72307. return hash;
  72308. };
  72309. /**
  72310. * Decomposes the current Matrix into a translation, rotation and scaling components
  72311. * @param scale defines the scale vector3 given as a reference to update
  72312. * @param rotation defines the rotation quaternion given as a reference to update
  72313. * @param translation defines the translation vector3 given as a reference to update
  72314. * @returns true if operation was successful
  72315. */
  72316. Matrix.prototype.decompose = function (scale, rotation, translation) {
  72317. if (this._isIdentity) {
  72318. if (translation) {
  72319. translation.setAll(0);
  72320. }
  72321. if (scale) {
  72322. scale.setAll(1);
  72323. }
  72324. if (rotation) {
  72325. rotation.copyFromFloats(0, 0, 0, 1);
  72326. }
  72327. return true;
  72328. }
  72329. var m = this._m;
  72330. if (translation) {
  72331. translation.copyFromFloats(m[12], m[13], m[14]);
  72332. }
  72333. scale = scale || MathTmp.Vector3[0];
  72334. scale.x = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
  72335. scale.y = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
  72336. scale.z = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
  72337. if (this.determinant() <= 0) {
  72338. scale.y *= -1;
  72339. }
  72340. if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
  72341. if (rotation) {
  72342. rotation.copyFromFloats(0.0, 0.0, 0.0, 1.0);
  72343. }
  72344. return false;
  72345. }
  72346. if (rotation) {
  72347. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  72348. 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]);
  72349. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
  72350. }
  72351. return true;
  72352. };
  72353. /**
  72354. * Gets specific row of the matrix
  72355. * @param index defines the number of the row to get
  72356. * @returns the index-th row of the current matrix as a new Vector4
  72357. */
  72358. Matrix.prototype.getRow = function (index) {
  72359. if (index < 0 || index > 3) {
  72360. return null;
  72361. }
  72362. var i = index * 4;
  72363. return new Vector4(this._m[i + 0], this._m[i + 1], this._m[i + 2], this._m[i + 3]);
  72364. };
  72365. /**
  72366. * Sets the index-th row of the current matrix to the vector4 values
  72367. * @param index defines the number of the row to set
  72368. * @param row defines the target vector4
  72369. * @returns the updated current matrix
  72370. */
  72371. Matrix.prototype.setRow = function (index, row) {
  72372. return this.setRowFromFloats(index, row.x, row.y, row.z, row.w);
  72373. };
  72374. /**
  72375. * Compute the transpose of the matrix
  72376. * @returns the new transposed matrix
  72377. */
  72378. Matrix.prototype.transpose = function () {
  72379. return Matrix.Transpose(this);
  72380. };
  72381. /**
  72382. * Compute the transpose of the matrix and store it in a given matrix
  72383. * @param result defines the target matrix
  72384. * @returns the current matrix
  72385. */
  72386. Matrix.prototype.transposeToRef = function (result) {
  72387. Matrix.TransposeToRef(this, result);
  72388. return this;
  72389. };
  72390. /**
  72391. * Sets the index-th row of the current matrix with the given 4 x float values
  72392. * @param index defines the row index
  72393. * @param x defines the x component to set
  72394. * @param y defines the y component to set
  72395. * @param z defines the z component to set
  72396. * @param w defines the w component to set
  72397. * @returns the updated current matrix
  72398. */
  72399. Matrix.prototype.setRowFromFloats = function (index, x, y, z, w) {
  72400. if (index < 0 || index > 3) {
  72401. return this;
  72402. }
  72403. var i = index * 4;
  72404. this._m[i + 0] = x;
  72405. this._m[i + 1] = y;
  72406. this._m[i + 2] = z;
  72407. this._m[i + 3] = w;
  72408. this._markAsUpdated();
  72409. return this;
  72410. };
  72411. /**
  72412. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72413. * @param scale defines the scale factor
  72414. * @returns a new matrix
  72415. */
  72416. Matrix.prototype.scale = function (scale) {
  72417. var result = new Matrix();
  72418. this.scaleToRef(scale, result);
  72419. return result;
  72420. };
  72421. /**
  72422. * Scale the current matrix values by a factor to a given result matrix
  72423. * @param scale defines the scale factor
  72424. * @param result defines the matrix to store the result
  72425. * @returns the current matrix
  72426. */
  72427. Matrix.prototype.scaleToRef = function (scale, result) {
  72428. for (var index = 0; index < 16; index++) {
  72429. result._m[index] = this._m[index] * scale;
  72430. }
  72431. result._markAsUpdated();
  72432. return this;
  72433. };
  72434. /**
  72435. * Scale the current matrix values by a factor and add the result to a given matrix
  72436. * @param scale defines the scale factor
  72437. * @param result defines the Matrix to store the result
  72438. * @returns the current matrix
  72439. */
  72440. Matrix.prototype.scaleAndAddToRef = function (scale, result) {
  72441. for (var index = 0; index < 16; index++) {
  72442. result._m[index] += this._m[index] * scale;
  72443. }
  72444. result._markAsUpdated();
  72445. return this;
  72446. };
  72447. /**
  72448. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72449. * @param ref matrix to store the result
  72450. */
  72451. Matrix.prototype.toNormalMatrix = function (ref) {
  72452. var tmp = MathTmp.Matrix[0];
  72453. this.invertToRef(tmp);
  72454. tmp.transposeToRef(ref);
  72455. var m = ref._m;
  72456. 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);
  72457. };
  72458. /**
  72459. * Gets only rotation part of the current matrix
  72460. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72461. */
  72462. Matrix.prototype.getRotationMatrix = function () {
  72463. var result = new Matrix();
  72464. this.getRotationMatrixToRef(result);
  72465. return result;
  72466. };
  72467. /**
  72468. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72469. * @param result defines the target matrix to store data to
  72470. * @returns the current matrix
  72471. */
  72472. Matrix.prototype.getRotationMatrixToRef = function (result) {
  72473. var scale = MathTmp.Vector3[0];
  72474. if (!this.decompose(scale)) {
  72475. Matrix.IdentityToRef(result);
  72476. return this;
  72477. }
  72478. var m = this._m;
  72479. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  72480. 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);
  72481. return this;
  72482. };
  72483. /**
  72484. * Toggles model matrix from being right handed to left handed in place and vice versa
  72485. */
  72486. Matrix.prototype.toggleModelMatrixHandInPlace = function () {
  72487. var m = this._m;
  72488. m[2] *= -1;
  72489. m[6] *= -1;
  72490. m[8] *= -1;
  72491. m[9] *= -1;
  72492. m[14] *= -1;
  72493. this._markAsUpdated();
  72494. };
  72495. /**
  72496. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72497. */
  72498. Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
  72499. var m = this._m;
  72500. m[8] *= -1;
  72501. m[9] *= -1;
  72502. m[10] *= -1;
  72503. m[11] *= -1;
  72504. this._markAsUpdated();
  72505. };
  72506. // Statics
  72507. /**
  72508. * Creates a matrix from an array
  72509. * @param array defines the source array
  72510. * @param offset defines an offset in the source array
  72511. * @returns a new Matrix set from the starting index of the given array
  72512. */
  72513. Matrix.FromArray = function (array, offset) {
  72514. if (offset === void 0) { offset = 0; }
  72515. var result = new Matrix();
  72516. Matrix.FromArrayToRef(array, offset, result);
  72517. return result;
  72518. };
  72519. /**
  72520. * Copy the content of an array into a given matrix
  72521. * @param array defines the source array
  72522. * @param offset defines an offset in the source array
  72523. * @param result defines the target matrix
  72524. */
  72525. Matrix.FromArrayToRef = function (array, offset, result) {
  72526. for (var index = 0; index < 16; index++) {
  72527. result._m[index] = array[index + offset];
  72528. }
  72529. result._markAsUpdated();
  72530. };
  72531. /**
  72532. * Stores an array into a matrix after having multiplied each component by a given factor
  72533. * @param array defines the source array
  72534. * @param offset defines the offset in the source array
  72535. * @param scale defines the scaling factor
  72536. * @param result defines the target matrix
  72537. */
  72538. Matrix.FromFloat32ArrayToRefScaled = function (array, offset, scale, result) {
  72539. for (var index = 0; index < 16; index++) {
  72540. result._m[index] = array[index + offset] * scale;
  72541. }
  72542. result._markAsUpdated();
  72543. };
  72544. Object.defineProperty(Matrix, "IdentityReadOnly", {
  72545. /**
  72546. * Gets an identity matrix that must not be updated
  72547. */
  72548. get: function () {
  72549. return Matrix._identityReadOnly;
  72550. },
  72551. enumerable: true,
  72552. configurable: true
  72553. });
  72554. /**
  72555. * Stores a list of values (16) inside a given matrix
  72556. * @param initialM11 defines 1st value of 1st row
  72557. * @param initialM12 defines 2nd value of 1st row
  72558. * @param initialM13 defines 3rd value of 1st row
  72559. * @param initialM14 defines 4th value of 1st row
  72560. * @param initialM21 defines 1st value of 2nd row
  72561. * @param initialM22 defines 2nd value of 2nd row
  72562. * @param initialM23 defines 3rd value of 2nd row
  72563. * @param initialM24 defines 4th value of 2nd row
  72564. * @param initialM31 defines 1st value of 3rd row
  72565. * @param initialM32 defines 2nd value of 3rd row
  72566. * @param initialM33 defines 3rd value of 3rd row
  72567. * @param initialM34 defines 4th value of 3rd row
  72568. * @param initialM41 defines 1st value of 4th row
  72569. * @param initialM42 defines 2nd value of 4th row
  72570. * @param initialM43 defines 3rd value of 4th row
  72571. * @param initialM44 defines 4th value of 4th row
  72572. * @param result defines the target matrix
  72573. */
  72574. Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) {
  72575. var m = result._m;
  72576. m[0] = initialM11;
  72577. m[1] = initialM12;
  72578. m[2] = initialM13;
  72579. m[3] = initialM14;
  72580. m[4] = initialM21;
  72581. m[5] = initialM22;
  72582. m[6] = initialM23;
  72583. m[7] = initialM24;
  72584. m[8] = initialM31;
  72585. m[9] = initialM32;
  72586. m[10] = initialM33;
  72587. m[11] = initialM34;
  72588. m[12] = initialM41;
  72589. m[13] = initialM42;
  72590. m[14] = initialM43;
  72591. m[15] = initialM44;
  72592. result._markAsUpdated();
  72593. };
  72594. /**
  72595. * Creates new matrix from a list of values (16)
  72596. * @param initialM11 defines 1st value of 1st row
  72597. * @param initialM12 defines 2nd value of 1st row
  72598. * @param initialM13 defines 3rd value of 1st row
  72599. * @param initialM14 defines 4th value of 1st row
  72600. * @param initialM21 defines 1st value of 2nd row
  72601. * @param initialM22 defines 2nd value of 2nd row
  72602. * @param initialM23 defines 3rd value of 2nd row
  72603. * @param initialM24 defines 4th value of 2nd row
  72604. * @param initialM31 defines 1st value of 3rd row
  72605. * @param initialM32 defines 2nd value of 3rd row
  72606. * @param initialM33 defines 3rd value of 3rd row
  72607. * @param initialM34 defines 4th value of 3rd row
  72608. * @param initialM41 defines 1st value of 4th row
  72609. * @param initialM42 defines 2nd value of 4th row
  72610. * @param initialM43 defines 3rd value of 4th row
  72611. * @param initialM44 defines 4th value of 4th row
  72612. * @returns the new matrix
  72613. */
  72614. Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) {
  72615. var result = new Matrix();
  72616. var m = result._m;
  72617. m[0] = initialM11;
  72618. m[1] = initialM12;
  72619. m[2] = initialM13;
  72620. m[3] = initialM14;
  72621. m[4] = initialM21;
  72622. m[5] = initialM22;
  72623. m[6] = initialM23;
  72624. m[7] = initialM24;
  72625. m[8] = initialM31;
  72626. m[9] = initialM32;
  72627. m[10] = initialM33;
  72628. m[11] = initialM34;
  72629. m[12] = initialM41;
  72630. m[13] = initialM42;
  72631. m[14] = initialM43;
  72632. m[15] = initialM44;
  72633. result._markAsUpdated();
  72634. return result;
  72635. };
  72636. /**
  72637. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72638. * @param scale defines the scale vector3
  72639. * @param rotation defines the rotation quaternion
  72640. * @param translation defines the translation vector3
  72641. * @returns a new matrix
  72642. */
  72643. Matrix.Compose = function (scale, rotation, translation) {
  72644. var result = new Matrix();
  72645. Matrix.ComposeToRef(scale, rotation, translation, result);
  72646. return result;
  72647. };
  72648. /**
  72649. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72650. * @param scale defines the scale vector3
  72651. * @param rotation defines the rotation quaternion
  72652. * @param translation defines the translation vector3
  72653. * @param result defines the target matrix
  72654. */
  72655. Matrix.ComposeToRef = function (scale, rotation, translation, result) {
  72656. Matrix.ScalingToRef(scale.x, scale.y, scale.z, MathTmp.Matrix[1]);
  72657. rotation.toRotationMatrix(MathTmp.Matrix[0]);
  72658. MathTmp.Matrix[1].multiplyToRef(MathTmp.Matrix[0], result);
  72659. result.setTranslation(translation);
  72660. };
  72661. /**
  72662. * Creates a new identity matrix
  72663. * @returns a new identity matrix
  72664. */
  72665. Matrix.Identity = function () {
  72666. 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);
  72667. identity._updateIdentityStatus(true);
  72668. return identity;
  72669. };
  72670. /**
  72671. * Creates a new identity matrix and stores the result in a given matrix
  72672. * @param result defines the target matrix
  72673. */
  72674. Matrix.IdentityToRef = function (result) {
  72675. 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);
  72676. result._updateIdentityStatus(true);
  72677. };
  72678. /**
  72679. * Creates a new zero matrix
  72680. * @returns a new zero matrix
  72681. */
  72682. Matrix.Zero = function () {
  72683. 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);
  72684. zero._updateIdentityStatus(false);
  72685. return zero;
  72686. };
  72687. /**
  72688. * Creates a new rotation matrix for "angle" radians around the X axis
  72689. * @param angle defines the angle (in radians) to use
  72690. * @return the new matrix
  72691. */
  72692. Matrix.RotationX = function (angle) {
  72693. var result = new Matrix();
  72694. Matrix.RotationXToRef(angle, result);
  72695. return result;
  72696. };
  72697. /**
  72698. * Creates a new matrix as the invert of a given matrix
  72699. * @param source defines the source matrix
  72700. * @returns the new matrix
  72701. */
  72702. Matrix.Invert = function (source) {
  72703. var result = new Matrix();
  72704. source.invertToRef(result);
  72705. return result;
  72706. };
  72707. /**
  72708. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  72709. * @param angle defines the angle (in radians) to use
  72710. * @param result defines the target matrix
  72711. */
  72712. Matrix.RotationXToRef = function (angle, result) {
  72713. var s = Math.sin(angle);
  72714. var c = Math.cos(angle);
  72715. 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);
  72716. result._updateIdentityStatus(c === 1 && s === 0);
  72717. };
  72718. /**
  72719. * Creates a new rotation matrix for "angle" radians around the Y axis
  72720. * @param angle defines the angle (in radians) to use
  72721. * @return the new matrix
  72722. */
  72723. Matrix.RotationY = function (angle) {
  72724. var result = new Matrix();
  72725. Matrix.RotationYToRef(angle, result);
  72726. return result;
  72727. };
  72728. /**
  72729. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72730. * @param angle defines the angle (in radians) to use
  72731. * @param result defines the target matrix
  72732. */
  72733. Matrix.RotationYToRef = function (angle, result) {
  72734. var s = Math.sin(angle);
  72735. var c = Math.cos(angle);
  72736. 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);
  72737. result._updateIdentityStatus(c === 1 && s === 0);
  72738. };
  72739. /**
  72740. * Creates a new rotation matrix for "angle" radians around the Z axis
  72741. * @param angle defines the angle (in radians) to use
  72742. * @return the new matrix
  72743. */
  72744. Matrix.RotationZ = function (angle) {
  72745. var result = new Matrix();
  72746. Matrix.RotationZToRef(angle, result);
  72747. return result;
  72748. };
  72749. /**
  72750. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72751. * @param angle defines the angle (in radians) to use
  72752. * @param result defines the target matrix
  72753. */
  72754. Matrix.RotationZToRef = function (angle, result) {
  72755. var s = Math.sin(angle);
  72756. var c = Math.cos(angle);
  72757. 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);
  72758. result._updateIdentityStatus(c === 1 && s === 0);
  72759. };
  72760. /**
  72761. * Creates a new rotation matrix for "angle" radians around the given axis
  72762. * @param axis defines the axis to use
  72763. * @param angle defines the angle (in radians) to use
  72764. * @return the new matrix
  72765. */
  72766. Matrix.RotationAxis = function (axis, angle) {
  72767. var result = new Matrix();
  72768. Matrix.RotationAxisToRef(axis, angle, result);
  72769. return result;
  72770. };
  72771. /**
  72772. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72773. * @param axis defines the axis to use
  72774. * @param angle defines the angle (in radians) to use
  72775. * @param result defines the target matrix
  72776. */
  72777. Matrix.RotationAxisToRef = function (axis, angle, result) {
  72778. var s = Math.sin(-angle);
  72779. var c = Math.cos(-angle);
  72780. var c1 = 1 - c;
  72781. axis.normalize();
  72782. var m = result._m;
  72783. m[0] = (axis.x * axis.x) * c1 + c;
  72784. m[1] = (axis.x * axis.y) * c1 - (axis.z * s);
  72785. m[2] = (axis.x * axis.z) * c1 + (axis.y * s);
  72786. m[3] = 0.0;
  72787. m[4] = (axis.y * axis.x) * c1 + (axis.z * s);
  72788. m[5] = (axis.y * axis.y) * c1 + c;
  72789. m[6] = (axis.y * axis.z) * c1 - (axis.x * s);
  72790. m[7] = 0.0;
  72791. m[8] = (axis.z * axis.x) * c1 - (axis.y * s);
  72792. m[9] = (axis.z * axis.y) * c1 + (axis.x * s);
  72793. m[10] = (axis.z * axis.z) * c1 + c;
  72794. m[11] = 0.0;
  72795. m[12] = 0.0;
  72796. m[13] = 0.0;
  72797. m[14] = 0.0;
  72798. m[15] = 1.0;
  72799. result._markAsUpdated();
  72800. };
  72801. /**
  72802. * Creates a rotation matrix
  72803. * @param yaw defines the yaw angle in radians (Y axis)
  72804. * @param pitch defines the pitch angle in radians (X axis)
  72805. * @param roll defines the roll angle in radians (X axis)
  72806. * @returns the new rotation matrix
  72807. */
  72808. Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
  72809. var result = new Matrix();
  72810. Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
  72811. return result;
  72812. };
  72813. /**
  72814. * Creates a rotation matrix and stores it in a given matrix
  72815. * @param yaw defines the yaw angle in radians (Y axis)
  72816. * @param pitch defines the pitch angle in radians (X axis)
  72817. * @param roll defines the roll angle in radians (X axis)
  72818. * @param result defines the target matrix
  72819. */
  72820. Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  72821. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, MathTmp.Quaternion[0]);
  72822. MathTmp.Quaternion[0].toRotationMatrix(result);
  72823. };
  72824. /**
  72825. * Creates a scaling matrix
  72826. * @param x defines the scale factor on X axis
  72827. * @param y defines the scale factor on Y axis
  72828. * @param z defines the scale factor on Z axis
  72829. * @returns the new matrix
  72830. */
  72831. Matrix.Scaling = function (x, y, z) {
  72832. var result = new Matrix();
  72833. Matrix.ScalingToRef(x, y, z, result);
  72834. return result;
  72835. };
  72836. /**
  72837. * Creates a scaling matrix and stores it in a given matrix
  72838. * @param x defines the scale factor on X axis
  72839. * @param y defines the scale factor on Y axis
  72840. * @param z defines the scale factor on Z axis
  72841. * @param result defines the target matrix
  72842. */
  72843. Matrix.ScalingToRef = function (x, y, z, result) {
  72844. 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);
  72845. result._updateIdentityStatus(x === 1 && y === 1 && z === 1);
  72846. };
  72847. /**
  72848. * Creates a translation matrix
  72849. * @param x defines the translation on X axis
  72850. * @param y defines the translation on Y axis
  72851. * @param z defines the translationon Z axis
  72852. * @returns the new matrix
  72853. */
  72854. Matrix.Translation = function (x, y, z) {
  72855. var result = new Matrix();
  72856. Matrix.TranslationToRef(x, y, z, result);
  72857. return result;
  72858. };
  72859. /**
  72860. * Creates a translation matrix and stores it in a given matrix
  72861. * @param x defines the translation on X axis
  72862. * @param y defines the translation on Y axis
  72863. * @param z defines the translationon Z axis
  72864. * @param result defines the target matrix
  72865. */
  72866. Matrix.TranslationToRef = function (x, y, z, result) {
  72867. 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);
  72868. result._updateIdentityStatus(x === 0 && y === 0 && z === 0);
  72869. };
  72870. /**
  72871. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72872. * @param startValue defines the start value
  72873. * @param endValue defines the end value
  72874. * @param gradient defines the gradient factor
  72875. * @returns the new matrix
  72876. */
  72877. Matrix.Lerp = function (startValue, endValue, gradient) {
  72878. var result = new Matrix();
  72879. Matrix.LerpToRef(startValue, endValue, gradient, result);
  72880. return result;
  72881. };
  72882. /**
  72883. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72884. * @param startValue defines the start value
  72885. * @param endValue defines the end value
  72886. * @param gradient defines the gradient factor
  72887. * @param result defines the Matrix object where to store data
  72888. */
  72889. Matrix.LerpToRef = function (startValue, endValue, gradient, result) {
  72890. var resultM = result._m;
  72891. var startM = startValue.m;
  72892. var endM = endValue.m;
  72893. for (var index = 0; index < 16; index++) {
  72894. resultM[index] = startM[index] * (1.0 - gradient) + endM[index] * gradient;
  72895. }
  72896. result._markAsUpdated();
  72897. };
  72898. /**
  72899. * Builds a new matrix whose values are computed by:
  72900. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72901. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72902. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72903. * @param startValue defines the first matrix
  72904. * @param endValue defines the second matrix
  72905. * @param gradient defines the gradient between the two matrices
  72906. * @returns the new matrix
  72907. */
  72908. Matrix.DecomposeLerp = function (startValue, endValue, gradient) {
  72909. var result = new Matrix();
  72910. Matrix.DecomposeLerpToRef(startValue, endValue, gradient, result);
  72911. return result;
  72912. };
  72913. /**
  72914. * Update a matrix to values which are computed by:
  72915. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72916. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72917. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72918. * @param startValue defines the first matrix
  72919. * @param endValue defines the second matrix
  72920. * @param gradient defines the gradient between the two matrices
  72921. * @param result defines the target matrix
  72922. */
  72923. Matrix.DecomposeLerpToRef = function (startValue, endValue, gradient, result) {
  72924. var startScale = MathTmp.Vector3[0];
  72925. var startRotation = MathTmp.Quaternion[0];
  72926. var startTranslation = MathTmp.Vector3[1];
  72927. startValue.decompose(startScale, startRotation, startTranslation);
  72928. var endScale = MathTmp.Vector3[2];
  72929. var endRotation = MathTmp.Quaternion[1];
  72930. var endTranslation = MathTmp.Vector3[3];
  72931. endValue.decompose(endScale, endRotation, endTranslation);
  72932. var resultScale = MathTmp.Vector3[4];
  72933. Vector3.LerpToRef(startScale, endScale, gradient, resultScale);
  72934. var resultRotation = MathTmp.Quaternion[2];
  72935. Quaternion.SlerpToRef(startRotation, endRotation, gradient, resultRotation);
  72936. var resultTranslation = MathTmp.Vector3[5];
  72937. Vector3.LerpToRef(startTranslation, endTranslation, gradient, resultTranslation);
  72938. Matrix.ComposeToRef(resultScale, resultRotation, resultTranslation, result);
  72939. };
  72940. /**
  72941. * 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"
  72942. * This function works in left handed mode
  72943. * @param eye defines the final position of the entity
  72944. * @param target defines where the entity should look at
  72945. * @param up defines the up vector for the entity
  72946. * @returns the new matrix
  72947. */
  72948. Matrix.LookAtLH = function (eye, target, up) {
  72949. var result = new Matrix();
  72950. Matrix.LookAtLHToRef(eye, target, up, result);
  72951. return result;
  72952. };
  72953. /**
  72954. * 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".
  72955. * This function works in left handed mode
  72956. * @param eye defines the final position of the entity
  72957. * @param target defines where the entity should look at
  72958. * @param up defines the up vector for the entity
  72959. * @param result defines the target matrix
  72960. */
  72961. Matrix.LookAtLHToRef = function (eye, target, up, result) {
  72962. var xAxis = MathTmp.Vector3[0];
  72963. var yAxis = MathTmp.Vector3[1];
  72964. var zAxis = MathTmp.Vector3[2];
  72965. // Z axis
  72966. target.subtractToRef(eye, zAxis);
  72967. zAxis.normalize();
  72968. // X axis
  72969. Vector3.CrossToRef(up, zAxis, xAxis);
  72970. var xSquareLength = xAxis.lengthSquared();
  72971. if (xSquareLength === 0) {
  72972. xAxis.x = 1.0;
  72973. }
  72974. else {
  72975. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  72976. }
  72977. // Y axis
  72978. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  72979. yAxis.normalize();
  72980. // Eye angles
  72981. var ex = -Vector3.Dot(xAxis, eye);
  72982. var ey = -Vector3.Dot(yAxis, eye);
  72983. var ez = -Vector3.Dot(zAxis, eye);
  72984. 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);
  72985. };
  72986. /**
  72987. * 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"
  72988. * This function works in right handed mode
  72989. * @param eye defines the final position of the entity
  72990. * @param target defines where the entity should look at
  72991. * @param up defines the up vector for the entity
  72992. * @returns the new matrix
  72993. */
  72994. Matrix.LookAtRH = function (eye, target, up) {
  72995. var result = new Matrix();
  72996. Matrix.LookAtRHToRef(eye, target, up, result);
  72997. return result;
  72998. };
  72999. /**
  73000. * 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".
  73001. * This function works in right handed mode
  73002. * @param eye defines the final position of the entity
  73003. * @param target defines where the entity should look at
  73004. * @param up defines the up vector for the entity
  73005. * @param result defines the target matrix
  73006. */
  73007. Matrix.LookAtRHToRef = function (eye, target, up, result) {
  73008. var xAxis = MathTmp.Vector3[0];
  73009. var yAxis = MathTmp.Vector3[1];
  73010. var zAxis = MathTmp.Vector3[2];
  73011. // Z axis
  73012. eye.subtractToRef(target, zAxis);
  73013. zAxis.normalize();
  73014. // X axis
  73015. Vector3.CrossToRef(up, zAxis, xAxis);
  73016. var xSquareLength = xAxis.lengthSquared();
  73017. if (xSquareLength === 0) {
  73018. xAxis.x = 1.0;
  73019. }
  73020. else {
  73021. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  73022. }
  73023. // Y axis
  73024. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  73025. yAxis.normalize();
  73026. // Eye angles
  73027. var ex = -Vector3.Dot(xAxis, eye);
  73028. var ey = -Vector3.Dot(yAxis, eye);
  73029. var ez = -Vector3.Dot(zAxis, eye);
  73030. 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);
  73031. };
  73032. /**
  73033. * Create a left-handed orthographic projection matrix
  73034. * @param width defines the viewport width
  73035. * @param height defines the viewport height
  73036. * @param znear defines the near clip plane
  73037. * @param zfar defines the far clip plane
  73038. * @returns a new matrix as a left-handed orthographic projection matrix
  73039. */
  73040. Matrix.OrthoLH = function (width, height, znear, zfar) {
  73041. var matrix = new Matrix();
  73042. Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
  73043. return matrix;
  73044. };
  73045. /**
  73046. * Store a left-handed orthographic projection to a given matrix
  73047. * @param width defines the viewport width
  73048. * @param height defines the viewport height
  73049. * @param znear defines the near clip plane
  73050. * @param zfar defines the far clip plane
  73051. * @param result defines the target matrix
  73052. */
  73053. Matrix.OrthoLHToRef = function (width, height, znear, zfar, result) {
  73054. var n = znear;
  73055. var f = zfar;
  73056. var a = 2.0 / width;
  73057. var b = 2.0 / height;
  73058. var c = 2.0 / (f - n);
  73059. var d = -(f + n) / (f - n);
  73060. 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);
  73061. result._updateIdentityStatus(a === 1 && b === 1 && c === 1 && d === 0);
  73062. };
  73063. /**
  73064. * Create a left-handed orthographic projection matrix
  73065. * @param left defines the viewport left coordinate
  73066. * @param right defines the viewport right coordinate
  73067. * @param bottom defines the viewport bottom coordinate
  73068. * @param top defines the viewport top coordinate
  73069. * @param znear defines the near clip plane
  73070. * @param zfar defines the far clip plane
  73071. * @returns a new matrix as a left-handed orthographic projection matrix
  73072. */
  73073. Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
  73074. var matrix = new Matrix();
  73075. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
  73076. return matrix;
  73077. };
  73078. /**
  73079. * Stores a left-handed orthographic projection into a given matrix
  73080. * @param left defines the viewport left coordinate
  73081. * @param right defines the viewport right coordinate
  73082. * @param bottom defines the viewport bottom coordinate
  73083. * @param top defines the viewport top coordinate
  73084. * @param znear defines the near clip plane
  73085. * @param zfar defines the far clip plane
  73086. * @param result defines the target matrix
  73087. */
  73088. Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
  73089. var n = znear;
  73090. var f = zfar;
  73091. var a = 2.0 / (right - left);
  73092. var b = 2.0 / (top - bottom);
  73093. var c = 2.0 / (f - n);
  73094. var d = -(f + n) / (f - n);
  73095. var i0 = (left + right) / (left - right);
  73096. var i1 = (top + bottom) / (bottom - top);
  73097. 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);
  73098. result._markAsUpdated();
  73099. };
  73100. /**
  73101. * Creates a right-handed orthographic projection matrix
  73102. * @param left defines the viewport left coordinate
  73103. * @param right defines the viewport right coordinate
  73104. * @param bottom defines the viewport bottom coordinate
  73105. * @param top defines the viewport top coordinate
  73106. * @param znear defines the near clip plane
  73107. * @param zfar defines the far clip plane
  73108. * @returns a new matrix as a right-handed orthographic projection matrix
  73109. */
  73110. Matrix.OrthoOffCenterRH = function (left, right, bottom, top, znear, zfar) {
  73111. var matrix = new Matrix();
  73112. Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
  73113. return matrix;
  73114. };
  73115. /**
  73116. * Stores a right-handed orthographic projection into a given matrix
  73117. * @param left defines the viewport left coordinate
  73118. * @param right defines the viewport right coordinate
  73119. * @param bottom defines the viewport bottom coordinate
  73120. * @param top defines the viewport top coordinate
  73121. * @param znear defines the near clip plane
  73122. * @param zfar defines the far clip plane
  73123. * @param result defines the target matrix
  73124. */
  73125. Matrix.OrthoOffCenterRHToRef = function (left, right, bottom, top, znear, zfar, result) {
  73126. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
  73127. result._m[10] *= -1; // No need to call _markAsUpdated as previous function already called it and let _isIdentityDirty to true
  73128. };
  73129. /**
  73130. * Creates a left-handed perspective projection matrix
  73131. * @param width defines the viewport width
  73132. * @param height defines the viewport height
  73133. * @param znear defines the near clip plane
  73134. * @param zfar defines the far clip plane
  73135. * @returns a new matrix as a left-handed perspective projection matrix
  73136. */
  73137. Matrix.PerspectiveLH = function (width, height, znear, zfar) {
  73138. var matrix = new Matrix();
  73139. var n = znear;
  73140. var f = zfar;
  73141. var a = 2.0 * n / width;
  73142. var b = 2.0 * n / height;
  73143. var c = (f + n) / (f - n);
  73144. var d = -2.0 * f * n / (f - n);
  73145. 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);
  73146. matrix._updateIdentityStatus(false);
  73147. return matrix;
  73148. };
  73149. /**
  73150. * Creates a left-handed perspective projection matrix
  73151. * @param fov defines the horizontal field of view
  73152. * @param aspect defines the aspect ratio
  73153. * @param znear defines the near clip plane
  73154. * @param zfar defines the far clip plane
  73155. * @returns a new matrix as a left-handed perspective projection matrix
  73156. */
  73157. Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
  73158. var matrix = new Matrix();
  73159. Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
  73160. return matrix;
  73161. };
  73162. /**
  73163. * Stores a left-handed perspective projection into a given matrix
  73164. * @param fov defines the horizontal field of view
  73165. * @param aspect defines the aspect ratio
  73166. * @param znear defines the near clip plane
  73167. * @param zfar defines the far clip plane
  73168. * @param result defines the target matrix
  73169. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73170. */
  73171. Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  73172. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  73173. var n = znear;
  73174. var f = zfar;
  73175. var t = 1.0 / (Math.tan(fov * 0.5));
  73176. var a = isVerticalFovFixed ? (t / aspect) : t;
  73177. var b = isVerticalFovFixed ? t : (t * aspect);
  73178. var c = (f + n) / (f - n);
  73179. var d = -2.0 * f * n / (f - n);
  73180. 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);
  73181. result._updateIdentityStatus(false);
  73182. };
  73183. /**
  73184. * Creates a right-handed perspective projection matrix
  73185. * @param fov defines the horizontal field of view
  73186. * @param aspect defines the aspect ratio
  73187. * @param znear defines the near clip plane
  73188. * @param zfar defines the far clip plane
  73189. * @returns a new matrix as a right-handed perspective projection matrix
  73190. */
  73191. Matrix.PerspectiveFovRH = function (fov, aspect, znear, zfar) {
  73192. var matrix = new Matrix();
  73193. Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
  73194. return matrix;
  73195. };
  73196. /**
  73197. * Stores a right-handed perspective projection into a given matrix
  73198. * @param fov defines the horizontal field of view
  73199. * @param aspect defines the aspect ratio
  73200. * @param znear defines the near clip plane
  73201. * @param zfar defines the far clip plane
  73202. * @param result defines the target matrix
  73203. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73204. */
  73205. Matrix.PerspectiveFovRHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  73206. //alternatively this could be expressed as:
  73207. // m = PerspectiveFovLHToRef
  73208. // m[10] *= -1.0;
  73209. // m[11] *= -1.0;
  73210. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  73211. var n = znear;
  73212. var f = zfar;
  73213. var t = 1.0 / (Math.tan(fov * 0.5));
  73214. var a = isVerticalFovFixed ? (t / aspect) : t;
  73215. var b = isVerticalFovFixed ? t : (t * aspect);
  73216. var c = -(f + n) / (f - n);
  73217. var d = -2 * f * n / (f - n);
  73218. 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);
  73219. result._updateIdentityStatus(false);
  73220. };
  73221. /**
  73222. * Stores a perspective projection for WebVR info a given matrix
  73223. * @param fov defines the field of view
  73224. * @param znear defines the near clip plane
  73225. * @param zfar defines the far clip plane
  73226. * @param result defines the target matrix
  73227. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  73228. */
  73229. Matrix.PerspectiveFovWebVRToRef = function (fov, znear, zfar, result, rightHanded) {
  73230. if (rightHanded === void 0) { rightHanded = false; }
  73231. var rightHandedFactor = rightHanded ? -1 : 1;
  73232. var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
  73233. var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
  73234. var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
  73235. var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
  73236. var xScale = 2.0 / (leftTan + rightTan);
  73237. var yScale = 2.0 / (upTan + downTan);
  73238. var m = result._m;
  73239. m[0] = xScale;
  73240. m[1] = m[2] = m[3] = m[4] = 0.0;
  73241. m[5] = yScale;
  73242. m[6] = m[7] = 0.0;
  73243. m[8] = ((leftTan - rightTan) * xScale * 0.5);
  73244. m[9] = -((upTan - downTan) * yScale * 0.5);
  73245. m[10] = -zfar / (znear - zfar);
  73246. m[11] = 1.0 * rightHandedFactor;
  73247. m[12] = m[13] = m[15] = 0.0;
  73248. m[14] = -(2.0 * zfar * znear) / (zfar - znear);
  73249. result._markAsUpdated();
  73250. };
  73251. /**
  73252. * Computes a complete transformation matrix
  73253. * @param viewport defines the viewport to use
  73254. * @param world defines the world matrix
  73255. * @param view defines the view matrix
  73256. * @param projection defines the projection matrix
  73257. * @param zmin defines the near clip plane
  73258. * @param zmax defines the far clip plane
  73259. * @returns the transformation matrix
  73260. */
  73261. Matrix.GetFinalMatrix = function (viewport, world, view, projection, zmin, zmax) {
  73262. var cw = viewport.width;
  73263. var ch = viewport.height;
  73264. var cx = viewport.x;
  73265. var cy = viewport.y;
  73266. 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);
  73267. var matrix = MathTmp.Matrix[0];
  73268. world.multiplyToRef(view, matrix);
  73269. matrix.multiplyToRef(projection, matrix);
  73270. return matrix.multiply(viewportMatrix);
  73271. };
  73272. /**
  73273. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  73274. * @param matrix defines the matrix to use
  73275. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  73276. */
  73277. Matrix.GetAsMatrix2x2 = function (matrix) {
  73278. var m = matrix.m;
  73279. return new Float32Array([m[0], m[1], m[4], m[5]]);
  73280. };
  73281. /**
  73282. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  73283. * @param matrix defines the matrix to use
  73284. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  73285. */
  73286. Matrix.GetAsMatrix3x3 = function (matrix) {
  73287. var m = matrix.m;
  73288. return new Float32Array([
  73289. m[0], m[1], m[2],
  73290. m[4], m[5], m[6],
  73291. m[8], m[9], m[10]
  73292. ]);
  73293. };
  73294. /**
  73295. * Compute the transpose of a given matrix
  73296. * @param matrix defines the matrix to transpose
  73297. * @returns the new matrix
  73298. */
  73299. Matrix.Transpose = function (matrix) {
  73300. var result = new Matrix();
  73301. Matrix.TransposeToRef(matrix, result);
  73302. return result;
  73303. };
  73304. /**
  73305. * Compute the transpose of a matrix and store it in a target matrix
  73306. * @param matrix defines the matrix to transpose
  73307. * @param result defines the target matrix
  73308. */
  73309. Matrix.TransposeToRef = function (matrix, result) {
  73310. var rm = result._m;
  73311. var mm = matrix.m;
  73312. rm[0] = mm[0];
  73313. rm[1] = mm[4];
  73314. rm[2] = mm[8];
  73315. rm[3] = mm[12];
  73316. rm[4] = mm[1];
  73317. rm[5] = mm[5];
  73318. rm[6] = mm[9];
  73319. rm[7] = mm[13];
  73320. rm[8] = mm[2];
  73321. rm[9] = mm[6];
  73322. rm[10] = mm[10];
  73323. rm[11] = mm[14];
  73324. rm[12] = mm[3];
  73325. rm[13] = mm[7];
  73326. rm[14] = mm[11];
  73327. rm[15] = mm[15];
  73328. // identity-ness does not change when transposing
  73329. result._updateIdentityStatus(matrix._isIdentity, matrix._isIdentityDirty);
  73330. };
  73331. /**
  73332. * Computes a reflection matrix from a plane
  73333. * @param plane defines the reflection plane
  73334. * @returns a new matrix
  73335. */
  73336. Matrix.Reflection = function (plane) {
  73337. var matrix = new Matrix();
  73338. Matrix.ReflectionToRef(plane, matrix);
  73339. return matrix;
  73340. };
  73341. /**
  73342. * Computes a reflection matrix from a plane
  73343. * @param plane defines the reflection plane
  73344. * @param result defines the target matrix
  73345. */
  73346. Matrix.ReflectionToRef = function (plane, result) {
  73347. plane.normalize();
  73348. var x = plane.normal.x;
  73349. var y = plane.normal.y;
  73350. var z = plane.normal.z;
  73351. var temp = -2 * x;
  73352. var temp2 = -2 * y;
  73353. var temp3 = -2 * z;
  73354. 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);
  73355. };
  73356. /**
  73357. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  73358. * @param xaxis defines the value of the 1st axis
  73359. * @param yaxis defines the value of the 2nd axis
  73360. * @param zaxis defines the value of the 3rd axis
  73361. * @param result defines the target matrix
  73362. */
  73363. Matrix.FromXYZAxesToRef = function (xaxis, yaxis, zaxis, result) {
  73364. 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);
  73365. };
  73366. /**
  73367. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  73368. * @param quat defines the quaternion to use
  73369. * @param result defines the target matrix
  73370. */
  73371. Matrix.FromQuaternionToRef = function (quat, result) {
  73372. var xx = quat.x * quat.x;
  73373. var yy = quat.y * quat.y;
  73374. var zz = quat.z * quat.z;
  73375. var xy = quat.x * quat.y;
  73376. var zw = quat.z * quat.w;
  73377. var zx = quat.z * quat.x;
  73378. var yw = quat.y * quat.w;
  73379. var yz = quat.y * quat.z;
  73380. var xw = quat.x * quat.w;
  73381. result._m[0] = 1.0 - (2.0 * (yy + zz));
  73382. result._m[1] = 2.0 * (xy + zw);
  73383. result._m[2] = 2.0 * (zx - yw);
  73384. result._m[3] = 0.0;
  73385. result._m[4] = 2.0 * (xy - zw);
  73386. result._m[5] = 1.0 - (2.0 * (zz + xx));
  73387. result._m[6] = 2.0 * (yz + xw);
  73388. result._m[7] = 0.0;
  73389. result._m[8] = 2.0 * (zx + yw);
  73390. result._m[9] = 2.0 * (yz - xw);
  73391. result._m[10] = 1.0 - (2.0 * (yy + xx));
  73392. result._m[11] = 0.0;
  73393. result._m[12] = 0.0;
  73394. result._m[13] = 0.0;
  73395. result._m[14] = 0.0;
  73396. result._m[15] = 1.0;
  73397. result._markAsUpdated();
  73398. };
  73399. Matrix._updateFlagSeed = 0;
  73400. Matrix._identityReadOnly = Matrix.Identity();
  73401. return Matrix;
  73402. }());
  73403. /**
  73404. * Represens a plane by the equation ax + by + cz + d = 0
  73405. */
  73406. var Plane = /** @class */ (function () {
  73407. /**
  73408. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73409. * @param a a component of the plane
  73410. * @param b b component of the plane
  73411. * @param c c component of the plane
  73412. * @param d d component of the plane
  73413. */
  73414. function Plane(a, b, c, d) {
  73415. this.normal = new Vector3(a, b, c);
  73416. this.d = d;
  73417. }
  73418. /**
  73419. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73420. */
  73421. Plane.prototype.asArray = function () {
  73422. return [this.normal.x, this.normal.y, this.normal.z, this.d];
  73423. };
  73424. // Methods
  73425. /**
  73426. * @returns a new plane copied from the current Plane.
  73427. */
  73428. Plane.prototype.clone = function () {
  73429. return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
  73430. };
  73431. /**
  73432. * @returns the string "Plane".
  73433. */
  73434. Plane.prototype.getClassName = function () {
  73435. return "Plane";
  73436. };
  73437. /**
  73438. * @returns the Plane hash code.
  73439. */
  73440. Plane.prototype.getHashCode = function () {
  73441. var hash = this.normal.getHashCode();
  73442. hash = (hash * 397) ^ (this.d || 0);
  73443. return hash;
  73444. };
  73445. /**
  73446. * Normalize the current Plane in place.
  73447. * @returns the updated Plane.
  73448. */
  73449. Plane.prototype.normalize = function () {
  73450. var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
  73451. var magnitude = 0.0;
  73452. if (norm !== 0) {
  73453. magnitude = 1.0 / norm;
  73454. }
  73455. this.normal.x *= magnitude;
  73456. this.normal.y *= magnitude;
  73457. this.normal.z *= magnitude;
  73458. this.d *= magnitude;
  73459. return this;
  73460. };
  73461. /**
  73462. * Applies a transformation the plane and returns the result
  73463. * @param transformation the transformation matrix to be applied to the plane
  73464. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73465. */
  73466. Plane.prototype.transform = function (transformation) {
  73467. var transposedMatrix = MathTmp.Matrix[0];
  73468. Matrix.TransposeToRef(transformation, transposedMatrix);
  73469. var m = transposedMatrix.m;
  73470. var x = this.normal.x;
  73471. var y = this.normal.y;
  73472. var z = this.normal.z;
  73473. var d = this.d;
  73474. var normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];
  73475. var normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];
  73476. var normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];
  73477. var finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];
  73478. return new Plane(normalX, normalY, normalZ, finalD);
  73479. };
  73480. /**
  73481. * Calcualtte the dot product between the point and the plane normal
  73482. * @param point point to calculate the dot product with
  73483. * @returns the dot product (float) of the point coordinates and the plane normal.
  73484. */
  73485. Plane.prototype.dotCoordinate = function (point) {
  73486. return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
  73487. };
  73488. /**
  73489. * Updates the current Plane from the plane defined by the three given points.
  73490. * @param point1 one of the points used to contruct the plane
  73491. * @param point2 one of the points used to contruct the plane
  73492. * @param point3 one of the points used to contruct the plane
  73493. * @returns the updated Plane.
  73494. */
  73495. Plane.prototype.copyFromPoints = function (point1, point2, point3) {
  73496. var x1 = point2.x - point1.x;
  73497. var y1 = point2.y - point1.y;
  73498. var z1 = point2.z - point1.z;
  73499. var x2 = point3.x - point1.x;
  73500. var y2 = point3.y - point1.y;
  73501. var z2 = point3.z - point1.z;
  73502. var yz = (y1 * z2) - (z1 * y2);
  73503. var xz = (z1 * x2) - (x1 * z2);
  73504. var xy = (x1 * y2) - (y1 * x2);
  73505. var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
  73506. var invPyth;
  73507. if (pyth !== 0) {
  73508. invPyth = 1.0 / pyth;
  73509. }
  73510. else {
  73511. invPyth = 0.0;
  73512. }
  73513. this.normal.x = yz * invPyth;
  73514. this.normal.y = xz * invPyth;
  73515. this.normal.z = xy * invPyth;
  73516. this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
  73517. return this;
  73518. };
  73519. /**
  73520. * Checks if the plane is facing a given direction
  73521. * @param direction the direction to check if the plane is facing
  73522. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73523. * @returns True is the vector "direction" is the same side than the plane normal.
  73524. */
  73525. Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
  73526. var dot = Vector3.Dot(this.normal, direction);
  73527. return (dot <= epsilon);
  73528. };
  73529. /**
  73530. * Calculates the distance to a point
  73531. * @param point point to calculate distance to
  73532. * @returns the signed distance (float) from the given point to the Plane.
  73533. */
  73534. Plane.prototype.signedDistanceTo = function (point) {
  73535. return Vector3.Dot(point, this.normal) + this.d;
  73536. };
  73537. // Statics
  73538. /**
  73539. * Creates a plane from an array
  73540. * @param array the array to create a plane from
  73541. * @returns a new Plane from the given array.
  73542. */
  73543. Plane.FromArray = function (array) {
  73544. return new Plane(array[0], array[1], array[2], array[3]);
  73545. };
  73546. /**
  73547. * Creates a plane from three points
  73548. * @param point1 point used to create the plane
  73549. * @param point2 point used to create the plane
  73550. * @param point3 point used to create the plane
  73551. * @returns a new Plane defined by the three given points.
  73552. */
  73553. Plane.FromPoints = function (point1, point2, point3) {
  73554. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  73555. result.copyFromPoints(point1, point2, point3);
  73556. return result;
  73557. };
  73558. /**
  73559. * Creates a plane from an origin point and a normal
  73560. * @param origin origin of the plane to be constructed
  73561. * @param normal normal of the plane to be constructed
  73562. * @returns a new Plane the normal vector to this plane at the given origin point.
  73563. * Note : the vector "normal" is updated because normalized.
  73564. */
  73565. Plane.FromPositionAndNormal = function (origin, normal) {
  73566. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  73567. normal.normalize();
  73568. result.normal = normal;
  73569. result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  73570. return result;
  73571. };
  73572. /**
  73573. * Calculates the distance from a plane and a point
  73574. * @param origin origin of the plane to be constructed
  73575. * @param normal normal of the plane to be constructed
  73576. * @param point point to calculate distance to
  73577. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73578. */
  73579. Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
  73580. var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  73581. return Vector3.Dot(point, normal) + d;
  73582. };
  73583. return Plane;
  73584. }());
  73585. /**
  73586. * Class used to represent a viewport on screen
  73587. */
  73588. var Viewport = /** @class */ (function () {
  73589. /**
  73590. * Creates a Viewport object located at (x, y) and sized (width, height)
  73591. * @param x defines viewport left coordinate
  73592. * @param y defines viewport top coordinate
  73593. * @param width defines the viewport width
  73594. * @param height defines the viewport height
  73595. */
  73596. function Viewport(
  73597. /** viewport left coordinate */
  73598. x,
  73599. /** viewport top coordinate */
  73600. y,
  73601. /**viewport width */
  73602. width,
  73603. /** viewport height */
  73604. height) {
  73605. this.x = x;
  73606. this.y = y;
  73607. this.width = width;
  73608. this.height = height;
  73609. }
  73610. /**
  73611. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  73612. * @param renderWidth defines the rendering width
  73613. * @param renderHeight defines the rendering height
  73614. * @returns a new Viewport
  73615. */
  73616. Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
  73617. return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
  73618. };
  73619. /**
  73620. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  73621. * @param renderWidth defines the rendering width
  73622. * @param renderHeight defines the rendering height
  73623. * @param ref defines the target viewport
  73624. * @returns the current viewport
  73625. */
  73626. Viewport.prototype.toGlobalToRef = function (renderWidth, renderHeight, ref) {
  73627. ref.x = this.x * renderWidth;
  73628. ref.y = this.y * renderHeight;
  73629. ref.width = this.width * renderWidth;
  73630. ref.height = this.height * renderHeight;
  73631. return this;
  73632. };
  73633. /**
  73634. * Returns a new Viewport copied from the current one
  73635. * @returns a new Viewport
  73636. */
  73637. Viewport.prototype.clone = function () {
  73638. return new Viewport(this.x, this.y, this.width, this.height);
  73639. };
  73640. return Viewport;
  73641. }());
  73642. /**
  73643. * Reprasents a camera frustum
  73644. */
  73645. var Frustum = /** @class */ (function () {
  73646. function Frustum() {
  73647. }
  73648. /**
  73649. * Gets the planes representing the frustum
  73650. * @param transform matrix to be applied to the returned planes
  73651. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  73652. */
  73653. Frustum.GetPlanes = function (transform) {
  73654. var frustumPlanes = [];
  73655. for (var index = 0; index < 6; index++) {
  73656. frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));
  73657. }
  73658. Frustum.GetPlanesToRef(transform, frustumPlanes);
  73659. return frustumPlanes;
  73660. };
  73661. /**
  73662. * Gets the near frustum plane transformed by the transform matrix
  73663. * @param transform transformation matrix to be applied to the resulting frustum plane
  73664. * @param frustumPlane the resuling frustum plane
  73665. */
  73666. Frustum.GetNearPlaneToRef = function (transform, frustumPlane) {
  73667. var m = transform.m;
  73668. frustumPlane.normal.x = m[3] + m[2];
  73669. frustumPlane.normal.y = m[7] + m[6];
  73670. frustumPlane.normal.z = m[11] + m[10];
  73671. frustumPlane.d = m[15] + m[14];
  73672. frustumPlane.normalize();
  73673. };
  73674. /**
  73675. * Gets the far frustum plane transformed by the transform matrix
  73676. * @param transform transformation matrix to be applied to the resulting frustum plane
  73677. * @param frustumPlane the resuling frustum plane
  73678. */
  73679. Frustum.GetFarPlaneToRef = function (transform, frustumPlane) {
  73680. var m = transform.m;
  73681. frustumPlane.normal.x = m[3] - m[2];
  73682. frustumPlane.normal.y = m[7] - m[6];
  73683. frustumPlane.normal.z = m[11] - m[10];
  73684. frustumPlane.d = m[15] - m[14];
  73685. frustumPlane.normalize();
  73686. };
  73687. /**
  73688. * Gets the left frustum plane transformed by the transform matrix
  73689. * @param transform transformation matrix to be applied to the resulting frustum plane
  73690. * @param frustumPlane the resuling frustum plane
  73691. */
  73692. Frustum.GetLeftPlaneToRef = function (transform, frustumPlane) {
  73693. var m = transform.m;
  73694. frustumPlane.normal.x = m[3] + m[0];
  73695. frustumPlane.normal.y = m[7] + m[4];
  73696. frustumPlane.normal.z = m[11] + m[8];
  73697. frustumPlane.d = m[15] + m[12];
  73698. frustumPlane.normalize();
  73699. };
  73700. /**
  73701. * Gets the right frustum plane transformed by the transform matrix
  73702. * @param transform transformation matrix to be applied to the resulting frustum plane
  73703. * @param frustumPlane the resuling frustum plane
  73704. */
  73705. Frustum.GetRightPlaneToRef = function (transform, frustumPlane) {
  73706. var m = transform.m;
  73707. frustumPlane.normal.x = m[3] - m[0];
  73708. frustumPlane.normal.y = m[7] - m[4];
  73709. frustumPlane.normal.z = m[11] - m[8];
  73710. frustumPlane.d = m[15] - m[12];
  73711. frustumPlane.normalize();
  73712. };
  73713. /**
  73714. * Gets the top frustum plane transformed by the transform matrix
  73715. * @param transform transformation matrix to be applied to the resulting frustum plane
  73716. * @param frustumPlane the resuling frustum plane
  73717. */
  73718. Frustum.GetTopPlaneToRef = function (transform, frustumPlane) {
  73719. var m = transform.m;
  73720. frustumPlane.normal.x = m[3] - m[1];
  73721. frustumPlane.normal.y = m[7] - m[5];
  73722. frustumPlane.normal.z = m[11] - m[9];
  73723. frustumPlane.d = m[15] - m[13];
  73724. frustumPlane.normalize();
  73725. };
  73726. /**
  73727. * Gets the bottom frustum plane transformed by the transform matrix
  73728. * @param transform transformation matrix to be applied to the resulting frustum plane
  73729. * @param frustumPlane the resuling frustum plane
  73730. */
  73731. Frustum.GetBottomPlaneToRef = function (transform, frustumPlane) {
  73732. var m = transform.m;
  73733. frustumPlane.normal.x = m[3] + m[1];
  73734. frustumPlane.normal.y = m[7] + m[5];
  73735. frustumPlane.normal.z = m[11] + m[9];
  73736. frustumPlane.d = m[15] + m[13];
  73737. frustumPlane.normalize();
  73738. };
  73739. /**
  73740. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  73741. * @param transform transformation matrix to be applied to the resulting frustum planes
  73742. * @param frustumPlanes the resuling frustum planes
  73743. */
  73744. Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
  73745. // Near
  73746. Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);
  73747. // Far
  73748. Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);
  73749. // Left
  73750. Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);
  73751. // Right
  73752. Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);
  73753. // Top
  73754. Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);
  73755. // Bottom
  73756. Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);
  73757. };
  73758. return Frustum;
  73759. }());
  73760. /** Defines supported spaces */
  73761. var Space;
  73762. (function (Space) {
  73763. /** Local (object) space */
  73764. Space[Space["LOCAL"] = 0] = "LOCAL";
  73765. /** World space */
  73766. Space[Space["WORLD"] = 1] = "WORLD";
  73767. /** Bone space */
  73768. Space[Space["BONE"] = 2] = "BONE";
  73769. })(Space || (Space = {}));
  73770. /** Defines the 3 main axes */
  73771. var Axis = /** @class */ (function () {
  73772. function Axis() {
  73773. }
  73774. /** X axis */
  73775. Axis.X = new Vector3(1.0, 0.0, 0.0);
  73776. /** Y axis */
  73777. Axis.Y = new Vector3(0.0, 1.0, 0.0);
  73778. /** Z axis */
  73779. Axis.Z = new Vector3(0.0, 0.0, 1.0);
  73780. return Axis;
  73781. }());
  73782. /** Class used to represent a Bezier curve */
  73783. var BezierCurve = /** @class */ (function () {
  73784. function BezierCurve() {
  73785. }
  73786. /**
  73787. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  73788. * @param t defines the time
  73789. * @param x1 defines the left coordinate on X axis
  73790. * @param y1 defines the left coordinate on Y axis
  73791. * @param x2 defines the right coordinate on X axis
  73792. * @param y2 defines the right coordinate on Y axis
  73793. * @returns the interpolated value
  73794. */
  73795. BezierCurve.Interpolate = function (t, x1, y1, x2, y2) {
  73796. // Extract X (which is equal to time here)
  73797. var f0 = 1 - 3 * x2 + 3 * x1;
  73798. var f1 = 3 * x2 - 6 * x1;
  73799. var f2 = 3 * x1;
  73800. var refinedT = t;
  73801. for (var i = 0; i < 5; i++) {
  73802. var refinedT2 = refinedT * refinedT;
  73803. var refinedT3 = refinedT2 * refinedT;
  73804. var x = f0 * refinedT3 + f1 * refinedT2 + f2 * refinedT;
  73805. var slope = 1.0 / (3.0 * f0 * refinedT2 + 2.0 * f1 * refinedT + f2);
  73806. refinedT -= (x - t) * slope;
  73807. refinedT = Math.min(1, Math.max(0, refinedT));
  73808. }
  73809. // Resolve cubic bezier for the given x
  73810. return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
  73811. 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
  73812. Math.pow(refinedT, 3);
  73813. };
  73814. return BezierCurve;
  73815. }());
  73816. /**
  73817. * Defines potential orientation for back face culling
  73818. */
  73819. var Orientation;
  73820. (function (Orientation) {
  73821. /**
  73822. * Clockwise
  73823. */
  73824. Orientation[Orientation["CW"] = 0] = "CW";
  73825. /** Counter clockwise */
  73826. Orientation[Orientation["CCW"] = 1] = "CCW";
  73827. })(Orientation || (Orientation = {}));
  73828. /**
  73829. * Defines angle representation
  73830. */
  73831. var Angle = /** @class */ (function () {
  73832. /**
  73833. * Creates an Angle object of "radians" radians (float).
  73834. * @param radians the angle in radians
  73835. */
  73836. function Angle(radians) {
  73837. this._radians = radians;
  73838. if (this._radians < 0.0) {
  73839. this._radians += (2.0 * Math.PI);
  73840. }
  73841. }
  73842. /**
  73843. * Get value in degrees
  73844. * @returns the Angle value in degrees (float)
  73845. */
  73846. Angle.prototype.degrees = function () {
  73847. return this._radians * 180.0 / Math.PI;
  73848. };
  73849. /**
  73850. * Get value in radians
  73851. * @returns the Angle value in radians (float)
  73852. */
  73853. Angle.prototype.radians = function () {
  73854. return this._radians;
  73855. };
  73856. /**
  73857. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  73858. * @param a defines first vector
  73859. * @param b defines second vector
  73860. * @returns a new Angle
  73861. */
  73862. Angle.BetweenTwoPoints = function (a, b) {
  73863. var delta = b.subtract(a);
  73864. var theta = Math.atan2(delta.y, delta.x);
  73865. return new Angle(theta);
  73866. };
  73867. /**
  73868. * Gets a new Angle object from the given float in radians
  73869. * @param radians defines the angle value in radians
  73870. * @returns a new Angle
  73871. */
  73872. Angle.FromRadians = function (radians) {
  73873. return new Angle(radians);
  73874. };
  73875. /**
  73876. * Gets a new Angle object from the given float in degrees
  73877. * @param degrees defines the angle value in degrees
  73878. * @returns a new Angle
  73879. */
  73880. Angle.FromDegrees = function (degrees) {
  73881. return new Angle(degrees * Math.PI / 180.0);
  73882. };
  73883. return Angle;
  73884. }());
  73885. /**
  73886. * This represents an arc in a 2d space.
  73887. */
  73888. var Arc2 = /** @class */ (function () {
  73889. /**
  73890. * Creates an Arc object from the three given points : start, middle and end.
  73891. * @param startPoint Defines the start point of the arc
  73892. * @param midPoint Defines the midlle point of the arc
  73893. * @param endPoint Defines the end point of the arc
  73894. */
  73895. function Arc2(
  73896. /** Defines the start point of the arc */
  73897. startPoint,
  73898. /** Defines the mid point of the arc */
  73899. midPoint,
  73900. /** Defines the end point of the arc */
  73901. endPoint) {
  73902. this.startPoint = startPoint;
  73903. this.midPoint = midPoint;
  73904. this.endPoint = endPoint;
  73905. var temp = Math.pow(midPoint.x, 2) + Math.pow(midPoint.y, 2);
  73906. var startToMid = (Math.pow(startPoint.x, 2) + Math.pow(startPoint.y, 2) - temp) / 2.;
  73907. var midToEnd = (temp - Math.pow(endPoint.x, 2) - Math.pow(endPoint.y, 2)) / 2.;
  73908. var det = (startPoint.x - midPoint.x) * (midPoint.y - endPoint.y) - (midPoint.x - endPoint.x) * (startPoint.y - midPoint.y);
  73909. 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);
  73910. this.radius = this.centerPoint.subtract(this.startPoint).length();
  73911. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  73912. var a1 = this.startAngle.degrees();
  73913. var a2 = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees();
  73914. var a3 = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  73915. // angles correction
  73916. if (a2 - a1 > +180.0) {
  73917. a2 -= 360.0;
  73918. }
  73919. if (a2 - a1 < -180.0) {
  73920. a2 += 360.0;
  73921. }
  73922. if (a3 - a2 > +180.0) {
  73923. a3 -= 360.0;
  73924. }
  73925. if (a3 - a2 < -180.0) {
  73926. a3 += 360.0;
  73927. }
  73928. this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
  73929. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
  73930. }
  73931. return Arc2;
  73932. }());
  73933. /**
  73934. * Represents a 2D path made up of multiple 2D points
  73935. */
  73936. var Path2 = /** @class */ (function () {
  73937. /**
  73938. * Creates a Path2 object from the starting 2D coordinates x and y.
  73939. * @param x the starting points x value
  73940. * @param y the starting points y value
  73941. */
  73942. function Path2(x, y) {
  73943. this._points = new Array();
  73944. this._length = 0.0;
  73945. /**
  73946. * If the path start and end point are the same
  73947. */
  73948. this.closed = false;
  73949. this._points.push(new Vector2(x, y));
  73950. }
  73951. /**
  73952. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  73953. * @param x the added points x value
  73954. * @param y the added points y value
  73955. * @returns the updated Path2.
  73956. */
  73957. Path2.prototype.addLineTo = function (x, y) {
  73958. if (this.closed) {
  73959. return this;
  73960. }
  73961. var newPoint = new Vector2(x, y);
  73962. var previousPoint = this._points[this._points.length - 1];
  73963. this._points.push(newPoint);
  73964. this._length += newPoint.subtract(previousPoint).length();
  73965. return this;
  73966. };
  73967. /**
  73968. * 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.
  73969. * @param midX middle point x value
  73970. * @param midY middle point y value
  73971. * @param endX end point x value
  73972. * @param endY end point y value
  73973. * @param numberOfSegments (default: 36)
  73974. * @returns the updated Path2.
  73975. */
  73976. Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
  73977. if (numberOfSegments === void 0) { numberOfSegments = 36; }
  73978. if (this.closed) {
  73979. return this;
  73980. }
  73981. var startPoint = this._points[this._points.length - 1];
  73982. var midPoint = new Vector2(midX, midY);
  73983. var endPoint = new Vector2(endX, endY);
  73984. var arc = new Arc2(startPoint, midPoint, endPoint);
  73985. var increment = arc.angle.radians() / numberOfSegments;
  73986. if (arc.orientation === Orientation.CW) {
  73987. increment *= -1;
  73988. }
  73989. var currentAngle = arc.startAngle.radians() + increment;
  73990. for (var i = 0; i < numberOfSegments; i++) {
  73991. var x = Math.cos(currentAngle) * arc.radius + arc.centerPoint.x;
  73992. var y = Math.sin(currentAngle) * arc.radius + arc.centerPoint.y;
  73993. this.addLineTo(x, y);
  73994. currentAngle += increment;
  73995. }
  73996. return this;
  73997. };
  73998. /**
  73999. * Closes the Path2.
  74000. * @returns the Path2.
  74001. */
  74002. Path2.prototype.close = function () {
  74003. this.closed = true;
  74004. return this;
  74005. };
  74006. /**
  74007. * Gets the sum of the distance between each sequential point in the path
  74008. * @returns the Path2 total length (float).
  74009. */
  74010. Path2.prototype.length = function () {
  74011. var result = this._length;
  74012. if (!this.closed) {
  74013. var lastPoint = this._points[this._points.length - 1];
  74014. var firstPoint = this._points[0];
  74015. result += (firstPoint.subtract(lastPoint).length());
  74016. }
  74017. return result;
  74018. };
  74019. /**
  74020. * Gets the points which construct the path
  74021. * @returns the Path2 internal array of points.
  74022. */
  74023. Path2.prototype.getPoints = function () {
  74024. return this._points;
  74025. };
  74026. /**
  74027. * Retreives the point at the distance aways from the starting point
  74028. * @param normalizedLengthPosition the length along the path to retreive the point from
  74029. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  74030. */
  74031. Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
  74032. if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
  74033. return Vector2.Zero();
  74034. }
  74035. var lengthPosition = normalizedLengthPosition * this.length();
  74036. var previousOffset = 0;
  74037. for (var i = 0; i < this._points.length; i++) {
  74038. var j = (i + 1) % this._points.length;
  74039. var a = this._points[i];
  74040. var b = this._points[j];
  74041. var bToA = b.subtract(a);
  74042. var nextOffset = (bToA.length() + previousOffset);
  74043. if (lengthPosition >= previousOffset && lengthPosition <= nextOffset) {
  74044. var dir = bToA.normalize();
  74045. var localOffset = lengthPosition - previousOffset;
  74046. return new Vector2(a.x + (dir.x * localOffset), a.y + (dir.y * localOffset));
  74047. }
  74048. previousOffset = nextOffset;
  74049. }
  74050. return Vector2.Zero();
  74051. };
  74052. /**
  74053. * Creates a new path starting from an x and y position
  74054. * @param x starting x value
  74055. * @param y starting y value
  74056. * @returns a new Path2 starting at the coordinates (x, y).
  74057. */
  74058. Path2.StartingAt = function (x, y) {
  74059. return new Path2(x, y);
  74060. };
  74061. return Path2;
  74062. }());
  74063. /**
  74064. * Represents a 3D path made up of multiple 3D points
  74065. */
  74066. var Path3D = /** @class */ (function () {
  74067. /**
  74068. * new Path3D(path, normal, raw)
  74069. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  74070. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  74071. * @param path an array of Vector3, the curve axis of the Path3D
  74072. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  74073. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  74074. */
  74075. function Path3D(
  74076. /**
  74077. * an array of Vector3, the curve axis of the Path3D
  74078. */
  74079. path, firstNormal, raw) {
  74080. if (firstNormal === void 0) { firstNormal = null; }
  74081. this.path = path;
  74082. this._curve = new Array();
  74083. this._distances = new Array();
  74084. this._tangents = new Array();
  74085. this._normals = new Array();
  74086. this._binormals = new Array();
  74087. for (var p = 0; p < path.length; p++) {
  74088. this._curve[p] = path[p].clone(); // hard copy
  74089. }
  74090. this._raw = raw || false;
  74091. this._compute(firstNormal);
  74092. }
  74093. /**
  74094. * Returns the Path3D array of successive Vector3 designing its curve.
  74095. * @returns the Path3D array of successive Vector3 designing its curve.
  74096. */
  74097. Path3D.prototype.getCurve = function () {
  74098. return this._curve;
  74099. };
  74100. /**
  74101. * Returns an array populated with tangent vectors on each Path3D curve point.
  74102. * @returns an array populated with tangent vectors on each Path3D curve point.
  74103. */
  74104. Path3D.prototype.getTangents = function () {
  74105. return this._tangents;
  74106. };
  74107. /**
  74108. * Returns an array populated with normal vectors on each Path3D curve point.
  74109. * @returns an array populated with normal vectors on each Path3D curve point.
  74110. */
  74111. Path3D.prototype.getNormals = function () {
  74112. return this._normals;
  74113. };
  74114. /**
  74115. * Returns an array populated with binormal vectors on each Path3D curve point.
  74116. * @returns an array populated with binormal vectors on each Path3D curve point.
  74117. */
  74118. Path3D.prototype.getBinormals = function () {
  74119. return this._binormals;
  74120. };
  74121. /**
  74122. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  74123. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  74124. */
  74125. Path3D.prototype.getDistances = function () {
  74126. return this._distances;
  74127. };
  74128. /**
  74129. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  74130. * @param path path which all values are copied into the curves points
  74131. * @param firstNormal which should be projected onto the curve
  74132. * @returns the same object updated.
  74133. */
  74134. Path3D.prototype.update = function (path, firstNormal) {
  74135. if (firstNormal === void 0) { firstNormal = null; }
  74136. for (var p = 0; p < path.length; p++) {
  74137. this._curve[p].x = path[p].x;
  74138. this._curve[p].y = path[p].y;
  74139. this._curve[p].z = path[p].z;
  74140. }
  74141. this._compute(firstNormal);
  74142. return this;
  74143. };
  74144. // private function compute() : computes tangents, normals and binormals
  74145. Path3D.prototype._compute = function (firstNormal) {
  74146. var l = this._curve.length;
  74147. // first and last tangents
  74148. this._tangents[0] = this._getFirstNonNullVector(0);
  74149. if (!this._raw) {
  74150. this._tangents[0].normalize();
  74151. }
  74152. this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
  74153. if (!this._raw) {
  74154. this._tangents[l - 1].normalize();
  74155. }
  74156. // normals and binormals at first point : arbitrary vector with _normalVector()
  74157. var tg0 = this._tangents[0];
  74158. var pp0 = this._normalVector(tg0, firstNormal);
  74159. this._normals[0] = pp0;
  74160. if (!this._raw) {
  74161. this._normals[0].normalize();
  74162. }
  74163. this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
  74164. if (!this._raw) {
  74165. this._binormals[0].normalize();
  74166. }
  74167. this._distances[0] = 0.0;
  74168. // normals and binormals : next points
  74169. var prev; // previous vector (segment)
  74170. var cur; // current vector (segment)
  74171. var curTang; // current tangent
  74172. // previous normal
  74173. var prevBinor; // previous binormal
  74174. for (var i = 1; i < l; i++) {
  74175. // tangents
  74176. prev = this._getLastNonNullVector(i);
  74177. if (i < l - 1) {
  74178. cur = this._getFirstNonNullVector(i);
  74179. this._tangents[i] = prev.add(cur);
  74180. this._tangents[i].normalize();
  74181. }
  74182. this._distances[i] = this._distances[i - 1] + prev.length();
  74183. // normals and binormals
  74184. // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
  74185. curTang = this._tangents[i];
  74186. prevBinor = this._binormals[i - 1];
  74187. this._normals[i] = Vector3.Cross(prevBinor, curTang);
  74188. if (!this._raw) {
  74189. this._normals[i].normalize();
  74190. }
  74191. this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
  74192. if (!this._raw) {
  74193. this._binormals[i].normalize();
  74194. }
  74195. }
  74196. };
  74197. // private function getFirstNonNullVector(index)
  74198. // returns the first non null vector from index : curve[index + N].subtract(curve[index])
  74199. Path3D.prototype._getFirstNonNullVector = function (index) {
  74200. var i = 1;
  74201. var nNVector = this._curve[index + i].subtract(this._curve[index]);
  74202. while (nNVector.length() === 0 && index + i + 1 < this._curve.length) {
  74203. i++;
  74204. nNVector = this._curve[index + i].subtract(this._curve[index]);
  74205. }
  74206. return nNVector;
  74207. };
  74208. // private function getLastNonNullVector(index)
  74209. // returns the last non null vector from index : curve[index].subtract(curve[index - N])
  74210. Path3D.prototype._getLastNonNullVector = function (index) {
  74211. var i = 1;
  74212. var nLVector = this._curve[index].subtract(this._curve[index - i]);
  74213. while (nLVector.length() === 0 && index > i + 1) {
  74214. i++;
  74215. nLVector = this._curve[index].subtract(this._curve[index - i]);
  74216. }
  74217. return nLVector;
  74218. };
  74219. // private function normalVector(v0, vt, va) :
  74220. // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
  74221. // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
  74222. Path3D.prototype._normalVector = function (vt, va) {
  74223. var normal0;
  74224. var tgl = vt.length();
  74225. if (tgl === 0.0) {
  74226. tgl = 1.0;
  74227. }
  74228. if (va === undefined || va === null) {
  74229. var point;
  74230. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.y) / tgl, 1.0, Epsilon)) { // search for a point in the plane
  74231. point = new Vector3(0.0, -1.0, 0.0);
  74232. }
  74233. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.x) / tgl, 1.0, Epsilon)) {
  74234. point = new Vector3(1.0, 0.0, 0.0);
  74235. }
  74236. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.z) / tgl, 1.0, Epsilon)) {
  74237. point = new Vector3(0.0, 0.0, 1.0);
  74238. }
  74239. else {
  74240. point = Vector3.Zero();
  74241. }
  74242. normal0 = Vector3.Cross(vt, point);
  74243. }
  74244. else {
  74245. normal0 = Vector3.Cross(vt, va);
  74246. Vector3.CrossToRef(normal0, vt, normal0);
  74247. }
  74248. normal0.normalize();
  74249. return normal0;
  74250. };
  74251. return Path3D;
  74252. }());
  74253. /**
  74254. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  74255. * A Curve3 is designed from a series of successive Vector3.
  74256. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  74257. */
  74258. var Curve3 = /** @class */ (function () {
  74259. /**
  74260. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  74261. * A Curve3 is designed from a series of successive Vector3.
  74262. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  74263. * @param points points which make up the curve
  74264. */
  74265. function Curve3(points) {
  74266. this._length = 0.0;
  74267. this._points = points;
  74268. this._length = this._computeLength(points);
  74269. }
  74270. /**
  74271. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  74272. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  74273. * @param v1 (Vector3) the control point
  74274. * @param v2 (Vector3) the end point of the Quadratic Bezier
  74275. * @param nbPoints (integer) the wanted number of points in the curve
  74276. * @returns the created Curve3
  74277. */
  74278. Curve3.CreateQuadraticBezier = function (v0, v1, v2, nbPoints) {
  74279. nbPoints = nbPoints > 2 ? nbPoints : 3;
  74280. var bez = new Array();
  74281. var equation = function (t, val0, val1, val2) {
  74282. var res = (1.0 - t) * (1.0 - t) * val0 + 2.0 * t * (1.0 - t) * val1 + t * t * val2;
  74283. return res;
  74284. };
  74285. for (var i = 0; i <= nbPoints; i++) {
  74286. 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)));
  74287. }
  74288. return new Curve3(bez);
  74289. };
  74290. /**
  74291. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  74292. * @param v0 (Vector3) the origin point of the Cubic Bezier
  74293. * @param v1 (Vector3) the first control point
  74294. * @param v2 (Vector3) the second control point
  74295. * @param v3 (Vector3) the end point of the Cubic Bezier
  74296. * @param nbPoints (integer) the wanted number of points in the curve
  74297. * @returns the created Curve3
  74298. */
  74299. Curve3.CreateCubicBezier = function (v0, v1, v2, v3, nbPoints) {
  74300. nbPoints = nbPoints > 3 ? nbPoints : 4;
  74301. var bez = new Array();
  74302. var equation = function (t, val0, val1, val2, val3) {
  74303. 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;
  74304. return res;
  74305. };
  74306. for (var i = 0; i <= nbPoints; i++) {
  74307. 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)));
  74308. }
  74309. return new Curve3(bez);
  74310. };
  74311. /**
  74312. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  74313. * @param p1 (Vector3) the origin point of the Hermite Spline
  74314. * @param t1 (Vector3) the tangent vector at the origin point
  74315. * @param p2 (Vector3) the end point of the Hermite Spline
  74316. * @param t2 (Vector3) the tangent vector at the end point
  74317. * @param nbPoints (integer) the wanted number of points in the curve
  74318. * @returns the created Curve3
  74319. */
  74320. Curve3.CreateHermiteSpline = function (p1, t1, p2, t2, nbPoints) {
  74321. var hermite = new Array();
  74322. var step = 1.0 / nbPoints;
  74323. for (var i = 0; i <= nbPoints; i++) {
  74324. hermite.push(Vector3.Hermite(p1, t1, p2, t2, i * step));
  74325. }
  74326. return new Curve3(hermite);
  74327. };
  74328. /**
  74329. * Returns a Curve3 object along a CatmullRom Spline curve :
  74330. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  74331. * @param nbPoints (integer) the wanted number of points between each curve control points
  74332. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  74333. * @returns the created Curve3
  74334. */
  74335. Curve3.CreateCatmullRomSpline = function (points, nbPoints, closed) {
  74336. var catmullRom = new Array();
  74337. var step = 1.0 / nbPoints;
  74338. var amount = 0.0;
  74339. if (closed) {
  74340. var pointsCount = points.length;
  74341. for (var i = 0; i < pointsCount; i++) {
  74342. amount = 0;
  74343. for (var c = 0; c < nbPoints; c++) {
  74344. catmullRom.push(Vector3.CatmullRom(points[i % pointsCount], points[(i + 1) % pointsCount], points[(i + 2) % pointsCount], points[(i + 3) % pointsCount], amount));
  74345. amount += step;
  74346. }
  74347. }
  74348. catmullRom.push(catmullRom[0]);
  74349. }
  74350. else {
  74351. var totalPoints = new Array();
  74352. totalPoints.push(points[0].clone());
  74353. Array.prototype.push.apply(totalPoints, points);
  74354. totalPoints.push(points[points.length - 1].clone());
  74355. for (var i = 0; i < totalPoints.length - 3; i++) {
  74356. amount = 0;
  74357. for (var c = 0; c < nbPoints; c++) {
  74358. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  74359. amount += step;
  74360. }
  74361. }
  74362. i--;
  74363. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  74364. }
  74365. return new Curve3(catmullRom);
  74366. };
  74367. /**
  74368. * @returns the Curve3 stored array of successive Vector3
  74369. */
  74370. Curve3.prototype.getPoints = function () {
  74371. return this._points;
  74372. };
  74373. /**
  74374. * @returns the computed length (float) of the curve.
  74375. */
  74376. Curve3.prototype.length = function () {
  74377. return this._length;
  74378. };
  74379. /**
  74380. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  74381. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  74382. * curveA and curveB keep unchanged.
  74383. * @param curve the curve to continue from this curve
  74384. * @returns the newly constructed curve
  74385. */
  74386. Curve3.prototype.continue = function (curve) {
  74387. var lastPoint = this._points[this._points.length - 1];
  74388. var continuedPoints = this._points.slice();
  74389. var curvePoints = curve.getPoints();
  74390. for (var i = 1; i < curvePoints.length; i++) {
  74391. continuedPoints.push(curvePoints[i].subtract(curvePoints[0]).add(lastPoint));
  74392. }
  74393. var continuedCurve = new Curve3(continuedPoints);
  74394. return continuedCurve;
  74395. };
  74396. Curve3.prototype._computeLength = function (path) {
  74397. var l = 0;
  74398. for (var i = 1; i < path.length; i++) {
  74399. l += (path[i].subtract(path[i - 1])).length();
  74400. }
  74401. return l;
  74402. };
  74403. return Curve3;
  74404. }());
  74405. // Vertex formats
  74406. /**
  74407. * Contains position and normal vectors for a vertex
  74408. */
  74409. var PositionNormalVertex = /** @class */ (function () {
  74410. /**
  74411. * Creates a PositionNormalVertex
  74412. * @param position the position of the vertex (defaut: 0,0,0)
  74413. * @param normal the normal of the vertex (defaut: 0,1,0)
  74414. */
  74415. function PositionNormalVertex(
  74416. /** the position of the vertex (defaut: 0,0,0) */
  74417. position,
  74418. /** the normal of the vertex (defaut: 0,1,0) */
  74419. normal) {
  74420. if (position === void 0) { position = Vector3.Zero(); }
  74421. if (normal === void 0) { normal = Vector3.Up(); }
  74422. this.position = position;
  74423. this.normal = normal;
  74424. }
  74425. /**
  74426. * Clones the PositionNormalVertex
  74427. * @returns the cloned PositionNormalVertex
  74428. */
  74429. PositionNormalVertex.prototype.clone = function () {
  74430. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  74431. };
  74432. return PositionNormalVertex;
  74433. }());
  74434. /**
  74435. * Contains position, normal and uv vectors for a vertex
  74436. */
  74437. var PositionNormalTextureVertex = /** @class */ (function () {
  74438. /**
  74439. * Creates a PositionNormalTextureVertex
  74440. * @param position the position of the vertex (defaut: 0,0,0)
  74441. * @param normal the normal of the vertex (defaut: 0,1,0)
  74442. * @param uv the uv of the vertex (default: 0,0)
  74443. */
  74444. function PositionNormalTextureVertex(
  74445. /** the position of the vertex (defaut: 0,0,0) */
  74446. position,
  74447. /** the normal of the vertex (defaut: 0,1,0) */
  74448. normal,
  74449. /** the uv of the vertex (default: 0,0) */
  74450. uv) {
  74451. if (position === void 0) { position = Vector3.Zero(); }
  74452. if (normal === void 0) { normal = Vector3.Up(); }
  74453. if (uv === void 0) { uv = Vector2.Zero(); }
  74454. this.position = position;
  74455. this.normal = normal;
  74456. this.uv = uv;
  74457. }
  74458. /**
  74459. * Clones the PositionNormalTextureVertex
  74460. * @returns the cloned PositionNormalTextureVertex
  74461. */
  74462. PositionNormalTextureVertex.prototype.clone = function () {
  74463. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  74464. };
  74465. return PositionNormalTextureVertex;
  74466. }());
  74467. // Temporary pre-allocated objects for engine internal use
  74468. // usage in any internal function :
  74469. // var tmp = Tmp.Vector3[0]; <= gets access to the first pre-created Vector3
  74470. // There's a Tmp array per object type : int, float, Vector2, Vector3, Vector4, Quaternion, Matrix
  74471. /**
  74472. * @hidden
  74473. */
  74474. var Tmp = /** @class */ (function () {
  74475. function Tmp() {
  74476. }
  74477. Tmp.Color3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Color3.Black);
  74478. Tmp.Color4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, function () { return new Color4(0, 0, 0, 0); });
  74479. Tmp.Vector2 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector2.Zero); // 3 temp Vector2 at once should be enough
  74480. Tmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
  74481. Tmp.Vector4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
  74482. Tmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
  74483. Tmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
  74484. return Tmp;
  74485. }());
  74486. /**
  74487. * @hidden
  74488. * Same as Tmp but not exported to keep it only for math functions to avoid conflicts
  74489. */
  74490. var MathTmp = /** @class */ (function () {
  74491. function MathTmp() {
  74492. }
  74493. MathTmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, Vector3.Zero);
  74494. MathTmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Matrix.Identity);
  74495. MathTmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Quaternion.Zero);
  74496. return MathTmp;
  74497. }());
  74498. /***/ }),
  74499. /***/ "./Maths/sphericalPolynomial.ts":
  74500. /*!**************************************!*\
  74501. !*** ./Maths/sphericalPolynomial.ts ***!
  74502. \**************************************/
  74503. /*! exports provided: SphericalPolynomial, SphericalHarmonics */
  74504. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74505. "use strict";
  74506. __webpack_require__.r(__webpack_exports__);
  74507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return SphericalPolynomial; });
  74508. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return SphericalHarmonics; });
  74509. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  74510. /**
  74511. * Class representing spherical polynomial coefficients to the 3rd degree
  74512. */
  74513. var SphericalPolynomial = /** @class */ (function () {
  74514. function SphericalPolynomial() {
  74515. /**
  74516. * The x coefficients of the spherical polynomial
  74517. */
  74518. this.x = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74519. /**
  74520. * The y coefficients of the spherical polynomial
  74521. */
  74522. this.y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74523. /**
  74524. * The z coefficients of the spherical polynomial
  74525. */
  74526. this.z = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74527. /**
  74528. * The xx coefficients of the spherical polynomial
  74529. */
  74530. this.xx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74531. /**
  74532. * The yy coefficients of the spherical polynomial
  74533. */
  74534. this.yy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74535. /**
  74536. * The zz coefficients of the spherical polynomial
  74537. */
  74538. this.zz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74539. /**
  74540. * The xy coefficients of the spherical polynomial
  74541. */
  74542. this.xy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74543. /**
  74544. * The yz coefficients of the spherical polynomial
  74545. */
  74546. this.yz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74547. /**
  74548. * The zx coefficients of the spherical polynomial
  74549. */
  74550. this.zx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74551. }
  74552. /**
  74553. * Adds an ambient color to the spherical polynomial
  74554. * @param color the color to add
  74555. */
  74556. SphericalPolynomial.prototype.addAmbient = function (color) {
  74557. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  74558. this.xx = this.xx.add(colorVector);
  74559. this.yy = this.yy.add(colorVector);
  74560. this.zz = this.zz.add(colorVector);
  74561. };
  74562. /**
  74563. * Scales the spherical polynomial by the given amount
  74564. * @param scale the amount to scale
  74565. */
  74566. SphericalPolynomial.prototype.scale = function (scale) {
  74567. this.x = this.x.scale(scale);
  74568. this.y = this.y.scale(scale);
  74569. this.z = this.z.scale(scale);
  74570. this.xx = this.xx.scale(scale);
  74571. this.yy = this.yy.scale(scale);
  74572. this.zz = this.zz.scale(scale);
  74573. this.yz = this.yz.scale(scale);
  74574. this.zx = this.zx.scale(scale);
  74575. this.xy = this.xy.scale(scale);
  74576. };
  74577. /**
  74578. * Gets the spherical polynomial from harmonics
  74579. * @param harmonics the spherical harmonics
  74580. * @returns the spherical polynomial
  74581. */
  74582. SphericalPolynomial.FromHarmonics = function (harmonics) {
  74583. var result = new SphericalPolynomial();
  74584. result.x = harmonics.l11.scale(1.02333);
  74585. result.y = harmonics.l1_1.scale(1.02333);
  74586. result.z = harmonics.l10.scale(1.02333);
  74587. result.xx = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).add(harmonics.lL22.scale(0.429043));
  74588. result.yy = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).subtract(harmonics.lL22.scale(0.429043));
  74589. result.zz = harmonics.l00.scale(0.886277).add(harmonics.l20.scale(0.495417));
  74590. result.yz = harmonics.l2_1.scale(0.858086);
  74591. result.zx = harmonics.l21.scale(0.858086);
  74592. result.xy = harmonics.l2_2.scale(0.858086);
  74593. result.scale(1.0 / Math.PI);
  74594. return result;
  74595. };
  74596. /**
  74597. * Constructs a spherical polynomial from an array.
  74598. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  74599. * @returns the spherical polynomial
  74600. */
  74601. SphericalPolynomial.FromArray = function (data) {
  74602. var sp = new SphericalPolynomial();
  74603. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sp.x);
  74604. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sp.y);
  74605. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sp.z);
  74606. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sp.xx);
  74607. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sp.yy);
  74608. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sp.zz);
  74609. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sp.yz);
  74610. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sp.zx);
  74611. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sp.xy);
  74612. return sp;
  74613. };
  74614. return SphericalPolynomial;
  74615. }());
  74616. /**
  74617. * Class representing spherical harmonics coefficients to the 3rd degree
  74618. */
  74619. var SphericalHarmonics = /** @class */ (function () {
  74620. function SphericalHarmonics() {
  74621. /**
  74622. * The l0,0 coefficients of the spherical harmonics
  74623. */
  74624. this.l00 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74625. /**
  74626. * The l1,-1 coefficients of the spherical harmonics
  74627. */
  74628. this.l1_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74629. /**
  74630. * The l1,0 coefficients of the spherical harmonics
  74631. */
  74632. this.l10 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74633. /**
  74634. * The l1,1 coefficients of the spherical harmonics
  74635. */
  74636. this.l11 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74637. /**
  74638. * The l2,-2 coefficients of the spherical harmonics
  74639. */
  74640. this.l2_2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74641. /**
  74642. * The l2,-1 coefficients of the spherical harmonics
  74643. */
  74644. this.l2_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74645. /**
  74646. * The l2,0 coefficients of the spherical harmonics
  74647. */
  74648. this.l20 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74649. /**
  74650. * The l2,1 coefficients of the spherical harmonics
  74651. */
  74652. this.l21 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74653. /**
  74654. * The l2,2 coefficients of the spherical harmonics
  74655. */
  74656. this.lL22 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74657. }
  74658. /**
  74659. * Adds a light to the spherical harmonics
  74660. * @param direction the direction of the light
  74661. * @param color the color of the light
  74662. * @param deltaSolidAngle the delta solid angle of the light
  74663. */
  74664. SphericalHarmonics.prototype.addLight = function (direction, color, deltaSolidAngle) {
  74665. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  74666. var c = colorVector.scale(deltaSolidAngle);
  74667. this.l00 = this.l00.add(c.scale(0.282095));
  74668. this.l1_1 = this.l1_1.add(c.scale(0.488603 * direction.y));
  74669. this.l10 = this.l10.add(c.scale(0.488603 * direction.z));
  74670. this.l11 = this.l11.add(c.scale(0.488603 * direction.x));
  74671. this.l2_2 = this.l2_2.add(c.scale(1.092548 * direction.x * direction.y));
  74672. this.l2_1 = this.l2_1.add(c.scale(1.092548 * direction.y * direction.z));
  74673. this.l21 = this.l21.add(c.scale(1.092548 * direction.x * direction.z));
  74674. this.l20 = this.l20.add(c.scale(0.315392 * (3.0 * direction.z * direction.z - 1.0)));
  74675. this.lL22 = this.lL22.add(c.scale(0.546274 * (direction.x * direction.x - direction.y * direction.y)));
  74676. };
  74677. /**
  74678. * Scales the spherical harmonics by the given amount
  74679. * @param scale the amount to scale
  74680. */
  74681. SphericalHarmonics.prototype.scale = function (scale) {
  74682. this.l00 = this.l00.scale(scale);
  74683. this.l1_1 = this.l1_1.scale(scale);
  74684. this.l10 = this.l10.scale(scale);
  74685. this.l11 = this.l11.scale(scale);
  74686. this.l2_2 = this.l2_2.scale(scale);
  74687. this.l2_1 = this.l2_1.scale(scale);
  74688. this.l20 = this.l20.scale(scale);
  74689. this.l21 = this.l21.scale(scale);
  74690. this.lL22 = this.lL22.scale(scale);
  74691. };
  74692. /**
  74693. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  74694. *
  74695. * ```
  74696. * E_lm = A_l * L_lm
  74697. * ```
  74698. *
  74699. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  74700. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  74701. * the scaling factors are given in equation 9.
  74702. */
  74703. SphericalHarmonics.prototype.convertIncidentRadianceToIrradiance = function () {
  74704. // Constant (Band 0)
  74705. this.l00 = this.l00.scale(3.141593);
  74706. // Linear (Band 1)
  74707. this.l1_1 = this.l1_1.scale(2.094395);
  74708. this.l10 = this.l10.scale(2.094395);
  74709. this.l11 = this.l11.scale(2.094395);
  74710. // Quadratic (Band 2)
  74711. this.l2_2 = this.l2_2.scale(0.785398);
  74712. this.l2_1 = this.l2_1.scale(0.785398);
  74713. this.l20 = this.l20.scale(0.785398);
  74714. this.l21 = this.l21.scale(0.785398);
  74715. this.lL22 = this.lL22.scale(0.785398);
  74716. };
  74717. /**
  74718. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  74719. *
  74720. * ```
  74721. * L = (1/pi) * E * rho
  74722. * ```
  74723. *
  74724. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  74725. */
  74726. SphericalHarmonics.prototype.convertIrradianceToLambertianRadiance = function () {
  74727. this.scale(1.0 / Math.PI);
  74728. // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied
  74729. // (The pixel shader must apply albedo after texture fetches, etc).
  74730. };
  74731. /**
  74732. * Gets the spherical harmonics from polynomial
  74733. * @param polynomial the spherical polynomial
  74734. * @returns the spherical harmonics
  74735. */
  74736. SphericalHarmonics.FromPolynomial = function (polynomial) {
  74737. var result = new SphericalHarmonics();
  74738. result.l00 = polynomial.xx.scale(0.376127).add(polynomial.yy.scale(0.376127)).add(polynomial.zz.scale(0.376126));
  74739. result.l1_1 = polynomial.y.scale(0.977204);
  74740. result.l10 = polynomial.z.scale(0.977204);
  74741. result.l11 = polynomial.x.scale(0.977204);
  74742. result.l2_2 = polynomial.xy.scale(1.16538);
  74743. result.l2_1 = polynomial.yz.scale(1.16538);
  74744. result.l20 = polynomial.zz.scale(1.34567).subtract(polynomial.xx.scale(0.672834)).subtract(polynomial.yy.scale(0.672834));
  74745. result.l21 = polynomial.zx.scale(1.16538);
  74746. result.lL22 = polynomial.xx.scale(1.16538).subtract(polynomial.yy.scale(1.16538));
  74747. result.scale(Math.PI);
  74748. return result;
  74749. };
  74750. /**
  74751. * Constructs a spherical harmonics from an array.
  74752. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  74753. * @returns the spherical harmonics
  74754. */
  74755. SphericalHarmonics.FromArray = function (data) {
  74756. var sh = new SphericalHarmonics();
  74757. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sh.l00);
  74758. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sh.l1_1);
  74759. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sh.l10);
  74760. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sh.l11);
  74761. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sh.l2_2);
  74762. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sh.l2_1);
  74763. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sh.l20);
  74764. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sh.l21);
  74765. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sh.lL22);
  74766. return sh;
  74767. };
  74768. return SphericalHarmonics;
  74769. }());
  74770. /***/ }),
  74771. /***/ "./Meshes/Builders/boxBuilder.ts":
  74772. /*!***************************************!*\
  74773. !*** ./Meshes/Builders/boxBuilder.ts ***!
  74774. \***************************************/
  74775. /*! exports provided: BoxBuilder */
  74776. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74777. "use strict";
  74778. __webpack_require__.r(__webpack_exports__);
  74779. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return BoxBuilder; });
  74780. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  74781. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  74782. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  74783. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox = function (options) {
  74784. var normalsSource = [
  74785. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1),
  74786. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1),
  74787. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0),
  74788. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0),
  74789. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0),
  74790. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)
  74791. ];
  74792. var indices = [];
  74793. var positions = [];
  74794. var normals = [];
  74795. var uvs = [];
  74796. var width = options.width || options.size || 1;
  74797. var height = options.height || options.size || 1;
  74798. var depth = options.depth || options.size || 1;
  74799. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  74800. var faceUV = options.faceUV || new Array(6);
  74801. var faceColors = options.faceColors;
  74802. var colors = [];
  74803. // default face colors and UV if undefined
  74804. for (var f = 0; f < 6; f++) {
  74805. if (faceUV[f] === undefined) {
  74806. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  74807. }
  74808. if (faceColors && faceColors[f] === undefined) {
  74809. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  74810. }
  74811. }
  74812. var scaleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](width / 2, height / 2, depth / 2);
  74813. // Create each face in turn.
  74814. for (var index = 0; index < normalsSource.length; index++) {
  74815. var normal = normalsSource[index];
  74816. // Get two vectors perpendicular to the face normal and to each other.
  74817. var side1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normal.y, normal.z, normal.x);
  74818. var side2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(normal, side1);
  74819. // Six indices (two triangles) per face.
  74820. var verticesLength = positions.length / 3;
  74821. indices.push(verticesLength);
  74822. indices.push(verticesLength + 1);
  74823. indices.push(verticesLength + 2);
  74824. indices.push(verticesLength);
  74825. indices.push(verticesLength + 2);
  74826. indices.push(verticesLength + 3);
  74827. // Four vertices per face.
  74828. var vertex = normal.subtract(side1).subtract(side2).multiply(scaleVector);
  74829. positions.push(vertex.x, vertex.y, vertex.z);
  74830. normals.push(normal.x, normal.y, normal.z);
  74831. uvs.push(faceUV[index].z, faceUV[index].w);
  74832. if (faceColors) {
  74833. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74834. }
  74835. vertex = normal.subtract(side1).add(side2).multiply(scaleVector);
  74836. positions.push(vertex.x, vertex.y, vertex.z);
  74837. normals.push(normal.x, normal.y, normal.z);
  74838. uvs.push(faceUV[index].x, faceUV[index].w);
  74839. if (faceColors) {
  74840. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74841. }
  74842. vertex = normal.add(side1).add(side2).multiply(scaleVector);
  74843. positions.push(vertex.x, vertex.y, vertex.z);
  74844. normals.push(normal.x, normal.y, normal.z);
  74845. uvs.push(faceUV[index].x, faceUV[index].y);
  74846. if (faceColors) {
  74847. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74848. }
  74849. vertex = normal.add(side1).subtract(side2).multiply(scaleVector);
  74850. positions.push(vertex.x, vertex.y, vertex.z);
  74851. normals.push(normal.x, normal.y, normal.z);
  74852. uvs.push(faceUV[index].z, faceUV[index].y);
  74853. if (faceColors) {
  74854. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  74855. }
  74856. }
  74857. // sides
  74858. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  74859. // Result
  74860. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  74861. vertexData.indices = indices;
  74862. vertexData.positions = positions;
  74863. vertexData.normals = normals;
  74864. vertexData.uvs = uvs;
  74865. if (faceColors) {
  74866. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  74867. vertexData.colors = totalColors;
  74868. }
  74869. return vertexData;
  74870. };
  74871. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateBox = function (name, size, scene, updatable, sideOrientation) {
  74872. if (scene === void 0) { scene = null; }
  74873. var options = {
  74874. size: size,
  74875. sideOrientation: sideOrientation,
  74876. updatable: updatable
  74877. };
  74878. return BoxBuilder.CreateBox(name, options, scene);
  74879. };
  74880. /**
  74881. * Class containing static functions to help procedurally build meshes
  74882. */
  74883. var BoxBuilder = /** @class */ (function () {
  74884. function BoxBuilder() {
  74885. }
  74886. /**
  74887. * Creates a box mesh
  74888. * * The parameter `size` sets the size (float) of each box side (default 1)
  74889. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  74890. * * 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)
  74891. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  74892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74893. * * 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
  74894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74895. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  74896. * @param name defines the name of the mesh
  74897. * @param options defines the options used to create the mesh
  74898. * @param scene defines the hosting scene
  74899. * @returns the box mesh
  74900. */
  74901. BoxBuilder.CreateBox = function (name, options, scene) {
  74902. if (scene === void 0) { scene = null; }
  74903. var box = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  74904. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  74905. box._originalBuilderSideOrientation = options.sideOrientation;
  74906. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox(options);
  74907. vertexData.applyToMesh(box, options.updatable);
  74908. return box;
  74909. };
  74910. return BoxBuilder;
  74911. }());
  74912. /***/ }),
  74913. /***/ "./Meshes/Builders/cylinderBuilder.ts":
  74914. /*!********************************************!*\
  74915. !*** ./Meshes/Builders/cylinderBuilder.ts ***!
  74916. \********************************************/
  74917. /*! exports provided: CylinderBuilder */
  74918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74919. "use strict";
  74920. __webpack_require__.r(__webpack_exports__);
  74921. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return CylinderBuilder; });
  74922. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  74923. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  74924. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  74925. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  74926. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder = function (options) {
  74927. var height = options.height || 2;
  74928. var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
  74929. var diameterBottom = (options.diameterBottom === 0) ? 0 : options.diameterBottom || options.diameter || 1;
  74930. var tessellation = options.tessellation || 24;
  74931. var subdivisions = options.subdivisions || 1;
  74932. var hasRings = options.hasRings ? true : false;
  74933. var enclose = options.enclose ? true : false;
  74934. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  74935. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  74936. var faceUV = options.faceUV || new Array(3);
  74937. var faceColors = options.faceColors;
  74938. // default face colors and UV if undefined
  74939. var quadNb = (arc !== 1 && enclose) ? 2 : 0;
  74940. var ringNb = (hasRings) ? subdivisions : 1;
  74941. var surfaceNb = 2 + (1 + quadNb) * ringNb;
  74942. var f;
  74943. for (f = 0; f < surfaceNb; f++) {
  74944. if (faceColors && faceColors[f] === undefined) {
  74945. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  74946. }
  74947. }
  74948. for (f = 0; f < surfaceNb; f++) {
  74949. if (faceUV && faceUV[f] === undefined) {
  74950. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  74951. }
  74952. }
  74953. var indices = new Array();
  74954. var positions = new Array();
  74955. var normals = new Array();
  74956. var uvs = new Array();
  74957. var colors = new Array();
  74958. var angle_step = Math.PI * 2 * arc / tessellation;
  74959. var angle;
  74960. var h;
  74961. var radius;
  74962. var tan = (diameterBottom - diameterTop) / 2 / height;
  74963. var ringVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74964. var ringNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74965. var ringFirstVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74966. var ringFirstNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74967. var quadNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74968. var Y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Y;
  74969. // positions, normals, uvs
  74970. var i;
  74971. var j;
  74972. var r;
  74973. var ringIdx = 1;
  74974. var s = 1; // surface index
  74975. var cs = 0;
  74976. var v = 0;
  74977. for (i = 0; i <= subdivisions; i++) {
  74978. h = i / subdivisions;
  74979. radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;
  74980. ringIdx = (hasRings && i !== 0 && i !== subdivisions) ? 2 : 1;
  74981. for (r = 0; r < ringIdx; r++) {
  74982. if (hasRings) {
  74983. s += r;
  74984. }
  74985. if (enclose) {
  74986. s += 2 * r;
  74987. }
  74988. for (j = 0; j <= tessellation; j++) {
  74989. angle = j * angle_step;
  74990. // position
  74991. ringVertex.x = Math.cos(-angle) * radius;
  74992. ringVertex.y = -height / 2 + h * height;
  74993. ringVertex.z = Math.sin(-angle) * radius;
  74994. // normal
  74995. if (diameterTop === 0 && i === subdivisions) {
  74996. // if no top cap, reuse former normals
  74997. ringNormal.x = normals[normals.length - (tessellation + 1) * 3];
  74998. ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];
  74999. ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];
  75000. }
  75001. else {
  75002. ringNormal.x = ringVertex.x;
  75003. ringNormal.z = ringVertex.z;
  75004. ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;
  75005. ringNormal.normalize();
  75006. }
  75007. // keep first ring vertex values for enclose
  75008. if (j === 0) {
  75009. ringFirstVertex.copyFrom(ringVertex);
  75010. ringFirstNormal.copyFrom(ringNormal);
  75011. }
  75012. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  75013. normals.push(ringNormal.x, ringNormal.y, ringNormal.z);
  75014. if (hasRings) {
  75015. v = (cs !== s) ? faceUV[s].y : faceUV[s].w;
  75016. }
  75017. else {
  75018. v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
  75019. }
  75020. uvs.push(faceUV[s].x + (faceUV[s].z - faceUV[s].x) * j / tessellation, v);
  75021. if (faceColors) {
  75022. colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
  75023. }
  75024. }
  75025. // if enclose, add four vertices and their dedicated normals
  75026. if (arc !== 1 && enclose) {
  75027. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  75028. positions.push(0, ringVertex.y, 0);
  75029. positions.push(0, ringVertex.y, 0);
  75030. positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);
  75031. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(Y, ringNormal, quadNormal);
  75032. quadNormal.normalize();
  75033. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  75034. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(ringFirstNormal, Y, quadNormal);
  75035. quadNormal.normalize();
  75036. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  75037. if (hasRings) {
  75038. v = (cs !== s) ? faceUV[s + 1].y : faceUV[s + 1].w;
  75039. }
  75040. else {
  75041. v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
  75042. }
  75043. uvs.push(faceUV[s + 1].x, v);
  75044. uvs.push(faceUV[s + 1].z, v);
  75045. if (hasRings) {
  75046. v = (cs !== s) ? faceUV[s + 2].y : faceUV[s + 2].w;
  75047. }
  75048. else {
  75049. v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
  75050. }
  75051. uvs.push(faceUV[s + 2].x, v);
  75052. uvs.push(faceUV[s + 2].z, v);
  75053. if (faceColors) {
  75054. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  75055. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  75056. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  75057. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  75058. }
  75059. }
  75060. if (cs !== s) {
  75061. cs = s;
  75062. }
  75063. }
  75064. }
  75065. // indices
  75066. var e = (arc !== 1 && enclose) ? tessellation + 4 : tessellation; // correction of number of iteration if enclose
  75067. var s;
  75068. i = 0;
  75069. for (s = 0; s < subdivisions; s++) {
  75070. var i0 = 0;
  75071. var i1 = 0;
  75072. var i2 = 0;
  75073. var i3 = 0;
  75074. for (j = 0; j < tessellation; j++) {
  75075. i0 = i * (e + 1) + j;
  75076. i1 = (i + 1) * (e + 1) + j;
  75077. i2 = i * (e + 1) + (j + 1);
  75078. i3 = (i + 1) * (e + 1) + (j + 1);
  75079. indices.push(i0, i1, i2);
  75080. indices.push(i3, i2, i1);
  75081. }
  75082. if (arc !== 1 && enclose) { // if enclose, add two quads
  75083. indices.push(i0 + 2, i1 + 2, i2 + 2);
  75084. indices.push(i3 + 2, i2 + 2, i1 + 2);
  75085. indices.push(i0 + 4, i1 + 4, i2 + 4);
  75086. indices.push(i3 + 4, i2 + 4, i1 + 4);
  75087. }
  75088. i = (hasRings) ? (i + 2) : (i + 1);
  75089. }
  75090. // Caps
  75091. var createCylinderCap = function (isTop) {
  75092. var radius = isTop ? diameterTop / 2 : diameterBottom / 2;
  75093. if (radius === 0) {
  75094. return;
  75095. }
  75096. // Cap positions, normals & uvs
  75097. var angle;
  75098. var circleVector;
  75099. var i;
  75100. var u = (isTop) ? faceUV[surfaceNb - 1] : faceUV[0];
  75101. var c = null;
  75102. if (faceColors) {
  75103. c = (isTop) ? faceColors[surfaceNb - 1] : faceColors[0];
  75104. }
  75105. // cap center
  75106. var vbase = positions.length / 3;
  75107. var offset = isTop ? height / 2 : -height / 2;
  75108. var center = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, offset, 0);
  75109. positions.push(center.x, center.y, center.z);
  75110. normals.push(0, isTop ? 1 : -1, 0);
  75111. uvs.push(u.x + (u.z - u.x) * 0.5, u.y + (u.w - u.y) * 0.5);
  75112. if (c) {
  75113. colors.push(c.r, c.g, c.b, c.a);
  75114. }
  75115. var textureScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0.5, 0.5);
  75116. for (i = 0; i <= tessellation; i++) {
  75117. angle = Math.PI * 2 * i * arc / tessellation;
  75118. var cos = Math.cos(-angle);
  75119. var sin = Math.sin(-angle);
  75120. circleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](cos * radius, offset, sin * radius);
  75121. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);
  75122. positions.push(circleVector.x, circleVector.y, circleVector.z);
  75123. normals.push(0, isTop ? 1 : -1, 0);
  75124. uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, u.y + (u.w - u.y) * textureCoordinate.y);
  75125. if (c) {
  75126. colors.push(c.r, c.g, c.b, c.a);
  75127. }
  75128. }
  75129. // Cap indices
  75130. for (i = 0; i < tessellation; i++) {
  75131. if (!isTop) {
  75132. indices.push(vbase);
  75133. indices.push(vbase + (i + 1));
  75134. indices.push(vbase + (i + 2));
  75135. }
  75136. else {
  75137. indices.push(vbase);
  75138. indices.push(vbase + (i + 2));
  75139. indices.push(vbase + (i + 1));
  75140. }
  75141. }
  75142. };
  75143. // add caps to geometry
  75144. createCylinderCap(false);
  75145. createCylinderCap(true);
  75146. // Sides
  75147. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  75148. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75149. vertexData.indices = indices;
  75150. vertexData.positions = positions;
  75151. vertexData.normals = normals;
  75152. vertexData.uvs = uvs;
  75153. if (faceColors) {
  75154. vertexData.colors = colors;
  75155. }
  75156. return vertexData;
  75157. };
  75158. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  75159. if (scene === undefined || !(scene instanceof _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"])) {
  75160. if (scene !== undefined) {
  75161. sideOrientation = updatable || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DEFAULTSIDE;
  75162. updatable = scene;
  75163. }
  75164. scene = subdivisions;
  75165. subdivisions = 1;
  75166. }
  75167. var options = {
  75168. height: height,
  75169. diameterTop: diameterTop,
  75170. diameterBottom: diameterBottom,
  75171. tessellation: tessellation,
  75172. subdivisions: subdivisions,
  75173. sideOrientation: sideOrientation,
  75174. updatable: updatable
  75175. };
  75176. return CylinderBuilder.CreateCylinder(name, options, scene);
  75177. };
  75178. /**
  75179. * Class containing static functions to help procedurally build meshes
  75180. */
  75181. var CylinderBuilder = /** @class */ (function () {
  75182. function CylinderBuilder() {
  75183. }
  75184. /**
  75185. * Creates a cylinder or a cone mesh
  75186. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  75187. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  75188. * * 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.
  75189. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  75190. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  75191. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  75192. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  75193. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  75194. * * 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).
  75195. * * 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
  75196. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  75197. * * 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
  75198. * * 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.
  75199. * * If `enclose` is false, a ring surface is one element.
  75200. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  75201. * * 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
  75202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  75203. * * 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
  75204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  75205. * @param name defines the name of the mesh
  75206. * @param options defines the options used to create the mesh
  75207. * @param scene defines the hosting scene
  75208. * @returns the cylinder mesh
  75209. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  75210. */
  75211. CylinderBuilder.CreateCylinder = function (name, options, scene) {
  75212. var cylinder = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  75213. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  75214. cylinder._originalBuilderSideOrientation = options.sideOrientation;
  75215. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder(options);
  75216. vertexData.applyToMesh(cylinder, options.updatable);
  75217. return cylinder;
  75218. };
  75219. return CylinderBuilder;
  75220. }());
  75221. /***/ }),
  75222. /***/ "./Meshes/Builders/decalBuilder.ts":
  75223. /*!*****************************************!*\
  75224. !*** ./Meshes/Builders/decalBuilder.ts ***!
  75225. \*****************************************/
  75226. /*! exports provided: DecalBuilder */
  75227. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75228. "use strict";
  75229. __webpack_require__.r(__webpack_exports__);
  75230. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return DecalBuilder; });
  75231. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  75232. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75233. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  75234. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75235. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  75236. var options = {
  75237. position: position,
  75238. normal: normal,
  75239. size: size,
  75240. angle: angle
  75241. };
  75242. return DecalBuilder.CreateDecal(name, sourceMesh, options);
  75243. };
  75244. /**
  75245. * Class containing static functions to help procedurally build meshes
  75246. */
  75247. var DecalBuilder = /** @class */ (function () {
  75248. function DecalBuilder() {
  75249. }
  75250. /**
  75251. * Creates a decal mesh.
  75252. * 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
  75253. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  75254. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  75255. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  75256. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  75257. * @param name defines the name of the mesh
  75258. * @param sourceMesh defines the mesh where the decal must be applied
  75259. * @param options defines the options used to create the mesh
  75260. * @param scene defines the hosting scene
  75261. * @returns the decal mesh
  75262. * @see https://doc.babylonjs.com/how_to/decals
  75263. */
  75264. DecalBuilder.CreateDecal = function (name, sourceMesh, options) {
  75265. var indices = sourceMesh.getIndices();
  75266. var positions = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  75267. var normals = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  75268. var position = options.position || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75269. var normal = options.normal || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up();
  75270. var size = options.size || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  75271. var angle = options.angle || 0;
  75272. // Getting correct rotation
  75273. if (!normal) {
  75274. var target = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1);
  75275. var camera = sourceMesh.getScene().activeCamera;
  75276. var cameraWorldTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(target, camera.getWorldMatrix());
  75277. normal = camera.globalPosition.subtract(cameraWorldTarget);
  75278. }
  75279. var yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
  75280. var len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
  75281. var pitch = Math.atan2(normal.y, len);
  75282. // Matrix
  75283. 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));
  75284. var inverseDecalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Invert(decalWorldMatrix);
  75285. var meshWorldMatrix = sourceMesh.getWorldMatrix();
  75286. var transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
  75287. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  75288. vertexData.indices = [];
  75289. vertexData.positions = [];
  75290. vertexData.normals = [];
  75291. vertexData.uvs = [];
  75292. var currentVertexDataIndex = 0;
  75293. var extractDecalVector3 = function (indexId) {
  75294. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]();
  75295. if (!indices || !positions || !normals) {
  75296. return result;
  75297. }
  75298. var vertexId = indices[indexId];
  75299. result.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);
  75300. // Send vector to decal local world
  75301. result.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(result.position, transformMatrix);
  75302. // Get normal
  75303. result.normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);
  75304. result.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result.normal, transformMatrix);
  75305. return result;
  75306. }; // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js
  75307. var clip = function (vertices, axis) {
  75308. if (vertices.length === 0) {
  75309. return vertices;
  75310. }
  75311. var clipSize = 0.5 * Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(size, axis));
  75312. var clipVertices = function (v0, v1) {
  75313. var clipFactor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetClipFactor(v0.position, v1.position, axis, clipSize);
  75314. 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));
  75315. };
  75316. var result = new Array();
  75317. for (var index = 0; index < vertices.length; index += 3) {
  75318. var v1Out;
  75319. var v2Out;
  75320. var v3Out;
  75321. var total = 0;
  75322. var nV1 = null;
  75323. var nV2 = null;
  75324. var nV3 = null;
  75325. var nV4 = null;
  75326. var d1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index].position, axis) - clipSize;
  75327. var d2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 1].position, axis) - clipSize;
  75328. var d3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 2].position, axis) - clipSize;
  75329. v1Out = d1 > 0;
  75330. v2Out = d2 > 0;
  75331. v3Out = d3 > 0;
  75332. total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
  75333. switch (total) {
  75334. case 0:
  75335. result.push(vertices[index]);
  75336. result.push(vertices[index + 1]);
  75337. result.push(vertices[index + 2]);
  75338. break;
  75339. case 1:
  75340. if (v1Out) {
  75341. nV1 = vertices[index + 1];
  75342. nV2 = vertices[index + 2];
  75343. nV3 = clipVertices(vertices[index], nV1);
  75344. nV4 = clipVertices(vertices[index], nV2);
  75345. }
  75346. if (v2Out) {
  75347. nV1 = vertices[index];
  75348. nV2 = vertices[index + 2];
  75349. nV3 = clipVertices(vertices[index + 1], nV1);
  75350. nV4 = clipVertices(vertices[index + 1], nV2);
  75351. result.push(nV3);
  75352. result.push(nV2.clone());
  75353. result.push(nV1.clone());
  75354. result.push(nV2.clone());
  75355. result.push(nV3.clone());
  75356. result.push(nV4);
  75357. break;
  75358. }
  75359. if (v3Out) {
  75360. nV1 = vertices[index];
  75361. nV2 = vertices[index + 1];
  75362. nV3 = clipVertices(vertices[index + 2], nV1);
  75363. nV4 = clipVertices(vertices[index + 2], nV2);
  75364. }
  75365. if (nV1 && nV2 && nV3 && nV4) {
  75366. result.push(nV1.clone());
  75367. result.push(nV2.clone());
  75368. result.push(nV3);
  75369. result.push(nV4);
  75370. result.push(nV3.clone());
  75371. result.push(nV2.clone());
  75372. }
  75373. break;
  75374. case 2:
  75375. if (!v1Out) {
  75376. nV1 = vertices[index].clone();
  75377. nV2 = clipVertices(nV1, vertices[index + 1]);
  75378. nV3 = clipVertices(nV1, vertices[index + 2]);
  75379. result.push(nV1);
  75380. result.push(nV2);
  75381. result.push(nV3);
  75382. }
  75383. if (!v2Out) {
  75384. nV1 = vertices[index + 1].clone();
  75385. nV2 = clipVertices(nV1, vertices[index + 2]);
  75386. nV3 = clipVertices(nV1, vertices[index]);
  75387. result.push(nV1);
  75388. result.push(nV2);
  75389. result.push(nV3);
  75390. }
  75391. if (!v3Out) {
  75392. nV1 = vertices[index + 2].clone();
  75393. nV2 = clipVertices(nV1, vertices[index]);
  75394. nV3 = clipVertices(nV1, vertices[index + 1]);
  75395. result.push(nV1);
  75396. result.push(nV2);
  75397. result.push(nV3);
  75398. }
  75399. break;
  75400. case 3:
  75401. break;
  75402. }
  75403. }
  75404. return result;
  75405. };
  75406. for (var index = 0; index < indices.length; index += 3) {
  75407. var faceVertices = new Array();
  75408. faceVertices.push(extractDecalVector3(index));
  75409. faceVertices.push(extractDecalVector3(index + 1));
  75410. faceVertices.push(extractDecalVector3(index + 2));
  75411. // Clip
  75412. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0));
  75413. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0));
  75414. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0));
  75415. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0));
  75416. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1));
  75417. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1));
  75418. if (faceVertices.length === 0) {
  75419. continue;
  75420. }
  75421. // Add UVs and get back to world
  75422. for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
  75423. var vertex = faceVertices[vIndex];
  75424. //TODO check for Int32Array | Uint32Array | Uint16Array
  75425. vertexData.indices.push(currentVertexDataIndex);
  75426. vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
  75427. vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
  75428. vertexData.uvs.push(0.5 + vertex.position.x / size.x);
  75429. vertexData.uvs.push(0.5 + vertex.position.y / size.y);
  75430. currentVertexDataIndex++;
  75431. }
  75432. }
  75433. // Return mesh
  75434. var decal = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, sourceMesh.getScene());
  75435. vertexData.applyToMesh(decal);
  75436. decal.position = position.clone();
  75437. decal.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pitch, yaw, angle);
  75438. return decal;
  75439. };
  75440. return DecalBuilder;
  75441. }());
  75442. /***/ }),
  75443. /***/ "./Meshes/Builders/discBuilder.ts":
  75444. /*!****************************************!*\
  75445. !*** ./Meshes/Builders/discBuilder.ts ***!
  75446. \****************************************/
  75447. /*! exports provided: DiscBuilder */
  75448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75449. "use strict";
  75450. __webpack_require__.r(__webpack_exports__);
  75451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return DiscBuilder; });
  75452. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75453. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75454. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc = function (options) {
  75455. var positions = new Array();
  75456. var indices = new Array();
  75457. var normals = new Array();
  75458. var uvs = new Array();
  75459. var radius = options.radius || 0.5;
  75460. var tessellation = options.tessellation || 64;
  75461. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  75462. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  75463. // positions and uvs
  75464. positions.push(0, 0, 0); // disc center first
  75465. uvs.push(0.5, 0.5);
  75466. var theta = Math.PI * 2 * arc;
  75467. var step = theta / tessellation;
  75468. for (var a = 0; a < theta; a += step) {
  75469. var x = Math.cos(a);
  75470. var y = Math.sin(a);
  75471. var u = (x + 1) / 2;
  75472. var v = (1 - y) / 2;
  75473. positions.push(radius * x, radius * y, 0);
  75474. uvs.push(u, v);
  75475. }
  75476. if (arc === 1) {
  75477. positions.push(positions[3], positions[4], positions[5]); // close the circle
  75478. uvs.push(uvs[2], uvs[3]);
  75479. }
  75480. //indices
  75481. var vertexNb = positions.length / 3;
  75482. for (var i = 1; i < vertexNb - 1; i++) {
  75483. indices.push(i + 1, 0, i);
  75484. }
  75485. // result
  75486. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ComputeNormals(positions, indices, normals);
  75487. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  75488. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  75489. vertexData.indices = indices;
  75490. vertexData.positions = positions;
  75491. vertexData.normals = normals;
  75492. vertexData.uvs = uvs;
  75493. return vertexData;
  75494. };
  75495. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  75496. if (scene === void 0) { scene = null; }
  75497. var options = {
  75498. radius: radius,
  75499. tessellation: tessellation,
  75500. sideOrientation: sideOrientation,
  75501. updatable: updatable
  75502. };
  75503. return DiscBuilder.CreateDisc(name, options, scene);
  75504. };
  75505. /**
  75506. * Class containing static functions to help procedurally build meshes
  75507. */
  75508. var DiscBuilder = /** @class */ (function () {
  75509. function DiscBuilder() {
  75510. }
  75511. /**
  75512. * Creates a plane polygonal mesh. By default, this is a disc
  75513. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  75514. * * 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
  75515. * * 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
  75516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  75517. * * 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
  75518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  75519. * @param name defines the name of the mesh
  75520. * @param options defines the options used to create the mesh
  75521. * @param scene defines the hosting scene
  75522. * @returns the plane polygonal mesh
  75523. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  75524. */
  75525. DiscBuilder.CreateDisc = function (name, options, scene) {
  75526. if (scene === void 0) { scene = null; }
  75527. var disc = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  75528. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  75529. disc._originalBuilderSideOrientation = options.sideOrientation;
  75530. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc(options);
  75531. vertexData.applyToMesh(disc, options.updatable);
  75532. return disc;
  75533. };
  75534. return DiscBuilder;
  75535. }());
  75536. /***/ }),
  75537. /***/ "./Meshes/Builders/groundBuilder.ts":
  75538. /*!******************************************!*\
  75539. !*** ./Meshes/Builders/groundBuilder.ts ***!
  75540. \******************************************/
  75541. /*! exports provided: GroundBuilder */
  75542. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75543. "use strict";
  75544. __webpack_require__.r(__webpack_exports__);
  75545. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return GroundBuilder; });
  75546. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  75547. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75548. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75549. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../groundMesh */ "./Meshes/groundMesh.ts");
  75550. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  75551. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround = function (options) {
  75552. var indices = [];
  75553. var positions = [];
  75554. var normals = [];
  75555. var uvs = [];
  75556. var row, col;
  75557. var width = options.width || 1;
  75558. var height = options.height || 1;
  75559. var subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  75560. var subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  75561. for (row = 0; row <= subdivisionsY; row++) {
  75562. for (col = 0; col <= subdivisionsX; col++) {
  75563. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * width) / subdivisionsX - (width / 2.0), 0, ((subdivisionsY - row) * height) / subdivisionsY - (height / 2.0));
  75564. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  75565. positions.push(position.x, position.y, position.z);
  75566. normals.push(normal.x, normal.y, normal.z);
  75567. uvs.push(col / subdivisionsX, 1.0 - row / subdivisionsY);
  75568. }
  75569. }
  75570. for (row = 0; row < subdivisionsY; row++) {
  75571. for (col = 0; col < subdivisionsX; col++) {
  75572. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  75573. indices.push(col + 1 + row * (subdivisionsX + 1));
  75574. indices.push(col + row * (subdivisionsX + 1));
  75575. indices.push(col + (row + 1) * (subdivisionsX + 1));
  75576. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  75577. indices.push(col + row * (subdivisionsX + 1));
  75578. }
  75579. }
  75580. // Result
  75581. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75582. vertexData.indices = indices;
  75583. vertexData.positions = positions;
  75584. vertexData.normals = normals;
  75585. vertexData.uvs = uvs;
  75586. return vertexData;
  75587. };
  75588. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround = function (options) {
  75589. var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
  75590. var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
  75591. var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
  75592. var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
  75593. var subdivisions = options.subdivisions || { w: 1, h: 1 };
  75594. var precision = options.precision || { w: 1, h: 1 };
  75595. var indices = new Array();
  75596. var positions = new Array();
  75597. var normals = new Array();
  75598. var uvs = new Array();
  75599. var row, col, tileRow, tileCol;
  75600. subdivisions.h = (subdivisions.h < 1) ? 1 : subdivisions.h;
  75601. subdivisions.w = (subdivisions.w < 1) ? 1 : subdivisions.w;
  75602. precision.w = (precision.w < 1) ? 1 : precision.w;
  75603. precision.h = (precision.h < 1) ? 1 : precision.h;
  75604. var tileSize = {
  75605. 'w': (xmax - xmin) / subdivisions.w,
  75606. 'h': (zmax - zmin) / subdivisions.h
  75607. };
  75608. function applyTile(xTileMin, zTileMin, xTileMax, zTileMax) {
  75609. // Indices
  75610. var base = positions.length / 3;
  75611. var rowLength = precision.w + 1;
  75612. for (row = 0; row < precision.h; row++) {
  75613. for (col = 0; col < precision.w; col++) {
  75614. var square = [
  75615. base + col + row * rowLength,
  75616. base + (col + 1) + row * rowLength,
  75617. base + (col + 1) + (row + 1) * rowLength,
  75618. base + col + (row + 1) * rowLength
  75619. ];
  75620. indices.push(square[1]);
  75621. indices.push(square[2]);
  75622. indices.push(square[3]);
  75623. indices.push(square[0]);
  75624. indices.push(square[1]);
  75625. indices.push(square[3]);
  75626. }
  75627. }
  75628. // Position, normals and uvs
  75629. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75630. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  75631. for (row = 0; row <= precision.h; row++) {
  75632. position.z = (row * (zTileMax - zTileMin)) / precision.h + zTileMin;
  75633. for (col = 0; col <= precision.w; col++) {
  75634. position.x = (col * (xTileMax - xTileMin)) / precision.w + xTileMin;
  75635. position.y = 0;
  75636. positions.push(position.x, position.y, position.z);
  75637. normals.push(normal.x, normal.y, normal.z);
  75638. uvs.push(col / precision.w, row / precision.h);
  75639. }
  75640. }
  75641. }
  75642. for (tileRow = 0; tileRow < subdivisions.h; tileRow++) {
  75643. for (tileCol = 0; tileCol < subdivisions.w; tileCol++) {
  75644. applyTile(xmin + tileCol * tileSize.w, zmin + tileRow * tileSize.h, xmin + (tileCol + 1) * tileSize.w, zmin + (tileRow + 1) * tileSize.h);
  75645. }
  75646. }
  75647. // Result
  75648. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75649. vertexData.indices = indices;
  75650. vertexData.positions = positions;
  75651. vertexData.normals = normals;
  75652. vertexData.uvs = uvs;
  75653. return vertexData;
  75654. };
  75655. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap = function (options) {
  75656. var indices = [];
  75657. var positions = [];
  75658. var normals = [];
  75659. var uvs = [];
  75660. var row, col;
  75661. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  75662. var alphaFilter = options.alphaFilter || 0.0;
  75663. // Vertices
  75664. for (row = 0; row <= options.subdivisions; row++) {
  75665. for (col = 0; col <= options.subdivisions; col++) {
  75666. 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));
  75667. // Compute height
  75668. var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
  75669. var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;
  75670. var pos = (heightMapX + heightMapY * options.bufferWidth) * 4;
  75671. var r = options.buffer[pos] / 255.0;
  75672. var g = options.buffer[pos + 1] / 255.0;
  75673. var b = options.buffer[pos + 2] / 255.0;
  75674. var a = options.buffer[pos + 3] / 255.0;
  75675. var gradient = r * filter.r + g * filter.g + b * filter.b;
  75676. // If our alpha channel is not within our filter then we will assign a 'special' height
  75677. // Then when building the indices, we will ignore any vertex that is using the special height
  75678. if (a >= alphaFilter) {
  75679. position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
  75680. }
  75681. else {
  75682. position.y = options.minHeight - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; // We can't have a height below minHeight, normally.
  75683. }
  75684. // Add vertex
  75685. positions.push(position.x, position.y, position.z);
  75686. normals.push(0, 0, 0);
  75687. uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
  75688. }
  75689. }
  75690. // Indices
  75691. for (row = 0; row < options.subdivisions; row++) {
  75692. for (col = 0; col < options.subdivisions; col++) {
  75693. // Calculate Indices
  75694. var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
  75695. var idx2 = (col + 1 + row * (options.subdivisions + 1));
  75696. var idx3 = (col + row * (options.subdivisions + 1));
  75697. var idx4 = (col + (row + 1) * (options.subdivisions + 1));
  75698. // Check that all indices are visible (based on our special height)
  75699. // Only display the vertex if all Indices are visible
  75700. // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
  75701. var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
  75702. var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
  75703. var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
  75704. if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
  75705. indices.push(idx1);
  75706. indices.push(idx2);
  75707. indices.push(idx3);
  75708. }
  75709. var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
  75710. if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
  75711. indices.push(idx4);
  75712. indices.push(idx1);
  75713. indices.push(idx3);
  75714. }
  75715. }
  75716. }
  75717. // Normals
  75718. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  75719. // Result
  75720. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75721. vertexData.indices = indices;
  75722. vertexData.positions = positions;
  75723. vertexData.normals = normals;
  75724. vertexData.uvs = uvs;
  75725. return vertexData;
  75726. };
  75727. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  75728. var options = {
  75729. width: width,
  75730. height: height,
  75731. subdivisions: subdivisions,
  75732. updatable: updatable
  75733. };
  75734. return GroundBuilder.CreateGround(name, options, scene);
  75735. };
  75736. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  75737. var options = {
  75738. xmin: xmin,
  75739. zmin: zmin,
  75740. xmax: xmax,
  75741. zmax: zmax,
  75742. subdivisions: subdivisions,
  75743. precision: precision,
  75744. updatable: updatable
  75745. };
  75746. return GroundBuilder.CreateTiledGround(name, options, scene);
  75747. };
  75748. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  75749. var options = {
  75750. width: width,
  75751. height: height,
  75752. subdivisions: subdivisions,
  75753. minHeight: minHeight,
  75754. maxHeight: maxHeight,
  75755. updatable: updatable,
  75756. onReady: onReady,
  75757. alphaFilter: alphaFilter
  75758. };
  75759. return GroundBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  75760. };
  75761. /**
  75762. * Class containing static functions to help procedurally build meshes
  75763. */
  75764. var GroundBuilder = /** @class */ (function () {
  75765. function GroundBuilder() {
  75766. }
  75767. /**
  75768. * Creates a ground mesh
  75769. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  75770. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  75771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  75772. * @param name defines the name of the mesh
  75773. * @param options defines the options used to create the mesh
  75774. * @param scene defines the hosting scene
  75775. * @returns the ground mesh
  75776. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  75777. */
  75778. GroundBuilder.CreateGround = function (name, options, scene) {
  75779. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  75780. ground._setReady(false);
  75781. ground._subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  75782. ground._subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  75783. ground._width = options.width || 1;
  75784. ground._height = options.height || 1;
  75785. ground._maxX = ground._width / 2;
  75786. ground._maxZ = ground._height / 2;
  75787. ground._minX = -ground._maxX;
  75788. ground._minZ = -ground._maxZ;
  75789. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround(options);
  75790. vertexData.applyToMesh(ground, options.updatable);
  75791. ground._setReady(true);
  75792. return ground;
  75793. };
  75794. /**
  75795. * Creates a tiled ground mesh
  75796. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  75797. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  75798. * * 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
  75799. * * 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
  75800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  75801. * @param name defines the name of the mesh
  75802. * @param options defines the options used to create the mesh
  75803. * @param scene defines the hosting scene
  75804. * @returns the tiled ground mesh
  75805. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  75806. */
  75807. GroundBuilder.CreateTiledGround = function (name, options, scene) {
  75808. var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  75809. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround(options);
  75810. vertexData.applyToMesh(tiledGround, options.updatable);
  75811. return tiledGround;
  75812. };
  75813. /**
  75814. * Creates a ground mesh from a height map
  75815. * * The parameter `url` sets the URL of the height map image resource.
  75816. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  75817. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  75818. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  75819. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  75820. * * 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.
  75821. * * 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).
  75822. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  75823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  75824. * @param name defines the name of the mesh
  75825. * @param url defines the url to the height map
  75826. * @param options defines the options used to create the mesh
  75827. * @param scene defines the hosting scene
  75828. * @returns the ground mesh
  75829. * @see https://doc.babylonjs.com/babylon101/height_map
  75830. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  75831. */
  75832. GroundBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  75833. var width = options.width || 10.0;
  75834. var height = options.height || 10.0;
  75835. var subdivisions = options.subdivisions || 1 | 0;
  75836. var minHeight = options.minHeight || 0.0;
  75837. var maxHeight = options.maxHeight || 1.0;
  75838. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  75839. var alphaFilter = options.alphaFilter || 0.0;
  75840. var updatable = options.updatable;
  75841. var onReady = options.onReady;
  75842. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  75843. ground._subdivisionsX = subdivisions;
  75844. ground._subdivisionsY = subdivisions;
  75845. ground._width = width;
  75846. ground._height = height;
  75847. ground._maxX = ground._width / 2.0;
  75848. ground._maxZ = ground._height / 2.0;
  75849. ground._minX = -ground._maxX;
  75850. ground._minZ = -ground._maxZ;
  75851. ground._setReady(false);
  75852. var onload = function (img) {
  75853. // Getting height map data
  75854. var canvas = document.createElement("canvas");
  75855. var context = canvas.getContext("2d");
  75856. if (!context) {
  75857. throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
  75858. }
  75859. if (scene.isDisposed) {
  75860. return;
  75861. }
  75862. var bufferWidth = img.width;
  75863. var bufferHeight = img.height;
  75864. canvas.width = bufferWidth;
  75865. canvas.height = bufferHeight;
  75866. context.drawImage(img, 0, 0);
  75867. // Create VertexData from map data
  75868. // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  75869. var buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
  75870. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap({
  75871. width: width, height: height,
  75872. subdivisions: subdivisions,
  75873. minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
  75874. buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
  75875. alphaFilter: alphaFilter
  75876. });
  75877. vertexData.applyToMesh(ground, updatable);
  75878. //execute ready callback, if set
  75879. if (onReady) {
  75880. onReady(ground);
  75881. }
  75882. ground._setReady(true);
  75883. };
  75884. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  75885. return ground;
  75886. };
  75887. return GroundBuilder;
  75888. }());
  75889. /***/ }),
  75890. /***/ "./Meshes/Builders/icoSphereBuilder.ts":
  75891. /*!*********************************************!*\
  75892. !*** ./Meshes/Builders/icoSphereBuilder.ts ***!
  75893. \*********************************************/
  75894. /*! exports provided: IcoSphereBuilder */
  75895. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75896. "use strict";
  75897. __webpack_require__.r(__webpack_exports__);
  75898. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return IcoSphereBuilder; });
  75899. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  75900. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75901. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75902. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere = function (options) {
  75903. var sideOrientation = options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  75904. var radius = options.radius || 1;
  75905. var flat = (options.flat === undefined) ? true : options.flat;
  75906. var subdivisions = options.subdivisions || 4;
  75907. var radiusX = options.radiusX || radius;
  75908. var radiusY = options.radiusY || radius;
  75909. var radiusZ = options.radiusZ || radius;
  75910. var t = (1 + Math.sqrt(5)) / 2;
  75911. // 12 vertex x,y,z
  75912. var ico_vertices = [
  75913. -1, t, -0, 1, t, 0, -1, -t, 0, 1, -t, 0,
  75914. 0, -1, -t, 0, 1, -t, 0, -1, t, 0, 1, t,
  75915. t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, -1 // v8-11
  75916. ];
  75917. // index of 3 vertex makes a face of icopshere
  75918. var ico_indices = [
  75919. 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23,
  75920. 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8,
  75921. 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9,
  75922. 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1
  75923. ];
  75924. // vertex for uv have aliased position, not for UV
  75925. var vertices_unalias_id = [
  75926. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  75927. // vertex alias
  75928. 0,
  75929. 2,
  75930. 3,
  75931. 3,
  75932. 3,
  75933. 4,
  75934. 7,
  75935. 8,
  75936. 9,
  75937. 9,
  75938. 10,
  75939. 11 // 23: B + 12
  75940. ];
  75941. // uv as integer step (not pixels !)
  75942. var ico_vertexuv = [
  75943. 5, 1, 3, 1, 6, 4, 0, 0,
  75944. 5, 3, 4, 2, 2, 2, 4, 0,
  75945. 2, 0, 1, 1, 6, 0, 6, 2,
  75946. // vertex alias (for same vertex on different faces)
  75947. 0, 4,
  75948. 3, 3,
  75949. 4, 4,
  75950. 3, 1,
  75951. 4, 2,
  75952. 4, 4,
  75953. 0, 2,
  75954. 1, 1,
  75955. 2, 2,
  75956. 3, 3,
  75957. 1, 3,
  75958. 2, 4 // 23: B + 12
  75959. ];
  75960. // Vertices[0, 1, ...9, A, B] : position on UV plane
  75961. // '+' indicate duplicate position to be fixed (3,9:0,2,3,4,7,8,A,B)
  75962. // First island of uv mapping
  75963. // v = 4h 3+ 2
  75964. // v = 3h 9+ 4
  75965. // v = 2h 9+ 5 B
  75966. // v = 1h 9 1 0
  75967. // v = 0h 3 8 7 A
  75968. // u = 0 1 2 3 4 5 6 *a
  75969. // Second island of uv mapping
  75970. // v = 4h 0+ B+ 4+
  75971. // v = 3h A+ 2+
  75972. // v = 2h 7+ 6 3+
  75973. // v = 1h 8+ 3+
  75974. // v = 0h
  75975. // u = 0 1 2 3 4 5 6 *a
  75976. // Face layout on texture UV mapping
  75977. // ============
  75978. // \ 4 /\ 16 / ======
  75979. // \ / \ / /\ 11 /
  75980. // \/ 7 \/ / \ /
  75981. // ======= / 10 \/
  75982. // /\ 17 /\ =======
  75983. // / \ / \ \ 15 /\
  75984. // / 8 \/ 12 \ \ / \
  75985. // ============ \/ 6 \
  75986. // \ 18 /\ ============
  75987. // \ / \ \ 5 /\ 0 /
  75988. // \/ 13 \ \ / \ /
  75989. // ======= \/ 1 \/
  75990. // =============
  75991. // /\ 19 /\ 2 /\
  75992. // / \ / \ / \
  75993. // / 14 \/ 9 \/ 3 \
  75994. // ===================
  75995. // uv step is u:1 or 0.5, v:cos(30)=sqrt(3)/2, ratio approx is 84/97
  75996. var ustep = 138 / 1024;
  75997. var vstep = 239 / 1024;
  75998. var uoffset = 60 / 1024;
  75999. var voffset = 26 / 1024;
  76000. // Second island should have margin, not to touch the first island
  76001. // avoid any borderline artefact in pixel rounding
  76002. var island_u_offset = -40 / 1024;
  76003. var island_v_offset = +20 / 1024;
  76004. // face is either island 0 or 1 :
  76005. // second island is for faces : [4, 7, 8, 12, 13, 16, 17, 18]
  76006. var island = [
  76007. 0, 0, 0, 0, 1,
  76008. 0, 0, 1, 1, 0,
  76009. 0, 0, 1, 1, 0,
  76010. 0, 1, 1, 1, 0 // 15 - 19
  76011. ];
  76012. var indices = new Array();
  76013. var positions = new Array();
  76014. var normals = new Array();
  76015. var uvs = new Array();
  76016. var current_indice = 0;
  76017. // prepare array of 3 vector (empty) (to be worked in place, shared for each face)
  76018. var face_vertex_pos = new Array(3);
  76019. var face_vertex_uv = new Array(3);
  76020. var v012;
  76021. for (v012 = 0; v012 < 3; v012++) {
  76022. face_vertex_pos[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76023. face_vertex_uv[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  76024. }
  76025. // create all with normals
  76026. for (var face = 0; face < 20; face++) {
  76027. // 3 vertex per face
  76028. for (v012 = 0; v012 < 3; v012++) {
  76029. // look up vertex 0,1,2 to its index in 0 to 11 (or 23 including alias)
  76030. var v_id = ico_indices[3 * face + v012];
  76031. // vertex have 3D position (x,y,z)
  76032. 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]);
  76033. // Normalize to get normal, then scale to radius
  76034. face_vertex_pos[v012].normalize().scaleInPlace(radius);
  76035. // uv Coordinates from vertex ID
  76036. 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);
  76037. }
  76038. // Subdivide the face (interpolate pos, norm, uv)
  76039. // - pos is linear interpolation, then projected to sphere (converge polyhedron to sphere)
  76040. // - norm is linear interpolation of vertex corner normal
  76041. // (to be checked if better to re-calc from face vertex, or if approximation is OK ??? )
  76042. // - uv is linear interpolation
  76043. //
  76044. // Topology is as below for sub-divide by 2
  76045. // vertex shown as v0,v1,v2
  76046. // interp index is i1 to progress in range [v0,v1[
  76047. // interp index is i2 to progress in range [v0,v2[
  76048. // face index as (i1,i2) for /\ : (i1,i2),(i1+1,i2),(i1,i2+1)
  76049. // and (i1,i2)' for \/ : (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  76050. //
  76051. //
  76052. // i2 v2
  76053. // ^ ^
  76054. // / / \
  76055. // / / \
  76056. // / / \
  76057. // / / (0,1) \
  76058. // / #---------\
  76059. // / / \ (0,0)'/ \
  76060. // / / \ / \
  76061. // / / \ / \
  76062. // / / (0,0) \ / (1,0) \
  76063. // / #---------#---------\
  76064. // v0 v1
  76065. //
  76066. // --------------------> i1
  76067. //
  76068. // interp of (i1,i2):
  76069. // along i2 : x0=lerp(v0,v2, i2/S) <---> x1=lerp(v1,v2, i2/S)
  76070. // along i1 : lerp(x0,x1, i1/(S-i2))
  76071. //
  76072. // centroid of triangle is needed to get help normal computation
  76073. // (c1,c2) are used for centroid location
  76074. var interp_vertex = function (i1, i2, c1, c2) {
  76075. // vertex is interpolated from
  76076. // - face_vertex_pos[0..2]
  76077. // - face_vertex_uv[0..2]
  76078. var pos_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], i2 / subdivisions);
  76079. var pos_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], i2 / subdivisions);
  76080. var pos_interp = (subdivisions === i2) ? face_vertex_pos[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(pos_x0, pos_x1, i1 / (subdivisions - i2));
  76081. pos_interp.normalize();
  76082. var vertex_normal;
  76083. if (flat) {
  76084. // in flat mode, recalculate normal as face centroid normal
  76085. var centroid_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], c2 / subdivisions);
  76086. var centroid_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], c2 / subdivisions);
  76087. vertex_normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(centroid_x0, centroid_x1, c1 / (subdivisions - c2));
  76088. }
  76089. else {
  76090. // in smooth mode, recalculate normal from each single vertex position
  76091. vertex_normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pos_interp.x, pos_interp.y, pos_interp.z);
  76092. }
  76093. // Vertex normal need correction due to X,Y,Z radius scaling
  76094. vertex_normal.x /= radiusX;
  76095. vertex_normal.y /= radiusY;
  76096. vertex_normal.z /= radiusZ;
  76097. vertex_normal.normalize();
  76098. var uv_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[0], face_vertex_uv[2], i2 / subdivisions);
  76099. var uv_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[1], face_vertex_uv[2], i2 / subdivisions);
  76100. var uv_interp = (subdivisions === i2) ? face_vertex_uv[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(uv_x0, uv_x1, i1 / (subdivisions - i2));
  76101. positions.push(pos_interp.x * radiusX, pos_interp.y * radiusY, pos_interp.z * radiusZ);
  76102. normals.push(vertex_normal.x, vertex_normal.y, vertex_normal.z);
  76103. uvs.push(uv_interp.x, uv_interp.y);
  76104. // push each vertex has member of a face
  76105. // Same vertex can bleong to multiple face, it is pushed multiple time (duplicate vertex are present)
  76106. indices.push(current_indice);
  76107. current_indice++;
  76108. };
  76109. for (var i2 = 0; i2 < subdivisions; i2++) {
  76110. for (var i1 = 0; i1 + i2 < subdivisions; i1++) {
  76111. // face : (i1,i2) for /\ :
  76112. // interp for : (i1,i2),(i1+1,i2),(i1,i2+1)
  76113. interp_vertex(i1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  76114. interp_vertex(i1 + 1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  76115. interp_vertex(i1, i2 + 1, i1 + 1.0 / 3, i2 + 1.0 / 3);
  76116. if (i1 + i2 + 1 < subdivisions) {
  76117. // face : (i1,i2)' for \/ :
  76118. // interp for (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  76119. interp_vertex(i1 + 1, i2, i1 + 2.0 / 3, i2 + 2.0 / 3);
  76120. interp_vertex(i1 + 1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  76121. interp_vertex(i1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  76122. }
  76123. }
  76124. }
  76125. }
  76126. // Sides
  76127. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76128. // Result
  76129. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76130. vertexData.indices = indices;
  76131. vertexData.positions = positions;
  76132. vertexData.normals = normals;
  76133. vertexData.uvs = uvs;
  76134. return vertexData;
  76135. };
  76136. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateIcoSphere = function (name, options, scene) {
  76137. return IcoSphereBuilder.CreateIcoSphere(name, options, scene);
  76138. };
  76139. /**
  76140. * Class containing static functions to help procedurally build meshes
  76141. */
  76142. var IcoSphereBuilder = /** @class */ (function () {
  76143. function IcoSphereBuilder() {
  76144. }
  76145. /**
  76146. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  76147. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  76148. * * 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`)
  76149. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  76150. * * 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
  76151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76152. * * 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
  76153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76154. * @param name defines the name of the mesh
  76155. * @param options defines the options used to create the mesh
  76156. * @param scene defines the hosting scene
  76157. * @returns the icosahedron mesh
  76158. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  76159. */
  76160. IcoSphereBuilder.CreateIcoSphere = function (name, options, scene) {
  76161. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  76162. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76163. sphere._originalBuilderSideOrientation = options.sideOrientation;
  76164. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere(options);
  76165. vertexData.applyToMesh(sphere, options.updatable);
  76166. return sphere;
  76167. };
  76168. return IcoSphereBuilder;
  76169. }());
  76170. /***/ }),
  76171. /***/ "./Meshes/Builders/index.ts":
  76172. /*!**********************************!*\
  76173. !*** ./Meshes/Builders/index.ts ***!
  76174. \**********************************/
  76175. /*! exports provided: BoxBuilder, DiscBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  76176. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76177. "use strict";
  76178. __webpack_require__.r(__webpack_exports__);
  76179. /* harmony import */ var _boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  76180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  76181. /* harmony import */ var _discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./discBuilder */ "./Meshes/Builders/discBuilder.ts");
  76182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"]; });
  76183. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  76184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"]; });
  76185. /* harmony import */ var _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  76186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"]; });
  76187. /* harmony import */ var _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  76188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"]; });
  76189. /* harmony import */ var _torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  76190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"]; });
  76191. /* harmony import */ var _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  76192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"]; });
  76193. /* harmony import */ var _linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  76194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"]; });
  76195. /* harmony import */ var _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  76196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"]; });
  76197. /* harmony import */ var _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  76198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"]; });
  76199. /* harmony import */ var _latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  76200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"]; });
  76201. /* harmony import */ var _planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  76202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"]; });
  76203. /* harmony import */ var _groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  76204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"]; });
  76205. /* harmony import */ var _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  76206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"]; });
  76207. /* harmony import */ var _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  76208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"]; });
  76209. /* harmony import */ var _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  76210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"]; });
  76211. /* harmony import */ var _decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  76212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"]; });
  76213. /***/ }),
  76214. /***/ "./Meshes/Builders/latheBuilder.ts":
  76215. /*!*****************************************!*\
  76216. !*** ./Meshes/Builders/latheBuilder.ts ***!
  76217. \*****************************************/
  76218. /*! exports provided: LatheBuilder */
  76219. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76220. "use strict";
  76221. __webpack_require__.r(__webpack_exports__);
  76222. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return LatheBuilder; });
  76223. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76224. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76225. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  76226. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  76227. var options = {
  76228. shape: shape,
  76229. radius: radius,
  76230. tessellation: tessellation,
  76231. sideOrientation: sideOrientation,
  76232. updatable: updatable
  76233. };
  76234. return LatheBuilder.CreateLathe(name, options, scene);
  76235. };
  76236. /**
  76237. * Class containing static functions to help procedurally build meshes
  76238. */
  76239. var LatheBuilder = /** @class */ (function () {
  76240. function LatheBuilder() {
  76241. }
  76242. /**
  76243. * Creates lathe mesh.
  76244. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  76245. * * 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
  76246. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  76247. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  76248. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  76249. * * 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
  76250. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  76251. * * 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
  76252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76253. * * 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
  76254. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  76255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76256. * @param name defines the name of the mesh
  76257. * @param options defines the options used to create the mesh
  76258. * @param scene defines the hosting scene
  76259. * @returns the lathe mesh
  76260. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  76261. */
  76262. LatheBuilder.CreateLathe = function (name, options, scene) {
  76263. var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
  76264. var closed = (options.closed === undefined) ? true : options.closed;
  76265. var shape = options.shape;
  76266. var radius = options.radius || 1;
  76267. var tessellation = options.tessellation || 64;
  76268. var clip = options.clip || 0;
  76269. var updatable = options.updatable;
  76270. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76271. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  76272. var pi2 = Math.PI * 2;
  76273. var paths = new Array();
  76274. var invertUV = options.invertUV || false;
  76275. var i = 0;
  76276. var p = 0;
  76277. var step = pi2 / tessellation * arc;
  76278. var rotated;
  76279. var path = new Array();
  76280. for (i = 0; i <= tessellation - clip; i++) {
  76281. var path = [];
  76282. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  76283. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[0].y, 0));
  76284. 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));
  76285. }
  76286. for (p = 0; p < shape.length; p++) {
  76287. 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);
  76288. path.push(rotated);
  76289. }
  76290. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  76291. 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));
  76292. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[shape.length - 1].y, 0));
  76293. }
  76294. paths.push(path);
  76295. }
  76296. // lathe ribbon
  76297. 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);
  76298. return lathe;
  76299. };
  76300. return LatheBuilder;
  76301. }());
  76302. /***/ }),
  76303. /***/ "./Meshes/Builders/linesBuilder.ts":
  76304. /*!*****************************************!*\
  76305. !*** ./Meshes/Builders/linesBuilder.ts ***!
  76306. \*****************************************/
  76307. /*! exports provided: LinesBuilder */
  76308. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76309. "use strict";
  76310. __webpack_require__.r(__webpack_exports__);
  76311. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return LinesBuilder; });
  76312. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76313. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76314. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76315. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  76316. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  76317. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem = function (options) {
  76318. var indices = [];
  76319. var positions = [];
  76320. var lines = options.lines;
  76321. var colors = options.colors;
  76322. var vertexColors = [];
  76323. var idx = 0;
  76324. for (var l = 0; l < lines.length; l++) {
  76325. var points = lines[l];
  76326. for (var index = 0; index < points.length; index++) {
  76327. positions.push(points[index].x, points[index].y, points[index].z);
  76328. if (colors) {
  76329. var color = colors[l];
  76330. vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);
  76331. }
  76332. if (index > 0) {
  76333. indices.push(idx - 1);
  76334. indices.push(idx);
  76335. }
  76336. idx++;
  76337. }
  76338. }
  76339. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76340. vertexData.indices = indices;
  76341. vertexData.positions = positions;
  76342. if (colors) {
  76343. vertexData.colors = vertexColors;
  76344. }
  76345. return vertexData;
  76346. };
  76347. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines = function (options) {
  76348. var dashSize = options.dashSize || 3;
  76349. var gapSize = options.gapSize || 1;
  76350. var dashNb = options.dashNb || 200;
  76351. var points = options.points;
  76352. var positions = new Array();
  76353. var indices = new Array();
  76354. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76355. var lg = 0;
  76356. var nb = 0;
  76357. var shft = 0;
  76358. var dashshft = 0;
  76359. var curshft = 0;
  76360. var idx = 0;
  76361. var i = 0;
  76362. for (i = 0; i < points.length - 1; i++) {
  76363. points[i + 1].subtractToRef(points[i], curvect);
  76364. lg += curvect.length();
  76365. }
  76366. shft = lg / dashNb;
  76367. dashshft = dashSize * shft / (dashSize + gapSize);
  76368. for (i = 0; i < points.length - 1; i++) {
  76369. points[i + 1].subtractToRef(points[i], curvect);
  76370. nb = Math.floor(curvect.length() / shft);
  76371. curvect.normalize();
  76372. for (var j = 0; j < nb; j++) {
  76373. curshft = shft * j;
  76374. positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);
  76375. positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);
  76376. indices.push(idx, idx + 1);
  76377. idx += 2;
  76378. }
  76379. }
  76380. // Result
  76381. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76382. vertexData.positions = positions;
  76383. vertexData.indices = indices;
  76384. return vertexData;
  76385. };
  76386. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines = function (name, points, scene, updatable, instance) {
  76387. if (scene === void 0) { scene = null; }
  76388. if (updatable === void 0) { updatable = false; }
  76389. if (instance === void 0) { instance = null; }
  76390. var options = {
  76391. points: points,
  76392. updatable: updatable,
  76393. instance: instance
  76394. };
  76395. return LinesBuilder.CreateLines(name, options, scene);
  76396. };
  76397. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  76398. if (scene === void 0) { scene = null; }
  76399. var options = {
  76400. points: points,
  76401. dashSize: dashSize,
  76402. gapSize: gapSize,
  76403. dashNb: dashNb,
  76404. updatable: updatable,
  76405. instance: instance
  76406. };
  76407. return LinesBuilder.CreateDashedLines(name, options, scene);
  76408. };
  76409. /**
  76410. * Class containing static functions to help procedurally build meshes
  76411. */
  76412. var LinesBuilder = /** @class */ (function () {
  76413. function LinesBuilder() {
  76414. }
  76415. /**
  76416. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  76417. * * 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
  76418. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  76419. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  76420. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  76421. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  76422. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  76423. * * 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
  76424. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  76425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76426. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  76427. * @param name defines the name of the new line system
  76428. * @param options defines the options used to create the line system
  76429. * @param scene defines the hosting scene
  76430. * @returns a new line system mesh
  76431. */
  76432. LinesBuilder.CreateLineSystem = function (name, options, scene) {
  76433. var instance = options.instance;
  76434. var lines = options.lines;
  76435. var colors = options.colors;
  76436. if (instance) { // lines update
  76437. var positions = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  76438. var vertexColor;
  76439. var lineColors;
  76440. if (colors) {
  76441. vertexColor = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  76442. }
  76443. var i = 0;
  76444. var c = 0;
  76445. for (var l = 0; l < lines.length; l++) {
  76446. var points = lines[l];
  76447. for (var p = 0; p < points.length; p++) {
  76448. positions[i] = points[p].x;
  76449. positions[i + 1] = points[p].y;
  76450. positions[i + 2] = points[p].z;
  76451. if (colors && vertexColor) {
  76452. lineColors = colors[l];
  76453. vertexColor[c] = lineColors[p].r;
  76454. vertexColor[c + 1] = lineColors[p].g;
  76455. vertexColor[c + 2] = lineColors[p].b;
  76456. vertexColor[c + 3] = lineColors[p].a;
  76457. c += 4;
  76458. }
  76459. i += 3;
  76460. }
  76461. }
  76462. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  76463. if (colors && vertexColor) {
  76464. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, vertexColor, false, false);
  76465. }
  76466. return instance;
  76467. }
  76468. // line system creation
  76469. var useVertexColor = (colors) ? true : false;
  76470. var lineSystem = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha);
  76471. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem(options);
  76472. vertexData.applyToMesh(lineSystem, options.updatable);
  76473. return lineSystem;
  76474. };
  76475. /**
  76476. * Creates a line mesh
  76477. * 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
  76478. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  76479. * * The parameter `points` is an array successive Vector3
  76480. * * 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
  76481. * * The optional parameter `colors` is an array of successive Color4, one per line point
  76482. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  76483. * * When updating an instance, remember that only point positions can change, not the number of points
  76484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76485. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  76486. * @param name defines the name of the new line system
  76487. * @param options defines the options used to create the line system
  76488. * @param scene defines the hosting scene
  76489. * @returns a new line mesh
  76490. */
  76491. LinesBuilder.CreateLines = function (name, options, scene) {
  76492. if (scene === void 0) { scene = null; }
  76493. var colors = (options.colors) ? [options.colors] : null;
  76494. var lines = LinesBuilder.CreateLineSystem(name, { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha }, scene);
  76495. return lines;
  76496. };
  76497. /**
  76498. * Creates a dashed line mesh
  76499. * * 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
  76500. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  76501. * * The parameter `points` is an array successive Vector3
  76502. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  76503. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  76504. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  76505. * * 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
  76506. * * When updating an instance, remember that only point positions can change, not the number of points
  76507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76508. * @param name defines the name of the mesh
  76509. * @param options defines the options used to create the mesh
  76510. * @param scene defines the hosting scene
  76511. * @returns the dashed line mesh
  76512. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  76513. */
  76514. LinesBuilder.CreateDashedLines = function (name, options, scene) {
  76515. if (scene === void 0) { scene = null; }
  76516. var points = options.points;
  76517. var instance = options.instance;
  76518. var gapSize = options.gapSize || 1;
  76519. var dashSize = options.dashSize || 3;
  76520. if (instance) { // dashed lines update
  76521. var positionFunction = function (positions) {
  76522. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76523. var nbSeg = positions.length / 6;
  76524. var lg = 0;
  76525. var nb = 0;
  76526. var shft = 0;
  76527. var dashshft = 0;
  76528. var curshft = 0;
  76529. var p = 0;
  76530. var i = 0;
  76531. var j = 0;
  76532. for (i = 0; i < points.length - 1; i++) {
  76533. points[i + 1].subtractToRef(points[i], curvect);
  76534. lg += curvect.length();
  76535. }
  76536. shft = lg / nbSeg;
  76537. var dashSize = instance._creationDataStorage.dashSize;
  76538. var gapSize = instance._creationDataStorage.gapSize;
  76539. dashshft = dashSize * shft / (dashSize + gapSize);
  76540. for (i = 0; i < points.length - 1; i++) {
  76541. points[i + 1].subtractToRef(points[i], curvect);
  76542. nb = Math.floor(curvect.length() / shft);
  76543. curvect.normalize();
  76544. j = 0;
  76545. while (j < nb && p < positions.length) {
  76546. curshft = shft * j;
  76547. positions[p] = points[i].x + curshft * curvect.x;
  76548. positions[p + 1] = points[i].y + curshft * curvect.y;
  76549. positions[p + 2] = points[i].z + curshft * curvect.z;
  76550. positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
  76551. positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
  76552. positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
  76553. p += 6;
  76554. j++;
  76555. }
  76556. }
  76557. while (p < positions.length) {
  76558. positions[p] = points[i].x;
  76559. positions[p + 1] = points[i].y;
  76560. positions[p + 2] = points[i].z;
  76561. p += 3;
  76562. }
  76563. };
  76564. instance.updateMeshPositions(positionFunction, false);
  76565. return instance;
  76566. }
  76567. // dashed lines creation
  76568. var dashedLines = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene);
  76569. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines(options);
  76570. vertexData.applyToMesh(dashedLines, options.updatable);
  76571. dashedLines._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  76572. dashedLines._creationDataStorage.dashSize = dashSize;
  76573. dashedLines._creationDataStorage.gapSize = gapSize;
  76574. return dashedLines;
  76575. };
  76576. return LinesBuilder;
  76577. }());
  76578. /***/ }),
  76579. /***/ "./Meshes/Builders/planeBuilder.ts":
  76580. /*!*****************************************!*\
  76581. !*** ./Meshes/Builders/planeBuilder.ts ***!
  76582. \*****************************************/
  76583. /*! exports provided: PlaneBuilder */
  76584. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76585. "use strict";
  76586. __webpack_require__.r(__webpack_exports__);
  76587. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return PlaneBuilder; });
  76588. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76589. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76590. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane = function (options) {
  76591. var indices = [];
  76592. var positions = [];
  76593. var normals = [];
  76594. var uvs = [];
  76595. var width = options.width || options.size || 1;
  76596. var height = options.height || options.size || 1;
  76597. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  76598. // Vertices
  76599. var halfWidth = width / 2.0;
  76600. var halfHeight = height / 2.0;
  76601. positions.push(-halfWidth, -halfHeight, 0);
  76602. normals.push(0, 0, -1.0);
  76603. uvs.push(0.0, 0.0);
  76604. positions.push(halfWidth, -halfHeight, 0);
  76605. normals.push(0, 0, -1.0);
  76606. uvs.push(1.0, 0.0);
  76607. positions.push(halfWidth, halfHeight, 0);
  76608. normals.push(0, 0, -1.0);
  76609. uvs.push(1.0, 1.0);
  76610. positions.push(-halfWidth, halfHeight, 0);
  76611. normals.push(0, 0, -1.0);
  76612. uvs.push(0.0, 1.0);
  76613. // Indices
  76614. indices.push(0);
  76615. indices.push(1);
  76616. indices.push(2);
  76617. indices.push(0);
  76618. indices.push(2);
  76619. indices.push(3);
  76620. // Sides
  76621. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76622. // Result
  76623. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  76624. vertexData.indices = indices;
  76625. vertexData.positions = positions;
  76626. vertexData.normals = normals;
  76627. vertexData.uvs = uvs;
  76628. return vertexData;
  76629. };
  76630. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  76631. var options = {
  76632. size: size,
  76633. width: size,
  76634. height: size,
  76635. sideOrientation: sideOrientation,
  76636. updatable: updatable
  76637. };
  76638. return PlaneBuilder.CreatePlane(name, options, scene);
  76639. };
  76640. /**
  76641. * Class containing static functions to help procedurally build meshes
  76642. */
  76643. var PlaneBuilder = /** @class */ (function () {
  76644. function PlaneBuilder() {
  76645. }
  76646. /**
  76647. * Creates a plane mesh
  76648. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  76649. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  76650. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  76651. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76652. * * 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
  76653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76654. * @param name defines the name of the mesh
  76655. * @param options defines the options used to create the mesh
  76656. * @param scene defines the hosting scene
  76657. * @returns the plane mesh
  76658. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  76659. */
  76660. PlaneBuilder.CreatePlane = function (name, options, scene) {
  76661. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  76662. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76663. plane._originalBuilderSideOrientation = options.sideOrientation;
  76664. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane(options);
  76665. vertexData.applyToMesh(plane, options.updatable);
  76666. if (options.sourcePlane) {
  76667. plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
  76668. plane.setDirection(options.sourcePlane.normal.scale(-1));
  76669. }
  76670. return plane;
  76671. };
  76672. return PlaneBuilder;
  76673. }());
  76674. /***/ }),
  76675. /***/ "./Meshes/Builders/polygonBuilder.ts":
  76676. /*!*******************************************!*\
  76677. !*** ./Meshes/Builders/polygonBuilder.ts ***!
  76678. \*******************************************/
  76679. /*! exports provided: PolygonBuilder */
  76680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76681. "use strict";
  76682. __webpack_require__.r(__webpack_exports__);
  76683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return PolygonBuilder; });
  76684. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76685. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76686. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76687. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../polygonMesh */ "./Meshes/polygonMesh.ts");
  76688. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  76689. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  76690. var faceUV = fUV || new Array(3);
  76691. var faceColors = fColors;
  76692. var colors = [];
  76693. // default face colors and UV if undefined
  76694. for (var f = 0; f < 3; f++) {
  76695. if (faceUV[f] === undefined) {
  76696. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  76697. }
  76698. if (faceColors && faceColors[f] === undefined) {
  76699. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  76700. }
  76701. }
  76702. var positions = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  76703. var normals = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  76704. var uvs = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  76705. var indices = polygon.getIndices();
  76706. // set face colours and textures
  76707. var idx = 0;
  76708. var face = 0;
  76709. for (var index = 0; index < normals.length; index += 3) {
  76710. //Edge Face no. 1
  76711. if (Math.abs(normals[index + 1]) < 0.001) {
  76712. face = 1;
  76713. }
  76714. //Top Face no. 0
  76715. if (Math.abs(normals[index + 1] - 1) < 0.001) {
  76716. face = 0;
  76717. }
  76718. //Bottom Face no. 2
  76719. if (Math.abs(normals[index + 1] + 1) < 0.001) {
  76720. face = 2;
  76721. }
  76722. idx = index / 3;
  76723. uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
  76724. uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
  76725. if (faceColors) {
  76726. colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
  76727. }
  76728. }
  76729. // sides
  76730. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
  76731. // Result
  76732. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76733. vertexData.indices = indices;
  76734. vertexData.positions = positions;
  76735. vertexData.normals = normals;
  76736. vertexData.uvs = uvs;
  76737. if (faceColors) {
  76738. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  76739. vertexData.colors = totalColors;
  76740. }
  76741. return vertexData;
  76742. };
  76743. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  76744. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76745. var options = {
  76746. shape: shape,
  76747. holes: holes,
  76748. updatable: updatable,
  76749. sideOrientation: sideOrientation
  76750. };
  76751. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  76752. };
  76753. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  76754. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76755. var options = {
  76756. shape: shape,
  76757. holes: holes,
  76758. depth: depth,
  76759. updatable: updatable,
  76760. sideOrientation: sideOrientation
  76761. };
  76762. return PolygonBuilder.ExtrudePolygon(name, options, scene, earcutInjection);
  76763. };
  76764. /**
  76765. * Class containing static functions to help procedurally build meshes
  76766. */
  76767. var PolygonBuilder = /** @class */ (function () {
  76768. function PolygonBuilder() {
  76769. }
  76770. /**
  76771. * Creates a polygon mesh
  76772. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  76773. * * 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
  76774. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76776. * * 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)
  76777. * * Remember you can only change the shape positions, not their number when updating a polygon
  76778. * @param name defines the name of the mesh
  76779. * @param options defines the options used to create the mesh
  76780. * @param scene defines the hosting scene
  76781. * @param earcutInjection can be used to inject your own earcut reference
  76782. * @returns the polygon mesh
  76783. */
  76784. PolygonBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  76785. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76786. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76787. var shape = options.shape;
  76788. var holes = options.holes || [];
  76789. var depth = options.depth || 0;
  76790. var contours = [];
  76791. var hole = [];
  76792. for (var i = 0; i < shape.length; i++) {
  76793. contours[i] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](shape[i].x, shape[i].z);
  76794. }
  76795. var epsilon = 0.00000001;
  76796. if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
  76797. contours.pop();
  76798. }
  76799. var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_3__["PolygonMeshBuilder"](name, contours, scene, earcutInjection);
  76800. for (var hNb = 0; hNb < holes.length; hNb++) {
  76801. hole = [];
  76802. for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
  76803. hole.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](holes[hNb][hPoint].x, holes[hNb][hPoint].z));
  76804. }
  76805. polygonTriangulation.addHole(hole);
  76806. }
  76807. var polygon = polygonTriangulation.build(options.updatable, depth);
  76808. polygon._originalBuilderSideOrientation = options.sideOrientation;
  76809. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs);
  76810. vertexData.applyToMesh(polygon, options.updatable);
  76811. return polygon;
  76812. };
  76813. /**
  76814. * Creates an extruded polygon mesh, with depth in the Y direction.
  76815. * * 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)
  76816. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  76817. * @param name defines the name of the mesh
  76818. * @param options defines the options used to create the mesh
  76819. * @param scene defines the hosting scene
  76820. * @param earcutInjection can be used to inject your own earcut reference
  76821. * @returns the polygon mesh
  76822. */
  76823. PolygonBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  76824. if (earcutInjection === void 0) { earcutInjection = earcut; }
  76825. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  76826. };
  76827. return PolygonBuilder;
  76828. }());
  76829. /***/ }),
  76830. /***/ "./Meshes/Builders/polyhedronBuilder.ts":
  76831. /*!**********************************************!*\
  76832. !*** ./Meshes/Builders/polyhedronBuilder.ts ***!
  76833. \**********************************************/
  76834. /*! exports provided: PolyhedronBuilder */
  76835. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76836. "use strict";
  76837. __webpack_require__.r(__webpack_exports__);
  76838. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return PolyhedronBuilder; });
  76839. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76840. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76841. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76842. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron = function (options) {
  76843. // provided polyhedron types :
  76844. // 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  76845. // 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)
  76846. var polyhedra = [];
  76847. 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]] };
  76848. 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]] };
  76849. polyhedra[2] = {
  76850. 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]],
  76851. 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]]
  76852. };
  76853. polyhedra[3] = {
  76854. 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]],
  76855. 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]]
  76856. };
  76857. polyhedra[4] = {
  76858. 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]],
  76859. 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]]
  76860. };
  76861. 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]] };
  76862. 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]] };
  76863. 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]] };
  76864. 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]] };
  76865. 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]] };
  76866. 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]] };
  76867. 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]] };
  76868. 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]] };
  76869. 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]] };
  76870. polyhedra[14] = {
  76871. 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]],
  76872. 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]]
  76873. };
  76874. var type = options.type && (options.type < 0 || options.type >= polyhedra.length) ? 0 : options.type || 0;
  76875. var size = options.size;
  76876. var sizeX = options.sizeX || size || 1;
  76877. var sizeY = options.sizeY || size || 1;
  76878. var sizeZ = options.sizeZ || size || 1;
  76879. var data = options.custom || polyhedra[type];
  76880. var nbfaces = data.face.length;
  76881. var faceUV = options.faceUV || new Array(nbfaces);
  76882. var faceColors = options.faceColors;
  76883. var flat = (options.flat === undefined) ? true : options.flat;
  76884. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  76885. var positions = new Array();
  76886. var indices = new Array();
  76887. var normals = new Array();
  76888. var uvs = new Array();
  76889. var colors = new Array();
  76890. var index = 0;
  76891. var faceIdx = 0; // face cursor in the array "indexes"
  76892. var indexes = new Array();
  76893. var i = 0;
  76894. var f = 0;
  76895. var u, v, ang, x, y, tmp;
  76896. // default face colors and UV if undefined
  76897. if (flat) {
  76898. for (f = 0; f < nbfaces; f++) {
  76899. if (faceColors && faceColors[f] === undefined) {
  76900. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  76901. }
  76902. if (faceUV && faceUV[f] === undefined) {
  76903. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  76904. }
  76905. }
  76906. }
  76907. if (!flat) {
  76908. for (i = 0; i < data.vertex.length; i++) {
  76909. positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
  76910. uvs.push(0, 0);
  76911. }
  76912. for (f = 0; f < nbfaces; f++) {
  76913. for (i = 0; i < data.face[f].length - 2; i++) {
  76914. indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
  76915. }
  76916. }
  76917. }
  76918. else {
  76919. for (f = 0; f < nbfaces; f++) {
  76920. var fl = data.face[f].length; // number of vertices of the current face
  76921. ang = 2 * Math.PI / fl;
  76922. x = 0.5 * Math.tan(ang / 2);
  76923. y = 0.5;
  76924. // positions, uvs, colors
  76925. for (i = 0; i < fl; i++) {
  76926. // positions
  76927. 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);
  76928. indexes.push(index);
  76929. index++;
  76930. // uvs
  76931. u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
  76932. v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
  76933. uvs.push(u, v);
  76934. tmp = x * Math.cos(ang) - y * Math.sin(ang);
  76935. y = x * Math.sin(ang) + y * Math.cos(ang);
  76936. x = tmp;
  76937. // colors
  76938. if (faceColors) {
  76939. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  76940. }
  76941. }
  76942. // indices from indexes
  76943. for (i = 0; i < fl - 2; i++) {
  76944. indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
  76945. }
  76946. faceIdx += fl;
  76947. }
  76948. }
  76949. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  76950. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76951. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76952. vertexData.positions = positions;
  76953. vertexData.indices = indices;
  76954. vertexData.normals = normals;
  76955. vertexData.uvs = uvs;
  76956. if (faceColors && flat) {
  76957. vertexData.colors = colors;
  76958. }
  76959. return vertexData;
  76960. };
  76961. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolyhedron = function (name, options, scene) {
  76962. return PolyhedronBuilder.CreatePolyhedron(name, options, scene);
  76963. };
  76964. /**
  76965. * Class containing static functions to help procedurally build meshes
  76966. */
  76967. var PolyhedronBuilder = /** @class */ (function () {
  76968. function PolyhedronBuilder() {
  76969. }
  76970. /**
  76971. * Creates a polyhedron mesh
  76972. * * 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
  76973. * * The parameter `size` (positive float, default 1) sets the polygon size
  76974. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  76975. * * 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`
  76976. * * 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
  76977. * * 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)`)
  76978. * * 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
  76979. * * 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
  76980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76981. * * 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
  76982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76983. * @param name defines the name of the mesh
  76984. * @param options defines the options used to create the mesh
  76985. * @param scene defines the hosting scene
  76986. * @returns the polyhedron mesh
  76987. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  76988. */
  76989. PolyhedronBuilder.CreatePolyhedron = function (name, options, scene) {
  76990. var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  76991. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76992. polyhedron._originalBuilderSideOrientation = options.sideOrientation;
  76993. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron(options);
  76994. vertexData.applyToMesh(polyhedron, options.updatable);
  76995. return polyhedron;
  76996. };
  76997. return PolyhedronBuilder;
  76998. }());
  76999. /***/ }),
  77000. /***/ "./Meshes/Builders/ribbonBuilder.ts":
  77001. /*!******************************************!*\
  77002. !*** ./Meshes/Builders/ribbonBuilder.ts ***!
  77003. \******************************************/
  77004. /*! exports provided: RibbonBuilder */
  77005. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77006. "use strict";
  77007. __webpack_require__.r(__webpack_exports__);
  77008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return RibbonBuilder; });
  77009. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77010. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77011. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  77012. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77013. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  77014. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon = function (options) {
  77015. var pathArray = options.pathArray;
  77016. var closeArray = options.closeArray || false;
  77017. var closePath = options.closePath || false;
  77018. var invertUV = options.invertUV || false;
  77019. var defaultOffset = Math.floor(pathArray[0].length / 2);
  77020. var offset = options.offset || defaultOffset;
  77021. offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
  77022. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  77023. var customUV = options.uvs;
  77024. var customColors = options.colors;
  77025. var positions = [];
  77026. var indices = [];
  77027. var normals = [];
  77028. var uvs = [];
  77029. var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
  77030. var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
  77031. var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
  77032. var vTotalDistance = []; // vTotalDistance[i] : total distance between points i of first and last path from pathArray
  77033. var minlg; // minimal length among all paths from pathArray
  77034. var lg = []; // array of path lengths : nb of vertex per path
  77035. var idx = []; // array of path indexes : index of each path (first vertex) in the total vertex number
  77036. var p; // path iterator
  77037. var i; // point iterator
  77038. var j; // point iterator
  77039. // if single path in pathArray
  77040. if (pathArray.length < 2) {
  77041. var ar1 = [];
  77042. var ar2 = [];
  77043. for (i = 0; i < pathArray[0].length - offset; i++) {
  77044. ar1.push(pathArray[0][i]);
  77045. ar2.push(pathArray[0][i + offset]);
  77046. }
  77047. pathArray = [ar1, ar2];
  77048. }
  77049. // positions and horizontal distances (u)
  77050. var idc = 0;
  77051. var closePathCorr = (closePath) ? 1 : 0; // the final index will be +1 if closePath
  77052. var path;
  77053. var l;
  77054. minlg = pathArray[0].length;
  77055. var vectlg;
  77056. var dist;
  77057. for (p = 0; p < pathArray.length; p++) {
  77058. uTotalDistance[p] = 0;
  77059. us[p] = [0];
  77060. path = pathArray[p];
  77061. l = path.length;
  77062. minlg = (minlg < l) ? minlg : l;
  77063. j = 0;
  77064. while (j < l) {
  77065. positions.push(path[j].x, path[j].y, path[j].z);
  77066. if (j > 0) {
  77067. vectlg = path[j].subtract(path[j - 1]).length();
  77068. dist = vectlg + uTotalDistance[p];
  77069. us[p].push(dist);
  77070. uTotalDistance[p] = dist;
  77071. }
  77072. j++;
  77073. }
  77074. if (closePath) { // an extra hidden vertex is added in the "positions" array
  77075. j--;
  77076. positions.push(path[0].x, path[0].y, path[0].z);
  77077. vectlg = path[j].subtract(path[0]).length();
  77078. dist = vectlg + uTotalDistance[p];
  77079. us[p].push(dist);
  77080. uTotalDistance[p] = dist;
  77081. }
  77082. lg[p] = l + closePathCorr;
  77083. idx[p] = idc;
  77084. idc += (l + closePathCorr);
  77085. }
  77086. // vertical distances (v)
  77087. var path1;
  77088. var path2;
  77089. var vertex1 = null;
  77090. var vertex2 = null;
  77091. for (i = 0; i < minlg + closePathCorr; i++) {
  77092. vTotalDistance[i] = 0;
  77093. vs[i] = [0];
  77094. for (p = 0; p < pathArray.length - 1; p++) {
  77095. path1 = pathArray[p];
  77096. path2 = pathArray[p + 1];
  77097. if (i === minlg) { // closePath
  77098. vertex1 = path1[0];
  77099. vertex2 = path2[0];
  77100. }
  77101. else {
  77102. vertex1 = path1[i];
  77103. vertex2 = path2[i];
  77104. }
  77105. vectlg = vertex2.subtract(vertex1).length();
  77106. dist = vectlg + vTotalDistance[i];
  77107. vs[i].push(dist);
  77108. vTotalDistance[i] = dist;
  77109. }
  77110. if (closeArray && vertex2 && vertex1) {
  77111. path1 = pathArray[p];
  77112. path2 = pathArray[0];
  77113. if (i === minlg) { // closePath
  77114. vertex2 = path2[0];
  77115. }
  77116. vectlg = vertex2.subtract(vertex1).length();
  77117. dist = vectlg + vTotalDistance[i];
  77118. vTotalDistance[i] = dist;
  77119. }
  77120. }
  77121. // uvs
  77122. var u;
  77123. var v;
  77124. if (customUV) {
  77125. for (p = 0; p < customUV.length; p++) {
  77126. uvs.push(customUV[p].x, customUV[p].y);
  77127. }
  77128. }
  77129. else {
  77130. for (p = 0; p < pathArray.length; p++) {
  77131. for (i = 0; i < minlg + closePathCorr; i++) {
  77132. u = (uTotalDistance[p] != 0.0) ? us[p][i] / uTotalDistance[p] : 0.0;
  77133. v = (vTotalDistance[i] != 0.0) ? vs[i][p] / vTotalDistance[i] : 0.0;
  77134. if (invertUV) {
  77135. uvs.push(v, u);
  77136. }
  77137. else {
  77138. uvs.push(u, v);
  77139. }
  77140. }
  77141. }
  77142. }
  77143. // indices
  77144. p = 0; // path index
  77145. var pi = 0; // positions array index
  77146. var l1 = lg[p] - 1; // path1 length
  77147. var l2 = lg[p + 1] - 1; // path2 length
  77148. var min = (l1 < l2) ? l1 : l2; // current path stop index
  77149. var shft = idx[1] - idx[0]; // shift
  77150. var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
  77151. while (pi <= min && p < path1nb) { // stay under min and don't go over next to last path
  77152. // 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
  77153. indices.push(pi, pi + shft, pi + 1);
  77154. indices.push(pi + shft + 1, pi + 1, pi + shft);
  77155. pi += 1;
  77156. if (pi === min) { // if end of one of two consecutive paths reached, go to next existing path
  77157. p++;
  77158. if (p === lg.length - 1) { // last path of pathArray reached <=> closeArray == true
  77159. shft = idx[0] - idx[p];
  77160. l1 = lg[p] - 1;
  77161. l2 = lg[0] - 1;
  77162. }
  77163. else {
  77164. shft = idx[p + 1] - idx[p];
  77165. l1 = lg[p] - 1;
  77166. l2 = lg[p + 1] - 1;
  77167. }
  77168. pi = idx[p];
  77169. min = (l1 < l2) ? l1 + pi : l2 + pi;
  77170. }
  77171. }
  77172. // normals
  77173. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals);
  77174. if (closePath) { // update both the first and last vertex normals to their average value
  77175. var indexFirst = 0;
  77176. var indexLast = 0;
  77177. for (p = 0; p < pathArray.length; p++) {
  77178. indexFirst = idx[p] * 3;
  77179. if (p + 1 < pathArray.length) {
  77180. indexLast = (idx[p + 1] - 1) * 3;
  77181. }
  77182. else {
  77183. indexLast = normals.length - 3;
  77184. }
  77185. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  77186. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  77187. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  77188. normals[indexLast] = normals[indexFirst];
  77189. normals[indexLast + 1] = normals[indexFirst + 1];
  77190. normals[indexLast + 2] = normals[indexFirst + 2];
  77191. }
  77192. }
  77193. // sides
  77194. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77195. // Colors
  77196. var colors = null;
  77197. if (customColors) {
  77198. colors = new Float32Array(customColors.length * 4);
  77199. for (var c = 0; c < customColors.length; c++) {
  77200. colors[c * 4] = customColors[c].r;
  77201. colors[c * 4 + 1] = customColors[c].g;
  77202. colors[c * 4 + 2] = customColors[c].b;
  77203. colors[c * 4 + 3] = customColors[c].a;
  77204. }
  77205. }
  77206. // Result
  77207. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  77208. var positions32 = new Float32Array(positions);
  77209. var normals32 = new Float32Array(normals);
  77210. var uvs32 = new Float32Array(uvs);
  77211. vertexData.indices = indices;
  77212. vertexData.positions = positions32;
  77213. vertexData.normals = normals32;
  77214. vertexData.uvs = uvs32;
  77215. if (colors) {
  77216. vertexData.set(colors, _buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  77217. }
  77218. if (closePath) {
  77219. vertexData._idx = idx;
  77220. }
  77221. return vertexData;
  77222. };
  77223. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  77224. if (closeArray === void 0) { closeArray = false; }
  77225. if (updatable === void 0) { updatable = false; }
  77226. return RibbonBuilder.CreateRibbon(name, {
  77227. pathArray: pathArray,
  77228. closeArray: closeArray,
  77229. closePath: closePath,
  77230. offset: offset,
  77231. updatable: updatable,
  77232. sideOrientation: sideOrientation,
  77233. instance: instance
  77234. }, scene);
  77235. };
  77236. /**
  77237. * Class containing static functions to help procedurally build meshes
  77238. */
  77239. var RibbonBuilder = /** @class */ (function () {
  77240. function RibbonBuilder() {
  77241. }
  77242. /**
  77243. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  77244. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  77245. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  77246. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  77247. * * 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
  77248. * * 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
  77249. * * 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
  77250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77251. * * 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
  77252. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  77253. * * 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
  77254. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  77255. * * 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
  77256. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  77257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77258. * @param name defines the name of the mesh
  77259. * @param options defines the options used to create the mesh
  77260. * @param scene defines the hosting scene
  77261. * @returns the ribbon mesh
  77262. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  77263. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77264. */
  77265. RibbonBuilder.CreateRibbon = function (name, options, scene) {
  77266. if (scene === void 0) { scene = null; }
  77267. var pathArray = options.pathArray;
  77268. var closeArray = options.closeArray;
  77269. var closePath = options.closePath;
  77270. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77271. var instance = options.instance;
  77272. var updatable = options.updatable;
  77273. if (instance) { // existing ribbon instance update
  77274. // positionFunction : ribbon case
  77275. // only pathArray and sideOrientation parameters are taken into account for positions update
  77276. var minimum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0].setAll(Number.MAX_VALUE);
  77277. var maximum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1].setAll(-Number.MAX_VALUE);
  77278. var positionFunction = function (positions) {
  77279. var minlg = pathArray[0].length;
  77280. var mesh = instance;
  77281. var i = 0;
  77282. var ns = (mesh._originalBuilderSideOrientation === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DOUBLESIDE) ? 2 : 1;
  77283. for (var si = 1; si <= ns; ++si) {
  77284. for (var p = 0; p < pathArray.length; ++p) {
  77285. var path = pathArray[p];
  77286. var l = path.length;
  77287. minlg = (minlg < l) ? minlg : l;
  77288. for (var j = 0; j < minlg; ++j) {
  77289. var pathPoint = path[j];
  77290. positions[i] = pathPoint.x;
  77291. positions[i + 1] = pathPoint.y;
  77292. positions[i + 2] = pathPoint.z;
  77293. minimum_1.minimizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  77294. maximum_1.maximizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  77295. i += 3;
  77296. }
  77297. if (mesh._creationDataStorage && mesh._creationDataStorage.closePath) {
  77298. var pathPoint = path[0];
  77299. positions[i] = pathPoint.x;
  77300. positions[i + 1] = pathPoint.y;
  77301. positions[i + 2] = pathPoint.z;
  77302. i += 3;
  77303. }
  77304. }
  77305. }
  77306. };
  77307. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  77308. positionFunction(positions);
  77309. if (instance._boundingInfo) {
  77310. instance._boundingInfo.reConstruct(minimum_1, maximum_1, instance._worldMatrix);
  77311. }
  77312. else {
  77313. instance._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](minimum_1, maximum_1, instance._worldMatrix);
  77314. }
  77315. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positions, false, false);
  77316. if (options.colors) {
  77317. var colors = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  77318. for (var c = 0, colorIndex = 0; c < options.colors.length; c++, colorIndex += 4) {
  77319. var color = options.colors[c];
  77320. colors[colorIndex] = color.r;
  77321. colors[colorIndex + 1] = color.g;
  77322. colors[colorIndex + 2] = color.b;
  77323. colors[colorIndex + 3] = color.a;
  77324. }
  77325. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colors, false, false);
  77326. }
  77327. if (options.uvs) {
  77328. var uvs = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  77329. for (var i = 0; i < options.uvs.length; i++) {
  77330. uvs[i * 2] = options.uvs[i].x;
  77331. uvs[i * 2 + 1] = options.uvs[i].y;
  77332. }
  77333. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvs, false, false);
  77334. }
  77335. if (!instance.areNormalsFrozen || instance.isFacetDataEnabled) {
  77336. var indices = instance.getIndices();
  77337. var normals = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  77338. var params = instance.isFacetDataEnabled ? instance.getFacetDataParameters() : null;
  77339. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals, params);
  77340. if (instance._creationDataStorage && instance._creationDataStorage.closePath) {
  77341. var indexFirst = 0;
  77342. var indexLast = 0;
  77343. for (var p = 0; p < pathArray.length; p++) {
  77344. indexFirst = instance._creationDataStorage.idx[p] * 3;
  77345. if (p + 1 < pathArray.length) {
  77346. indexLast = (instance._creationDataStorage.idx[p + 1] - 1) * 3;
  77347. }
  77348. else {
  77349. indexLast = normals.length - 3;
  77350. }
  77351. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  77352. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  77353. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  77354. normals[indexLast] = normals[indexFirst];
  77355. normals[indexLast + 1] = normals[indexFirst + 1];
  77356. normals[indexLast + 2] = normals[indexFirst + 2];
  77357. }
  77358. }
  77359. if (!(instance.areNormalsFrozen)) {
  77360. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normals, false, false);
  77361. }
  77362. }
  77363. return instance;
  77364. }
  77365. else { // new ribbon creation
  77366. var ribbon = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77367. ribbon._originalBuilderSideOrientation = sideOrientation;
  77368. ribbon._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  77369. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon(options);
  77370. if (closePath) {
  77371. ribbon._creationDataStorage.idx = vertexData._idx;
  77372. }
  77373. ribbon._creationDataStorage.closePath = closePath;
  77374. ribbon._creationDataStorage.closeArray = closeArray;
  77375. vertexData.applyToMesh(ribbon, updatable);
  77376. return ribbon;
  77377. }
  77378. };
  77379. return RibbonBuilder;
  77380. }());
  77381. /***/ }),
  77382. /***/ "./Meshes/Builders/shapeBuilder.ts":
  77383. /*!*****************************************!*\
  77384. !*** ./Meshes/Builders/shapeBuilder.ts ***!
  77385. \*****************************************/
  77386. /*! exports provided: ShapeBuilder */
  77387. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77388. "use strict";
  77389. __webpack_require__.r(__webpack_exports__);
  77390. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return ShapeBuilder; });
  77391. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77392. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77393. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  77394. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  77395. if (scene === void 0) { scene = null; }
  77396. var options = {
  77397. shape: shape,
  77398. path: path,
  77399. scale: scale,
  77400. rotation: rotation,
  77401. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  77402. sideOrientation: sideOrientation,
  77403. instance: instance,
  77404. updatable: updatable
  77405. };
  77406. return ShapeBuilder.ExtrudeShape(name, options, scene);
  77407. };
  77408. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  77409. var options = {
  77410. shape: shape,
  77411. path: path,
  77412. scaleFunction: scaleFunction,
  77413. rotationFunction: rotationFunction,
  77414. ribbonCloseArray: ribbonCloseArray,
  77415. ribbonClosePath: ribbonClosePath,
  77416. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  77417. sideOrientation: sideOrientation,
  77418. instance: instance,
  77419. updatable: updatable
  77420. };
  77421. return ShapeBuilder.ExtrudeShapeCustom(name, options, scene);
  77422. };
  77423. /**
  77424. * Class containing static functions to help procedurally build meshes
  77425. */
  77426. var ShapeBuilder = /** @class */ (function () {
  77427. function ShapeBuilder() {
  77428. }
  77429. /**
  77430. * 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.
  77431. * * 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.
  77432. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  77433. * * 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.
  77434. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  77435. * * 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
  77436. * * 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
  77437. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  77438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77439. * * 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
  77440. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  77441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77442. * @param name defines the name of the mesh
  77443. * @param options defines the options used to create the mesh
  77444. * @param scene defines the hosting scene
  77445. * @returns the extruded shape mesh
  77446. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77448. */
  77449. ShapeBuilder.ExtrudeShape = function (name, options, scene) {
  77450. if (scene === void 0) { scene = null; }
  77451. var path = options.path;
  77452. var shape = options.shape;
  77453. var scale = options.scale || 1;
  77454. var rotation = options.rotation || 0;
  77455. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  77456. var updatable = options.updatable;
  77457. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77458. var instance = options.instance || null;
  77459. var invertUV = options.invertUV || false;
  77460. 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);
  77461. };
  77462. /**
  77463. * Creates an custom extruded shape mesh.
  77464. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  77465. * * 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.
  77466. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  77467. * * 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
  77468. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  77469. * * 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
  77470. * * It must returns a float value that will be the scale value applied to the shape on each path point
  77471. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77472. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  77473. * * 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
  77474. * * 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
  77475. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  77476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77477. * * 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
  77478. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  77479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77480. * @param name defines the name of the mesh
  77481. * @param options defines the options used to create the mesh
  77482. * @param scene defines the hosting scene
  77483. * @returns the custom extruded shape mesh
  77484. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  77485. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77487. */
  77488. ShapeBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  77489. var path = options.path;
  77490. var shape = options.shape;
  77491. var scaleFunction = options.scaleFunction || (function () { return 1; });
  77492. var rotationFunction = options.rotationFunction || (function () { return 0; });
  77493. var ribbonCloseArray = options.ribbonCloseArray || false;
  77494. var ribbonClosePath = options.ribbonClosePath || false;
  77495. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  77496. var updatable = options.updatable;
  77497. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77498. var instance = options.instance;
  77499. var invertUV = options.invertUV || false;
  77500. 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);
  77501. };
  77502. ShapeBuilder._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
  77503. // extrusion geometry
  77504. var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
  77505. var tangents = path3D.getTangents();
  77506. var normals = path3D.getNormals();
  77507. var binormals = path3D.getBinormals();
  77508. var distances = path3D.getDistances();
  77509. var angle = 0;
  77510. var returnScale = function () { return scale !== null ? scale : 1; };
  77511. var returnRotation = function () { return rotation !== null ? rotation : 0; };
  77512. var rotate = custom && rotateFunction ? rotateFunction : returnRotation;
  77513. var scl = custom && scaleFunction ? scaleFunction : returnScale;
  77514. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  77515. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  77516. for (var i = 0; i < curve.length; i++) {
  77517. var shapePath = new Array();
  77518. var angleStep = rotate(i, distances[i]);
  77519. var scaleRatio = scl(i, distances[i]);
  77520. for (var p = 0; p < shape.length; p++) {
  77521. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], angle, rotationMatrix);
  77522. var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
  77523. var rotated = shapePath[p] ? shapePath[p] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77524. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(planed, rotationMatrix, rotated);
  77525. rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
  77526. shapePath[p] = rotated;
  77527. }
  77528. shapePaths[index] = shapePath;
  77529. angle += angleStep;
  77530. index++;
  77531. }
  77532. // cap
  77533. var capPath = function (shapePath) {
  77534. var pointCap = Array();
  77535. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77536. var i;
  77537. for (i = 0; i < shapePath.length; i++) {
  77538. barycenter.addInPlace(shapePath[i]);
  77539. }
  77540. barycenter.scaleInPlace(1.0 / shapePath.length);
  77541. for (i = 0; i < shapePath.length; i++) {
  77542. pointCap.push(barycenter);
  77543. }
  77544. return pointCap;
  77545. };
  77546. switch (cap) {
  77547. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  77548. break;
  77549. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  77550. shapePaths[0] = capPath(shapePaths[2]);
  77551. shapePaths[1] = shapePaths[2];
  77552. break;
  77553. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  77554. shapePaths[index] = shapePaths[index - 1];
  77555. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  77556. break;
  77557. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  77558. shapePaths[0] = capPath(shapePaths[2]);
  77559. shapePaths[1] = shapePaths[2];
  77560. shapePaths[index] = shapePaths[index - 1];
  77561. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  77562. break;
  77563. default:
  77564. break;
  77565. }
  77566. return shapePaths;
  77567. };
  77568. var path3D;
  77569. var pathArray;
  77570. if (instance) { // instance update
  77571. var storage = instance._creationDataStorage;
  77572. path3D = storage.path3D.update(curve);
  77573. pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
  77574. instance = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon("", pathArray, false, false, 0, scene || undefined, false, 0, instance);
  77575. return instance;
  77576. }
  77577. // extruded shape creation
  77578. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](curve);
  77579. var newShapePaths = new Array();
  77580. cap = (cap < 0 || cap > 3) ? 0 : cap;
  77581. pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
  77582. 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);
  77583. extrudedGeneric._creationDataStorage.pathArray = pathArray;
  77584. extrudedGeneric._creationDataStorage.path3D = path3D;
  77585. extrudedGeneric._creationDataStorage.cap = cap;
  77586. return extrudedGeneric;
  77587. };
  77588. return ShapeBuilder;
  77589. }());
  77590. /***/ }),
  77591. /***/ "./Meshes/Builders/sphereBuilder.ts":
  77592. /*!******************************************!*\
  77593. !*** ./Meshes/Builders/sphereBuilder.ts ***!
  77594. \******************************************/
  77595. /*! exports provided: SphereBuilder */
  77596. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77597. "use strict";
  77598. __webpack_require__.r(__webpack_exports__);
  77599. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return SphereBuilder; });
  77600. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77601. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77602. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77603. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere = function (options) {
  77604. var segments = options.segments || 32;
  77605. var diameterX = options.diameterX || options.diameter || 1;
  77606. var diameterY = options.diameterY || options.diameter || 1;
  77607. var diameterZ = options.diameterZ || options.diameter || 1;
  77608. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  77609. var slice = options.slice && (options.slice <= 0) ? 1.0 : options.slice || 1.0;
  77610. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77611. var radius = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](diameterX / 2, diameterY / 2, diameterZ / 2);
  77612. var totalZRotationSteps = 2 + segments;
  77613. var totalYRotationSteps = 2 * totalZRotationSteps;
  77614. var indices = [];
  77615. var positions = [];
  77616. var normals = [];
  77617. var uvs = [];
  77618. for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
  77619. var normalizedZ = zRotationStep / totalZRotationSteps;
  77620. var angleZ = normalizedZ * Math.PI * slice;
  77621. for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
  77622. var normalizedY = yRotationStep / totalYRotationSteps;
  77623. var angleY = normalizedY * Math.PI * 2 * arc;
  77624. var rotationZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationZ(-angleZ);
  77625. var rotationY = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(angleY);
  77626. var afterRotZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), rotationZ);
  77627. var complete = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(afterRotZ, rotationY);
  77628. var vertex = complete.multiply(radius);
  77629. var normal = complete.divide(radius).normalize();
  77630. positions.push(vertex.x, vertex.y, vertex.z);
  77631. normals.push(normal.x, normal.y, normal.z);
  77632. uvs.push(normalizedY, normalizedZ);
  77633. }
  77634. if (zRotationStep > 0) {
  77635. var verticesCount = positions.length / 3;
  77636. for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1); (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
  77637. indices.push((firstIndex));
  77638. indices.push((firstIndex + 1));
  77639. indices.push(firstIndex + totalYRotationSteps + 1);
  77640. indices.push((firstIndex + totalYRotationSteps + 1));
  77641. indices.push((firstIndex + 1));
  77642. indices.push((firstIndex + totalYRotationSteps + 2));
  77643. }
  77644. }
  77645. }
  77646. // Sides
  77647. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77648. // Result
  77649. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77650. vertexData.indices = indices;
  77651. vertexData.positions = positions;
  77652. vertexData.normals = normals;
  77653. vertexData.uvs = uvs;
  77654. return vertexData;
  77655. };
  77656. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  77657. var options = {
  77658. segments: segments,
  77659. diameterX: diameter,
  77660. diameterY: diameter,
  77661. diameterZ: diameter,
  77662. sideOrientation: sideOrientation,
  77663. updatable: updatable
  77664. };
  77665. return SphereBuilder.CreateSphere(name, options, scene);
  77666. };
  77667. /**
  77668. * Class containing static functions to help procedurally build meshes
  77669. */
  77670. var SphereBuilder = /** @class */ (function () {
  77671. function SphereBuilder() {
  77672. }
  77673. /**
  77674. * Creates a sphere mesh
  77675. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  77676. * * 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`)
  77677. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  77678. * * 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
  77679. * * 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)
  77680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77681. * * 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
  77682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77683. * @param name defines the name of the mesh
  77684. * @param options defines the options used to create the mesh
  77685. * @param scene defines the hosting scene
  77686. * @returns the sphere mesh
  77687. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  77688. */
  77689. SphereBuilder.CreateSphere = function (name, options, scene) {
  77690. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77691. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77692. sphere._originalBuilderSideOrientation = options.sideOrientation;
  77693. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere(options);
  77694. vertexData.applyToMesh(sphere, options.updatable);
  77695. return sphere;
  77696. };
  77697. return SphereBuilder;
  77698. }());
  77699. /***/ }),
  77700. /***/ "./Meshes/Builders/torusBuilder.ts":
  77701. /*!*****************************************!*\
  77702. !*** ./Meshes/Builders/torusBuilder.ts ***!
  77703. \*****************************************/
  77704. /*! exports provided: TorusBuilder */
  77705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77706. "use strict";
  77707. __webpack_require__.r(__webpack_exports__);
  77708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return TorusBuilder; });
  77709. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77710. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77711. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77712. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus = function (options) {
  77713. var indices = [];
  77714. var positions = [];
  77715. var normals = [];
  77716. var uvs = [];
  77717. var diameter = options.diameter || 1;
  77718. var thickness = options.thickness || 0.5;
  77719. var tessellation = options.tessellation || 16;
  77720. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77721. var stride = tessellation + 1;
  77722. for (var i = 0; i <= tessellation; i++) {
  77723. var u = i / tessellation;
  77724. var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
  77725. 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));
  77726. for (var j = 0; j <= tessellation; j++) {
  77727. var v = 1 - j / tessellation;
  77728. var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
  77729. var dx = Math.cos(innerAngle);
  77730. var dy = Math.sin(innerAngle);
  77731. // Create a vertex.
  77732. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](dx, dy, 0);
  77733. var position = normal.scale(thickness / 2);
  77734. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](u, v);
  77735. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(position, transform);
  77736. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, transform);
  77737. positions.push(position.x, position.y, position.z);
  77738. normals.push(normal.x, normal.y, normal.z);
  77739. uvs.push(textureCoordinate.x, textureCoordinate.y);
  77740. // And create indices for two triangles.
  77741. var nextI = (i + 1) % stride;
  77742. var nextJ = (j + 1) % stride;
  77743. indices.push(i * stride + j);
  77744. indices.push(i * stride + nextJ);
  77745. indices.push(nextI * stride + j);
  77746. indices.push(i * stride + nextJ);
  77747. indices.push(nextI * stride + nextJ);
  77748. indices.push(nextI * stride + j);
  77749. }
  77750. }
  77751. // Sides
  77752. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77753. // Result
  77754. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77755. vertexData.indices = indices;
  77756. vertexData.positions = positions;
  77757. vertexData.normals = normals;
  77758. vertexData.uvs = uvs;
  77759. return vertexData;
  77760. };
  77761. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  77762. var options = {
  77763. diameter: diameter,
  77764. thickness: thickness,
  77765. tessellation: tessellation,
  77766. sideOrientation: sideOrientation,
  77767. updatable: updatable
  77768. };
  77769. return TorusBuilder.CreateTorus(name, options, scene);
  77770. };
  77771. /**
  77772. * Class containing static functions to help procedurally build meshes
  77773. */
  77774. var TorusBuilder = /** @class */ (function () {
  77775. function TorusBuilder() {
  77776. }
  77777. /**
  77778. * Creates a torus mesh
  77779. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  77780. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  77781. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  77782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77783. * * 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
  77784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77785. * @param name defines the name of the mesh
  77786. * @param options defines the options used to create the mesh
  77787. * @param scene defines the hosting scene
  77788. * @returns the torus mesh
  77789. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  77790. */
  77791. TorusBuilder.CreateTorus = function (name, options, scene) {
  77792. var torus = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77793. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77794. torus._originalBuilderSideOrientation = options.sideOrientation;
  77795. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus(options);
  77796. vertexData.applyToMesh(torus, options.updatable);
  77797. return torus;
  77798. };
  77799. return TorusBuilder;
  77800. }());
  77801. /***/ }),
  77802. /***/ "./Meshes/Builders/torusKnotBuilder.ts":
  77803. /*!*********************************************!*\
  77804. !*** ./Meshes/Builders/torusKnotBuilder.ts ***!
  77805. \*********************************************/
  77806. /*! exports provided: TorusKnotBuilder */
  77807. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77808. "use strict";
  77809. __webpack_require__.r(__webpack_exports__);
  77810. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return TorusKnotBuilder; });
  77811. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77812. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77813. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77814. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot = function (options) {
  77815. var indices = new Array();
  77816. var positions = new Array();
  77817. var normals = new Array();
  77818. var uvs = new Array();
  77819. var radius = options.radius || 2;
  77820. var tube = options.tube || 0.5;
  77821. var radialSegments = options.radialSegments || 32;
  77822. var tubularSegments = options.tubularSegments || 32;
  77823. var p = options.p || 2;
  77824. var q = options.q || 3;
  77825. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77826. // Helper
  77827. var getPos = function (angle) {
  77828. var cu = Math.cos(angle);
  77829. var su = Math.sin(angle);
  77830. var quOverP = q / p * angle;
  77831. var cs = Math.cos(quOverP);
  77832. var tx = radius * (2 + cs) * 0.5 * cu;
  77833. var ty = radius * (2 + cs) * su * 0.5;
  77834. var tz = radius * Math.sin(quOverP) * 0.5;
  77835. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](tx, ty, tz);
  77836. };
  77837. // Vertices
  77838. var i;
  77839. var j;
  77840. for (i = 0; i <= radialSegments; i++) {
  77841. var modI = i % radialSegments;
  77842. var u = modI / radialSegments * 2 * p * Math.PI;
  77843. var p1 = getPos(u);
  77844. var p2 = getPos(u + 0.01);
  77845. var tang = p2.subtract(p1);
  77846. var n = p2.add(p1);
  77847. var bitan = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(tang, n);
  77848. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(bitan, tang);
  77849. bitan.normalize();
  77850. n.normalize();
  77851. for (j = 0; j < tubularSegments; j++) {
  77852. var modJ = j % tubularSegments;
  77853. var v = modJ / tubularSegments * 2 * Math.PI;
  77854. var cx = -tube * Math.cos(v);
  77855. var cy = tube * Math.sin(v);
  77856. positions.push(p1.x + cx * n.x + cy * bitan.x);
  77857. positions.push(p1.y + cx * n.y + cy * bitan.y);
  77858. positions.push(p1.z + cx * n.z + cy * bitan.z);
  77859. uvs.push(i / radialSegments);
  77860. uvs.push(j / tubularSegments);
  77861. }
  77862. }
  77863. for (i = 0; i < radialSegments; i++) {
  77864. for (j = 0; j < tubularSegments; j++) {
  77865. var jNext = (j + 1) % tubularSegments;
  77866. var a = i * tubularSegments + j;
  77867. var b = (i + 1) * tubularSegments + j;
  77868. var c = (i + 1) * tubularSegments + jNext;
  77869. var d = i * tubularSegments + jNext;
  77870. indices.push(d);
  77871. indices.push(b);
  77872. indices.push(a);
  77873. indices.push(d);
  77874. indices.push(c);
  77875. indices.push(b);
  77876. }
  77877. }
  77878. // Normals
  77879. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  77880. // Sides
  77881. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77882. // Result
  77883. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77884. vertexData.indices = indices;
  77885. vertexData.positions = positions;
  77886. vertexData.normals = normals;
  77887. vertexData.uvs = uvs;
  77888. return vertexData;
  77889. };
  77890. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  77891. var options = {
  77892. radius: radius,
  77893. tube: tube,
  77894. radialSegments: radialSegments,
  77895. tubularSegments: tubularSegments,
  77896. p: p,
  77897. q: q,
  77898. sideOrientation: sideOrientation,
  77899. updatable: updatable
  77900. };
  77901. return TorusKnotBuilder.CreateTorusKnot(name, options, scene);
  77902. };
  77903. /**
  77904. * Class containing static functions to help procedurally build meshes
  77905. */
  77906. var TorusKnotBuilder = /** @class */ (function () {
  77907. function TorusKnotBuilder() {
  77908. }
  77909. /**
  77910. * Creates a torus knot mesh
  77911. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  77912. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  77913. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  77914. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  77915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77916. * * 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
  77917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77918. * @param name defines the name of the mesh
  77919. * @param options defines the options used to create the mesh
  77920. * @param scene defines the hosting scene
  77921. * @returns the torus knot mesh
  77922. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  77923. */
  77924. TorusKnotBuilder.CreateTorusKnot = function (name, options, scene) {
  77925. var torusKnot = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77926. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77927. torusKnot._originalBuilderSideOrientation = options.sideOrientation;
  77928. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot(options);
  77929. vertexData.applyToMesh(torusKnot, options.updatable);
  77930. return torusKnot;
  77931. };
  77932. return TorusKnotBuilder;
  77933. }());
  77934. /***/ }),
  77935. /***/ "./Meshes/Builders/tubeBuilder.ts":
  77936. /*!****************************************!*\
  77937. !*** ./Meshes/Builders/tubeBuilder.ts ***!
  77938. \****************************************/
  77939. /*! exports provided: TubeBuilder */
  77940. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77941. "use strict";
  77942. __webpack_require__.r(__webpack_exports__);
  77943. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return TubeBuilder; });
  77944. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77945. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77946. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  77947. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  77948. var options = {
  77949. path: path,
  77950. radius: radius,
  77951. tessellation: tessellation,
  77952. radiusFunction: radiusFunction,
  77953. arc: 1,
  77954. cap: cap,
  77955. updatable: updatable,
  77956. sideOrientation: sideOrientation,
  77957. instance: instance
  77958. };
  77959. return TubeBuilder.CreateTube(name, options, scene);
  77960. };
  77961. /**
  77962. * Class containing static functions to help procedurally build meshes
  77963. */
  77964. var TubeBuilder = /** @class */ (function () {
  77965. function TubeBuilder() {
  77966. }
  77967. /**
  77968. * Creates a tube mesh.
  77969. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  77970. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  77971. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  77972. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  77973. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  77974. * * 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)
  77975. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  77976. * * 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
  77977. * * 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
  77978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77979. * * 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
  77980. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  77981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77982. * @param name defines the name of the mesh
  77983. * @param options defines the options used to create the mesh
  77984. * @param scene defines the hosting scene
  77985. * @returns the tube mesh
  77986. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77987. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  77988. */
  77989. TubeBuilder.CreateTube = function (name, options, scene) {
  77990. var path = options.path;
  77991. var instance = options.instance;
  77992. var radius = 1.0;
  77993. if (options.radius !== undefined) {
  77994. radius = options.radius;
  77995. }
  77996. else if (instance) {
  77997. radius = instance._creationDataStorage.radius;
  77998. }
  77999. var tessellation = options.tessellation || 64 | 0;
  78000. var radiusFunction = options.radiusFunction || null;
  78001. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  78002. var invertUV = options.invertUV || false;
  78003. var updatable = options.updatable;
  78004. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78005. options.arc = options.arc && (options.arc <= 0.0 || options.arc > 1.0) ? 1.0 : options.arc || 1.0;
  78006. // tube geometry
  78007. var tubePathArray = function (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) {
  78008. var tangents = path3D.getTangents();
  78009. var normals = path3D.getNormals();
  78010. var distances = path3D.getDistances();
  78011. var pi2 = Math.PI * 2;
  78012. var step = pi2 / tessellation * arc;
  78013. var returnRadius = function () { return radius; };
  78014. var radiusFunctionFinal = radiusFunction || returnRadius;
  78015. var circlePath;
  78016. var rad;
  78017. var normal;
  78018. var rotated;
  78019. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  78020. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  78021. for (var i = 0; i < path.length; i++) {
  78022. rad = radiusFunctionFinal(i, distances[i]); // current radius
  78023. circlePath = Array(); // current circle array
  78024. normal = normals[i]; // current normal
  78025. for (var t = 0; t < tessellation; t++) {
  78026. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], step * t, rotationMatrix);
  78027. rotated = circlePath[t] ? circlePath[t] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78028. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(normal, rotationMatrix, rotated);
  78029. rotated.scaleInPlace(rad).addInPlace(path[i]);
  78030. circlePath[t] = rotated;
  78031. }
  78032. circlePaths[index] = circlePath;
  78033. index++;
  78034. }
  78035. // cap
  78036. var capPath = function (nbPoints, pathIndex) {
  78037. var pointCap = Array();
  78038. for (var i = 0; i < nbPoints; i++) {
  78039. pointCap.push(path[pathIndex]);
  78040. }
  78041. return pointCap;
  78042. };
  78043. switch (cap) {
  78044. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  78045. break;
  78046. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  78047. circlePaths[0] = capPath(tessellation, 0);
  78048. circlePaths[1] = circlePaths[2].slice(0);
  78049. break;
  78050. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  78051. circlePaths[index] = circlePaths[index - 1].slice(0);
  78052. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  78053. break;
  78054. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  78055. circlePaths[0] = capPath(tessellation, 0);
  78056. circlePaths[1] = circlePaths[2].slice(0);
  78057. circlePaths[index] = circlePaths[index - 1].slice(0);
  78058. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  78059. break;
  78060. default:
  78061. break;
  78062. }
  78063. return circlePaths;
  78064. };
  78065. var path3D;
  78066. var pathArray;
  78067. if (instance) { // tube update
  78068. var storage = instance._creationDataStorage;
  78069. var arc = options.arc || storage.arc;
  78070. path3D = storage.path3D.update(path);
  78071. pathArray = tubePathArray(path, path3D, storage.pathArray, radius, storage.tessellation, radiusFunction, storage.cap, arc);
  78072. instance = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon("", { pathArray: pathArray, instance: instance });
  78073. // Update mode, no need to recreate the storage.
  78074. storage.path3D = path3D;
  78075. storage.pathArray = pathArray;
  78076. storage.arc = arc;
  78077. storage.radius = radius;
  78078. return instance;
  78079. }
  78080. // tube creation
  78081. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](path);
  78082. var newPathArray = new Array();
  78083. cap = (cap < 0 || cap > 3) ? 0 : cap;
  78084. pathArray = tubePathArray(path, path3D, newPathArray, radius, tessellation, radiusFunction, cap, options.arc);
  78085. 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);
  78086. tube._creationDataStorage.pathArray = pathArray;
  78087. tube._creationDataStorage.path3D = path3D;
  78088. tube._creationDataStorage.tessellation = tessellation;
  78089. tube._creationDataStorage.cap = cap;
  78090. tube._creationDataStorage.arc = options.arc;
  78091. tube._creationDataStorage.radius = radius;
  78092. return tube;
  78093. };
  78094. return TubeBuilder;
  78095. }());
  78096. /***/ }),
  78097. /***/ "./Meshes/Compression/dracoCompression.ts":
  78098. /*!************************************************!*\
  78099. !*** ./Meshes/Compression/dracoCompression.ts ***!
  78100. \************************************************/
  78101. /*! exports provided: DracoCompression */
  78102. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78103. "use strict";
  78104. __webpack_require__.r(__webpack_exports__);
  78105. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return DracoCompression; });
  78106. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  78107. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78108. /**
  78109. * Draco compression (https://google.github.io/draco/)
  78110. *
  78111. * This class wraps the Draco module.
  78112. *
  78113. * **Encoder**
  78114. *
  78115. * The encoder is not currently implemented.
  78116. *
  78117. * **Decoder**
  78118. *
  78119. * 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.
  78120. *
  78121. * To update the configuration, use the following code:
  78122. * ```javascript
  78123. * DracoCompression.Configuration = {
  78124. * decoder: {
  78125. * wasmUrl: "<url to the WebAssembly library>",
  78126. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  78127. * fallbackUrl: "<url to the fallback JavaScript library>",
  78128. * }
  78129. * };
  78130. * ```
  78131. *
  78132. * 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.
  78133. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  78134. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  78135. *
  78136. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  78137. * ```javascript
  78138. * var dracoCompression = new DracoCompression();
  78139. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  78140. * [VertexBuffer.PositionKind]: 0
  78141. * });
  78142. * ```
  78143. *
  78144. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  78145. */
  78146. var DracoCompression = /** @class */ (function () {
  78147. /**
  78148. * Constructor
  78149. */
  78150. function DracoCompression() {
  78151. }
  78152. Object.defineProperty(DracoCompression, "DecoderAvailable", {
  78153. /**
  78154. * Returns true if the decoder is available.
  78155. */
  78156. get: function () {
  78157. if (typeof DracoDecoderModule !== "undefined") {
  78158. return true;
  78159. }
  78160. var decoder = DracoCompression.Configuration.decoder;
  78161. if (decoder) {
  78162. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  78163. return true;
  78164. }
  78165. if (decoder.fallbackUrl) {
  78166. return true;
  78167. }
  78168. }
  78169. return false;
  78170. },
  78171. enumerable: true,
  78172. configurable: true
  78173. });
  78174. /**
  78175. * Stop all async operations and release resources.
  78176. */
  78177. DracoCompression.prototype.dispose = function () {
  78178. };
  78179. /**
  78180. * Decode Draco compressed mesh data to vertex data.
  78181. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  78182. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  78183. * @returns A promise that resolves with the decoded vertex data
  78184. */
  78185. DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
  78186. var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
  78187. return DracoCompression._GetDecoderModule().then(function (wrappedModule) {
  78188. var module = wrappedModule.module;
  78189. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  78190. var buffer = new module.DecoderBuffer();
  78191. buffer.Init(dataView, dataView.byteLength);
  78192. var decoder = new module.Decoder();
  78193. var geometry;
  78194. var status;
  78195. try {
  78196. var type = decoder.GetEncodedGeometryType(buffer);
  78197. switch (type) {
  78198. case module.TRIANGULAR_MESH:
  78199. geometry = new module.Mesh();
  78200. status = decoder.DecodeBufferToMesh(buffer, geometry);
  78201. break;
  78202. case module.POINT_CLOUD:
  78203. geometry = new module.PointCloud();
  78204. status = decoder.DecodeBufferToPointCloud(buffer, geometry);
  78205. break;
  78206. default:
  78207. throw new Error("Invalid geometry type " + type);
  78208. }
  78209. if (!status.ok() || !geometry.ptr) {
  78210. throw new Error(status.error_msg());
  78211. }
  78212. var numPoints = geometry.num_points();
  78213. if (type === module.TRIANGULAR_MESH) {
  78214. var numFaces = geometry.num_faces();
  78215. var faceIndices = new module.DracoInt32Array();
  78216. try {
  78217. var indices = new Uint32Array(numFaces * 3);
  78218. for (var i = 0; i < numFaces; i++) {
  78219. decoder.GetFaceFromMesh(geometry, i, faceIndices);
  78220. var offset = i * 3;
  78221. indices[offset + 0] = faceIndices.GetValue(0);
  78222. indices[offset + 1] = faceIndices.GetValue(1);
  78223. indices[offset + 2] = faceIndices.GetValue(2);
  78224. }
  78225. vertexData.indices = indices;
  78226. }
  78227. finally {
  78228. module.destroy(faceIndices);
  78229. }
  78230. }
  78231. for (var kind in attributes) {
  78232. var uniqueId = attributes[kind];
  78233. var attribute = decoder.GetAttributeByUniqueId(geometry, uniqueId);
  78234. var dracoData = new module.DracoFloat32Array();
  78235. try {
  78236. decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
  78237. var babylonData = new Float32Array(numPoints * attribute.num_components());
  78238. for (var i = 0; i < babylonData.length; i++) {
  78239. babylonData[i] = dracoData.GetValue(i);
  78240. }
  78241. vertexData.set(babylonData, kind);
  78242. }
  78243. finally {
  78244. module.destroy(dracoData);
  78245. }
  78246. }
  78247. }
  78248. finally {
  78249. if (geometry) {
  78250. module.destroy(geometry);
  78251. }
  78252. module.destroy(decoder);
  78253. module.destroy(buffer);
  78254. }
  78255. return vertexData;
  78256. });
  78257. };
  78258. DracoCompression._GetDecoderModule = function () {
  78259. if (!DracoCompression._DecoderModulePromise) {
  78260. var promise = null;
  78261. var config_1 = {};
  78262. if (typeof DracoDecoderModule !== "undefined") {
  78263. promise = Promise.resolve();
  78264. }
  78265. else {
  78266. var decoder = DracoCompression.Configuration.decoder;
  78267. if (decoder) {
  78268. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  78269. promise = Promise.all([
  78270. DracoCompression._LoadScriptAsync(decoder.wasmUrl),
  78271. DracoCompression._LoadFileAsync(decoder.wasmBinaryUrl).then(function (data) {
  78272. config_1.wasmBinary = data;
  78273. })
  78274. ]);
  78275. }
  78276. else if (decoder.fallbackUrl) {
  78277. promise = DracoCompression._LoadScriptAsync(decoder.fallbackUrl);
  78278. }
  78279. }
  78280. }
  78281. if (!promise) {
  78282. throw new Error("Draco decoder module is not available");
  78283. }
  78284. DracoCompression._DecoderModulePromise = promise.then(function () {
  78285. return new Promise(function (resolve) {
  78286. config_1.onModuleLoaded = function (decoderModule) {
  78287. // decoderModule is Promise-like. Wrap before resolving to avoid loop.
  78288. resolve({ module: decoderModule });
  78289. };
  78290. DracoDecoderModule(config_1);
  78291. });
  78292. });
  78293. }
  78294. return DracoCompression._DecoderModulePromise;
  78295. };
  78296. DracoCompression._LoadScriptAsync = function (url) {
  78297. return new Promise(function (resolve, reject) {
  78298. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadScript(url, function () {
  78299. resolve();
  78300. }, function (message) {
  78301. reject(new Error(message));
  78302. });
  78303. });
  78304. };
  78305. DracoCompression._LoadFileAsync = function (url) {
  78306. return new Promise(function (resolve, reject) {
  78307. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(url, function (data) {
  78308. resolve(data);
  78309. }, undefined, undefined, true, function (request, exception) {
  78310. reject(exception);
  78311. });
  78312. });
  78313. };
  78314. /**
  78315. * The configuration. Defaults to the following urls:
  78316. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  78317. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  78318. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  78319. */
  78320. DracoCompression.Configuration = {
  78321. decoder: {
  78322. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  78323. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  78324. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  78325. }
  78326. };
  78327. return DracoCompression;
  78328. }());
  78329. /***/ }),
  78330. /***/ "./Meshes/Compression/index.ts":
  78331. /*!*************************************!*\
  78332. !*** ./Meshes/Compression/index.ts ***!
  78333. \*************************************/
  78334. /*! exports provided: DracoCompression */
  78335. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78336. "use strict";
  78337. __webpack_require__.r(__webpack_exports__);
  78338. /* harmony import */ var _dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dracoCompression */ "./Meshes/Compression/dracoCompression.ts");
  78339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  78340. /***/ }),
  78341. /***/ "./Meshes/abstractMesh.ts":
  78342. /*!********************************!*\
  78343. !*** ./Meshes/abstractMesh.ts ***!
  78344. \********************************/
  78345. /*! exports provided: AbstractMesh */
  78346. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78347. "use strict";
  78348. __webpack_require__.r(__webpack_exports__);
  78349. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return AbstractMesh; });
  78350. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  78351. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  78352. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  78353. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  78354. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  78355. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  78356. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78357. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  78358. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  78359. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  78360. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  78361. /** @hidden */
  78362. var _FacetDataStorage = /** @class */ (function () {
  78363. function _FacetDataStorage() {
  78364. this.facetNb = 0; // facet number
  78365. this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space
  78366. this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
  78367. this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
  78368. this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
  78369. this.bbSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(); // bbox size approximated for facet data
  78370. this.subDiv = {
  78371. max: 1,
  78372. X: 1,
  78373. Y: 1,
  78374. Z: 1
  78375. };
  78376. this.facetDepthSort = false; // is the facet depth sort to be computed
  78377. this.facetDepthSortEnabled = false; // is the facet depth sort initialized
  78378. }
  78379. return _FacetDataStorage;
  78380. }());
  78381. /**
  78382. * Class used to store all common mesh properties
  78383. */
  78384. var AbstractMesh = /** @class */ (function (_super) {
  78385. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractMesh, _super);
  78386. // Constructor
  78387. /**
  78388. * Creates a new AbstractMesh
  78389. * @param name defines the name of the mesh
  78390. * @param scene defines the hosting scene
  78391. */
  78392. function AbstractMesh(name, scene) {
  78393. if (scene === void 0) { scene = null; }
  78394. var _this = _super.call(this, name, scene, false) || this;
  78395. _this._facetData = new _FacetDataStorage();
  78396. /**
  78397. * The culling strategy to use to check whether the mesh must be rendered or not.
  78398. * This value can be changed at any time and will be used on the next render mesh selection.
  78399. * The possible values are :
  78400. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  78401. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  78402. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  78403. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  78404. * Please read each static variable documentation to get details about the culling process.
  78405. * */
  78406. _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
  78407. // Events
  78408. /**
  78409. * An event triggered when this mesh collides with another one
  78410. */
  78411. _this.onCollideObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78412. /**
  78413. * An event triggered when the collision's position changes
  78414. */
  78415. _this.onCollisionPositionChangeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78416. /**
  78417. * An event triggered when material is changed
  78418. */
  78419. _this.onMaterialChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78420. // Properties
  78421. /**
  78422. * Gets or sets the orientation for POV movement & rotation
  78423. */
  78424. _this.definedFacingForward = true;
  78425. _this._visibility = 1.0;
  78426. /** Gets or sets the alpha index used to sort transparent meshes
  78427. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  78428. */
  78429. _this.alphaIndex = Number.MAX_VALUE;
  78430. /**
  78431. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  78432. */
  78433. _this.isVisible = true;
  78434. /**
  78435. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78436. */
  78437. _this.isPickable = true;
  78438. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  78439. _this.showSubMeshesBoundingBox = false;
  78440. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  78441. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  78442. */
  78443. _this.isBlocker = false;
  78444. /**
  78445. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  78446. */
  78447. _this.enablePointerMoveEvents = false;
  78448. /**
  78449. * Specifies the rendering group id for this mesh (0 by default)
  78450. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78451. */
  78452. _this.renderingGroupId = 0;
  78453. _this._receiveShadows = false;
  78454. /** Defines color to use when rendering outline */
  78455. _this.outlineColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  78456. /** Define width to use when rendering outline */
  78457. _this.outlineWidth = 0.02;
  78458. /** Defines color to use when rendering overlay */
  78459. _this.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  78460. /** Defines alpha to use when rendering overlay */
  78461. _this.overlayAlpha = 0.5;
  78462. _this._hasVertexAlpha = false;
  78463. _this._useVertexColors = true;
  78464. _this._computeBonesUsingShaders = true;
  78465. _this._numBoneInfluencers = 4;
  78466. _this._applyFog = true;
  78467. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  78468. _this.useOctreeForRenderingSelection = true;
  78469. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  78470. _this.useOctreeForPicking = true;
  78471. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  78472. _this.useOctreeForCollisions = true;
  78473. _this._layerMask = 0x0FFFFFFF;
  78474. /**
  78475. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  78476. */
  78477. _this.alwaysSelectAsActiveMesh = false;
  78478. /**
  78479. * Gets or sets the current action manager
  78480. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78481. */
  78482. _this.actionManager = null;
  78483. // Collisions
  78484. _this._checkCollisions = false;
  78485. _this._collisionMask = -1;
  78486. _this._collisionGroup = -1;
  78487. /**
  78488. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  78489. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  78490. */
  78491. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 1, 0.5);
  78492. /**
  78493. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  78494. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  78495. */
  78496. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  78497. _this._oldPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  78498. _this._diffPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  78499. // Edges
  78500. /**
  78501. * Defines edge width used when edgesRenderer is enabled
  78502. * @see https://www.babylonjs-playground.com/#10OJSG#13
  78503. */
  78504. _this.edgesWidth = 1;
  78505. /**
  78506. * Defines edge color used when edgesRenderer is enabled
  78507. * @see https://www.babylonjs-playground.com/#10OJSG#13
  78508. */
  78509. _this.edgesColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](1, 0, 0, 1);
  78510. /** @hidden */
  78511. _this._renderId = 0;
  78512. /** @hidden */
  78513. _this._intersectionsInProgress = new Array();
  78514. /** @hidden */
  78515. _this._unIndexed = false;
  78516. /** @hidden */
  78517. _this._lightSources = new Array();
  78518. /**
  78519. * An event triggered when the mesh is rebuilt.
  78520. */
  78521. _this.onRebuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78522. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  78523. if (collidedMesh === void 0) { collidedMesh = null; }
  78524. newPosition.subtractToRef(_this._oldPositionForCollisions, _this._diffPositionForCollisions);
  78525. if (_this._diffPositionForCollisions.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  78526. _this.position.addInPlace(_this._diffPositionForCollisions);
  78527. }
  78528. if (collidedMesh) {
  78529. _this.onCollideObservable.notifyObservers(collidedMesh);
  78530. }
  78531. _this.onCollisionPositionChangeObservable.notifyObservers(_this.position);
  78532. };
  78533. _this.getScene().addMesh(_this);
  78534. _this._resyncLightSources();
  78535. return _this;
  78536. }
  78537. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
  78538. /**
  78539. * No billboard
  78540. */
  78541. get: function () {
  78542. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE;
  78543. },
  78544. enumerable: true,
  78545. configurable: true
  78546. });
  78547. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
  78548. /** Billboard on X axis */
  78549. get: function () {
  78550. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_X;
  78551. },
  78552. enumerable: true,
  78553. configurable: true
  78554. });
  78555. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
  78556. /** Billboard on Y axis */
  78557. get: function () {
  78558. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Y;
  78559. },
  78560. enumerable: true,
  78561. configurable: true
  78562. });
  78563. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
  78564. /** Billboard on Z axis */
  78565. get: function () {
  78566. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Z;
  78567. },
  78568. enumerable: true,
  78569. configurable: true
  78570. });
  78571. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
  78572. /** Billboard on all axes */
  78573. get: function () {
  78574. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_ALL;
  78575. },
  78576. enumerable: true,
  78577. configurable: true
  78578. });
  78579. Object.defineProperty(AbstractMesh.prototype, "facetNb", {
  78580. /**
  78581. * Gets the number of facets in the mesh
  78582. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  78583. */
  78584. get: function () {
  78585. return this._facetData.facetNb;
  78586. },
  78587. enumerable: true,
  78588. configurable: true
  78589. });
  78590. Object.defineProperty(AbstractMesh.prototype, "partitioningSubdivisions", {
  78591. /**
  78592. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  78593. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  78594. */
  78595. get: function () {
  78596. return this._facetData.partitioningSubdivisions;
  78597. },
  78598. set: function (nb) {
  78599. this._facetData.partitioningSubdivisions = nb;
  78600. },
  78601. enumerable: true,
  78602. configurable: true
  78603. });
  78604. Object.defineProperty(AbstractMesh.prototype, "partitioningBBoxRatio", {
  78605. /**
  78606. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  78607. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  78608. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  78609. */
  78610. get: function () {
  78611. return this._facetData.partitioningBBoxRatio;
  78612. },
  78613. set: function (ratio) {
  78614. this._facetData.partitioningBBoxRatio = ratio;
  78615. },
  78616. enumerable: true,
  78617. configurable: true
  78618. });
  78619. Object.defineProperty(AbstractMesh.prototype, "mustDepthSortFacets", {
  78620. /**
  78621. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  78622. * Works only for updatable meshes.
  78623. * Doesn't work with multi-materials
  78624. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  78625. */
  78626. get: function () {
  78627. return this._facetData.facetDepthSort;
  78628. },
  78629. set: function (sort) {
  78630. this._facetData.facetDepthSort = sort;
  78631. },
  78632. enumerable: true,
  78633. configurable: true
  78634. });
  78635. Object.defineProperty(AbstractMesh.prototype, "facetDepthSortFrom", {
  78636. /**
  78637. * The location (Vector3) where the facet depth sort must be computed from.
  78638. * By default, the active camera position.
  78639. * Used only when facet depth sort is enabled
  78640. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  78641. */
  78642. get: function () {
  78643. return this._facetData.facetDepthSortFrom;
  78644. },
  78645. set: function (location) {
  78646. this._facetData.facetDepthSortFrom = location;
  78647. },
  78648. enumerable: true,
  78649. configurable: true
  78650. });
  78651. Object.defineProperty(AbstractMesh.prototype, "isFacetDataEnabled", {
  78652. /**
  78653. * gets a boolean indicating if facetData is enabled
  78654. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  78655. */
  78656. get: function () {
  78657. return this._facetData.facetDataEnabled;
  78658. },
  78659. enumerable: true,
  78660. configurable: true
  78661. });
  78662. /** @hidden */
  78663. AbstractMesh.prototype._updateNonUniformScalingState = function (value) {
  78664. if (!_super.prototype._updateNonUniformScalingState.call(this, value)) {
  78665. return false;
  78666. }
  78667. this._markSubMeshesAsMiscDirty();
  78668. return true;
  78669. };
  78670. Object.defineProperty(AbstractMesh.prototype, "onCollide", {
  78671. /** Set a function to call when this mesh collides with another one */
  78672. set: function (callback) {
  78673. if (this._onCollideObserver) {
  78674. this.onCollideObservable.remove(this._onCollideObserver);
  78675. }
  78676. this._onCollideObserver = this.onCollideObservable.add(callback);
  78677. },
  78678. enumerable: true,
  78679. configurable: true
  78680. });
  78681. Object.defineProperty(AbstractMesh.prototype, "onCollisionPositionChange", {
  78682. /** Set a function to call when the collision's position changes */
  78683. set: function (callback) {
  78684. if (this._onCollisionPositionChangeObserver) {
  78685. this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver);
  78686. }
  78687. this._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
  78688. },
  78689. enumerable: true,
  78690. configurable: true
  78691. });
  78692. Object.defineProperty(AbstractMesh.prototype, "visibility", {
  78693. /**
  78694. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  78695. */
  78696. get: function () {
  78697. return this._visibility;
  78698. },
  78699. /**
  78700. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  78701. */
  78702. set: function (value) {
  78703. if (this._visibility === value) {
  78704. return;
  78705. }
  78706. this._visibility = value;
  78707. this._markSubMeshesAsMiscDirty();
  78708. },
  78709. enumerable: true,
  78710. configurable: true
  78711. });
  78712. Object.defineProperty(AbstractMesh.prototype, "material", {
  78713. /** Gets or sets current material */
  78714. get: function () {
  78715. return this._material;
  78716. },
  78717. set: function (value) {
  78718. if (this._material === value) {
  78719. return;
  78720. }
  78721. // remove from material mesh map id needed
  78722. if (this._material && this._material.meshMap) {
  78723. this._material.meshMap[this.uniqueId] = undefined;
  78724. }
  78725. this._material = value;
  78726. if (value && value.meshMap) {
  78727. value.meshMap[this.uniqueId] = this;
  78728. }
  78729. if (this.onMaterialChangedObservable.hasObservers) {
  78730. this.onMaterialChangedObservable.notifyObservers(this);
  78731. }
  78732. if (!this.subMeshes) {
  78733. return;
  78734. }
  78735. this._unBindEffect();
  78736. },
  78737. enumerable: true,
  78738. configurable: true
  78739. });
  78740. Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
  78741. /**
  78742. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  78743. * @see http://doc.babylonjs.com/babylon101/shadows
  78744. */
  78745. get: function () {
  78746. return this._receiveShadows;
  78747. },
  78748. set: function (value) {
  78749. if (this._receiveShadows === value) {
  78750. return;
  78751. }
  78752. this._receiveShadows = value;
  78753. this._markSubMeshesAsLightDirty();
  78754. },
  78755. enumerable: true,
  78756. configurable: true
  78757. });
  78758. Object.defineProperty(AbstractMesh.prototype, "hasVertexAlpha", {
  78759. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  78760. get: function () {
  78761. return this._hasVertexAlpha;
  78762. },
  78763. set: function (value) {
  78764. if (this._hasVertexAlpha === value) {
  78765. return;
  78766. }
  78767. this._hasVertexAlpha = value;
  78768. this._markSubMeshesAsAttributesDirty();
  78769. this._markSubMeshesAsMiscDirty();
  78770. },
  78771. enumerable: true,
  78772. configurable: true
  78773. });
  78774. Object.defineProperty(AbstractMesh.prototype, "useVertexColors", {
  78775. /** 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) */
  78776. get: function () {
  78777. return this._useVertexColors;
  78778. },
  78779. set: function (value) {
  78780. if (this._useVertexColors === value) {
  78781. return;
  78782. }
  78783. this._useVertexColors = value;
  78784. this._markSubMeshesAsAttributesDirty();
  78785. },
  78786. enumerable: true,
  78787. configurable: true
  78788. });
  78789. Object.defineProperty(AbstractMesh.prototype, "computeBonesUsingShaders", {
  78790. /**
  78791. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  78792. */
  78793. get: function () {
  78794. return this._computeBonesUsingShaders;
  78795. },
  78796. set: function (value) {
  78797. if (this._computeBonesUsingShaders === value) {
  78798. return;
  78799. }
  78800. this._computeBonesUsingShaders = value;
  78801. this._markSubMeshesAsAttributesDirty();
  78802. },
  78803. enumerable: true,
  78804. configurable: true
  78805. });
  78806. Object.defineProperty(AbstractMesh.prototype, "numBoneInfluencers", {
  78807. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  78808. get: function () {
  78809. return this._numBoneInfluencers;
  78810. },
  78811. set: function (value) {
  78812. if (this._numBoneInfluencers === value) {
  78813. return;
  78814. }
  78815. this._numBoneInfluencers = value;
  78816. this._markSubMeshesAsAttributesDirty();
  78817. },
  78818. enumerable: true,
  78819. configurable: true
  78820. });
  78821. Object.defineProperty(AbstractMesh.prototype, "applyFog", {
  78822. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  78823. get: function () {
  78824. return this._applyFog;
  78825. },
  78826. set: function (value) {
  78827. if (this._applyFog === value) {
  78828. return;
  78829. }
  78830. this._applyFog = value;
  78831. this._markSubMeshesAsMiscDirty();
  78832. },
  78833. enumerable: true,
  78834. configurable: true
  78835. });
  78836. Object.defineProperty(AbstractMesh.prototype, "layerMask", {
  78837. /**
  78838. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  78839. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  78840. */
  78841. get: function () {
  78842. return this._layerMask;
  78843. },
  78844. set: function (value) {
  78845. if (value === this._layerMask) {
  78846. return;
  78847. }
  78848. this._layerMask = value;
  78849. this._resyncLightSources();
  78850. },
  78851. enumerable: true,
  78852. configurable: true
  78853. });
  78854. Object.defineProperty(AbstractMesh.prototype, "collisionMask", {
  78855. /**
  78856. * Gets or sets a collision mask used to mask collisions (default is -1).
  78857. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  78858. */
  78859. get: function () {
  78860. return this._collisionMask;
  78861. },
  78862. set: function (mask) {
  78863. this._collisionMask = !isNaN(mask) ? mask : -1;
  78864. },
  78865. enumerable: true,
  78866. configurable: true
  78867. });
  78868. Object.defineProperty(AbstractMesh.prototype, "collisionGroup", {
  78869. /**
  78870. * Gets or sets the current collision group mask (-1 by default).
  78871. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  78872. */
  78873. get: function () {
  78874. return this._collisionGroup;
  78875. },
  78876. set: function (mask) {
  78877. this._collisionGroup = !isNaN(mask) ? mask : -1;
  78878. },
  78879. enumerable: true,
  78880. configurable: true
  78881. });
  78882. Object.defineProperty(AbstractMesh.prototype, "_positions", {
  78883. /** @hidden */
  78884. get: function () {
  78885. return null;
  78886. },
  78887. enumerable: true,
  78888. configurable: true
  78889. });
  78890. Object.defineProperty(AbstractMesh.prototype, "skeleton", {
  78891. get: function () {
  78892. return this._skeleton;
  78893. },
  78894. /**
  78895. * Gets or sets a skeleton to apply skining transformations
  78896. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78897. */
  78898. set: function (value) {
  78899. if (this._skeleton && this._skeleton.needInitialSkinMatrix) {
  78900. this._skeleton._unregisterMeshWithPoseMatrix(this);
  78901. }
  78902. if (value && value.needInitialSkinMatrix) {
  78903. value._registerMeshWithPoseMatrix(this);
  78904. }
  78905. this._skeleton = value;
  78906. if (!this._skeleton) {
  78907. this._bonesTransformMatrices = null;
  78908. }
  78909. this._markSubMeshesAsAttributesDirty();
  78910. },
  78911. enumerable: true,
  78912. configurable: true
  78913. });
  78914. /**
  78915. * Returns the string "AbstractMesh"
  78916. * @returns "AbstractMesh"
  78917. */
  78918. AbstractMesh.prototype.getClassName = function () {
  78919. return "AbstractMesh";
  78920. };
  78921. /**
  78922. * Gets a string representation of the current mesh
  78923. * @param fullDetails defines a boolean indicating if full details must be included
  78924. * @returns a string representation of the current mesh
  78925. */
  78926. AbstractMesh.prototype.toString = function (fullDetails) {
  78927. var ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  78928. ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  78929. if (this._skeleton) {
  78930. ret += ", skeleton: " + this._skeleton.name;
  78931. }
  78932. if (fullDetails) {
  78933. ret += ", billboard mode: " + (["NONE", "X", "Y", null, "Z", null, null, "ALL"])[this.billboardMode];
  78934. ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingFreezeWorldMatrix ? "YES" : "NO");
  78935. }
  78936. return ret;
  78937. };
  78938. /** @hidden */
  78939. AbstractMesh.prototype._rebuild = function () {
  78940. this.onRebuildObservable.notifyObservers(this);
  78941. if (this._occlusionQuery) {
  78942. this._occlusionQuery = null;
  78943. }
  78944. if (!this.subMeshes) {
  78945. return;
  78946. }
  78947. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  78948. var subMesh = _a[_i];
  78949. subMesh._rebuild();
  78950. }
  78951. };
  78952. /** @hidden */
  78953. AbstractMesh.prototype._resyncLightSources = function () {
  78954. this._lightSources.length = 0;
  78955. for (var _i = 0, _a = this.getScene().lights; _i < _a.length; _i++) {
  78956. var light = _a[_i];
  78957. if (!light.isEnabled()) {
  78958. continue;
  78959. }
  78960. if (light.canAffectMesh(this)) {
  78961. this._lightSources.push(light);
  78962. }
  78963. }
  78964. this._markSubMeshesAsLightDirty();
  78965. };
  78966. /** @hidden */
  78967. AbstractMesh.prototype._resyncLighSource = function (light) {
  78968. var isIn = light.isEnabled() && light.canAffectMesh(this);
  78969. var index = this._lightSources.indexOf(light);
  78970. if (index === -1) {
  78971. if (!isIn) {
  78972. return;
  78973. }
  78974. this._lightSources.push(light);
  78975. }
  78976. else {
  78977. if (isIn) {
  78978. return;
  78979. }
  78980. this._lightSources.splice(index, 1);
  78981. }
  78982. this._markSubMeshesAsLightDirty();
  78983. };
  78984. /** @hidden */
  78985. AbstractMesh.prototype._unBindEffect = function () {
  78986. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  78987. var subMesh = _a[_i];
  78988. subMesh.setEffect(null);
  78989. }
  78990. };
  78991. /** @hidden */
  78992. AbstractMesh.prototype._removeLightSource = function (light) {
  78993. var index = this._lightSources.indexOf(light);
  78994. if (index === -1) {
  78995. return;
  78996. }
  78997. this._lightSources.splice(index, 1);
  78998. this._markSubMeshesAsLightDirty();
  78999. };
  79000. AbstractMesh.prototype._markSubMeshesAsDirty = function (func) {
  79001. if (!this.subMeshes) {
  79002. return;
  79003. }
  79004. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  79005. var subMesh = _a[_i];
  79006. if (subMesh._materialDefines) {
  79007. func(subMesh._materialDefines);
  79008. }
  79009. }
  79010. };
  79011. /** @hidden */
  79012. AbstractMesh.prototype._markSubMeshesAsLightDirty = function () {
  79013. this._markSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
  79014. };
  79015. /** @hidden */
  79016. AbstractMesh.prototype._markSubMeshesAsAttributesDirty = function () {
  79017. this._markSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
  79018. };
  79019. /** @hidden */
  79020. AbstractMesh.prototype._markSubMeshesAsMiscDirty = function () {
  79021. if (!this.subMeshes) {
  79022. return;
  79023. }
  79024. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  79025. var subMesh = _a[_i];
  79026. var material = subMesh.getMaterial();
  79027. if (material) {
  79028. material.markAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MATERIAL_MiscDirtyFlag);
  79029. }
  79030. }
  79031. };
  79032. Object.defineProperty(AbstractMesh.prototype, "scaling", {
  79033. /**
  79034. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  79035. */
  79036. get: function () {
  79037. return this._scaling;
  79038. },
  79039. set: function (newScaling) {
  79040. this._scaling = newScaling;
  79041. if (this.physicsImpostor) {
  79042. this.physicsImpostor.forceUpdate();
  79043. }
  79044. },
  79045. enumerable: true,
  79046. configurable: true
  79047. });
  79048. Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
  79049. // Methods
  79050. /**
  79051. * Returns true if the mesh is blocked. Implemented by child classes
  79052. */
  79053. get: function () {
  79054. return false;
  79055. },
  79056. enumerable: true,
  79057. configurable: true
  79058. });
  79059. /**
  79060. * Returns the mesh itself by default. Implemented by child classes
  79061. * @param camera defines the camera to use to pick the right LOD level
  79062. * @returns the currentAbstractMesh
  79063. */
  79064. AbstractMesh.prototype.getLOD = function (camera) {
  79065. return this;
  79066. };
  79067. /**
  79068. * Returns 0 by default. Implemented by child classes
  79069. * @returns an integer
  79070. */
  79071. AbstractMesh.prototype.getTotalVertices = function () {
  79072. return 0;
  79073. };
  79074. /**
  79075. * Returns a positive integer : the total number of indices in this mesh geometry.
  79076. * @returns the numner of indices or zero if the mesh has no geometry.
  79077. */
  79078. AbstractMesh.prototype.getTotalIndices = function () {
  79079. return 0;
  79080. };
  79081. /**
  79082. * Returns null by default. Implemented by child classes
  79083. * @returns null
  79084. */
  79085. AbstractMesh.prototype.getIndices = function () {
  79086. return null;
  79087. };
  79088. /**
  79089. * Returns the array of the requested vertex data kind. Implemented by child classes
  79090. * @param kind defines the vertex data kind to use
  79091. * @returns null
  79092. */
  79093. AbstractMesh.prototype.getVerticesData = function (kind) {
  79094. return null;
  79095. };
  79096. /**
  79097. * Sets the vertex data of the mesh geometry for the requested `kind`.
  79098. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  79099. * Note that a new underlying VertexBuffer object is created each call.
  79100. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  79101. * @param kind defines vertex data kind:
  79102. * * VertexBuffer.PositionKind
  79103. * * VertexBuffer.UVKind
  79104. * * VertexBuffer.UV2Kind
  79105. * * VertexBuffer.UV3Kind
  79106. * * VertexBuffer.UV4Kind
  79107. * * VertexBuffer.UV5Kind
  79108. * * VertexBuffer.UV6Kind
  79109. * * VertexBuffer.ColorKind
  79110. * * VertexBuffer.MatricesIndicesKind
  79111. * * VertexBuffer.MatricesIndicesExtraKind
  79112. * * VertexBuffer.MatricesWeightsKind
  79113. * * VertexBuffer.MatricesWeightsExtraKind
  79114. * @param data defines the data source
  79115. * @param updatable defines if the data must be flagged as updatable (or static)
  79116. * @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
  79117. * @returns the current mesh
  79118. */
  79119. AbstractMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  79120. return this;
  79121. };
  79122. /**
  79123. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  79124. * If the mesh has no geometry, it is simply returned as it is.
  79125. * @param kind defines vertex data kind:
  79126. * * VertexBuffer.PositionKind
  79127. * * VertexBuffer.UVKind
  79128. * * VertexBuffer.UV2Kind
  79129. * * VertexBuffer.UV3Kind
  79130. * * VertexBuffer.UV4Kind
  79131. * * VertexBuffer.UV5Kind
  79132. * * VertexBuffer.UV6Kind
  79133. * * VertexBuffer.ColorKind
  79134. * * VertexBuffer.MatricesIndicesKind
  79135. * * VertexBuffer.MatricesIndicesExtraKind
  79136. * * VertexBuffer.MatricesWeightsKind
  79137. * * VertexBuffer.MatricesWeightsExtraKind
  79138. * @param data defines the data source
  79139. * @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
  79140. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  79141. * @returns the current mesh
  79142. */
  79143. AbstractMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  79144. return this;
  79145. };
  79146. /**
  79147. * Sets the mesh indices,
  79148. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  79149. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  79150. * @param totalVertices Defines the total number of vertices
  79151. * @returns the current mesh
  79152. */
  79153. AbstractMesh.prototype.setIndices = function (indices, totalVertices) {
  79154. return this;
  79155. };
  79156. /**
  79157. * Gets a boolean indicating if specific vertex data is present
  79158. * @param kind defines the vertex data kind to use
  79159. * @returns true is data kind is present
  79160. */
  79161. AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
  79162. return false;
  79163. };
  79164. /**
  79165. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  79166. * @returns a BoundingInfo
  79167. */
  79168. AbstractMesh.prototype.getBoundingInfo = function () {
  79169. if (this._masterMesh) {
  79170. return this._masterMesh.getBoundingInfo();
  79171. }
  79172. if (!this._boundingInfo) {
  79173. // this._boundingInfo is being created here
  79174. this._updateBoundingInfo();
  79175. }
  79176. // cannot be null.
  79177. return this._boundingInfo;
  79178. };
  79179. /**
  79180. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79181. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  79182. * @returns the current mesh
  79183. */
  79184. AbstractMesh.prototype.normalizeToUnitCube = function (includeDescendants) {
  79185. if (includeDescendants === void 0) { includeDescendants = true; }
  79186. var boundingVectors = this.getHierarchyBoundingVectors(includeDescendants);
  79187. var sizeVec = boundingVectors.max.subtract(boundingVectors.min);
  79188. var maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
  79189. if (maxDimension === 0) {
  79190. return this;
  79191. }
  79192. var scale = 1 / maxDimension;
  79193. this.scaling.scaleInPlace(scale);
  79194. return this;
  79195. };
  79196. /**
  79197. * Overwrite the current bounding info
  79198. * @param boundingInfo defines the new bounding info
  79199. * @returns the current mesh
  79200. */
  79201. AbstractMesh.prototype.setBoundingInfo = function (boundingInfo) {
  79202. this._boundingInfo = boundingInfo;
  79203. return this;
  79204. };
  79205. Object.defineProperty(AbstractMesh.prototype, "useBones", {
  79206. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  79207. get: function () {
  79208. 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));
  79209. },
  79210. enumerable: true,
  79211. configurable: true
  79212. });
  79213. /** @hidden */
  79214. AbstractMesh.prototype._preActivate = function () {
  79215. };
  79216. /** @hidden */
  79217. AbstractMesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  79218. };
  79219. /** @hidden */
  79220. AbstractMesh.prototype._activate = function (renderId) {
  79221. this._renderId = renderId;
  79222. };
  79223. /**
  79224. * Gets the current world matrix
  79225. * @returns a Matrix
  79226. */
  79227. AbstractMesh.prototype.getWorldMatrix = function () {
  79228. if (this._masterMesh) {
  79229. return this._masterMesh.getWorldMatrix();
  79230. }
  79231. return _super.prototype.getWorldMatrix.call(this);
  79232. };
  79233. /** @hidden */
  79234. AbstractMesh.prototype._getWorldMatrixDeterminant = function () {
  79235. if (this._masterMesh) {
  79236. return this._masterMesh._getWorldMatrixDeterminant();
  79237. }
  79238. return _super.prototype._getWorldMatrixDeterminant.call(this);
  79239. };
  79240. // ================================== Point of View Movement =================================
  79241. /**
  79242. * Perform relative position change from the point of view of behind the front of the mesh.
  79243. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79244. * Supports definition of mesh facing forward or backward
  79245. * @param amountRight defines the distance on the right axis
  79246. * @param amountUp defines the distance on the up axis
  79247. * @param amountForward defines the distance on the forward axis
  79248. * @returns the current mesh
  79249. */
  79250. AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
  79251. this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
  79252. return this;
  79253. };
  79254. /**
  79255. * Calculate relative position change from the point of view of behind the front of the mesh.
  79256. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79257. * Supports definition of mesh facing forward or backward
  79258. * @param amountRight defines the distance on the right axis
  79259. * @param amountUp defines the distance on the up axis
  79260. * @param amountForward defines the distance on the forward axis
  79261. * @returns the new displacement vector
  79262. */
  79263. AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
  79264. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  79265. var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  79266. rotQuaternion.toRotationMatrix(rotMatrix);
  79267. var translationDelta = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79268. var defForwardMult = this.definedFacingForward ? -1 : 1;
  79269. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
  79270. return translationDelta;
  79271. };
  79272. // ================================== Point of View Rotation =================================
  79273. /**
  79274. * Perform relative rotation change from the point of view of behind the front of the mesh.
  79275. * Supports definition of mesh facing forward or backward
  79276. * @param flipBack defines the flip
  79277. * @param twirlClockwise defines the twirl
  79278. * @param tiltRight defines the tilt
  79279. * @returns the current mesh
  79280. */
  79281. AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  79282. this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
  79283. return this;
  79284. };
  79285. /**
  79286. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  79287. * Supports definition of mesh facing forward or backward.
  79288. * @param flipBack defines the flip
  79289. * @param twirlClockwise defines the twirl
  79290. * @param tiltRight defines the tilt
  79291. * @returns the new rotation vector
  79292. */
  79293. AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  79294. var defForwardMult = this.definedFacingForward ? 1 : -1;
  79295. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
  79296. };
  79297. /**
  79298. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  79299. * @param includeDescendants Include bounding info from descendants as well (true by default)
  79300. * @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
  79301. * @returns the new bounding vectors
  79302. */
  79303. AbstractMesh.prototype.getHierarchyBoundingVectors = function (includeDescendants, predicate) {
  79304. if (includeDescendants === void 0) { includeDescendants = true; }
  79305. if (predicate === void 0) { predicate = null; }
  79306. // Ensures that all world matrix will be recomputed.
  79307. this.getScene().incrementRenderId();
  79308. this.computeWorldMatrix(true);
  79309. var min;
  79310. var max;
  79311. var boundingInfo = this.getBoundingInfo();
  79312. if (!this.subMeshes) {
  79313. min = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  79314. max = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  79315. }
  79316. else {
  79317. min = boundingInfo.boundingBox.minimumWorld;
  79318. max = boundingInfo.boundingBox.maximumWorld;
  79319. }
  79320. if (includeDescendants) {
  79321. var descendants = this.getDescendants(false);
  79322. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  79323. var descendant = descendants_1[_i];
  79324. var childMesh = descendant;
  79325. childMesh.computeWorldMatrix(true);
  79326. // Filters meshes based on custom predicate function.
  79327. if (predicate && !predicate(childMesh)) {
  79328. continue;
  79329. }
  79330. //make sure we have the needed params to get mix and max
  79331. if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
  79332. continue;
  79333. }
  79334. var childBoundingInfo = childMesh.getBoundingInfo();
  79335. var boundingBox = childBoundingInfo.boundingBox;
  79336. var minBox = boundingBox.minimumWorld;
  79337. var maxBox = boundingBox.maximumWorld;
  79338. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  79339. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  79340. }
  79341. }
  79342. return {
  79343. min: min,
  79344. max: max
  79345. };
  79346. };
  79347. /**
  79348. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79349. * This means the mesh underlying bounding box and sphere are recomputed.
  79350. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79351. * @returns the current mesh
  79352. */
  79353. AbstractMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  79354. if (applySkeleton === void 0) { applySkeleton = false; }
  79355. if (this._boundingInfo && this._boundingInfo.isLocked) {
  79356. return this;
  79357. }
  79358. this._refreshBoundingInfo(this._getPositionData(applySkeleton), null);
  79359. return this;
  79360. };
  79361. /** @hidden */
  79362. AbstractMesh.prototype._refreshBoundingInfo = function (data, bias) {
  79363. if (data) {
  79364. var extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMax(data, 0, this.getTotalVertices(), bias);
  79365. if (this._boundingInfo) {
  79366. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  79367. }
  79368. else {
  79369. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](extend.minimum, extend.maximum);
  79370. }
  79371. }
  79372. if (this.subMeshes) {
  79373. for (var index = 0; index < this.subMeshes.length; index++) {
  79374. this.subMeshes[index].refreshBoundingInfo();
  79375. }
  79376. }
  79377. this._updateBoundingInfo();
  79378. };
  79379. /** @hidden */
  79380. AbstractMesh.prototype._getPositionData = function (applySkeleton) {
  79381. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  79382. if (data && applySkeleton && this.skeleton) {
  79383. data = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Slice(data);
  79384. var matricesIndicesData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind);
  79385. var matricesWeightsData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind);
  79386. if (matricesWeightsData && matricesIndicesData) {
  79387. var needExtras = this.numBoneInfluencers > 4;
  79388. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  79389. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  79390. var skeletonMatrices = this.skeleton.getTransformMatrices(this);
  79391. var tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  79392. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  79393. var tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  79394. var matWeightIdx = 0;
  79395. for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
  79396. finalMatrix.reset();
  79397. var inf;
  79398. var weight;
  79399. for (inf = 0; inf < 4; inf++) {
  79400. weight = matricesWeightsData[matWeightIdx + inf];
  79401. if (weight > 0) {
  79402. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  79403. finalMatrix.addToSelf(tempMatrix);
  79404. }
  79405. }
  79406. if (needExtras) {
  79407. for (inf = 0; inf < 4; inf++) {
  79408. weight = matricesWeightsExtraData[matWeightIdx + inf];
  79409. if (weight > 0) {
  79410. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  79411. finalMatrix.addToSelf(tempMatrix);
  79412. }
  79413. }
  79414. }
  79415. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
  79416. tempVector.toArray(data, index);
  79417. }
  79418. }
  79419. }
  79420. return data;
  79421. };
  79422. /** @hidden */
  79423. AbstractMesh.prototype._updateBoundingInfo = function () {
  79424. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  79425. if (this._boundingInfo) {
  79426. this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
  79427. }
  79428. else {
  79429. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
  79430. }
  79431. this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
  79432. return this;
  79433. };
  79434. /** @hidden */
  79435. AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
  79436. if (!this.subMeshes) {
  79437. return this;
  79438. }
  79439. var count = this.subMeshes.length;
  79440. for (var subIndex = 0; subIndex < count; subIndex++) {
  79441. var subMesh = this.subMeshes[subIndex];
  79442. if (count > 1 || !subMesh.IsGlobal) {
  79443. subMesh.updateBoundingInfo(matrix);
  79444. }
  79445. }
  79446. return this;
  79447. };
  79448. /** @hidden */
  79449. AbstractMesh.prototype._afterComputeWorldMatrix = function () {
  79450. // Bounding info
  79451. this._updateBoundingInfo();
  79452. };
  79453. /**
  79454. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79455. * A mesh is in the frustum if its bounding box intersects the frustum
  79456. * @param frustumPlanes defines the frustum to test
  79457. * @returns true if the mesh is in the frustum planes
  79458. */
  79459. AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
  79460. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  79461. };
  79462. /**
  79463. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  79464. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  79465. * @param frustumPlanes defines the frustum to test
  79466. * @returns true if the mesh is completely in the frustum planes
  79467. */
  79468. AbstractMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  79469. return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(frustumPlanes);
  79470. };
  79471. /**
  79472. * True if the mesh intersects another mesh or a SolidParticle object
  79473. * @param mesh defines a target mesh or SolidParticle to test
  79474. * @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)
  79475. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  79476. * @returns true if there is an intersection
  79477. */
  79478. AbstractMesh.prototype.intersectsMesh = function (mesh, precise, includeDescendants) {
  79479. if (precise === void 0) { precise = false; }
  79480. if (!this._boundingInfo || !mesh._boundingInfo) {
  79481. return false;
  79482. }
  79483. if (this._boundingInfo.intersects(mesh._boundingInfo, precise)) {
  79484. return true;
  79485. }
  79486. if (includeDescendants) {
  79487. for (var _i = 0, _a = this.getChildMeshes(); _i < _a.length; _i++) {
  79488. var child = _a[_i];
  79489. if (child.intersectsMesh(mesh, precise, true)) {
  79490. return true;
  79491. }
  79492. }
  79493. }
  79494. return false;
  79495. };
  79496. /**
  79497. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  79498. * @param point defines the point to test
  79499. * @returns true if there is an intersection
  79500. */
  79501. AbstractMesh.prototype.intersectsPoint = function (point) {
  79502. if (!this._boundingInfo) {
  79503. return false;
  79504. }
  79505. return this._boundingInfo.intersectsPoint(point);
  79506. };
  79507. Object.defineProperty(AbstractMesh.prototype, "checkCollisions", {
  79508. // Collisions
  79509. /**
  79510. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  79511. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79512. */
  79513. get: function () {
  79514. return this._checkCollisions;
  79515. },
  79516. set: function (collisionEnabled) {
  79517. this._checkCollisions = collisionEnabled;
  79518. },
  79519. enumerable: true,
  79520. configurable: true
  79521. });
  79522. Object.defineProperty(AbstractMesh.prototype, "collider", {
  79523. /**
  79524. * Gets Collider object used to compute collisions (not physics)
  79525. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79526. */
  79527. get: function () {
  79528. return this._collider;
  79529. },
  79530. enumerable: true,
  79531. configurable: true
  79532. });
  79533. /**
  79534. * Move the mesh using collision engine
  79535. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79536. * @param displacement defines the requested displacement vector
  79537. * @returns the current mesh
  79538. */
  79539. AbstractMesh.prototype.moveWithCollisions = function (displacement) {
  79540. var globalPosition = this.getAbsolutePosition();
  79541. globalPosition.addToRef(this.ellipsoidOffset, this._oldPositionForCollisions);
  79542. var coordinator = this.getScene().collisionCoordinator;
  79543. if (!this._collider) {
  79544. this._collider = coordinator.createCollider();
  79545. }
  79546. this._collider._radius = this.ellipsoid;
  79547. coordinator.getNewPosition(this._oldPositionForCollisions, displacement, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
  79548. return this;
  79549. };
  79550. // Collisions
  79551. /** @hidden */
  79552. AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
  79553. this._generatePointsArray();
  79554. if (!this._positions) {
  79555. return this;
  79556. }
  79557. // Transformation
  79558. if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
  79559. subMesh._lastColliderTransformMatrix = transformMatrix.clone();
  79560. subMesh._lastColliderWorldVertices = [];
  79561. subMesh._trianglePlanes = [];
  79562. var start = subMesh.verticesStart;
  79563. var end = (subMesh.verticesStart + subMesh.verticesCount);
  79564. for (var i = start; i < end; i++) {
  79565. subMesh._lastColliderWorldVertices.push(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this._positions[i], transformMatrix));
  79566. }
  79567. }
  79568. // Collide
  79569. collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial());
  79570. if (collider.collisionFound) {
  79571. collider.collidedMesh = this;
  79572. }
  79573. return this;
  79574. };
  79575. /** @hidden */
  79576. AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
  79577. var subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
  79578. var len = subMeshes.length;
  79579. for (var index = 0; index < len; index++) {
  79580. var subMesh = subMeshes.data[index];
  79581. // Bounding test
  79582. if (len > 1 && !subMesh._checkCollision(collider)) {
  79583. continue;
  79584. }
  79585. this._collideForSubMesh(subMesh, transformMatrix, collider);
  79586. }
  79587. return this;
  79588. };
  79589. /** @hidden */
  79590. AbstractMesh.prototype._checkCollision = function (collider) {
  79591. // Bounding box test
  79592. if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider)) {
  79593. return this;
  79594. }
  79595. // Transformation matrix
  79596. var collisionsScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  79597. var collisionsTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  79598. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
  79599. this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
  79600. this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
  79601. return this;
  79602. };
  79603. // Picking
  79604. /** @hidden */
  79605. AbstractMesh.prototype._generatePointsArray = function () {
  79606. return false;
  79607. };
  79608. /**
  79609. * Checks if the passed Ray intersects with the mesh
  79610. * @param ray defines the ray to use
  79611. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  79612. * @returns the picking info
  79613. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79614. */
  79615. AbstractMesh.prototype.intersects = function (ray, fastCheck) {
  79616. var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
  79617. var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
  79618. var boundingInfo = this._boundingInfo;
  79619. if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
  79620. return pickingInfo;
  79621. }
  79622. if (!this._generatePointsArray()) {
  79623. return pickingInfo;
  79624. }
  79625. var intersectInfo = null;
  79626. var subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
  79627. var len = subMeshes.length;
  79628. for (var index = 0; index < len; index++) {
  79629. var subMesh = subMeshes.data[index];
  79630. // Bounding test
  79631. if (len > 1 && !subMesh.canIntersects(ray)) {
  79632. continue;
  79633. }
  79634. var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck);
  79635. if (currentIntersectInfo) {
  79636. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  79637. intersectInfo = currentIntersectInfo;
  79638. intersectInfo.subMeshId = index;
  79639. if (fastCheck) {
  79640. break;
  79641. }
  79642. }
  79643. }
  79644. }
  79645. if (intersectInfo) {
  79646. // Get picked point
  79647. var world = this.getWorldMatrix();
  79648. var worldOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  79649. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  79650. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
  79651. ray.direction.scaleToRef(intersectInfo.distance, direction);
  79652. var worldDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(direction, world);
  79653. var pickedPoint = worldDirection.addInPlace(worldOrigin);
  79654. // Return result
  79655. pickingInfo.hit = true;
  79656. pickingInfo.distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(worldOrigin, pickedPoint);
  79657. pickingInfo.pickedPoint = pickedPoint;
  79658. pickingInfo.pickedMesh = this;
  79659. pickingInfo.bu = intersectInfo.bu || 0;
  79660. pickingInfo.bv = intersectInfo.bv || 0;
  79661. pickingInfo.faceId = intersectInfo.faceId;
  79662. pickingInfo.subMeshId = intersectInfo.subMeshId;
  79663. return pickingInfo;
  79664. }
  79665. return pickingInfo;
  79666. };
  79667. /**
  79668. * Clones the current mesh
  79669. * @param name defines the mesh name
  79670. * @param newParent defines the new mesh parent
  79671. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  79672. * @returns the new mesh
  79673. */
  79674. AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  79675. return null;
  79676. };
  79677. /**
  79678. * Disposes all the submeshes of the current meshnp
  79679. * @returns the current mesh
  79680. */
  79681. AbstractMesh.prototype.releaseSubMeshes = function () {
  79682. if (this.subMeshes) {
  79683. while (this.subMeshes.length) {
  79684. this.subMeshes[0].dispose();
  79685. }
  79686. }
  79687. else {
  79688. this.subMeshes = new Array();
  79689. }
  79690. return this;
  79691. };
  79692. /**
  79693. * Releases resources associated with this abstract mesh.
  79694. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79695. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79696. */
  79697. AbstractMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  79698. var _this = this;
  79699. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  79700. var index;
  79701. // Smart Array Retainers.
  79702. this.getScene().freeActiveMeshes();
  79703. this.getScene().freeRenderingGroups();
  79704. // Action manager
  79705. if (this.actionManager !== undefined && this.actionManager !== null) {
  79706. this.actionManager.dispose();
  79707. this.actionManager = null;
  79708. }
  79709. // Skeleton
  79710. this._skeleton = null;
  79711. // Intersections in progress
  79712. for (index = 0; index < this._intersectionsInProgress.length; index++) {
  79713. var other = this._intersectionsInProgress[index];
  79714. var pos = other._intersectionsInProgress.indexOf(this);
  79715. other._intersectionsInProgress.splice(pos, 1);
  79716. }
  79717. this._intersectionsInProgress = [];
  79718. // Lights
  79719. var lights = this.getScene().lights;
  79720. lights.forEach(function (light) {
  79721. var meshIndex = light.includedOnlyMeshes.indexOf(_this);
  79722. if (meshIndex !== -1) {
  79723. light.includedOnlyMeshes.splice(meshIndex, 1);
  79724. }
  79725. meshIndex = light.excludedMeshes.indexOf(_this);
  79726. if (meshIndex !== -1) {
  79727. light.excludedMeshes.splice(meshIndex, 1);
  79728. }
  79729. // Shadow generators
  79730. var generator = light.getShadowGenerator();
  79731. if (generator) {
  79732. var shadowMap = generator.getShadowMap();
  79733. if (shadowMap && shadowMap.renderList) {
  79734. meshIndex = shadowMap.renderList.indexOf(_this);
  79735. if (meshIndex !== -1) {
  79736. shadowMap.renderList.splice(meshIndex, 1);
  79737. }
  79738. }
  79739. }
  79740. });
  79741. // SubMeshes
  79742. if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
  79743. this.releaseSubMeshes();
  79744. }
  79745. // Query
  79746. var engine = this.getScene().getEngine();
  79747. if (this._occlusionQuery) {
  79748. this.isOcclusionQueryInProgress = false;
  79749. engine.deleteQuery(this._occlusionQuery);
  79750. this._occlusionQuery = null;
  79751. }
  79752. // Engine
  79753. engine.wipeCaches();
  79754. // Remove from scene
  79755. this.getScene().removeMesh(this);
  79756. if (disposeMaterialAndTextures) {
  79757. if (this.material) {
  79758. this.material.dispose(false, true);
  79759. }
  79760. }
  79761. if (!doNotRecurse) {
  79762. // Particles
  79763. for (index = 0; index < this.getScene().particleSystems.length; index++) {
  79764. if (this.getScene().particleSystems[index].emitter === this) {
  79765. this.getScene().particleSystems[index].dispose();
  79766. index--;
  79767. }
  79768. }
  79769. }
  79770. // facet data
  79771. if (this._facetData.facetDataEnabled) {
  79772. this.disableFacetData();
  79773. }
  79774. this.onAfterWorldMatrixUpdateObservable.clear();
  79775. this.onCollideObservable.clear();
  79776. this.onCollisionPositionChangeObservable.clear();
  79777. this.onRebuildObservable.clear();
  79778. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  79779. };
  79780. /**
  79781. * Adds the passed mesh as a child to the current mesh
  79782. * @param mesh defines the child mesh
  79783. * @returns the current mesh
  79784. */
  79785. AbstractMesh.prototype.addChild = function (mesh) {
  79786. mesh.setParent(this);
  79787. return this;
  79788. };
  79789. /**
  79790. * Removes the passed mesh from the current mesh children list
  79791. * @param mesh defines the child mesh
  79792. * @returns the current mesh
  79793. */
  79794. AbstractMesh.prototype.removeChild = function (mesh) {
  79795. mesh.setParent(null);
  79796. return this;
  79797. };
  79798. // Facet data
  79799. /** @hidden */
  79800. AbstractMesh.prototype._initFacetData = function () {
  79801. var data = this._facetData;
  79802. if (!data.facetNormals) {
  79803. data.facetNormals = new Array();
  79804. }
  79805. if (!data.facetPositions) {
  79806. data.facetPositions = new Array();
  79807. }
  79808. if (!data.facetPartitioning) {
  79809. data.facetPartitioning = new Array();
  79810. }
  79811. data.facetNb = (this.getIndices().length / 3) | 0;
  79812. data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
  79813. data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
  79814. for (var f = 0; f < data.facetNb; f++) {
  79815. data.facetNormals[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79816. data.facetPositions[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79817. }
  79818. data.facetDataEnabled = true;
  79819. return this;
  79820. };
  79821. /**
  79822. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  79823. * This method can be called within the render loop.
  79824. * 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
  79825. * @returns the current mesh
  79826. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79827. */
  79828. AbstractMesh.prototype.updateFacetData = function () {
  79829. var data = this._facetData;
  79830. if (!data.facetDataEnabled) {
  79831. this._initFacetData();
  79832. }
  79833. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  79834. var indices = this.getIndices();
  79835. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  79836. var bInfo = this.getBoundingInfo();
  79837. if (data.facetDepthSort && !data.facetDepthSortEnabled) {
  79838. // init arrays, matrix and sort function on first call
  79839. data.facetDepthSortEnabled = true;
  79840. if (indices instanceof Uint16Array) {
  79841. data.depthSortedIndices = new Uint16Array(indices);
  79842. }
  79843. else if (indices instanceof Uint32Array) {
  79844. data.depthSortedIndices = new Uint32Array(indices);
  79845. }
  79846. else {
  79847. var needs32bits = false;
  79848. for (var i = 0; i < indices.length; i++) {
  79849. if (indices[i] > 65535) {
  79850. needs32bits = true;
  79851. break;
  79852. }
  79853. }
  79854. if (needs32bits) {
  79855. data.depthSortedIndices = new Uint32Array(indices);
  79856. }
  79857. else {
  79858. data.depthSortedIndices = new Uint16Array(indices);
  79859. }
  79860. }
  79861. data.facetDepthSortFunction = function (f1, f2) {
  79862. return (f2.sqDistance - f1.sqDistance);
  79863. };
  79864. if (!data.facetDepthSortFrom) {
  79865. var camera = this.getScene().activeCamera;
  79866. data.facetDepthSortFrom = (camera) ? camera.position : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79867. }
  79868. data.depthSortedFacets = [];
  79869. for (var f = 0; f < data.facetNb; f++) {
  79870. var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
  79871. data.depthSortedFacets.push(depthSortedFacet);
  79872. }
  79873. data.invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  79874. data.facetDepthSortOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79875. }
  79876. 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"];
  79877. 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"];
  79878. 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"];
  79879. var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
  79880. bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
  79881. data.subDiv.max = data.partitioningSubdivisions;
  79882. data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax); // adjust the number of subdivisions per axis
  79883. data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax); // according to each bbox size per axis
  79884. data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
  79885. data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
  79886. data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
  79887. data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
  79888. // set the parameters for ComputeNormals()
  79889. data.facetParameters.facetNormals = this.getFacetLocalNormals();
  79890. data.facetParameters.facetPositions = this.getFacetLocalPositions();
  79891. data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
  79892. data.facetParameters.bInfo = bInfo;
  79893. data.facetParameters.bbSize = data.bbSize;
  79894. data.facetParameters.subDiv = data.subDiv;
  79895. data.facetParameters.ratio = this.partitioningBBoxRatio;
  79896. data.facetParameters.depthSort = data.facetDepthSort;
  79897. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  79898. this.computeWorldMatrix(true);
  79899. this._worldMatrix.invertToRef(data.invertedMatrix);
  79900. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
  79901. data.facetParameters.distanceTo = data.facetDepthSortOrigin;
  79902. }
  79903. data.facetParameters.depthSortedFacets = data.depthSortedFacets;
  79904. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, data.facetParameters);
  79905. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  79906. data.depthSortedFacets.sort(data.facetDepthSortFunction);
  79907. var l = (data.depthSortedIndices.length / 3) | 0;
  79908. for (var f = 0; f < l; f++) {
  79909. var sind = data.depthSortedFacets[f].ind;
  79910. data.depthSortedIndices[f * 3] = indices[sind];
  79911. data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
  79912. data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
  79913. }
  79914. this.updateIndices(data.depthSortedIndices);
  79915. }
  79916. return this;
  79917. };
  79918. /**
  79919. * Returns the facetLocalNormals array.
  79920. * The normals are expressed in the mesh local spac
  79921. * @returns an array of Vector3
  79922. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79923. */
  79924. AbstractMesh.prototype.getFacetLocalNormals = function () {
  79925. if (!this._facetData.facetNormals) {
  79926. this.updateFacetData();
  79927. }
  79928. return this._facetData.facetNormals;
  79929. };
  79930. /**
  79931. * Returns the facetLocalPositions array.
  79932. * The facet positions are expressed in the mesh local space
  79933. * @returns an array of Vector3
  79934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79935. */
  79936. AbstractMesh.prototype.getFacetLocalPositions = function () {
  79937. if (!this._facetData.facetPositions) {
  79938. this.updateFacetData();
  79939. }
  79940. return this._facetData.facetPositions;
  79941. };
  79942. /**
  79943. * Returns the facetLocalPartioning array
  79944. * @returns an array of array of numbers
  79945. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79946. */
  79947. AbstractMesh.prototype.getFacetLocalPartitioning = function () {
  79948. if (!this._facetData.facetPartitioning) {
  79949. this.updateFacetData();
  79950. }
  79951. return this._facetData.facetPartitioning;
  79952. };
  79953. /**
  79954. * Returns the i-th facet position in the world system.
  79955. * This method allocates a new Vector3 per call
  79956. * @param i defines the facet index
  79957. * @returns a new Vector3
  79958. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79959. */
  79960. AbstractMesh.prototype.getFacetPosition = function (i) {
  79961. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79962. this.getFacetPositionToRef(i, pos);
  79963. return pos;
  79964. };
  79965. /**
  79966. * Sets the reference Vector3 with the i-th facet position in the world system
  79967. * @param i defines the facet index
  79968. * @param ref defines the target vector
  79969. * @returns the current mesh
  79970. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79971. */
  79972. AbstractMesh.prototype.getFacetPositionToRef = function (i, ref) {
  79973. var localPos = (this.getFacetLocalPositions())[i];
  79974. var world = this.getWorldMatrix();
  79975. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(localPos, world, ref);
  79976. return this;
  79977. };
  79978. /**
  79979. * Returns the i-th facet normal in the world system.
  79980. * This method allocates a new Vector3 per call
  79981. * @param i defines the facet index
  79982. * @returns a new Vector3
  79983. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79984. */
  79985. AbstractMesh.prototype.getFacetNormal = function (i) {
  79986. var norm = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79987. this.getFacetNormalToRef(i, norm);
  79988. return norm;
  79989. };
  79990. /**
  79991. * Sets the reference Vector3 with the i-th facet normal in the world system
  79992. * @param i defines the facet index
  79993. * @param ref defines the target vector
  79994. * @returns the current mesh
  79995. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79996. */
  79997. AbstractMesh.prototype.getFacetNormalToRef = function (i, ref) {
  79998. var localNorm = (this.getFacetLocalNormals())[i];
  79999. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
  80000. return this;
  80001. };
  80002. /**
  80003. * 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)
  80004. * @param x defines x coordinate
  80005. * @param y defines y coordinate
  80006. * @param z defines z coordinate
  80007. * @returns the array of facet indexes
  80008. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80009. */
  80010. AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
  80011. var bInfo = this.getBoundingInfo();
  80012. var data = this._facetData;
  80013. var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
  80014. var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
  80015. var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
  80016. if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
  80017. return null;
  80018. }
  80019. return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
  80020. };
  80021. /**
  80022. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  80023. * @param projected sets as the (x,y,z) world projection on the facet
  80024. * @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
  80025. * @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
  80026. * @param x defines x coordinate
  80027. * @param y defines y coordinate
  80028. * @param z defines z coordinate
  80029. * @returns the face index if found (or null instead)
  80030. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80031. */
  80032. AbstractMesh.prototype.getClosestFacetAtCoordinates = function (x, y, z, projected, checkFace, facing) {
  80033. if (checkFace === void 0) { checkFace = false; }
  80034. if (facing === void 0) { facing = true; }
  80035. var world = this.getWorldMatrix();
  80036. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5];
  80037. world.invertToRef(invMat);
  80038. var invVect = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[8];
  80039. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
  80040. var closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
  80041. if (projected) {
  80042. // tranform the local computed projected vector to world coordinates
  80043. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
  80044. }
  80045. return closest;
  80046. };
  80047. /**
  80048. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  80049. * @param projected sets as the (x,y,z) local projection on the facet
  80050. * @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
  80051. * @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
  80052. * @param x defines x coordinate
  80053. * @param y defines y coordinate
  80054. * @param z defines z coordinate
  80055. * @returns the face index if found (or null instead)
  80056. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80057. */
  80058. AbstractMesh.prototype.getClosestFacetAtLocalCoordinates = function (x, y, z, projected, checkFace, facing) {
  80059. if (checkFace === void 0) { checkFace = false; }
  80060. if (facing === void 0) { facing = true; }
  80061. var closest = null;
  80062. var tmpx = 0.0;
  80063. var tmpy = 0.0;
  80064. var tmpz = 0.0;
  80065. var d = 0.0; // tmp dot facet normal * facet position
  80066. var t0 = 0.0;
  80067. var projx = 0.0;
  80068. var projy = 0.0;
  80069. var projz = 0.0;
  80070. // Get all the facets in the same partitioning block than (x, y, z)
  80071. var facetPositions = this.getFacetLocalPositions();
  80072. var facetNormals = this.getFacetLocalNormals();
  80073. var facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
  80074. if (!facetsInBlock) {
  80075. return null;
  80076. }
  80077. // Get the closest facet to (x, y, z)
  80078. var shortest = Number.MAX_VALUE; // init distance vars
  80079. var tmpDistance = shortest;
  80080. var fib; // current facet in the block
  80081. var norm; // current facet normal
  80082. var p0; // current facet barycenter position
  80083. // loop on all the facets in the current partitioning block
  80084. for (var idx = 0; idx < facetsInBlock.length; idx++) {
  80085. fib = facetsInBlock[idx];
  80086. norm = facetNormals[fib];
  80087. p0 = facetPositions[fib];
  80088. d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
  80089. if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
  80090. // compute (x,y,z) projection on the facet = (projx, projy, projz)
  80091. d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
  80092. t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
  80093. projx = x + norm.x * t0;
  80094. projy = y + norm.y * t0;
  80095. projz = z + norm.z * t0;
  80096. tmpx = projx - x;
  80097. tmpy = projy - y;
  80098. tmpz = projz - z;
  80099. tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
  80100. if (tmpDistance < shortest) { // just keep the closest facet to (x, y, z)
  80101. shortest = tmpDistance;
  80102. closest = fib;
  80103. if (projected) {
  80104. projected.x = projx;
  80105. projected.y = projy;
  80106. projected.z = projz;
  80107. }
  80108. }
  80109. }
  80110. }
  80111. return closest;
  80112. };
  80113. /**
  80114. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  80115. * @returns the parameters
  80116. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80117. */
  80118. AbstractMesh.prototype.getFacetDataParameters = function () {
  80119. return this._facetData.facetParameters;
  80120. };
  80121. /**
  80122. * Disables the feature FacetData and frees the related memory
  80123. * @returns the current mesh
  80124. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80125. */
  80126. AbstractMesh.prototype.disableFacetData = function () {
  80127. if (this._facetData.facetDataEnabled) {
  80128. this._facetData.facetDataEnabled = false;
  80129. this._facetData.facetPositions = new Array();
  80130. this._facetData.facetNormals = new Array();
  80131. this._facetData.facetPartitioning = new Array();
  80132. this._facetData.facetParameters = null;
  80133. this._facetData.depthSortedIndices = new Uint32Array(0);
  80134. }
  80135. return this;
  80136. };
  80137. /**
  80138. * Updates the AbstractMesh indices array
  80139. * @param indices defines the data source
  80140. * @returns the current mesh
  80141. */
  80142. AbstractMesh.prototype.updateIndices = function (indices) {
  80143. return this;
  80144. };
  80145. /**
  80146. * Creates new normals data for the mesh
  80147. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  80148. * @returns the current mesh
  80149. */
  80150. AbstractMesh.prototype.createNormals = function (updatable) {
  80151. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  80152. var indices = this.getIndices();
  80153. var normals;
  80154. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  80155. normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  80156. }
  80157. else {
  80158. normals = [];
  80159. }
  80160. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
  80161. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind, normals, updatable);
  80162. return this;
  80163. };
  80164. /**
  80165. * Align the mesh with a normal
  80166. * @param normal defines the normal to use
  80167. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  80168. * @returns the current mesh
  80169. */
  80170. AbstractMesh.prototype.alignWithNormal = function (normal, upDirection) {
  80171. if (!upDirection) {
  80172. upDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y;
  80173. }
  80174. var axisX = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  80175. var axisZ = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  80176. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(upDirection, normal, axisZ);
  80177. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(normal, axisZ, axisX);
  80178. if (this.rotationQuaternion) {
  80179. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
  80180. }
  80181. else {
  80182. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
  80183. }
  80184. return this;
  80185. };
  80186. /** @hidden */
  80187. AbstractMesh.prototype._checkOcclusionQuery = function () {
  80188. return false;
  80189. };
  80190. /** No occlusion */
  80191. AbstractMesh.OCCLUSION_TYPE_NONE = 0;
  80192. /** Occlusion set to optimisitic */
  80193. AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
  80194. /** Occlusion set to strict */
  80195. AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
  80196. /** Use an accurante occlusion algorithm */
  80197. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
  80198. /** Use a conservative occlusion algorithm */
  80199. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
  80200. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80201. * Test order :
  80202. * Is the bounding sphere outside the frustum ?
  80203. * If not, are the bounding box vertices outside the frustum ?
  80204. * It not, then the cullable object is in the frustum.
  80205. */
  80206. AbstractMesh.CULLINGSTRATEGY_STANDARD = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD;
  80207. /** Culling strategy : Bounding Sphere Only.
  80208. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80209. * It's also less accurate than the standard because some not visible objects can still be selected.
  80210. * Test : is the bounding sphere outside the frustum ?
  80211. * If not, then the cullable object is in the frustum.
  80212. */
  80213. AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  80214. /** Culling strategy : Optimistic Inclusion.
  80215. * This in an inclusion test first, then the standard exclusion test.
  80216. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80217. * 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.
  80218. * Anyway, it's as accurate as the standard strategy.
  80219. * Test :
  80220. * Is the cullable object bounding sphere center in the frustum ?
  80221. * If not, apply the default culling strategy.
  80222. */
  80223. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
  80224. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80225. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80226. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80227. * 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.
  80228. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80229. * Test :
  80230. * Is the cullable object bounding sphere center in the frustum ?
  80231. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80232. */
  80233. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;
  80234. return AbstractMesh;
  80235. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"]));
  80236. /***/ }),
  80237. /***/ "./Meshes/buffer.ts":
  80238. /*!**************************!*\
  80239. !*** ./Meshes/buffer.ts ***!
  80240. \**************************/
  80241. /*! exports provided: Buffer, VertexBuffer */
  80242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80243. "use strict";
  80244. __webpack_require__.r(__webpack_exports__);
  80245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return Buffer; });
  80246. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return VertexBuffer; });
  80247. /**
  80248. * Class used to store data that will be store in GPU memory
  80249. */
  80250. var Buffer = /** @class */ (function () {
  80251. /**
  80252. * Constructor
  80253. * @param engine the engine
  80254. * @param data the data to use for this buffer
  80255. * @param updatable whether the data is updatable
  80256. * @param stride the stride (optional)
  80257. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80258. * @param instanced whether the buffer is instanced (optional)
  80259. * @param useBytes set to true if the stride in in bytes (optional)
  80260. */
  80261. function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes) {
  80262. if (stride === void 0) { stride = 0; }
  80263. if (postponeInternalCreation === void 0) { postponeInternalCreation = false; }
  80264. if (instanced === void 0) { instanced = false; }
  80265. if (useBytes === void 0) { useBytes = false; }
  80266. if (engine.getScene) { // old versions of VertexBuffer accepted 'mesh' instead of 'engine'
  80267. this._engine = engine.getScene().getEngine();
  80268. }
  80269. else {
  80270. this._engine = engine;
  80271. }
  80272. this._updatable = updatable;
  80273. this._instanced = instanced;
  80274. this._data = data;
  80275. this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
  80276. if (!postponeInternalCreation) { // by default
  80277. this.create();
  80278. }
  80279. }
  80280. /**
  80281. * Create a new VertexBuffer based on the current buffer
  80282. * @param kind defines the vertex buffer kind (position, normal, etc.)
  80283. * @param offset defines offset in the buffer (0 by default)
  80284. * @param size defines the size in floats of attributes (position is 3 for instance)
  80285. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  80286. * @param instanced defines if the vertex buffer contains indexed data
  80287. * @param useBytes defines if the offset and stride are in bytes
  80288. * @returns the new vertex buffer
  80289. */
  80290. Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride, instanced, useBytes) {
  80291. if (useBytes === void 0) { useBytes = false; }
  80292. var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
  80293. var byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;
  80294. // a lot of these parameters are ignored as they are overriden by the buffer
  80295. return new VertexBuffer(this._engine, this, kind, this._updatable, true, byteStride, instanced === undefined ? this._instanced : instanced, byteOffset, size, undefined, undefined, true);
  80296. };
  80297. // Properties
  80298. /**
  80299. * Gets a boolean indicating if the Buffer is updatable?
  80300. * @returns true if the buffer is updatable
  80301. */
  80302. Buffer.prototype.isUpdatable = function () {
  80303. return this._updatable;
  80304. };
  80305. /**
  80306. * Gets current buffer's data
  80307. * @returns a DataArray or null
  80308. */
  80309. Buffer.prototype.getData = function () {
  80310. return this._data;
  80311. };
  80312. /**
  80313. * Gets underlying native buffer
  80314. * @returns underlying native buffer
  80315. */
  80316. Buffer.prototype.getBuffer = function () {
  80317. return this._buffer;
  80318. };
  80319. /**
  80320. * Gets the stride in float32 units (i.e. byte stride / 4).
  80321. * May not be an integer if the byte stride is not divisible by 4.
  80322. * DEPRECATED. Use byteStride instead.
  80323. * @returns the stride in float32 units
  80324. */
  80325. Buffer.prototype.getStrideSize = function () {
  80326. return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
  80327. };
  80328. // Methods
  80329. /**
  80330. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80331. * @param data defines the data to store
  80332. */
  80333. Buffer.prototype.create = function (data) {
  80334. if (data === void 0) { data = null; }
  80335. if (!data && this._buffer) {
  80336. return; // nothing to do
  80337. }
  80338. data = data || this._data;
  80339. if (!data) {
  80340. return;
  80341. }
  80342. if (!this._buffer) { // create buffer
  80343. if (this._updatable) {
  80344. this._buffer = this._engine.createDynamicVertexBuffer(data);
  80345. this._data = data;
  80346. }
  80347. else {
  80348. this._buffer = this._engine.createVertexBuffer(data);
  80349. }
  80350. }
  80351. else if (this._updatable) { // update buffer
  80352. this._engine.updateDynamicVertexBuffer(this._buffer, data);
  80353. this._data = data;
  80354. }
  80355. };
  80356. /** @hidden */
  80357. Buffer.prototype._rebuild = function () {
  80358. this._buffer = null;
  80359. this.create(this._data);
  80360. };
  80361. /**
  80362. * Update current buffer data
  80363. * @param data defines the data to store
  80364. */
  80365. Buffer.prototype.update = function (data) {
  80366. this.create(data);
  80367. };
  80368. /**
  80369. * Updates the data directly.
  80370. * @param data the new data
  80371. * @param offset the new offset
  80372. * @param vertexCount the vertex count (optional)
  80373. * @param useBytes set to true if the offset is in bytes
  80374. */
  80375. Buffer.prototype.updateDirectly = function (data, offset, vertexCount, useBytes) {
  80376. if (useBytes === void 0) { useBytes = false; }
  80377. if (!this._buffer) {
  80378. return;
  80379. }
  80380. if (this._updatable) { // update buffer
  80381. this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, (vertexCount ? vertexCount * this.byteStride : undefined));
  80382. this._data = null;
  80383. }
  80384. };
  80385. /**
  80386. * Release all resources
  80387. */
  80388. Buffer.prototype.dispose = function () {
  80389. if (!this._buffer) {
  80390. return;
  80391. }
  80392. if (this._engine._releaseBuffer(this._buffer)) {
  80393. this._buffer = null;
  80394. }
  80395. };
  80396. return Buffer;
  80397. }());
  80398. /**
  80399. * Specialized buffer used to store vertex data
  80400. */
  80401. var VertexBuffer = /** @class */ (function () {
  80402. /**
  80403. * Constructor
  80404. * @param engine the engine
  80405. * @param data the data to use for this vertex buffer
  80406. * @param kind the vertex buffer kind
  80407. * @param updatable whether the data is updatable
  80408. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80409. * @param stride the stride (optional)
  80410. * @param instanced whether the buffer is instanced (optional)
  80411. * @param offset the offset of the data (optional)
  80412. * @param size the number of components (optional)
  80413. * @param type the type of the component (optional)
  80414. * @param normalized whether the data contains normalized data (optional)
  80415. * @param useBytes set to true if stride and offset are in bytes (optional)
  80416. */
  80417. function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized, useBytes) {
  80418. if (normalized === void 0) { normalized = false; }
  80419. if (useBytes === void 0) { useBytes = false; }
  80420. if (data instanceof Buffer) {
  80421. this._buffer = data;
  80422. this._ownsBuffer = false;
  80423. }
  80424. else {
  80425. this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);
  80426. this._ownsBuffer = true;
  80427. }
  80428. this._kind = kind;
  80429. if (type == undefined) {
  80430. var data_1 = this.getData();
  80431. this.type = VertexBuffer.FLOAT;
  80432. if (data_1 instanceof Int8Array) {
  80433. this.type = VertexBuffer.BYTE;
  80434. }
  80435. else if (data_1 instanceof Uint8Array) {
  80436. this.type = VertexBuffer.UNSIGNED_BYTE;
  80437. }
  80438. else if (data_1 instanceof Int16Array) {
  80439. this.type = VertexBuffer.SHORT;
  80440. }
  80441. else if (data_1 instanceof Uint16Array) {
  80442. this.type = VertexBuffer.UNSIGNED_SHORT;
  80443. }
  80444. else if (data_1 instanceof Int32Array) {
  80445. this.type = VertexBuffer.INT;
  80446. }
  80447. else if (data_1 instanceof Uint32Array) {
  80448. this.type = VertexBuffer.UNSIGNED_INT;
  80449. }
  80450. }
  80451. else {
  80452. this.type = type;
  80453. }
  80454. var typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
  80455. if (useBytes) {
  80456. this._size = size || (stride ? (stride / typeByteLength) : VertexBuffer.DeduceStride(kind));
  80457. this.byteStride = stride || this._buffer.byteStride || (this._size * typeByteLength);
  80458. this.byteOffset = offset || 0;
  80459. }
  80460. else {
  80461. this._size = size || stride || VertexBuffer.DeduceStride(kind);
  80462. this.byteStride = stride ? (stride * typeByteLength) : (this._buffer.byteStride || (this._size * typeByteLength));
  80463. this.byteOffset = (offset || 0) * typeByteLength;
  80464. }
  80465. this.normalized = normalized;
  80466. this._instanced = instanced !== undefined ? instanced : false;
  80467. this._instanceDivisor = instanced ? 1 : 0;
  80468. }
  80469. Object.defineProperty(VertexBuffer.prototype, "instanceDivisor", {
  80470. /**
  80471. * Gets or sets the instance divisor when in instanced mode
  80472. */
  80473. get: function () {
  80474. return this._instanceDivisor;
  80475. },
  80476. set: function (value) {
  80477. this._instanceDivisor = value;
  80478. if (value == 0) {
  80479. this._instanced = false;
  80480. }
  80481. else {
  80482. this._instanced = true;
  80483. }
  80484. },
  80485. enumerable: true,
  80486. configurable: true
  80487. });
  80488. /** @hidden */
  80489. VertexBuffer.prototype._rebuild = function () {
  80490. if (!this._buffer) {
  80491. return;
  80492. }
  80493. this._buffer._rebuild();
  80494. };
  80495. /**
  80496. * Returns the kind of the VertexBuffer (string)
  80497. * @returns a string
  80498. */
  80499. VertexBuffer.prototype.getKind = function () {
  80500. return this._kind;
  80501. };
  80502. // Properties
  80503. /**
  80504. * Gets a boolean indicating if the VertexBuffer is updatable?
  80505. * @returns true if the buffer is updatable
  80506. */
  80507. VertexBuffer.prototype.isUpdatable = function () {
  80508. return this._buffer.isUpdatable();
  80509. };
  80510. /**
  80511. * Gets current buffer's data
  80512. * @returns a DataArray or null
  80513. */
  80514. VertexBuffer.prototype.getData = function () {
  80515. return this._buffer.getData();
  80516. };
  80517. /**
  80518. * Gets underlying native buffer
  80519. * @returns underlying native buffer
  80520. */
  80521. VertexBuffer.prototype.getBuffer = function () {
  80522. return this._buffer.getBuffer();
  80523. };
  80524. /**
  80525. * Gets the stride in float32 units (i.e. byte stride / 4).
  80526. * May not be an integer if the byte stride is not divisible by 4.
  80527. * DEPRECATED. Use byteStride instead.
  80528. * @returns the stride in float32 units
  80529. */
  80530. VertexBuffer.prototype.getStrideSize = function () {
  80531. return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);
  80532. };
  80533. /**
  80534. * Returns the offset as a multiple of the type byte length.
  80535. * DEPRECATED. Use byteOffset instead.
  80536. * @returns the offset in bytes
  80537. */
  80538. VertexBuffer.prototype.getOffset = function () {
  80539. return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);
  80540. };
  80541. /**
  80542. * Returns the number of components per vertex attribute (integer)
  80543. * @returns the size in float
  80544. */
  80545. VertexBuffer.prototype.getSize = function () {
  80546. return this._size;
  80547. };
  80548. /**
  80549. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  80550. * @returns true if this buffer is instanced
  80551. */
  80552. VertexBuffer.prototype.getIsInstanced = function () {
  80553. return this._instanced;
  80554. };
  80555. /**
  80556. * Returns the instancing divisor, zero for non-instanced (integer).
  80557. * @returns a number
  80558. */
  80559. VertexBuffer.prototype.getInstanceDivisor = function () {
  80560. return this._instanceDivisor;
  80561. };
  80562. // Methods
  80563. /**
  80564. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80565. * @param data defines the data to store
  80566. */
  80567. VertexBuffer.prototype.create = function (data) {
  80568. this._buffer.create(data);
  80569. };
  80570. /**
  80571. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  80572. * This function will create a new buffer if the current one is not updatable
  80573. * @param data defines the data to store
  80574. */
  80575. VertexBuffer.prototype.update = function (data) {
  80576. this._buffer.update(data);
  80577. };
  80578. /**
  80579. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  80580. * Returns the directly updated WebGLBuffer.
  80581. * @param data the new data
  80582. * @param offset the new offset
  80583. * @param useBytes set to true if the offset is in bytes
  80584. */
  80585. VertexBuffer.prototype.updateDirectly = function (data, offset, useBytes) {
  80586. if (useBytes === void 0) { useBytes = false; }
  80587. this._buffer.updateDirectly(data, offset, undefined, useBytes);
  80588. };
  80589. /**
  80590. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  80591. */
  80592. VertexBuffer.prototype.dispose = function () {
  80593. if (this._ownsBuffer) {
  80594. this._buffer.dispose();
  80595. }
  80596. };
  80597. /**
  80598. * Enumerates each value of this vertex buffer as numbers.
  80599. * @param count the number of values to enumerate
  80600. * @param callback the callback function called for each value
  80601. */
  80602. VertexBuffer.prototype.forEach = function (count, callback) {
  80603. VertexBuffer.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
  80604. };
  80605. /**
  80606. * Deduces the stride given a kind.
  80607. * @param kind The kind string to deduce
  80608. * @returns The deduced stride
  80609. */
  80610. VertexBuffer.DeduceStride = function (kind) {
  80611. switch (kind) {
  80612. case VertexBuffer.UVKind:
  80613. case VertexBuffer.UV2Kind:
  80614. case VertexBuffer.UV3Kind:
  80615. case VertexBuffer.UV4Kind:
  80616. case VertexBuffer.UV5Kind:
  80617. case VertexBuffer.UV6Kind:
  80618. return 2;
  80619. case VertexBuffer.NormalKind:
  80620. case VertexBuffer.PositionKind:
  80621. return 3;
  80622. case VertexBuffer.ColorKind:
  80623. case VertexBuffer.MatricesIndicesKind:
  80624. case VertexBuffer.MatricesIndicesExtraKind:
  80625. case VertexBuffer.MatricesWeightsKind:
  80626. case VertexBuffer.MatricesWeightsExtraKind:
  80627. case VertexBuffer.TangentKind:
  80628. return 4;
  80629. default:
  80630. throw new Error("Invalid kind '" + kind + "'");
  80631. }
  80632. };
  80633. /**
  80634. * Gets the byte length of the given type.
  80635. * @param type the type
  80636. * @returns the number of bytes
  80637. */
  80638. VertexBuffer.GetTypeByteLength = function (type) {
  80639. switch (type) {
  80640. case VertexBuffer.BYTE:
  80641. case VertexBuffer.UNSIGNED_BYTE:
  80642. return 1;
  80643. case VertexBuffer.SHORT:
  80644. case VertexBuffer.UNSIGNED_SHORT:
  80645. return 2;
  80646. case VertexBuffer.INT:
  80647. case VertexBuffer.FLOAT:
  80648. return 4;
  80649. default:
  80650. throw new Error("Invalid type '" + type + "'");
  80651. }
  80652. };
  80653. /**
  80654. * Enumerates each value of the given parameters as numbers.
  80655. * @param data the data to enumerate
  80656. * @param byteOffset the byte offset of the data
  80657. * @param byteStride the byte stride of the data
  80658. * @param componentCount the number of components per element
  80659. * @param componentType the type of the component
  80660. * @param count the total number of components
  80661. * @param normalized whether the data is normalized
  80662. * @param callback the callback function called for each value
  80663. */
  80664. VertexBuffer.ForEach = function (data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
  80665. if (data instanceof Array) {
  80666. var offset = byteOffset / 4;
  80667. var stride = byteStride / 4;
  80668. for (var index = 0; index < count; index += componentCount) {
  80669. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  80670. callback(data[offset + componentIndex], index + componentIndex);
  80671. }
  80672. offset += stride;
  80673. }
  80674. }
  80675. else {
  80676. var dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
  80677. var componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
  80678. for (var index = 0; index < count; index += componentCount) {
  80679. var componentByteOffset = byteOffset;
  80680. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  80681. var value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
  80682. callback(value, index + componentIndex);
  80683. componentByteOffset += componentByteLength;
  80684. }
  80685. byteOffset += byteStride;
  80686. }
  80687. }
  80688. };
  80689. VertexBuffer._GetFloatValue = function (dataView, type, byteOffset, normalized) {
  80690. switch (type) {
  80691. case VertexBuffer.BYTE: {
  80692. var value = dataView.getInt8(byteOffset);
  80693. if (normalized) {
  80694. value = Math.max(value / 127, -1);
  80695. }
  80696. return value;
  80697. }
  80698. case VertexBuffer.UNSIGNED_BYTE: {
  80699. var value = dataView.getUint8(byteOffset);
  80700. if (normalized) {
  80701. value = value / 255;
  80702. }
  80703. return value;
  80704. }
  80705. case VertexBuffer.SHORT: {
  80706. var value = dataView.getInt16(byteOffset, true);
  80707. if (normalized) {
  80708. value = Math.max(value / 16383, -1);
  80709. }
  80710. return value;
  80711. }
  80712. case VertexBuffer.UNSIGNED_SHORT: {
  80713. var value = dataView.getUint16(byteOffset, true);
  80714. if (normalized) {
  80715. value = value / 65535;
  80716. }
  80717. return value;
  80718. }
  80719. case VertexBuffer.FLOAT: {
  80720. return dataView.getFloat32(byteOffset, true);
  80721. }
  80722. default: {
  80723. throw new Error("Invalid component type " + type);
  80724. }
  80725. }
  80726. };
  80727. /**
  80728. * The byte type.
  80729. */
  80730. VertexBuffer.BYTE = 5120;
  80731. /**
  80732. * The unsigned byte type.
  80733. */
  80734. VertexBuffer.UNSIGNED_BYTE = 5121;
  80735. /**
  80736. * The short type.
  80737. */
  80738. VertexBuffer.SHORT = 5122;
  80739. /**
  80740. * The unsigned short type.
  80741. */
  80742. VertexBuffer.UNSIGNED_SHORT = 5123;
  80743. /**
  80744. * The integer type.
  80745. */
  80746. VertexBuffer.INT = 5124;
  80747. /**
  80748. * The unsigned integer type.
  80749. */
  80750. VertexBuffer.UNSIGNED_INT = 5125;
  80751. /**
  80752. * The float type.
  80753. */
  80754. VertexBuffer.FLOAT = 5126;
  80755. // Enums
  80756. /**
  80757. * Positions
  80758. */
  80759. VertexBuffer.PositionKind = "position";
  80760. /**
  80761. * Normals
  80762. */
  80763. VertexBuffer.NormalKind = "normal";
  80764. /**
  80765. * Tangents
  80766. */
  80767. VertexBuffer.TangentKind = "tangent";
  80768. /**
  80769. * Texture coordinates
  80770. */
  80771. VertexBuffer.UVKind = "uv";
  80772. /**
  80773. * Texture coordinates 2
  80774. */
  80775. VertexBuffer.UV2Kind = "uv2";
  80776. /**
  80777. * Texture coordinates 3
  80778. */
  80779. VertexBuffer.UV3Kind = "uv3";
  80780. /**
  80781. * Texture coordinates 4
  80782. */
  80783. VertexBuffer.UV4Kind = "uv4";
  80784. /**
  80785. * Texture coordinates 5
  80786. */
  80787. VertexBuffer.UV5Kind = "uv5";
  80788. /**
  80789. * Texture coordinates 6
  80790. */
  80791. VertexBuffer.UV6Kind = "uv6";
  80792. /**
  80793. * Colors
  80794. */
  80795. VertexBuffer.ColorKind = "color";
  80796. /**
  80797. * Matrix indices (for bones)
  80798. */
  80799. VertexBuffer.MatricesIndicesKind = "matricesIndices";
  80800. /**
  80801. * Matrix weights (for bones)
  80802. */
  80803. VertexBuffer.MatricesWeightsKind = "matricesWeights";
  80804. /**
  80805. * Additional matrix indices (for bones)
  80806. */
  80807. VertexBuffer.MatricesIndicesExtraKind = "matricesIndicesExtra";
  80808. /**
  80809. * Additional matrix weights (for bones)
  80810. */
  80811. VertexBuffer.MatricesWeightsExtraKind = "matricesWeightsExtra";
  80812. return VertexBuffer;
  80813. }());
  80814. /***/ }),
  80815. /***/ "./Meshes/csg.ts":
  80816. /*!***********************!*\
  80817. !*** ./Meshes/csg.ts ***!
  80818. \***********************/
  80819. /*! exports provided: CSG */
  80820. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80821. "use strict";
  80822. __webpack_require__.r(__webpack_exports__);
  80823. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return CSG; });
  80824. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  80825. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  80826. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  80827. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  80828. /**
  80829. * Unique ID when we import meshes from Babylon to CSG
  80830. */
  80831. var currentCSGMeshId = 0;
  80832. /**
  80833. * Represents a vertex of a polygon. Use your own vertex class instead of this
  80834. * one to provide additional features like texture coordinates and vertex
  80835. * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
  80836. * `flip()`, and `interpolate()` methods that behave analogous to the ones
  80837. * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
  80838. * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
  80839. * is not used anywhere else.
  80840. * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
  80841. */
  80842. var Vertex = /** @class */ (function () {
  80843. /**
  80844. * Initializes the vertex
  80845. * @param pos The position of the vertex
  80846. * @param normal The normal of the vertex
  80847. * @param uv The texture coordinate of the vertex
  80848. */
  80849. function Vertex(
  80850. /**
  80851. * The position of the vertex
  80852. */
  80853. pos,
  80854. /**
  80855. * The normal of the vertex
  80856. */
  80857. normal,
  80858. /**
  80859. * The texture coordinate of the vertex
  80860. */
  80861. uv) {
  80862. this.pos = pos;
  80863. this.normal = normal;
  80864. this.uv = uv;
  80865. }
  80866. /**
  80867. * Make a clone, or deep copy, of the vertex
  80868. * @returns A new Vertex
  80869. */
  80870. Vertex.prototype.clone = function () {
  80871. return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
  80872. };
  80873. /**
  80874. * Invert all orientation-specific data (e.g. vertex normal). Called when the
  80875. * orientation of a polygon is flipped.
  80876. */
  80877. Vertex.prototype.flip = function () {
  80878. this.normal = this.normal.scale(-1);
  80879. };
  80880. /**
  80881. * Create a new vertex between this vertex and `other` by linearly
  80882. * interpolating all properties using a parameter of `t`. Subclasses should
  80883. * override this to interpolate additional properties.
  80884. * @param other the vertex to interpolate against
  80885. * @param t The factor used to linearly interpolate between the vertices
  80886. */
  80887. Vertex.prototype.interpolate = function (other, t) {
  80888. 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));
  80889. };
  80890. return Vertex;
  80891. }());
  80892. /**
  80893. * Represents a plane in 3D space.
  80894. */
  80895. var Plane = /** @class */ (function () {
  80896. /**
  80897. * Initializes the plane
  80898. * @param normal The normal for the plane
  80899. * @param w
  80900. */
  80901. function Plane(normal, w) {
  80902. this.normal = normal;
  80903. this.w = w;
  80904. }
  80905. /**
  80906. * Construct a plane from three points
  80907. * @param a Point a
  80908. * @param b Point b
  80909. * @param c Point c
  80910. */
  80911. Plane.FromPoints = function (a, b, c) {
  80912. var v0 = c.subtract(a);
  80913. var v1 = b.subtract(a);
  80914. if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {
  80915. return null;
  80916. }
  80917. var n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v0, v1));
  80918. return new Plane(n, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(n, a));
  80919. };
  80920. /**
  80921. * Clone, or make a deep copy of the plane
  80922. * @returns a new Plane
  80923. */
  80924. Plane.prototype.clone = function () {
  80925. return new Plane(this.normal.clone(), this.w);
  80926. };
  80927. /**
  80928. * Flip the face of the plane
  80929. */
  80930. Plane.prototype.flip = function () {
  80931. this.normal.scaleInPlace(-1);
  80932. this.w = -this.w;
  80933. };
  80934. /**
  80935. * Split `polygon` by this plane if needed, then put the polygon or polygon
  80936. * fragments in the appropriate lists. Coplanar polygons go into either
  80937. `* coplanarFront` or `coplanarBack` depending on their orientation with
  80938. * respect to this plane. Polygons in front or in back of this plane go into
  80939. * either `front` or `back`
  80940. * @param polygon The polygon to be split
  80941. * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
  80942. * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
  80943. * @param front Will contain the polygons in front of the plane
  80944. * @param back Will contain the polygons begind the plane
  80945. */
  80946. Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
  80947. var COPLANAR = 0;
  80948. var FRONT = 1;
  80949. var BACK = 2;
  80950. var SPANNING = 3;
  80951. // Classify each point as well as the entire polygon into one of the above
  80952. // four classes.
  80953. var polygonType = 0;
  80954. var types = [];
  80955. var i;
  80956. var t;
  80957. for (i = 0; i < polygon.vertices.length; i++) {
  80958. t = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.vertices[i].pos) - this.w;
  80959. var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
  80960. polygonType |= type;
  80961. types.push(type);
  80962. }
  80963. // Put the polygon in the correct list, splitting it when necessary
  80964. switch (polygonType) {
  80965. case COPLANAR:
  80966. (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
  80967. break;
  80968. case FRONT:
  80969. front.push(polygon);
  80970. break;
  80971. case BACK:
  80972. back.push(polygon);
  80973. break;
  80974. case SPANNING:
  80975. var f = [], b = [];
  80976. for (i = 0; i < polygon.vertices.length; i++) {
  80977. var j = (i + 1) % polygon.vertices.length;
  80978. var ti = types[i], tj = types[j];
  80979. var vi = polygon.vertices[i], vj = polygon.vertices[j];
  80980. if (ti !== BACK) {
  80981. f.push(vi);
  80982. }
  80983. if (ti !== FRONT) {
  80984. b.push(ti !== BACK ? vi.clone() : vi);
  80985. }
  80986. if ((ti | tj) === SPANNING) {
  80987. 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));
  80988. var v = vi.interpolate(vj, t);
  80989. f.push(v);
  80990. b.push(v.clone());
  80991. }
  80992. }
  80993. var poly;
  80994. if (f.length >= 3) {
  80995. poly = new Polygon(f, polygon.shared);
  80996. if (poly.plane) {
  80997. front.push(poly);
  80998. }
  80999. }
  81000. if (b.length >= 3) {
  81001. poly = new Polygon(b, polygon.shared);
  81002. if (poly.plane) {
  81003. back.push(poly);
  81004. }
  81005. }
  81006. break;
  81007. }
  81008. };
  81009. /**
  81010. * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
  81011. * point is on the plane
  81012. */
  81013. Plane.EPSILON = 1e-5;
  81014. return Plane;
  81015. }());
  81016. /**
  81017. * Represents a convex polygon. The vertices used to initialize a polygon must
  81018. * be coplanar and form a convex loop.
  81019. *
  81020. * Each convex polygon has a `shared` property, which is shared between all
  81021. * polygons that are clones of each other or were split from the same polygon.
  81022. * This can be used to define per-polygon properties (such as surface color)
  81023. */
  81024. var Polygon = /** @class */ (function () {
  81025. /**
  81026. * Initializes the polygon
  81027. * @param vertices The vertices of the polygon
  81028. * @param shared The properties shared across all polygons
  81029. */
  81030. function Polygon(vertices, shared) {
  81031. this.vertices = vertices;
  81032. this.shared = shared;
  81033. this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
  81034. }
  81035. /**
  81036. * Clones, or makes a deep copy, or the polygon
  81037. */
  81038. Polygon.prototype.clone = function () {
  81039. var vertices = this.vertices.map(function (v) { return v.clone(); });
  81040. return new Polygon(vertices, this.shared);
  81041. };
  81042. /**
  81043. * Flips the faces of the polygon
  81044. */
  81045. Polygon.prototype.flip = function () {
  81046. this.vertices.reverse().map(function (v) { v.flip(); });
  81047. this.plane.flip();
  81048. };
  81049. return Polygon;
  81050. }());
  81051. /**
  81052. * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
  81053. * by picking a polygon to split along. That polygon (and all other coplanar
  81054. * polygons) are added directly to that node and the other polygons are added to
  81055. * the front and/or back subtrees. This is not a leafy BSP tree since there is
  81056. * no distinction between internal and leaf nodes
  81057. */
  81058. var Node = /** @class */ (function () {
  81059. /**
  81060. * Initializes the node
  81061. * @param polygons A collection of polygons held in the node
  81062. */
  81063. function Node(polygons) {
  81064. this.plane = null;
  81065. this.front = null;
  81066. this.back = null;
  81067. this.polygons = new Array();
  81068. if (polygons) {
  81069. this.build(polygons);
  81070. }
  81071. }
  81072. /**
  81073. * Clones, or makes a deep copy, of the node
  81074. * @returns The cloned node
  81075. */
  81076. Node.prototype.clone = function () {
  81077. var node = new Node();
  81078. node.plane = this.plane && this.plane.clone();
  81079. node.front = this.front && this.front.clone();
  81080. node.back = this.back && this.back.clone();
  81081. node.polygons = this.polygons.map(function (p) { return p.clone(); });
  81082. return node;
  81083. };
  81084. /**
  81085. * Convert solid space to empty space and empty space to solid space
  81086. */
  81087. Node.prototype.invert = function () {
  81088. for (var i = 0; i < this.polygons.length; i++) {
  81089. this.polygons[i].flip();
  81090. }
  81091. if (this.plane) {
  81092. this.plane.flip();
  81093. }
  81094. if (this.front) {
  81095. this.front.invert();
  81096. }
  81097. if (this.back) {
  81098. this.back.invert();
  81099. }
  81100. var temp = this.front;
  81101. this.front = this.back;
  81102. this.back = temp;
  81103. };
  81104. /**
  81105. * Recursively remove all polygons in `polygons` that are inside this BSP
  81106. * tree.
  81107. * @param polygons Polygons to remove from the BSP
  81108. * @returns Polygons clipped from the BSP
  81109. */
  81110. Node.prototype.clipPolygons = function (polygons) {
  81111. if (!this.plane) {
  81112. return polygons.slice();
  81113. }
  81114. var front = new Array(), back = new Array();
  81115. for (var i = 0; i < polygons.length; i++) {
  81116. this.plane.splitPolygon(polygons[i], front, back, front, back);
  81117. }
  81118. if (this.front) {
  81119. front = this.front.clipPolygons(front);
  81120. }
  81121. if (this.back) {
  81122. back = this.back.clipPolygons(back);
  81123. }
  81124. else {
  81125. back = [];
  81126. }
  81127. return front.concat(back);
  81128. };
  81129. /**
  81130. * Remove all polygons in this BSP tree that are inside the other BSP tree
  81131. * `bsp`.
  81132. * @param bsp BSP containing polygons to remove from this BSP
  81133. */
  81134. Node.prototype.clipTo = function (bsp) {
  81135. this.polygons = bsp.clipPolygons(this.polygons);
  81136. if (this.front) {
  81137. this.front.clipTo(bsp);
  81138. }
  81139. if (this.back) {
  81140. this.back.clipTo(bsp);
  81141. }
  81142. };
  81143. /**
  81144. * Return a list of all polygons in this BSP tree
  81145. * @returns List of all polygons in this BSP tree
  81146. */
  81147. Node.prototype.allPolygons = function () {
  81148. var polygons = this.polygons.slice();
  81149. if (this.front) {
  81150. polygons = polygons.concat(this.front.allPolygons());
  81151. }
  81152. if (this.back) {
  81153. polygons = polygons.concat(this.back.allPolygons());
  81154. }
  81155. return polygons;
  81156. };
  81157. /**
  81158. * Build a BSP tree out of `polygons`. When called on an existing tree, the
  81159. * new polygons are filtered down to the bottom of the tree and become new
  81160. * nodes there. Each set of polygons is partitioned using the first polygon
  81161. * (no heuristic is used to pick a good split)
  81162. * @param polygons Polygons used to construct the BSP tree
  81163. */
  81164. Node.prototype.build = function (polygons) {
  81165. if (!polygons.length) {
  81166. return;
  81167. }
  81168. if (!this.plane) {
  81169. this.plane = polygons[0].plane.clone();
  81170. }
  81171. var front = new Array(), back = new Array();
  81172. for (var i = 0; i < polygons.length; i++) {
  81173. this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  81174. }
  81175. if (front.length) {
  81176. if (!this.front) {
  81177. this.front = new Node();
  81178. }
  81179. this.front.build(front);
  81180. }
  81181. if (back.length) {
  81182. if (!this.back) {
  81183. this.back = new Node();
  81184. }
  81185. this.back.build(back);
  81186. }
  81187. };
  81188. return Node;
  81189. }());
  81190. /**
  81191. * Class for building Constructive Solid Geometry
  81192. */
  81193. var CSG = /** @class */ (function () {
  81194. function CSG() {
  81195. this.polygons = new Array();
  81196. }
  81197. /**
  81198. * Convert the Mesh to CSG
  81199. * @param mesh The Mesh to convert to CSG
  81200. * @returns A new CSG from the Mesh
  81201. */
  81202. CSG.FromMesh = function (mesh) {
  81203. var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
  81204. var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
  81205. if (mesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]) {
  81206. mesh.computeWorldMatrix(true);
  81207. matrix = mesh.getWorldMatrix();
  81208. meshPosition = mesh.position.clone();
  81209. meshRotation = mesh.rotation.clone();
  81210. if (mesh.rotationQuaternion) {
  81211. meshRotationQuaternion = mesh.rotationQuaternion.clone();
  81212. }
  81213. meshScaling = mesh.scaling.clone();
  81214. }
  81215. else {
  81216. throw 'BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh';
  81217. }
  81218. 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);
  81219. var subMeshes = mesh.subMeshes;
  81220. for (var sm = 0, sml = subMeshes.length; sm < sml; sm++) {
  81221. for (var i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
  81222. vertices = [];
  81223. for (var j = 0; j < 3; j++) {
  81224. 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]);
  81225. uv = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uvs[indices[i + j] * 2], uvs[indices[i + j] * 2 + 1]);
  81226. 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]);
  81227. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(sourcePosition, matrix);
  81228. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(sourceNormal, matrix);
  81229. vertex = new Vertex(position, normal, uv);
  81230. vertices.push(vertex);
  81231. }
  81232. polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
  81233. // To handle the case of degenerated triangle
  81234. // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
  81235. if (polygon.plane) {
  81236. polygons.push(polygon);
  81237. }
  81238. }
  81239. }
  81240. var csg = CSG.FromPolygons(polygons);
  81241. csg.matrix = matrix;
  81242. csg.position = meshPosition;
  81243. csg.rotation = meshRotation;
  81244. csg.scaling = meshScaling;
  81245. csg.rotationQuaternion = meshRotationQuaternion;
  81246. currentCSGMeshId++;
  81247. return csg;
  81248. };
  81249. /**
  81250. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  81251. * @param polygons Polygons used to construct a CSG solid
  81252. */
  81253. CSG.FromPolygons = function (polygons) {
  81254. var csg = new CSG();
  81255. csg.polygons = polygons;
  81256. return csg;
  81257. };
  81258. /**
  81259. * Clones, or makes a deep copy, of the CSG
  81260. * @returns A new CSG
  81261. */
  81262. CSG.prototype.clone = function () {
  81263. var csg = new CSG();
  81264. csg.polygons = this.polygons.map(function (p) { return p.clone(); });
  81265. csg.copyTransformAttributes(this);
  81266. return csg;
  81267. };
  81268. /**
  81269. * Unions this CSG with another CSG
  81270. * @param csg The CSG to union against this CSG
  81271. * @returns The unioned CSG
  81272. */
  81273. CSG.prototype.union = function (csg) {
  81274. var a = new Node(this.clone().polygons);
  81275. var b = new Node(csg.clone().polygons);
  81276. a.clipTo(b);
  81277. b.clipTo(a);
  81278. b.invert();
  81279. b.clipTo(a);
  81280. b.invert();
  81281. a.build(b.allPolygons());
  81282. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  81283. };
  81284. /**
  81285. * Unions this CSG with another CSG in place
  81286. * @param csg The CSG to union against this CSG
  81287. */
  81288. CSG.prototype.unionInPlace = function (csg) {
  81289. var a = new Node(this.polygons);
  81290. var b = new Node(csg.polygons);
  81291. a.clipTo(b);
  81292. b.clipTo(a);
  81293. b.invert();
  81294. b.clipTo(a);
  81295. b.invert();
  81296. a.build(b.allPolygons());
  81297. this.polygons = a.allPolygons();
  81298. };
  81299. /**
  81300. * Subtracts this CSG with another CSG
  81301. * @param csg The CSG to subtract against this CSG
  81302. * @returns A new CSG
  81303. */
  81304. CSG.prototype.subtract = function (csg) {
  81305. var a = new Node(this.clone().polygons);
  81306. var b = new Node(csg.clone().polygons);
  81307. a.invert();
  81308. a.clipTo(b);
  81309. b.clipTo(a);
  81310. b.invert();
  81311. b.clipTo(a);
  81312. b.invert();
  81313. a.build(b.allPolygons());
  81314. a.invert();
  81315. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  81316. };
  81317. /**
  81318. * Subtracts this CSG with another CSG in place
  81319. * @param csg The CSG to subtact against this CSG
  81320. */
  81321. CSG.prototype.subtractInPlace = function (csg) {
  81322. var a = new Node(this.polygons);
  81323. var b = new Node(csg.polygons);
  81324. a.invert();
  81325. a.clipTo(b);
  81326. b.clipTo(a);
  81327. b.invert();
  81328. b.clipTo(a);
  81329. b.invert();
  81330. a.build(b.allPolygons());
  81331. a.invert();
  81332. this.polygons = a.allPolygons();
  81333. };
  81334. /**
  81335. * Intersect this CSG with another CSG
  81336. * @param csg The CSG to intersect against this CSG
  81337. * @returns A new CSG
  81338. */
  81339. CSG.prototype.intersect = function (csg) {
  81340. var a = new Node(this.clone().polygons);
  81341. var b = new Node(csg.clone().polygons);
  81342. a.invert();
  81343. b.clipTo(a);
  81344. b.invert();
  81345. a.clipTo(b);
  81346. b.clipTo(a);
  81347. a.build(b.allPolygons());
  81348. a.invert();
  81349. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  81350. };
  81351. /**
  81352. * Intersects this CSG with another CSG in place
  81353. * @param csg The CSG to intersect against this CSG
  81354. */
  81355. CSG.prototype.intersectInPlace = function (csg) {
  81356. var a = new Node(this.polygons);
  81357. var b = new Node(csg.polygons);
  81358. a.invert();
  81359. b.clipTo(a);
  81360. b.invert();
  81361. a.clipTo(b);
  81362. b.clipTo(a);
  81363. a.build(b.allPolygons());
  81364. a.invert();
  81365. this.polygons = a.allPolygons();
  81366. };
  81367. /**
  81368. * Return a new CSG solid with solid and empty space switched. This solid is
  81369. * not modified.
  81370. * @returns A new CSG solid with solid and empty space switched
  81371. */
  81372. CSG.prototype.inverse = function () {
  81373. var csg = this.clone();
  81374. csg.inverseInPlace();
  81375. return csg;
  81376. };
  81377. /**
  81378. * Inverses the CSG in place
  81379. */
  81380. CSG.prototype.inverseInPlace = function () {
  81381. this.polygons.map(function (p) { p.flip(); });
  81382. };
  81383. /**
  81384. * This is used to keep meshes transformations so they can be restored
  81385. * when we build back a Babylon Mesh
  81386. * NB : All CSG operations are performed in world coordinates
  81387. * @param csg The CSG to copy the transform attributes from
  81388. * @returns This CSG
  81389. */
  81390. CSG.prototype.copyTransformAttributes = function (csg) {
  81391. this.matrix = csg.matrix;
  81392. this.position = csg.position;
  81393. this.rotation = csg.rotation;
  81394. this.scaling = csg.scaling;
  81395. this.rotationQuaternion = csg.rotationQuaternion;
  81396. return this;
  81397. };
  81398. /**
  81399. * Build Raw mesh from CSG
  81400. * Coordinates here are in world space
  81401. * @param name The name of the mesh geometry
  81402. * @param scene The Scene
  81403. * @param keepSubMeshes Specifies if the submeshes should be kept
  81404. * @returns A new Mesh
  81405. */
  81406. CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
  81407. var matrix = this.matrix.clone();
  81408. matrix.invert();
  81409. 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;
  81410. if (keepSubMeshes) {
  81411. // Sort Polygons, since subMeshes are indices range
  81412. polygons.sort(function (a, b) {
  81413. if (a.shared.meshId === b.shared.meshId) {
  81414. return a.shared.subMeshId - b.shared.subMeshId;
  81415. }
  81416. else {
  81417. return a.shared.meshId - b.shared.meshId;
  81418. }
  81419. });
  81420. }
  81421. for (var i = 0, il = polygons.length; i < il; i++) {
  81422. polygon = polygons[i];
  81423. // Building SubMeshes
  81424. if (!subMesh_dict[polygon.shared.meshId]) {
  81425. subMesh_dict[polygon.shared.meshId] = {};
  81426. }
  81427. if (!subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId]) {
  81428. subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId] = {
  81429. indexStart: +Infinity,
  81430. indexEnd: -Infinity,
  81431. materialIndex: polygon.shared.materialIndex
  81432. };
  81433. }
  81434. subMesh_obj = subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId];
  81435. for (var j = 2, jl = polygon.vertices.length; j < jl; j++) {
  81436. polygonIndices[0] = 0;
  81437. polygonIndices[1] = j - 1;
  81438. polygonIndices[2] = j;
  81439. for (var k = 0; k < 3; k++) {
  81440. vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);
  81441. normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);
  81442. uv.copyFrom(polygon.vertices[polygonIndices[k]].uv);
  81443. var localVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(vertex, matrix);
  81444. var localNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, matrix);
  81445. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
  81446. // Check if 2 points can be merged
  81447. if (!(typeof vertex_idx !== 'undefined' &&
  81448. normals[vertex_idx * 3] === localNormal.x &&
  81449. normals[vertex_idx * 3 + 1] === localNormal.y &&
  81450. normals[vertex_idx * 3 + 2] === localNormal.z &&
  81451. uvs[vertex_idx * 2] === uv.x &&
  81452. uvs[vertex_idx * 2 + 1] === uv.y)) {
  81453. vertices.push(localVertex.x, localVertex.y, localVertex.z);
  81454. uvs.push(uv.x, uv.y);
  81455. normals.push(normal.x, normal.y, normal.z);
  81456. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z] = (vertices.length / 3) - 1;
  81457. }
  81458. indices.push(vertex_idx);
  81459. subMesh_obj.indexStart = Math.min(currentIndex, subMesh_obj.indexStart);
  81460. subMesh_obj.indexEnd = Math.max(currentIndex, subMesh_obj.indexEnd);
  81461. currentIndex++;
  81462. }
  81463. }
  81464. }
  81465. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, vertices);
  81466. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals);
  81467. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs);
  81468. mesh.setIndices(indices, null);
  81469. if (keepSubMeshes) {
  81470. // We offset the materialIndex by the previous number of materials in the CSG mixed meshes
  81471. var materialIndexOffset = 0, materialMaxIndex;
  81472. mesh.subMeshes = new Array();
  81473. for (var m in subMesh_dict) {
  81474. materialMaxIndex = -1;
  81475. for (var sm in subMesh_dict[m]) {
  81476. subMesh_obj = subMesh_dict[m][sm];
  81477. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].CreateFromIndices(subMesh_obj.materialIndex + materialIndexOffset, subMesh_obj.indexStart, subMesh_obj.indexEnd - subMesh_obj.indexStart + 1, mesh);
  81478. materialMaxIndex = Math.max(subMesh_obj.materialIndex, materialMaxIndex);
  81479. }
  81480. materialIndexOffset += ++materialMaxIndex;
  81481. }
  81482. }
  81483. return mesh;
  81484. };
  81485. /**
  81486. * Build Mesh from CSG taking material and transforms into account
  81487. * @param name The name of the Mesh
  81488. * @param material The material of the Mesh
  81489. * @param scene The Scene
  81490. * @param keepSubMeshes Specifies if submeshes should be kept
  81491. * @returns The new Mesh
  81492. */
  81493. CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
  81494. var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
  81495. mesh.material = material;
  81496. mesh.position.copyFrom(this.position);
  81497. mesh.rotation.copyFrom(this.rotation);
  81498. if (this.rotationQuaternion) {
  81499. mesh.rotationQuaternion = this.rotationQuaternion.clone();
  81500. }
  81501. mesh.scaling.copyFrom(this.scaling);
  81502. mesh.computeWorldMatrix(true);
  81503. return mesh;
  81504. };
  81505. return CSG;
  81506. }());
  81507. /***/ }),
  81508. /***/ "./Meshes/geometry.ts":
  81509. /*!****************************!*\
  81510. !*** ./Meshes/geometry.ts ***!
  81511. \****************************/
  81512. /*! exports provided: Geometry */
  81513. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81514. "use strict";
  81515. __webpack_require__.r(__webpack_exports__);
  81516. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return Geometry; });
  81517. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  81518. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81519. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  81520. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  81521. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  81522. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  81523. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  81524. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  81525. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  81526. /**
  81527. * Class used to store geometry data (vertex buffers + index buffer)
  81528. */
  81529. var Geometry = /** @class */ (function () {
  81530. /**
  81531. * Creates a new geometry
  81532. * @param id defines the unique ID
  81533. * @param scene defines the hosting scene
  81534. * @param vertexData defines the VertexData used to get geometry data
  81535. * @param updatable defines if geometry must be updatable (false by default)
  81536. * @param mesh defines the mesh that will be associated with the geometry
  81537. */
  81538. function Geometry(id, scene, vertexData, updatable, mesh) {
  81539. if (updatable === void 0) { updatable = false; }
  81540. if (mesh === void 0) { mesh = null; }
  81541. /**
  81542. * Gets the delay loading state of the geometry (none by default which means not delayed)
  81543. */
  81544. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  81545. this._totalVertices = 0;
  81546. this._isDisposed = false;
  81547. this._indexBufferIsUpdatable = false;
  81548. this.id = id;
  81549. this.uniqueId = scene.getUniqueId();
  81550. this._engine = scene.getEngine();
  81551. this._meshes = [];
  81552. this._scene = scene;
  81553. //Init vertex buffer cache
  81554. this._vertexBuffers = {};
  81555. this._indices = [];
  81556. this._updatable = updatable;
  81557. // vertexData
  81558. if (vertexData) {
  81559. this.setAllVerticesData(vertexData, updatable);
  81560. }
  81561. else {
  81562. this._totalVertices = 0;
  81563. this._indices = [];
  81564. }
  81565. if (this._engine.getCaps().vertexArrayObject) {
  81566. this._vertexArrayObjects = {};
  81567. }
  81568. // applyToMesh
  81569. if (mesh) {
  81570. this.applyToMesh(mesh);
  81571. mesh.computeWorldMatrix(true);
  81572. }
  81573. }
  81574. Object.defineProperty(Geometry.prototype, "boundingBias", {
  81575. /**
  81576. * 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
  81577. */
  81578. get: function () {
  81579. return this._boundingBias;
  81580. },
  81581. /**
  81582. * 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
  81583. */
  81584. set: function (value) {
  81585. if (this._boundingBias) {
  81586. this._boundingBias.copyFrom(value);
  81587. }
  81588. else {
  81589. this._boundingBias = value.clone();
  81590. }
  81591. this._updateBoundingInfo(true, null);
  81592. },
  81593. enumerable: true,
  81594. configurable: true
  81595. });
  81596. /**
  81597. * Static function used to attach a new empty geometry to a mesh
  81598. * @param mesh defines the mesh to attach the geometry to
  81599. * @returns the new Geometry
  81600. */
  81601. Geometry.CreateGeometryForMesh = function (mesh) {
  81602. var geometry = new Geometry(Geometry.RandomId(), mesh.getScene());
  81603. geometry.applyToMesh(mesh);
  81604. return geometry;
  81605. };
  81606. Object.defineProperty(Geometry.prototype, "extend", {
  81607. /**
  81608. * Gets the current extend of the geometry
  81609. */
  81610. get: function () {
  81611. return this._extend;
  81612. },
  81613. enumerable: true,
  81614. configurable: true
  81615. });
  81616. /**
  81617. * Gets the hosting scene
  81618. * @returns the hosting Scene
  81619. */
  81620. Geometry.prototype.getScene = function () {
  81621. return this._scene;
  81622. };
  81623. /**
  81624. * Gets the hosting engine
  81625. * @returns the hosting Engine
  81626. */
  81627. Geometry.prototype.getEngine = function () {
  81628. return this._engine;
  81629. };
  81630. /**
  81631. * Defines if the geometry is ready to use
  81632. * @returns true if the geometry is ready to be used
  81633. */
  81634. Geometry.prototype.isReady = function () {
  81635. return this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED || this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  81636. };
  81637. Object.defineProperty(Geometry.prototype, "doNotSerialize", {
  81638. /**
  81639. * Gets a value indicating that the geometry should not be serialized
  81640. */
  81641. get: function () {
  81642. for (var index = 0; index < this._meshes.length; index++) {
  81643. if (!this._meshes[index].doNotSerialize) {
  81644. return false;
  81645. }
  81646. }
  81647. return true;
  81648. },
  81649. enumerable: true,
  81650. configurable: true
  81651. });
  81652. /** @hidden */
  81653. Geometry.prototype._rebuild = function () {
  81654. if (this._vertexArrayObjects) {
  81655. this._vertexArrayObjects = {};
  81656. }
  81657. // Index buffer
  81658. if (this._meshes.length !== 0 && this._indices) {
  81659. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  81660. }
  81661. // Vertex buffers
  81662. for (var key in this._vertexBuffers) {
  81663. var vertexBuffer = this._vertexBuffers[key];
  81664. vertexBuffer._rebuild();
  81665. }
  81666. };
  81667. /**
  81668. * Affects all geometry data in one call
  81669. * @param vertexData defines the geometry data
  81670. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  81671. */
  81672. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  81673. vertexData.applyToGeometry(this, updatable);
  81674. this.notifyUpdate();
  81675. };
  81676. /**
  81677. * Set specific vertex data
  81678. * @param kind defines the data kind (Position, normal, etc...)
  81679. * @param data defines the vertex data to use
  81680. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81681. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81682. */
  81683. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  81684. if (updatable === void 0) { updatable = false; }
  81685. var buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"](this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  81686. this.setVerticesBuffer(buffer);
  81687. };
  81688. /**
  81689. * Removes a specific vertex data
  81690. * @param kind defines the data kind (Position, normal, etc...)
  81691. */
  81692. Geometry.prototype.removeVerticesData = function (kind) {
  81693. if (this._vertexBuffers[kind]) {
  81694. this._vertexBuffers[kind].dispose();
  81695. delete this._vertexBuffers[kind];
  81696. }
  81697. };
  81698. /**
  81699. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  81700. * @param buffer defines the vertex buffer to use
  81701. * @param totalVertices defines the total number of vertices for position kind (could be null)
  81702. */
  81703. Geometry.prototype.setVerticesBuffer = function (buffer, totalVertices) {
  81704. if (totalVertices === void 0) { totalVertices = null; }
  81705. var kind = buffer.getKind();
  81706. if (this._vertexBuffers[kind]) {
  81707. this._vertexBuffers[kind].dispose();
  81708. }
  81709. this._vertexBuffers[kind] = buffer;
  81710. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  81711. var data = buffer.getData();
  81712. if (totalVertices != null) {
  81713. this._totalVertices = totalVertices;
  81714. }
  81715. else {
  81716. if (data != null) {
  81717. this._totalVertices = data.length / (buffer.byteStride / 4);
  81718. }
  81719. }
  81720. this._updateExtend(data);
  81721. this._resetPointsArrayCache();
  81722. var meshes = this._meshes;
  81723. var numOfMeshes = meshes.length;
  81724. for (var index = 0; index < numOfMeshes; index++) {
  81725. var mesh = meshes[index];
  81726. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  81727. mesh._createGlobalSubMesh(false);
  81728. mesh.computeWorldMatrix(true);
  81729. }
  81730. }
  81731. this.notifyUpdate(kind);
  81732. if (this._vertexArrayObjects) {
  81733. this._disposeVertexArrayObjects();
  81734. this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
  81735. }
  81736. };
  81737. /**
  81738. * Update a specific vertex buffer
  81739. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  81740. * It will do nothing if the buffer is not updatable
  81741. * @param kind defines the data kind (Position, normal, etc...)
  81742. * @param data defines the data to use
  81743. * @param offset defines the offset in the target buffer where to store the data
  81744. * @param useBytes set to true if the offset is in bytes
  81745. */
  81746. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset, useBytes) {
  81747. if (useBytes === void 0) { useBytes = false; }
  81748. var vertexBuffer = this.getVertexBuffer(kind);
  81749. if (!vertexBuffer) {
  81750. return;
  81751. }
  81752. vertexBuffer.updateDirectly(data, offset, useBytes);
  81753. this.notifyUpdate(kind);
  81754. };
  81755. /**
  81756. * Update a specific vertex buffer
  81757. * This function will create a new buffer if the current one is not updatable
  81758. * @param kind defines the data kind (Position, normal, etc...)
  81759. * @param data defines the data to use
  81760. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  81761. */
  81762. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  81763. if (updateExtends === void 0) { updateExtends = false; }
  81764. var vertexBuffer = this.getVertexBuffer(kind);
  81765. if (!vertexBuffer) {
  81766. return;
  81767. }
  81768. vertexBuffer.update(data);
  81769. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  81770. this._updateBoundingInfo(updateExtends, data);
  81771. }
  81772. this.notifyUpdate(kind);
  81773. };
  81774. Geometry.prototype._updateBoundingInfo = function (updateExtends, data) {
  81775. if (updateExtends) {
  81776. this._updateExtend(data);
  81777. }
  81778. this._resetPointsArrayCache();
  81779. if (updateExtends) {
  81780. var meshes = this._meshes;
  81781. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  81782. var mesh = meshes_1[_i];
  81783. if (mesh._boundingInfo) {
  81784. mesh._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum);
  81785. }
  81786. else {
  81787. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  81788. }
  81789. var subMeshes = mesh.subMeshes;
  81790. for (var _a = 0, subMeshes_1 = subMeshes; _a < subMeshes_1.length; _a++) {
  81791. var subMesh = subMeshes_1[_a];
  81792. subMesh.refreshBoundingInfo();
  81793. }
  81794. }
  81795. }
  81796. };
  81797. /** @hidden */
  81798. Geometry.prototype._bind = function (effect, indexToBind) {
  81799. if (!effect) {
  81800. return;
  81801. }
  81802. if (indexToBind === undefined) {
  81803. indexToBind = this._indexBuffer;
  81804. }
  81805. var vbs = this.getVertexBuffers();
  81806. if (!vbs) {
  81807. return;
  81808. }
  81809. if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
  81810. this._engine.bindBuffers(vbs, indexToBind, effect);
  81811. return;
  81812. }
  81813. // Using VAO
  81814. if (!this._vertexArrayObjects[effect.key]) {
  81815. this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
  81816. }
  81817. this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
  81818. };
  81819. /**
  81820. * Gets total number of vertices
  81821. * @returns the total number of vertices
  81822. */
  81823. Geometry.prototype.getTotalVertices = function () {
  81824. if (!this.isReady()) {
  81825. return 0;
  81826. }
  81827. return this._totalVertices;
  81828. };
  81829. /**
  81830. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81831. * @param kind defines the data kind (Position, normal, etc...)
  81832. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81833. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81834. * @returns a float array containing vertex data
  81835. */
  81836. Geometry.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  81837. var vertexBuffer = this.getVertexBuffer(kind);
  81838. if (!vertexBuffer) {
  81839. return null;
  81840. }
  81841. var data = vertexBuffer.getData();
  81842. if (!data) {
  81843. return null;
  81844. }
  81845. var tightlyPackedByteStride = vertexBuffer.getSize() * _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].GetTypeByteLength(vertexBuffer.type);
  81846. var count = this._totalVertices * vertexBuffer.getSize();
  81847. if (vertexBuffer.type !== _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].FLOAT || vertexBuffer.byteStride !== tightlyPackedByteStride) {
  81848. var copy_1 = [];
  81849. vertexBuffer.forEach(count, function (value) { return copy_1.push(value); });
  81850. return copy_1;
  81851. }
  81852. if (!((data instanceof Array) || (data instanceof Float32Array)) || vertexBuffer.byteOffset !== 0 || data.length !== count) {
  81853. if (data instanceof Array) {
  81854. var offset = vertexBuffer.byteOffset / 4;
  81855. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data, offset, offset + count);
  81856. }
  81857. else if (data instanceof ArrayBuffer) {
  81858. return new Float32Array(data, vertexBuffer.byteOffset, count);
  81859. }
  81860. else {
  81861. var offset = data.byteOffset + vertexBuffer.byteOffset;
  81862. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  81863. var result = new Float32Array(count);
  81864. var source = new Float32Array(data.buffer, offset, count);
  81865. result.set(source);
  81866. return result;
  81867. }
  81868. return new Float32Array(data.buffer, offset, count);
  81869. }
  81870. }
  81871. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  81872. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data);
  81873. }
  81874. return data;
  81875. };
  81876. /**
  81877. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  81878. * @param kind defines the data kind (Position, normal, etc...)
  81879. * @returns true if the vertex buffer with the specified kind is updatable
  81880. */
  81881. Geometry.prototype.isVertexBufferUpdatable = function (kind) {
  81882. var vb = this._vertexBuffers[kind];
  81883. if (!vb) {
  81884. return false;
  81885. }
  81886. return vb.isUpdatable();
  81887. };
  81888. /**
  81889. * Gets a specific vertex buffer
  81890. * @param kind defines the data kind (Position, normal, etc...)
  81891. * @returns a VertexBuffer
  81892. */
  81893. Geometry.prototype.getVertexBuffer = function (kind) {
  81894. if (!this.isReady()) {
  81895. return null;
  81896. }
  81897. return this._vertexBuffers[kind];
  81898. };
  81899. /**
  81900. * Returns all vertex buffers
  81901. * @return an object holding all vertex buffers indexed by kind
  81902. */
  81903. Geometry.prototype.getVertexBuffers = function () {
  81904. if (!this.isReady()) {
  81905. return null;
  81906. }
  81907. return this._vertexBuffers;
  81908. };
  81909. /**
  81910. * Gets a boolean indicating if specific vertex buffer is present
  81911. * @param kind defines the data kind (Position, normal, etc...)
  81912. * @returns true if data is present
  81913. */
  81914. Geometry.prototype.isVerticesDataPresent = function (kind) {
  81915. if (!this._vertexBuffers) {
  81916. if (this._delayInfo) {
  81917. return this._delayInfo.indexOf(kind) !== -1;
  81918. }
  81919. return false;
  81920. }
  81921. return this._vertexBuffers[kind] !== undefined;
  81922. };
  81923. /**
  81924. * Gets a list of all attached data kinds (Position, normal, etc...)
  81925. * @returns a list of string containing all kinds
  81926. */
  81927. Geometry.prototype.getVerticesDataKinds = function () {
  81928. var result = [];
  81929. var kind;
  81930. if (!this._vertexBuffers && this._delayInfo) {
  81931. for (kind in this._delayInfo) {
  81932. result.push(kind);
  81933. }
  81934. }
  81935. else {
  81936. for (kind in this._vertexBuffers) {
  81937. result.push(kind);
  81938. }
  81939. }
  81940. return result;
  81941. };
  81942. /**
  81943. * Update index buffer
  81944. * @param indices defines the indices to store in the index buffer
  81945. * @param offset defines the offset in the target buffer where to store the data
  81946. */
  81947. Geometry.prototype.updateIndices = function (indices, offset) {
  81948. if (!this._indexBuffer) {
  81949. return;
  81950. }
  81951. if (!this._indexBufferIsUpdatable) {
  81952. this.setIndices(indices, null, true);
  81953. }
  81954. else {
  81955. var needToUpdateSubMeshes = indices.length !== this._indices.length;
  81956. this._indices = indices;
  81957. this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
  81958. if (needToUpdateSubMeshes) {
  81959. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  81960. var mesh = _a[_i];
  81961. mesh._createGlobalSubMesh(true);
  81962. }
  81963. }
  81964. }
  81965. };
  81966. /**
  81967. * Creates a new index buffer
  81968. * @param indices defines the indices to store in the index buffer
  81969. * @param totalVertices defines the total number of vertices (could be null)
  81970. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81971. */
  81972. Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
  81973. if (totalVertices === void 0) { totalVertices = null; }
  81974. if (updatable === void 0) { updatable = false; }
  81975. if (this._indexBuffer) {
  81976. this._engine._releaseBuffer(this._indexBuffer);
  81977. }
  81978. this._disposeVertexArrayObjects();
  81979. this._indices = indices;
  81980. this._indexBufferIsUpdatable = updatable;
  81981. if (this._meshes.length !== 0 && this._indices) {
  81982. this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
  81983. }
  81984. if (totalVertices != undefined) { // including null and undefined
  81985. this._totalVertices = totalVertices;
  81986. }
  81987. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  81988. var mesh = _a[_i];
  81989. mesh._createGlobalSubMesh(true);
  81990. }
  81991. this.notifyUpdate();
  81992. };
  81993. /**
  81994. * Return the total number of indices
  81995. * @returns the total number of indices
  81996. */
  81997. Geometry.prototype.getTotalIndices = function () {
  81998. if (!this.isReady()) {
  81999. return 0;
  82000. }
  82001. return this._indices.length;
  82002. };
  82003. /**
  82004. * Gets the index buffer array
  82005. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82006. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82007. * @returns the index buffer array
  82008. */
  82009. Geometry.prototype.getIndices = function (copyWhenShared, forceCopy) {
  82010. if (!this.isReady()) {
  82011. return null;
  82012. }
  82013. var orig = this._indices;
  82014. if (!forceCopy && (!copyWhenShared || this._meshes.length === 1)) {
  82015. return orig;
  82016. }
  82017. else {
  82018. var len = orig.length;
  82019. var copy = [];
  82020. for (var i = 0; i < len; i++) {
  82021. copy.push(orig[i]);
  82022. }
  82023. return copy;
  82024. }
  82025. };
  82026. /**
  82027. * Gets the index buffer
  82028. * @return the index buffer
  82029. */
  82030. Geometry.prototype.getIndexBuffer = function () {
  82031. if (!this.isReady()) {
  82032. return null;
  82033. }
  82034. return this._indexBuffer;
  82035. };
  82036. /** @hidden */
  82037. Geometry.prototype._releaseVertexArrayObject = function (effect) {
  82038. if (effect === void 0) { effect = null; }
  82039. if (!effect || !this._vertexArrayObjects) {
  82040. return;
  82041. }
  82042. if (this._vertexArrayObjects[effect.key]) {
  82043. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[effect.key]);
  82044. delete this._vertexArrayObjects[effect.key];
  82045. }
  82046. };
  82047. /**
  82048. * Release the associated resources for a specific mesh
  82049. * @param mesh defines the source mesh
  82050. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  82051. */
  82052. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  82053. var meshes = this._meshes;
  82054. var index = meshes.indexOf(mesh);
  82055. if (index === -1) {
  82056. return;
  82057. }
  82058. meshes.splice(index, 1);
  82059. mesh._geometry = null;
  82060. if (meshes.length === 0 && shouldDispose) {
  82061. this.dispose();
  82062. }
  82063. };
  82064. /**
  82065. * Apply current geometry to a given mesh
  82066. * @param mesh defines the mesh to apply geometry to
  82067. */
  82068. Geometry.prototype.applyToMesh = function (mesh) {
  82069. if (mesh._geometry === this) {
  82070. return;
  82071. }
  82072. var previousGeometry = mesh._geometry;
  82073. if (previousGeometry) {
  82074. previousGeometry.releaseForMesh(mesh);
  82075. }
  82076. var meshes = this._meshes;
  82077. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  82078. mesh._geometry = this;
  82079. this._scene.pushGeometry(this);
  82080. meshes.push(mesh);
  82081. if (this.isReady()) {
  82082. this._applyToMesh(mesh);
  82083. }
  82084. else {
  82085. mesh._boundingInfo = this._boundingInfo;
  82086. }
  82087. };
  82088. Geometry.prototype._updateExtend = function (data) {
  82089. if (data === void 0) { data = null; }
  82090. if (!data) {
  82091. data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  82092. }
  82093. this._extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].ExtractMinAndMax(data, 0, this._totalVertices, this.boundingBias, 3);
  82094. };
  82095. Geometry.prototype._applyToMesh = function (mesh) {
  82096. var numOfMeshes = this._meshes.length;
  82097. // vertexBuffers
  82098. for (var kind in this._vertexBuffers) {
  82099. if (numOfMeshes === 1) {
  82100. this._vertexBuffers[kind].create();
  82101. }
  82102. var buffer = this._vertexBuffers[kind].getBuffer();
  82103. if (buffer) {
  82104. buffer.references = numOfMeshes;
  82105. }
  82106. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  82107. if (!this._extend) {
  82108. this._updateExtend();
  82109. }
  82110. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  82111. mesh._createGlobalSubMesh(false);
  82112. //bounding info was just created again, world matrix should be applied again.
  82113. mesh._updateBoundingInfo();
  82114. }
  82115. }
  82116. // indexBuffer
  82117. if (numOfMeshes === 1 && this._indices && this._indices.length > 0) {
  82118. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  82119. }
  82120. if (this._indexBuffer) {
  82121. this._indexBuffer.references = numOfMeshes;
  82122. }
  82123. // morphTargets
  82124. mesh._syncGeometryWithMorphTargetManager();
  82125. // instances
  82126. mesh.synchronizeInstances();
  82127. };
  82128. Geometry.prototype.notifyUpdate = function (kind) {
  82129. if (this.onGeometryUpdated) {
  82130. this.onGeometryUpdated(this, kind);
  82131. }
  82132. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  82133. var mesh = _a[_i];
  82134. mesh._markSubMeshesAsAttributesDirty();
  82135. }
  82136. };
  82137. /**
  82138. * Load the geometry if it was flagged as delay loaded
  82139. * @param scene defines the hosting scene
  82140. * @param onLoaded defines a callback called when the geometry is loaded
  82141. */
  82142. Geometry.prototype.load = function (scene, onLoaded) {
  82143. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING) {
  82144. return;
  82145. }
  82146. if (this.isReady()) {
  82147. if (onLoaded) {
  82148. onLoaded();
  82149. }
  82150. return;
  82151. }
  82152. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING;
  82153. this._queueLoad(scene, onLoaded);
  82154. };
  82155. Geometry.prototype._queueLoad = function (scene, onLoaded) {
  82156. var _this = this;
  82157. if (!this.delayLoadingFile) {
  82158. return;
  82159. }
  82160. scene._addPendingData(this);
  82161. scene._loadFile(this.delayLoadingFile, function (data) {
  82162. if (!_this._delayLoadingFunction) {
  82163. return;
  82164. }
  82165. _this._delayLoadingFunction(JSON.parse(data), _this);
  82166. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  82167. _this._delayInfo = [];
  82168. scene._removePendingData(_this);
  82169. var meshes = _this._meshes;
  82170. var numOfMeshes = meshes.length;
  82171. for (var index = 0; index < numOfMeshes; index++) {
  82172. _this._applyToMesh(meshes[index]);
  82173. }
  82174. if (onLoaded) {
  82175. onLoaded();
  82176. }
  82177. }, undefined, true);
  82178. };
  82179. /**
  82180. * Invert the geometry to move from a right handed system to a left handed one.
  82181. */
  82182. Geometry.prototype.toLeftHanded = function () {
  82183. // Flip faces
  82184. var tIndices = this.getIndices(false);
  82185. if (tIndices != null && tIndices.length > 0) {
  82186. for (var i = 0; i < tIndices.length; i += 3) {
  82187. var tTemp = tIndices[i + 0];
  82188. tIndices[i + 0] = tIndices[i + 2];
  82189. tIndices[i + 2] = tTemp;
  82190. }
  82191. this.setIndices(tIndices);
  82192. }
  82193. // Negate position.z
  82194. var tPositions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, false);
  82195. if (tPositions != null && tPositions.length > 0) {
  82196. for (var i = 0; i < tPositions.length; i += 3) {
  82197. tPositions[i + 2] = -tPositions[i + 2];
  82198. }
  82199. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, tPositions, false);
  82200. }
  82201. // Negate normal.z
  82202. var tNormals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, false);
  82203. if (tNormals != null && tNormals.length > 0) {
  82204. for (var i = 0; i < tNormals.length; i += 3) {
  82205. tNormals[i + 2] = -tNormals[i + 2];
  82206. }
  82207. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, tNormals, false);
  82208. }
  82209. };
  82210. // Cache
  82211. /** @hidden */
  82212. Geometry.prototype._resetPointsArrayCache = function () {
  82213. this._positions = null;
  82214. };
  82215. /** @hidden */
  82216. Geometry.prototype._generatePointsArray = function () {
  82217. if (this._positions) {
  82218. return true;
  82219. }
  82220. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  82221. if (!data || data.length === 0) {
  82222. return false;
  82223. }
  82224. this._positions = [];
  82225. for (var index = 0; index < data.length; index += 3) {
  82226. this._positions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(data, index));
  82227. }
  82228. return true;
  82229. };
  82230. /**
  82231. * Gets a value indicating if the geometry is disposed
  82232. * @returns true if the geometry was disposed
  82233. */
  82234. Geometry.prototype.isDisposed = function () {
  82235. return this._isDisposed;
  82236. };
  82237. Geometry.prototype._disposeVertexArrayObjects = function () {
  82238. if (this._vertexArrayObjects) {
  82239. for (var kind in this._vertexArrayObjects) {
  82240. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
  82241. }
  82242. this._vertexArrayObjects = {};
  82243. }
  82244. };
  82245. /**
  82246. * Free all associated resources
  82247. */
  82248. Geometry.prototype.dispose = function () {
  82249. var meshes = this._meshes;
  82250. var numOfMeshes = meshes.length;
  82251. var index;
  82252. for (index = 0; index < numOfMeshes; index++) {
  82253. this.releaseForMesh(meshes[index]);
  82254. }
  82255. this._meshes = [];
  82256. this._disposeVertexArrayObjects();
  82257. for (var kind in this._vertexBuffers) {
  82258. this._vertexBuffers[kind].dispose();
  82259. }
  82260. this._vertexBuffers = {};
  82261. this._totalVertices = 0;
  82262. if (this._indexBuffer) {
  82263. this._engine._releaseBuffer(this._indexBuffer);
  82264. }
  82265. this._indexBuffer = null;
  82266. this._indices = [];
  82267. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  82268. this.delayLoadingFile = null;
  82269. this._delayLoadingFunction = null;
  82270. this._delayInfo = [];
  82271. this._boundingInfo = null;
  82272. this._scene.removeGeometry(this);
  82273. this._isDisposed = true;
  82274. };
  82275. /**
  82276. * Clone the current geometry into a new geometry
  82277. * @param id defines the unique ID of the new geometry
  82278. * @returns a new geometry object
  82279. */
  82280. Geometry.prototype.copy = function (id) {
  82281. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  82282. vertexData.indices = [];
  82283. var indices = this.getIndices();
  82284. if (indices) {
  82285. for (var index = 0; index < indices.length; index++) {
  82286. vertexData.indices.push(indices[index]);
  82287. }
  82288. }
  82289. var updatable = false;
  82290. var stopChecking = false;
  82291. var kind;
  82292. for (kind in this._vertexBuffers) {
  82293. // using slice() to make a copy of the array and not just reference it
  82294. var data = this.getVerticesData(kind);
  82295. if (data) {
  82296. if (data instanceof Float32Array) {
  82297. vertexData.set(new Float32Array(data), kind);
  82298. }
  82299. else {
  82300. vertexData.set(data.slice(0), kind);
  82301. }
  82302. if (!stopChecking) {
  82303. var vb = this.getVertexBuffer(kind);
  82304. if (vb) {
  82305. updatable = vb.isUpdatable();
  82306. stopChecking = !updatable;
  82307. }
  82308. }
  82309. }
  82310. }
  82311. var geometry = new Geometry(id, this._scene, vertexData, updatable);
  82312. geometry.delayLoadState = this.delayLoadState;
  82313. geometry.delayLoadingFile = this.delayLoadingFile;
  82314. geometry._delayLoadingFunction = this._delayLoadingFunction;
  82315. for (kind in this._delayInfo) {
  82316. geometry._delayInfo = geometry._delayInfo || [];
  82317. geometry._delayInfo.push(kind);
  82318. }
  82319. // Bounding info
  82320. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  82321. return geometry;
  82322. };
  82323. /**
  82324. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82325. * @return a JSON representation of the current geometry data (without the vertices data)
  82326. */
  82327. Geometry.prototype.serialize = function () {
  82328. var serializationObject = {};
  82329. serializationObject.id = this.id;
  82330. serializationObject.updatable = this._updatable;
  82331. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].HasTags(this)) {
  82332. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].GetTags(this);
  82333. }
  82334. return serializationObject;
  82335. };
  82336. Geometry.prototype.toNumberArray = function (origin) {
  82337. if (Array.isArray(origin)) {
  82338. return origin;
  82339. }
  82340. else {
  82341. return Array.prototype.slice.call(origin);
  82342. }
  82343. };
  82344. /**
  82345. * Serialize all vertices data into a JSON oject
  82346. * @returns a JSON representation of the current geometry data
  82347. */
  82348. Geometry.prototype.serializeVerticeData = function () {
  82349. var serializationObject = this.serialize();
  82350. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  82351. serializationObject.positions = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  82352. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  82353. serializationObject.positions._updatable = true;
  82354. }
  82355. }
  82356. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  82357. serializationObject.normals = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind));
  82358. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  82359. serializationObject.normals._updatable = true;
  82360. }
  82361. }
  82362. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  82363. serializationObject.tangets = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind));
  82364. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  82365. serializationObject.tangets._updatable = true;
  82366. }
  82367. }
  82368. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  82369. serializationObject.uvs = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind));
  82370. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  82371. serializationObject.uvs._updatable = true;
  82372. }
  82373. }
  82374. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  82375. serializationObject.uv2s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind));
  82376. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  82377. serializationObject.uv2s._updatable = true;
  82378. }
  82379. }
  82380. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  82381. serializationObject.uv3s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind));
  82382. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  82383. serializationObject.uv3s._updatable = true;
  82384. }
  82385. }
  82386. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  82387. serializationObject.uv4s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind));
  82388. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  82389. serializationObject.uv4s._updatable = true;
  82390. }
  82391. }
  82392. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  82393. serializationObject.uv5s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind));
  82394. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  82395. serializationObject.uv5s._updatable = true;
  82396. }
  82397. }
  82398. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  82399. serializationObject.uv6s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind));
  82400. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  82401. serializationObject.uv6s._updatable = true;
  82402. }
  82403. }
  82404. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  82405. serializationObject.colors = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind));
  82406. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  82407. serializationObject.colors._updatable = true;
  82408. }
  82409. }
  82410. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  82411. serializationObject.matricesIndices = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind));
  82412. serializationObject.matricesIndices._isExpanded = true;
  82413. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  82414. serializationObject.matricesIndices._updatable = true;
  82415. }
  82416. }
  82417. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  82418. serializationObject.matricesWeights = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind));
  82419. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  82420. serializationObject.matricesWeights._updatable = true;
  82421. }
  82422. }
  82423. serializationObject.indices = this.toNumberArray(this.getIndices());
  82424. return serializationObject;
  82425. };
  82426. // Statics
  82427. /**
  82428. * Extracts a clone of a mesh geometry
  82429. * @param mesh defines the source mesh
  82430. * @param id defines the unique ID of the new geometry object
  82431. * @returns the new geometry object
  82432. */
  82433. Geometry.ExtractFromMesh = function (mesh, id) {
  82434. var geometry = mesh._geometry;
  82435. if (!geometry) {
  82436. return null;
  82437. }
  82438. return geometry.copy(id);
  82439. };
  82440. /**
  82441. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82442. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82443. * Be aware Math.random() could cause collisions, but:
  82444. * "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"
  82445. * @returns a string containing a new GUID
  82446. */
  82447. Geometry.RandomId = function () {
  82448. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].RandomId();
  82449. };
  82450. /** @hidden */
  82451. Geometry._ImportGeometry = function (parsedGeometry, mesh) {
  82452. var scene = mesh.getScene();
  82453. // Geometry
  82454. var geometryId = parsedGeometry.geometryId;
  82455. if (geometryId) {
  82456. var geometry = scene.getGeometryByID(geometryId);
  82457. if (geometry) {
  82458. geometry.applyToMesh(mesh);
  82459. }
  82460. }
  82461. else if (parsedGeometry instanceof ArrayBuffer) {
  82462. var binaryInfo = mesh._binaryInfo;
  82463. if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
  82464. var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
  82465. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positionsData, false);
  82466. }
  82467. if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
  82468. var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
  82469. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normalsData, false);
  82470. }
  82471. if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
  82472. var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
  82473. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, tangentsData, false);
  82474. }
  82475. if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
  82476. var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
  82477. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvsData, false);
  82478. }
  82479. if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
  82480. var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
  82481. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, uvs2Data, false);
  82482. }
  82483. if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
  82484. var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
  82485. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, uvs3Data, false);
  82486. }
  82487. if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
  82488. var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
  82489. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, uvs4Data, false);
  82490. }
  82491. if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
  82492. var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
  82493. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, uvs5Data, false);
  82494. }
  82495. if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
  82496. var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
  82497. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, uvs6Data, false);
  82498. }
  82499. if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
  82500. var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
  82501. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
  82502. }
  82503. if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
  82504. var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
  82505. var floatIndices = [];
  82506. for (var i = 0; i < matricesIndicesData.length; i++) {
  82507. var index = matricesIndicesData[i];
  82508. floatIndices.push(index & 0x000000FF);
  82509. floatIndices.push((index & 0x0000FF00) >> 8);
  82510. floatIndices.push((index & 0x00FF0000) >> 16);
  82511. floatIndices.push(index >> 24);
  82512. }
  82513. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, false);
  82514. }
  82515. if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
  82516. var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
  82517. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, matricesWeightsData, false);
  82518. }
  82519. if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
  82520. var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
  82521. mesh.setIndices(indicesData, null);
  82522. }
  82523. if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
  82524. var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
  82525. mesh.subMeshes = [];
  82526. for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
  82527. var materialIndex = subMeshesData[(i * 5) + 0];
  82528. var verticesStart = subMeshesData[(i * 5) + 1];
  82529. var verticesCount = subMeshesData[(i * 5) + 2];
  82530. var indexStart = subMeshesData[(i * 5) + 3];
  82531. var indexCount = subMeshesData[(i * 5) + 4];
  82532. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
  82533. }
  82534. }
  82535. }
  82536. else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
  82537. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, parsedGeometry.positions, parsedGeometry.positions._updatable);
  82538. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
  82539. if (parsedGeometry.tangents) {
  82540. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
  82541. }
  82542. if (parsedGeometry.uvs) {
  82543. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
  82544. }
  82545. if (parsedGeometry.uvs2) {
  82546. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, parsedGeometry.uvs2, parsedGeometry.uvs2._updatable);
  82547. }
  82548. if (parsedGeometry.uvs3) {
  82549. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, parsedGeometry.uvs3, parsedGeometry.uvs3._updatable);
  82550. }
  82551. if (parsedGeometry.uvs4) {
  82552. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, parsedGeometry.uvs4, parsedGeometry.uvs4._updatable);
  82553. }
  82554. if (parsedGeometry.uvs5) {
  82555. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, parsedGeometry.uvs5, parsedGeometry.uvs5._updatable);
  82556. }
  82557. if (parsedGeometry.uvs6) {
  82558. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, parsedGeometry.uvs6, parsedGeometry.uvs6._updatable);
  82559. }
  82560. if (parsedGeometry.colors) {
  82561. 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);
  82562. }
  82563. if (parsedGeometry.matricesIndices) {
  82564. if (!parsedGeometry.matricesIndices._isExpanded) {
  82565. var floatIndices = [];
  82566. for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
  82567. var matricesIndex = parsedGeometry.matricesIndices[i];
  82568. floatIndices.push(matricesIndex & 0x000000FF);
  82569. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  82570. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  82571. floatIndices.push(matricesIndex >> 24);
  82572. }
  82573. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, parsedGeometry.matricesIndices._updatable);
  82574. }
  82575. else {
  82576. delete parsedGeometry.matricesIndices._isExpanded;
  82577. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, parsedGeometry.matricesIndices, parsedGeometry.matricesIndices._updatable);
  82578. }
  82579. }
  82580. if (parsedGeometry.matricesIndicesExtra) {
  82581. if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
  82582. var floatIndices = [];
  82583. for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
  82584. var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
  82585. floatIndices.push(matricesIndex & 0x000000FF);
  82586. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  82587. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  82588. floatIndices.push(matricesIndex >> 24);
  82589. }
  82590. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, floatIndices, parsedGeometry.matricesIndicesExtra._updatable);
  82591. }
  82592. else {
  82593. delete parsedGeometry.matricesIndices._isExpanded;
  82594. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, parsedGeometry.matricesIndicesExtra._updatable);
  82595. }
  82596. }
  82597. if (parsedGeometry.matricesWeights) {
  82598. Geometry._CleanMatricesWeights(parsedGeometry, mesh);
  82599. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
  82600. }
  82601. if (parsedGeometry.matricesWeightsExtra) {
  82602. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
  82603. }
  82604. mesh.setIndices(parsedGeometry.indices, null);
  82605. }
  82606. // SubMeshes
  82607. if (parsedGeometry.subMeshes) {
  82608. mesh.subMeshes = [];
  82609. for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
  82610. var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
  82611. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
  82612. }
  82613. }
  82614. // Flat shading
  82615. if (mesh._shouldGenerateFlatShading) {
  82616. mesh.convertToFlatShadedMesh();
  82617. delete mesh._shouldGenerateFlatShading;
  82618. }
  82619. // Update
  82620. mesh.computeWorldMatrix(true);
  82621. scene.onMeshImportedObservable.notifyObservers(mesh);
  82622. };
  82623. Geometry._CleanMatricesWeights = function (parsedGeometry, mesh) {
  82624. var epsilon = 1e-3;
  82625. if (!_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__["SceneLoaderFlags"].CleanBoneMatrixWeights) {
  82626. return;
  82627. }
  82628. var noInfluenceBoneIndex = 0.0;
  82629. if (parsedGeometry.skeletonId > -1) {
  82630. var skeleton = mesh.getScene().getLastSkeletonByID(parsedGeometry.skeletonId);
  82631. if (!skeleton) {
  82632. return;
  82633. }
  82634. noInfluenceBoneIndex = skeleton.bones.length;
  82635. }
  82636. else {
  82637. return;
  82638. }
  82639. var matricesIndices = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  82640. var matricesIndicesExtra = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  82641. var matricesWeights = parsedGeometry.matricesWeights;
  82642. var matricesWeightsExtra = parsedGeometry.matricesWeightsExtra;
  82643. var influencers = parsedGeometry.numBoneInfluencer;
  82644. var size = matricesWeights.length;
  82645. for (var i = 0; i < size; i += 4) {
  82646. var weight = 0.0;
  82647. var firstZeroWeight = -1;
  82648. for (var j = 0; j < 4; j++) {
  82649. var w = matricesWeights[i + j];
  82650. weight += w;
  82651. if (w < epsilon && firstZeroWeight < 0) {
  82652. firstZeroWeight = j;
  82653. }
  82654. }
  82655. if (matricesWeightsExtra) {
  82656. for (var j = 0; j < 4; j++) {
  82657. var w = matricesWeightsExtra[i + j];
  82658. weight += w;
  82659. if (w < epsilon && firstZeroWeight < 0) {
  82660. firstZeroWeight = j + 4;
  82661. }
  82662. }
  82663. }
  82664. if (firstZeroWeight < 0 || firstZeroWeight > (influencers - 1)) {
  82665. firstZeroWeight = influencers - 1;
  82666. }
  82667. if (weight > epsilon) {
  82668. var mweight = 1.0 / weight;
  82669. for (var j = 0; j < 4; j++) {
  82670. matricesWeights[i + j] *= mweight;
  82671. }
  82672. if (matricesWeightsExtra) {
  82673. for (var j = 0; j < 4; j++) {
  82674. matricesWeightsExtra[i + j] *= mweight;
  82675. }
  82676. }
  82677. }
  82678. else {
  82679. if (firstZeroWeight >= 4) {
  82680. matricesWeightsExtra[i + firstZeroWeight - 4] = 1.0 - weight;
  82681. matricesIndicesExtra[i + firstZeroWeight - 4] = noInfluenceBoneIndex;
  82682. }
  82683. else {
  82684. matricesWeights[i + firstZeroWeight] = 1.0 - weight;
  82685. matricesIndices[i + firstZeroWeight] = noInfluenceBoneIndex;
  82686. }
  82687. }
  82688. }
  82689. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, matricesIndices);
  82690. if (parsedGeometry.matricesWeightsExtra) {
  82691. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, matricesIndicesExtra);
  82692. }
  82693. };
  82694. /**
  82695. * Create a new geometry from persisted data (Using .babylon file format)
  82696. * @param parsedVertexData defines the persisted data
  82697. * @param scene defines the hosting scene
  82698. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82699. * @returns the new geometry object
  82700. */
  82701. Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
  82702. if (scene.getGeometryByID(parsedVertexData.id)) {
  82703. return null; // null since geometry could be something else than a box...
  82704. }
  82705. var geometry = new Geometry(parsedVertexData.id, scene, undefined, parsedVertexData.updatable);
  82706. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"]) {
  82707. _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].AddTagsTo(geometry, parsedVertexData.tags);
  82708. }
  82709. if (parsedVertexData.delayLoadingFile) {
  82710. geometry.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  82711. geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
  82712. 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));
  82713. geometry._delayInfo = [];
  82714. if (parsedVertexData.hasUVs) {
  82715. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  82716. }
  82717. if (parsedVertexData.hasUVs2) {
  82718. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  82719. }
  82720. if (parsedVertexData.hasUVs3) {
  82721. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind);
  82722. }
  82723. if (parsedVertexData.hasUVs4) {
  82724. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind);
  82725. }
  82726. if (parsedVertexData.hasUVs5) {
  82727. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind);
  82728. }
  82729. if (parsedVertexData.hasUVs6) {
  82730. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind);
  82731. }
  82732. if (parsedVertexData.hasColors) {
  82733. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  82734. }
  82735. if (parsedVertexData.hasMatricesIndices) {
  82736. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  82737. }
  82738. if (parsedVertexData.hasMatricesWeights) {
  82739. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  82740. }
  82741. geometry._delayLoadingFunction = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData;
  82742. }
  82743. else {
  82744. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData(parsedVertexData, geometry);
  82745. }
  82746. scene.pushGeometry(geometry, true);
  82747. return geometry;
  82748. };
  82749. return Geometry;
  82750. }());
  82751. /***/ }),
  82752. /***/ "./Meshes/groundMesh.ts":
  82753. /*!******************************!*\
  82754. !*** ./Meshes/groundMesh.ts ***!
  82755. \******************************/
  82756. /*! exports provided: GroundMesh */
  82757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82758. "use strict";
  82759. __webpack_require__.r(__webpack_exports__);
  82760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return GroundMesh; });
  82761. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  82762. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  82763. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  82764. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  82765. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._GroundMeshParser = function (parsedMesh, scene) {
  82766. return GroundMesh.Parse(parsedMesh, scene);
  82767. };
  82768. /**
  82769. * Mesh representing the gorund
  82770. */
  82771. var GroundMesh = /** @class */ (function (_super) {
  82772. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundMesh, _super);
  82773. function GroundMesh(name, scene) {
  82774. var _this = _super.call(this, name, scene) || this;
  82775. /** If octree should be generated */
  82776. _this.generateOctree = false;
  82777. return _this;
  82778. }
  82779. /**
  82780. * "GroundMesh"
  82781. * @returns "GroundMesh"
  82782. */
  82783. GroundMesh.prototype.getClassName = function () {
  82784. return "GroundMesh";
  82785. };
  82786. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  82787. /**
  82788. * The minimum of x and y subdivisions
  82789. */
  82790. get: function () {
  82791. return Math.min(this._subdivisionsX, this._subdivisionsY);
  82792. },
  82793. enumerable: true,
  82794. configurable: true
  82795. });
  82796. Object.defineProperty(GroundMesh.prototype, "subdivisionsX", {
  82797. /**
  82798. * X subdivisions
  82799. */
  82800. get: function () {
  82801. return this._subdivisionsX;
  82802. },
  82803. enumerable: true,
  82804. configurable: true
  82805. });
  82806. Object.defineProperty(GroundMesh.prototype, "subdivisionsY", {
  82807. /**
  82808. * Y subdivisions
  82809. */
  82810. get: function () {
  82811. return this._subdivisionsY;
  82812. },
  82813. enumerable: true,
  82814. configurable: true
  82815. });
  82816. /**
  82817. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  82818. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  82819. * @param chunksCount the number of subdivisions for x and y
  82820. * @param octreeBlocksSize (Default: 32)
  82821. */
  82822. GroundMesh.prototype.optimize = function (chunksCount, octreeBlocksSize) {
  82823. if (octreeBlocksSize === void 0) { octreeBlocksSize = 32; }
  82824. this._subdivisionsX = chunksCount;
  82825. this._subdivisionsY = chunksCount;
  82826. this.subdivide(chunksCount);
  82827. // Call the octree system optimization if it is defined.
  82828. var thisAsAny = this;
  82829. if (thisAsAny.createOrUpdateSubmeshesOctree) {
  82830. thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);
  82831. }
  82832. };
  82833. /**
  82834. * Returns a height (y) value in the Worl system :
  82835. * the ground altitude at the coordinates (x, z) expressed in the World system.
  82836. * @param x x coordinate
  82837. * @param z z coordinate
  82838. * @returns the ground y position if (x, z) are outside the ground surface.
  82839. */
  82840. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  82841. var world = this.getWorldMatrix();
  82842. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  82843. world.invertToRef(invMat);
  82844. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  82845. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space
  82846. x = tmpVect.x;
  82847. z = tmpVect.z;
  82848. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  82849. return this.position.y;
  82850. }
  82851. if (!this._heightQuads || this._heightQuads.length == 0) {
  82852. this._initHeightQuads();
  82853. this._computeHeightQuads();
  82854. }
  82855. var facet = this._getFacetAt(x, z);
  82856. var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
  82857. // return y in the World system
  82858. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);
  82859. return tmpVect.y;
  82860. };
  82861. /**
  82862. * Returns a normalized vector (Vector3) orthogonal to the ground
  82863. * at the ground coordinates (x, z) expressed in the World system.
  82864. * @param x x coordinate
  82865. * @param z z coordinate
  82866. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  82867. */
  82868. GroundMesh.prototype.getNormalAtCoordinates = function (x, z) {
  82869. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 1.0, 0.0);
  82870. this.getNormalAtCoordinatesToRef(x, z, normal);
  82871. return normal;
  82872. };
  82873. /**
  82874. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  82875. * at the ground coordinates (x, z) expressed in the World system.
  82876. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  82877. * @param x x coordinate
  82878. * @param z z coordinate
  82879. * @param ref vector to store the result
  82880. * @returns the GroundMesh.
  82881. */
  82882. GroundMesh.prototype.getNormalAtCoordinatesToRef = function (x, z, ref) {
  82883. var world = this.getWorldMatrix();
  82884. var tmpMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  82885. world.invertToRef(tmpMat);
  82886. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  82887. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space
  82888. x = tmpVect.x;
  82889. z = tmpVect.z;
  82890. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  82891. return this;
  82892. }
  82893. if (!this._heightQuads || this._heightQuads.length == 0) {
  82894. this._initHeightQuads();
  82895. this._computeHeightQuads();
  82896. }
  82897. var facet = this._getFacetAt(x, z);
  82898. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);
  82899. return this;
  82900. };
  82901. /**
  82902. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  82903. * if the ground has been updated.
  82904. * This can be used in the render loop.
  82905. * @returns the GroundMesh.
  82906. */
  82907. GroundMesh.prototype.updateCoordinateHeights = function () {
  82908. if (!this._heightQuads || this._heightQuads.length == 0) {
  82909. this._initHeightQuads();
  82910. }
  82911. this._computeHeightQuads();
  82912. return this;
  82913. };
  82914. // Returns the element "facet" from the heightQuads array relative to (x, z) local coordinates
  82915. GroundMesh.prototype._getFacetAt = function (x, z) {
  82916. // retrieve col and row from x, z coordinates in the ground local system
  82917. var col = Math.floor((x + this._maxX) * this._subdivisionsX / this._width);
  82918. var row = Math.floor(-(z + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY);
  82919. var quad = this._heightQuads[row * this._subdivisionsX + col];
  82920. var facet;
  82921. if (z < quad.slope.x * x + quad.slope.y) {
  82922. facet = quad.facet1;
  82923. }
  82924. else {
  82925. facet = quad.facet2;
  82926. }
  82927. return facet;
  82928. };
  82929. // Creates and populates the heightMap array with "facet" elements :
  82930. // a quad is two triangular facets separated by a slope, so a "facet" element is 1 slope + 2 facets
  82931. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  82932. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  82933. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  82934. // Returns the GroundMesh.
  82935. GroundMesh.prototype._initHeightQuads = function () {
  82936. var subdivisionsX = this._subdivisionsX;
  82937. var subdivisionsY = this._subdivisionsY;
  82938. this._heightQuads = new Array();
  82939. for (var row = 0; row < subdivisionsY; row++) {
  82940. for (var col = 0; col < subdivisionsX; col++) {
  82941. 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) };
  82942. this._heightQuads[row * subdivisionsX + col] = quad;
  82943. }
  82944. }
  82945. return this;
  82946. };
  82947. // Compute each quad element values and update the the heightMap array :
  82948. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  82949. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  82950. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  82951. // Returns the GroundMesh.
  82952. GroundMesh.prototype._computeHeightQuads = function () {
  82953. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  82954. if (!positions) {
  82955. return this;
  82956. }
  82957. var v1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  82958. var v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  82959. var v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  82960. var v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  82961. var v1v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  82962. var v1v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  82963. var v1v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  82964. var norm1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[7];
  82965. var norm2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  82966. var i = 0;
  82967. var j = 0;
  82968. var k = 0;
  82969. var cd = 0; // 2D slope coefficient : z = cd * x + h
  82970. var h = 0;
  82971. var d1 = 0; // facet plane equation : ax + by + cz + d = 0
  82972. var d2 = 0;
  82973. var subdivisionsX = this._subdivisionsX;
  82974. var subdivisionsY = this._subdivisionsY;
  82975. for (var row = 0; row < subdivisionsY; row++) {
  82976. for (var col = 0; col < subdivisionsX; col++) {
  82977. i = col * 3;
  82978. j = row * (subdivisionsX + 1) * 3;
  82979. k = (row + 1) * (subdivisionsX + 1) * 3;
  82980. v1.x = positions[j + i];
  82981. v1.y = positions[j + i + 1];
  82982. v1.z = positions[j + i + 2];
  82983. v2.x = positions[j + i + 3];
  82984. v2.y = positions[j + i + 4];
  82985. v2.z = positions[j + i + 5];
  82986. v3.x = positions[k + i];
  82987. v3.y = positions[k + i + 1];
  82988. v3.z = positions[k + i + 2];
  82989. v4.x = positions[k + i + 3];
  82990. v4.y = positions[k + i + 4];
  82991. v4.z = positions[k + i + 5];
  82992. // 2D slope V1V4
  82993. cd = (v4.z - v1.z) / (v4.x - v1.x);
  82994. h = v1.z - cd * v1.x; // v1 belongs to the slope
  82995. // facet equations :
  82996. // we compute each facet normal vector
  82997. // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0
  82998. // we compute the value d by applying the equation to v1 which belongs to the plane
  82999. // then we store the facet equation in a Vector4
  83000. v2.subtractToRef(v1, v1v2);
  83001. v3.subtractToRef(v1, v1v3);
  83002. v4.subtractToRef(v1, v1v4);
  83003. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class
  83004. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v2, v1v4, norm2);
  83005. norm1.normalize();
  83006. norm2.normalize();
  83007. d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);
  83008. d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);
  83009. var quad = this._heightQuads[row * subdivisionsX + col];
  83010. quad.slope.copyFromFloats(cd, h);
  83011. quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);
  83012. quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);
  83013. }
  83014. }
  83015. return this;
  83016. };
  83017. /**
  83018. * Serializes this ground mesh
  83019. * @param serializationObject object to write serialization to
  83020. */
  83021. GroundMesh.prototype.serialize = function (serializationObject) {
  83022. _super.prototype.serialize.call(this, serializationObject);
  83023. serializationObject.subdivisionsX = this._subdivisionsX;
  83024. serializationObject.subdivisionsY = this._subdivisionsY;
  83025. serializationObject.minX = this._minX;
  83026. serializationObject.maxX = this._maxX;
  83027. serializationObject.minZ = this._minZ;
  83028. serializationObject.maxZ = this._maxZ;
  83029. serializationObject.width = this._width;
  83030. serializationObject.height = this._height;
  83031. };
  83032. /**
  83033. * Parses a serialized ground mesh
  83034. * @param parsedMesh the serialized mesh
  83035. * @param scene the scene to create the ground mesh in
  83036. * @returns the created ground mesh
  83037. */
  83038. GroundMesh.Parse = function (parsedMesh, scene) {
  83039. var result = new GroundMesh(parsedMesh.name, scene);
  83040. result._subdivisionsX = parsedMesh.subdivisionsX || 1;
  83041. result._subdivisionsY = parsedMesh.subdivisionsY || 1;
  83042. result._minX = parsedMesh.minX;
  83043. result._maxX = parsedMesh.maxX;
  83044. result._minZ = parsedMesh.minZ;
  83045. result._maxZ = parsedMesh.maxZ;
  83046. result._width = parsedMesh.width;
  83047. result._height = parsedMesh.height;
  83048. return result;
  83049. };
  83050. return GroundMesh;
  83051. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  83052. /***/ }),
  83053. /***/ "./Meshes/index.ts":
  83054. /*!*************************!*\
  83055. !*** ./Meshes/index.ts ***!
  83056. \*************************/
  83057. /*! exports provided: AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, DiscBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DracoCompression, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  83058. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83059. "use strict";
  83060. __webpack_require__.r(__webpack_exports__);
  83061. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  83062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  83063. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  83064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"]; });
  83065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"]; });
  83066. /* harmony import */ var _Compression_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Compression/index */ "./Meshes/Compression/index.ts");
  83067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Compression_index__WEBPACK_IMPORTED_MODULE_2__["DracoCompression"]; });
  83068. /* harmony import */ var _csg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./csg */ "./Meshes/csg.ts");
  83069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _csg__WEBPACK_IMPORTED_MODULE_3__["CSG"]; });
  83070. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  83071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"]; });
  83072. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  83073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _groundMesh__WEBPACK_IMPORTED_MODULE_5__["GroundMesh"]; });
  83074. /* harmony import */ var _instancedMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./instancedMesh */ "./Meshes/instancedMesh.ts");
  83075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _instancedMesh__WEBPACK_IMPORTED_MODULE_6__["InstancedMesh"]; });
  83076. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  83077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_7__["LinesMesh"]; });
  83078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_7__["InstancedLinesMesh"]; });
  83079. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  83080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["MeshLODLevel"]; });
  83081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["_CreationDataStorage"]; });
  83082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["_InstancesBatch"]; });
  83083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["Mesh"]; });
  83084. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  83085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"]; });
  83086. /* harmony import */ var _meshBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./meshBuilder */ "./Meshes/meshBuilder.ts");
  83087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _meshBuilder__WEBPACK_IMPORTED_MODULE_10__["MeshBuilder"]; });
  83088. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  83089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationSettings"]; });
  83090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationQueue"]; });
  83091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationType"]; });
  83092. /* harmony import */ var _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./meshSimplificationSceneComponent */ "./Meshes/meshSimplificationSceneComponent.ts");
  83093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_12__["SimplicationQueueSceneComponent"]; });
  83094. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  83095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_13__["Polygon"]; });
  83096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_13__["PolygonMeshBuilder"]; });
  83097. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  83098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_14__["BaseSubMesh"]; });
  83099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_14__["SubMesh"]; });
  83100. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  83101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _transformNode__WEBPACK_IMPORTED_MODULE_15__["TransformNode"]; });
  83102. /* harmony import */ var _Builders_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/index */ "./Meshes/Builders/index.ts");
  83103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["BoxBuilder"]; });
  83104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["DiscBuilder"]; });
  83105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["SphereBuilder"]; });
  83106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["CylinderBuilder"]; });
  83107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["LinesBuilder"]; });
  83108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["PlaneBuilder"]; });
  83109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["RibbonBuilder"]; });
  83110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["TorusBuilder"]; });
  83111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["TorusKnotBuilder"]; });
  83112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["PolygonBuilder"]; });
  83113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["ShapeBuilder"]; });
  83114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["LatheBuilder"]; });
  83115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["GroundBuilder"]; });
  83116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["TubeBuilder"]; });
  83117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["PolyhedronBuilder"]; });
  83118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["IcoSphereBuilder"]; });
  83119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"]; });
  83120. /***/ }),
  83121. /***/ "./Meshes/instancedMesh.ts":
  83122. /*!*********************************!*\
  83123. !*** ./Meshes/instancedMesh.ts ***!
  83124. \*********************************/
  83125. /*! exports provided: InstancedMesh */
  83126. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83127. "use strict";
  83128. __webpack_require__.r(__webpack_exports__);
  83129. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return InstancedMesh; });
  83130. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  83131. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  83132. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  83133. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  83134. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  83135. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._instancedMeshFactory = function (name, mesh) {
  83136. return new InstancedMesh(name, mesh);
  83137. };
  83138. /**
  83139. * Creates an instance based on a source mesh.
  83140. */
  83141. var InstancedMesh = /** @class */ (function (_super) {
  83142. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedMesh, _super);
  83143. function InstancedMesh(name, source) {
  83144. var _this = _super.call(this, name, source.getScene()) || this;
  83145. /** @hidden */
  83146. _this._indexInSourceMeshInstanceArray = -1;
  83147. source.addInstance(_this);
  83148. _this._sourceMesh = source;
  83149. _this.position.copyFrom(source.position);
  83150. _this.rotation.copyFrom(source.rotation);
  83151. _this.scaling.copyFrom(source.scaling);
  83152. if (source.rotationQuaternion) {
  83153. _this.rotationQuaternion = source.rotationQuaternion.clone();
  83154. }
  83155. _this.infiniteDistance = source.infiniteDistance;
  83156. _this.setPivotMatrix(source.getPivotMatrix());
  83157. _this.refreshBoundingInfo();
  83158. _this._syncSubMeshes();
  83159. return _this;
  83160. }
  83161. /**
  83162. * Returns the string "InstancedMesh".
  83163. */
  83164. InstancedMesh.prototype.getClassName = function () {
  83165. return "InstancedMesh";
  83166. };
  83167. Object.defineProperty(InstancedMesh.prototype, "receiveShadows", {
  83168. // Methods
  83169. /**
  83170. * If the source mesh receives shadows
  83171. */
  83172. get: function () {
  83173. return this._sourceMesh.receiveShadows;
  83174. },
  83175. enumerable: true,
  83176. configurable: true
  83177. });
  83178. Object.defineProperty(InstancedMesh.prototype, "material", {
  83179. /**
  83180. * The material of the source mesh
  83181. */
  83182. get: function () {
  83183. return this._sourceMesh.material;
  83184. },
  83185. enumerable: true,
  83186. configurable: true
  83187. });
  83188. Object.defineProperty(InstancedMesh.prototype, "visibility", {
  83189. /**
  83190. * Visibility of the source mesh
  83191. */
  83192. get: function () {
  83193. return this._sourceMesh.visibility;
  83194. },
  83195. enumerable: true,
  83196. configurable: true
  83197. });
  83198. Object.defineProperty(InstancedMesh.prototype, "skeleton", {
  83199. /**
  83200. * Skeleton of the source mesh
  83201. */
  83202. get: function () {
  83203. return this._sourceMesh.skeleton;
  83204. },
  83205. enumerable: true,
  83206. configurable: true
  83207. });
  83208. Object.defineProperty(InstancedMesh.prototype, "renderingGroupId", {
  83209. /**
  83210. * Rendering ground id of the source mesh
  83211. */
  83212. get: function () {
  83213. return this._sourceMesh.renderingGroupId;
  83214. },
  83215. set: function (value) {
  83216. if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {
  83217. return;
  83218. }
  83219. //no-op with warning
  83220. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
  83221. },
  83222. enumerable: true,
  83223. configurable: true
  83224. });
  83225. /**
  83226. * Returns the total number of vertices (integer).
  83227. */
  83228. InstancedMesh.prototype.getTotalVertices = function () {
  83229. return this._sourceMesh.getTotalVertices();
  83230. };
  83231. /**
  83232. * Returns a positive integer : the total number of indices in this mesh geometry.
  83233. * @returns the numner of indices or zero if the mesh has no geometry.
  83234. */
  83235. InstancedMesh.prototype.getTotalIndices = function () {
  83236. return this._sourceMesh.getTotalIndices();
  83237. };
  83238. Object.defineProperty(InstancedMesh.prototype, "sourceMesh", {
  83239. /**
  83240. * The source mesh of the instance
  83241. */
  83242. get: function () {
  83243. return this._sourceMesh;
  83244. },
  83245. enumerable: true,
  83246. configurable: true
  83247. });
  83248. /**
  83249. * Is this node ready to be used/rendered
  83250. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83251. * @return {boolean} is it ready
  83252. */
  83253. InstancedMesh.prototype.isReady = function (completeCheck) {
  83254. if (completeCheck === void 0) { completeCheck = false; }
  83255. return this._sourceMesh.isReady(completeCheck, true);
  83256. };
  83257. /**
  83258. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83259. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  83260. * @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.
  83261. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  83262. */
  83263. InstancedMesh.prototype.getVerticesData = function (kind, copyWhenShared) {
  83264. return this._sourceMesh.getVerticesData(kind, copyWhenShared);
  83265. };
  83266. /**
  83267. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83268. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83269. * The `data` are either a numeric array either a Float32Array.
  83270. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  83271. * 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).
  83272. * Note that a new underlying VertexBuffer object is created each call.
  83273. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83274. *
  83275. * Possible `kind` values :
  83276. * - VertexBuffer.PositionKind
  83277. * - VertexBuffer.UVKind
  83278. * - VertexBuffer.UV2Kind
  83279. * - VertexBuffer.UV3Kind
  83280. * - VertexBuffer.UV4Kind
  83281. * - VertexBuffer.UV5Kind
  83282. * - VertexBuffer.UV6Kind
  83283. * - VertexBuffer.ColorKind
  83284. * - VertexBuffer.MatricesIndicesKind
  83285. * - VertexBuffer.MatricesIndicesExtraKind
  83286. * - VertexBuffer.MatricesWeightsKind
  83287. * - VertexBuffer.MatricesWeightsExtraKind
  83288. *
  83289. * Returns the Mesh.
  83290. */
  83291. InstancedMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  83292. if (this.sourceMesh) {
  83293. this.sourceMesh.setVerticesData(kind, data, updatable, stride);
  83294. }
  83295. return this.sourceMesh;
  83296. };
  83297. /**
  83298. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83299. * If the mesh has no geometry, it is simply returned as it is.
  83300. * The `data` are either a numeric array either a Float32Array.
  83301. * No new underlying VertexBuffer object is created.
  83302. * 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.
  83303. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  83304. *
  83305. * Possible `kind` values :
  83306. * - VertexBuffer.PositionKind
  83307. * - VertexBuffer.UVKind
  83308. * - VertexBuffer.UV2Kind
  83309. * - VertexBuffer.UV3Kind
  83310. * - VertexBuffer.UV4Kind
  83311. * - VertexBuffer.UV5Kind
  83312. * - VertexBuffer.UV6Kind
  83313. * - VertexBuffer.ColorKind
  83314. * - VertexBuffer.MatricesIndicesKind
  83315. * - VertexBuffer.MatricesIndicesExtraKind
  83316. * - VertexBuffer.MatricesWeightsKind
  83317. * - VertexBuffer.MatricesWeightsExtraKind
  83318. *
  83319. * Returns the Mesh.
  83320. */
  83321. InstancedMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  83322. if (this.sourceMesh) {
  83323. this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);
  83324. }
  83325. return this.sourceMesh;
  83326. };
  83327. /**
  83328. * Sets the mesh indices.
  83329. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  83330. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83331. * This method creates a new index buffer each call.
  83332. * Returns the Mesh.
  83333. */
  83334. InstancedMesh.prototype.setIndices = function (indices, totalVertices) {
  83335. if (totalVertices === void 0) { totalVertices = null; }
  83336. if (this.sourceMesh) {
  83337. this.sourceMesh.setIndices(indices, totalVertices);
  83338. }
  83339. return this.sourceMesh;
  83340. };
  83341. /**
  83342. * Boolean : True if the mesh owns the requested kind of data.
  83343. */
  83344. InstancedMesh.prototype.isVerticesDataPresent = function (kind) {
  83345. return this._sourceMesh.isVerticesDataPresent(kind);
  83346. };
  83347. /**
  83348. * Returns an array of indices (IndicesArray).
  83349. */
  83350. InstancedMesh.prototype.getIndices = function () {
  83351. return this._sourceMesh.getIndices();
  83352. };
  83353. Object.defineProperty(InstancedMesh.prototype, "_positions", {
  83354. get: function () {
  83355. return this._sourceMesh._positions;
  83356. },
  83357. enumerable: true,
  83358. configurable: true
  83359. });
  83360. /**
  83361. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83362. * This means the mesh underlying bounding box and sphere are recomputed.
  83363. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83364. * @returns the current mesh
  83365. */
  83366. InstancedMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  83367. if (applySkeleton === void 0) { applySkeleton = false; }
  83368. if (this._boundingInfo && this._boundingInfo.isLocked) {
  83369. return this;
  83370. }
  83371. var bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  83372. this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton), bias);
  83373. return this;
  83374. };
  83375. /** @hidden */
  83376. InstancedMesh.prototype._preActivate = function () {
  83377. if (this._currentLOD) {
  83378. this._currentLOD._preActivate();
  83379. }
  83380. return this;
  83381. };
  83382. /** @hidden */
  83383. InstancedMesh.prototype._activate = function (renderId) {
  83384. if (this._currentLOD) {
  83385. this._currentLOD._registerInstanceForRenderId(this, renderId);
  83386. }
  83387. return this;
  83388. };
  83389. /**
  83390. * Returns the current associated LOD AbstractMesh.
  83391. */
  83392. InstancedMesh.prototype.getLOD = function (camera) {
  83393. if (!camera) {
  83394. return this;
  83395. }
  83396. var boundingInfo = this.getBoundingInfo();
  83397. this._currentLOD = this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);
  83398. if (this._currentLOD === this.sourceMesh) {
  83399. return this;
  83400. }
  83401. return this._currentLOD;
  83402. };
  83403. /** @hidden */
  83404. InstancedMesh.prototype._syncSubMeshes = function () {
  83405. this.releaseSubMeshes();
  83406. if (this._sourceMesh.subMeshes) {
  83407. for (var index = 0; index < this._sourceMesh.subMeshes.length; index++) {
  83408. this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);
  83409. }
  83410. }
  83411. return this;
  83412. };
  83413. /** @hidden */
  83414. InstancedMesh.prototype._generatePointsArray = function () {
  83415. return this._sourceMesh._generatePointsArray();
  83416. };
  83417. /**
  83418. * Creates a new InstancedMesh from the current mesh.
  83419. * - name (string) : the cloned mesh name
  83420. * - newParent (optional Node) : the optional Node to parent the clone to.
  83421. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  83422. *
  83423. * Returns the clone.
  83424. */
  83425. InstancedMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  83426. var result = this._sourceMesh.createInstance(name);
  83427. // Deep copy
  83428. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__["DeepCopier"].DeepCopy(this, result, ["name", "subMeshes", "uniqueId"], []);
  83429. // Bounding info
  83430. this.refreshBoundingInfo();
  83431. // Parent
  83432. if (newParent) {
  83433. result.parent = newParent;
  83434. }
  83435. if (!doNotCloneChildren) {
  83436. // Children
  83437. for (var index = 0; index < this.getScene().meshes.length; index++) {
  83438. var mesh = this.getScene().meshes[index];
  83439. if (mesh.parent === this) {
  83440. mesh.clone(mesh.name, result);
  83441. }
  83442. }
  83443. }
  83444. result.computeWorldMatrix(true);
  83445. return result;
  83446. };
  83447. /**
  83448. * Disposes the InstancedMesh.
  83449. * Returns nothing.
  83450. */
  83451. InstancedMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  83452. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  83453. // Remove from mesh
  83454. this._sourceMesh.removeInstance(this);
  83455. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  83456. };
  83457. return InstancedMesh;
  83458. }(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]));
  83459. /***/ }),
  83460. /***/ "./Meshes/linesMesh.ts":
  83461. /*!*****************************!*\
  83462. !*** ./Meshes/linesMesh.ts ***!
  83463. \*****************************/
  83464. /*! exports provided: LinesMesh, InstancedLinesMesh */
  83465. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83466. "use strict";
  83467. __webpack_require__.r(__webpack_exports__);
  83468. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return LinesMesh; });
  83469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return InstancedLinesMesh; });
  83470. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  83471. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83472. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  83473. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  83474. /* harmony import */ var _Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/instancedMesh */ "./Meshes/instancedMesh.ts");
  83475. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  83476. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  83477. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  83478. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  83479. /**
  83480. * Line mesh
  83481. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  83482. */
  83483. var LinesMesh = /** @class */ (function (_super) {
  83484. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LinesMesh, _super);
  83485. /**
  83486. * Creates a new LinesMesh
  83487. * @param name defines the name
  83488. * @param scene defines the hosting scene
  83489. * @param parent defines the parent mesh if any
  83490. * @param source defines the optional source LinesMesh used to clone data from
  83491. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83492. * When false, achieved by calling a clone(), also passing False.
  83493. * This will make creation of children, recursive.
  83494. * @param useVertexColor defines if this LinesMesh supports vertex color
  83495. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  83496. */
  83497. function LinesMesh(name, scene, parent, source, doNotCloneChildren,
  83498. /**
  83499. * If vertex color should be applied to the mesh
  83500. */
  83501. useVertexColor,
  83502. /**
  83503. * If vertex alpha should be applied to the mesh
  83504. */
  83505. useVertexAlpha) {
  83506. if (scene === void 0) { scene = null; }
  83507. if (parent === void 0) { parent = null; }
  83508. var _this = _super.call(this, name, scene, parent, source, doNotCloneChildren) || this;
  83509. _this.useVertexColor = useVertexColor;
  83510. _this.useVertexAlpha = useVertexAlpha;
  83511. /**
  83512. * Color of the line (Default: White)
  83513. */
  83514. _this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  83515. /**
  83516. * Alpha of the line (Default: 1)
  83517. */
  83518. _this.alpha = 1;
  83519. if (source) {
  83520. _this.color = source.color.clone();
  83521. _this.alpha = source.alpha;
  83522. _this.useVertexColor = source.useVertexColor;
  83523. _this.useVertexAlpha = source.useVertexAlpha;
  83524. }
  83525. _this.intersectionThreshold = 0.1;
  83526. var defines = [];
  83527. var options = {
  83528. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "world0", "world1", "world2", "world3"],
  83529. uniforms: ["world", "viewProjection"],
  83530. needAlphaBlending: true,
  83531. defines: defines
  83532. };
  83533. if (useVertexAlpha === false) {
  83534. options.needAlphaBlending = false;
  83535. }
  83536. if (!useVertexColor) {
  83537. options.uniforms.push("color");
  83538. }
  83539. else {
  83540. options.defines.push("#define VERTEXCOLOR");
  83541. options.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  83542. }
  83543. _this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("colorShader", _this.getScene(), "color", options);
  83544. return _this;
  83545. }
  83546. /**
  83547. * Returns the string "LineMesh"
  83548. */
  83549. LinesMesh.prototype.getClassName = function () {
  83550. return "LinesMesh";
  83551. };
  83552. Object.defineProperty(LinesMesh.prototype, "material", {
  83553. /**
  83554. * @hidden
  83555. */
  83556. get: function () {
  83557. return this._colorShader;
  83558. },
  83559. /**
  83560. * @hidden
  83561. */
  83562. set: function (value) {
  83563. // Do nothing
  83564. },
  83565. enumerable: true,
  83566. configurable: true
  83567. });
  83568. Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
  83569. /**
  83570. * @hidden
  83571. */
  83572. get: function () {
  83573. return false;
  83574. },
  83575. enumerable: true,
  83576. configurable: true
  83577. });
  83578. /** @hidden */
  83579. LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
  83580. if (!this._geometry) {
  83581. return this;
  83582. }
  83583. // VBOs
  83584. this._geometry._bind(this._colorShader.getEffect());
  83585. // Color
  83586. if (!this.useVertexColor) {
  83587. this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
  83588. }
  83589. return this;
  83590. };
  83591. /** @hidden */
  83592. LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  83593. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  83594. return this;
  83595. }
  83596. var engine = this.getScene().getEngine();
  83597. // Draw order
  83598. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  83599. return this;
  83600. };
  83601. /**
  83602. * Disposes of the line mesh
  83603. * @param doNotRecurse If children should be disposed
  83604. */
  83605. LinesMesh.prototype.dispose = function (doNotRecurse) {
  83606. this._colorShader.dispose(false, false, true);
  83607. _super.prototype.dispose.call(this, doNotRecurse);
  83608. };
  83609. /**
  83610. * Returns a new LineMesh object cloned from the current one.
  83611. */
  83612. LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  83613. return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
  83614. };
  83615. /**
  83616. * Creates a new InstancedLinesMesh object from the mesh model.
  83617. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83618. * @param name defines the name of the new instance
  83619. * @returns a new InstancedLinesMesh
  83620. */
  83621. LinesMesh.prototype.createInstance = function (name) {
  83622. return new InstancedLinesMesh(name, this);
  83623. };
  83624. return LinesMesh;
  83625. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  83626. /**
  83627. * Creates an instance based on a source LinesMesh
  83628. */
  83629. var InstancedLinesMesh = /** @class */ (function (_super) {
  83630. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedLinesMesh, _super);
  83631. function InstancedLinesMesh(name, source) {
  83632. var _this = _super.call(this, name, source) || this;
  83633. _this.intersectionThreshold = source.intersectionThreshold;
  83634. return _this;
  83635. }
  83636. /**
  83637. * Returns the string "InstancedLinesMesh".
  83638. */
  83639. InstancedLinesMesh.prototype.getClassName = function () {
  83640. return "InstancedLinesMesh";
  83641. };
  83642. return InstancedLinesMesh;
  83643. }(_Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__["InstancedMesh"]));
  83644. /***/ }),
  83645. /***/ "./Meshes/mesh.ts":
  83646. /*!************************!*\
  83647. !*** ./Meshes/mesh.ts ***!
  83648. \************************/
  83649. /*! exports provided: MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh */
  83650. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83651. "use strict";
  83652. __webpack_require__.r(__webpack_exports__);
  83653. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return MeshLODLevel; });
  83654. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _CreationDataStorage; });
  83655. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _InstancesBatch; });
  83656. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return Mesh; });
  83657. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  83658. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  83659. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  83660. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  83661. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  83662. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83663. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  83664. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  83665. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  83666. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  83667. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  83668. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  83669. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  83670. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  83671. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  83672. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  83673. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  83674. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  83675. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  83676. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  83677. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  83678. /**
  83679. * Class used to represent a specific level of detail of a mesh
  83680. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  83681. */
  83682. var MeshLODLevel = /** @class */ (function () {
  83683. /**
  83684. * Creates a new LOD level
  83685. * @param distance defines the distance where this level should star being displayed
  83686. * @param mesh defines the mesh to use to render this level
  83687. */
  83688. function MeshLODLevel(
  83689. /** Defines the distance where this level should star being displayed */
  83690. distance,
  83691. /** Defines the mesh to use to render this level */
  83692. mesh) {
  83693. this.distance = distance;
  83694. this.mesh = mesh;
  83695. }
  83696. return MeshLODLevel;
  83697. }());
  83698. /**
  83699. * @hidden
  83700. **/
  83701. var _CreationDataStorage = /** @class */ (function () {
  83702. function _CreationDataStorage() {
  83703. }
  83704. return _CreationDataStorage;
  83705. }());
  83706. /**
  83707. * @hidden
  83708. **/
  83709. var _InstanceDataStorage = /** @class */ (function () {
  83710. function _InstanceDataStorage() {
  83711. this.visibleInstances = {};
  83712. this.renderIdForInstances = new Array();
  83713. this.batchCache = new _InstancesBatch();
  83714. this.instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
  83715. }
  83716. return _InstanceDataStorage;
  83717. }());
  83718. /**
  83719. * @hidden
  83720. **/
  83721. var _InstancesBatch = /** @class */ (function () {
  83722. function _InstancesBatch() {
  83723. this.mustReturn = false;
  83724. this.visibleInstances = new Array();
  83725. this.renderSelf = new Array();
  83726. }
  83727. return _InstancesBatch;
  83728. }());
  83729. /**
  83730. * Class used to represent renderable models
  83731. */
  83732. var Mesh = /** @class */ (function (_super) {
  83733. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Mesh, _super);
  83734. /**
  83735. * @constructor
  83736. * @param name The value used by scene.getMeshByName() to do a lookup.
  83737. * @param scene The scene to add this mesh to.
  83738. * @param parent The parent of this mesh, if it has one
  83739. * @param source An optional Mesh from which geometry is shared, cloned.
  83740. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83741. * When false, achieved by calling a clone(), also passing False.
  83742. * This will make creation of children, recursive.
  83743. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  83744. */
  83745. function Mesh(name, scene, parent, source, doNotCloneChildren, clonePhysicsImpostor) {
  83746. if (scene === void 0) { scene = null; }
  83747. if (parent === void 0) { parent = null; }
  83748. if (source === void 0) { source = null; }
  83749. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  83750. var _this = _super.call(this, name, scene) || this;
  83751. // Members
  83752. /**
  83753. * Gets the delay loading state of the mesh (when delay loading is turned on)
  83754. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  83755. */
  83756. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NONE;
  83757. /**
  83758. * Gets the list of instances created from this mesh
  83759. * it is not supposed to be modified manually.
  83760. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  83761. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83762. */
  83763. _this.instances = new Array();
  83764. _this._LODLevels = new Array();
  83765. /** @hidden */
  83766. _this._instanceDataStorage = new _InstanceDataStorage();
  83767. // Use by builder only to know what orientation were the mesh build in.
  83768. /** @hidden */
  83769. _this._originalBuilderSideOrientation = Mesh.DEFAULTSIDE;
  83770. /**
  83771. * Use this property to change the original side orientation defined at construction time
  83772. */
  83773. _this.overrideMaterialSideOrientation = null;
  83774. _this._areNormalsFrozen = false; // Will be used by ribbons mainly
  83775. // Will be used to save a source mesh reference, If any
  83776. _this._source = null;
  83777. /** @hidden */
  83778. _this._isMesh = true;
  83779. scene = _this.getScene();
  83780. if (source) {
  83781. // Geometry
  83782. if (source._geometry) {
  83783. source._geometry.applyToMesh(_this);
  83784. }
  83785. // Deep copy
  83786. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
  83787. "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
  83788. "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw",
  83789. "onAfterWorldMatrixUpdateObservable", "onCollideObservable", "onCollisionPositionChangeObservable", "onRebuildObservable",
  83790. "onDisposeObservable"
  83791. ], ["_poseMatrix"]);
  83792. // Source mesh
  83793. _this._source = source;
  83794. if (scene.useClonedMeshhMap) {
  83795. if (!source.meshMap) {
  83796. source.meshMap = {};
  83797. }
  83798. source.meshMap[_this.uniqueId] = _this;
  83799. }
  83800. // Construction Params
  83801. // Clone parameters allowing mesh to be updated in case of parametric shapes.
  83802. _this._originalBuilderSideOrientation = source._originalBuilderSideOrientation;
  83803. _this._creationDataStorage = source._creationDataStorage;
  83804. // Animation ranges
  83805. if (_this._source._ranges) {
  83806. var ranges = _this._source._ranges;
  83807. for (var name in ranges) {
  83808. if (!ranges.hasOwnProperty(name)) {
  83809. continue;
  83810. }
  83811. if (!ranges[name]) {
  83812. continue;
  83813. }
  83814. _this.createAnimationRange(name, ranges[name].from, ranges[name].to);
  83815. }
  83816. }
  83817. // Metadata
  83818. if (source.metadata && source.metadata.clone) {
  83819. _this.metadata = source.metadata.clone();
  83820. }
  83821. else {
  83822. _this.metadata = source.metadata;
  83823. }
  83824. // Tags
  83825. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(source)) {
  83826. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(_this, _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(source, true));
  83827. }
  83828. // Parent
  83829. _this.parent = source.parent;
  83830. // Pivot
  83831. _this.setPivotMatrix(source.getPivotMatrix());
  83832. _this.id = name + "." + source.id;
  83833. // Material
  83834. _this.material = source.material;
  83835. var index;
  83836. if (!doNotCloneChildren) {
  83837. // Children
  83838. var directDescendants = source.getDescendants(true);
  83839. for (var index_1 = 0; index_1 < directDescendants.length; index_1++) {
  83840. var child = directDescendants[index_1];
  83841. if (child.clone) {
  83842. child.clone(name + "." + child.name, _this);
  83843. }
  83844. }
  83845. }
  83846. // Physics clone
  83847. var physicsEngine = _this.getScene().getPhysicsEngine();
  83848. if (clonePhysicsImpostor && physicsEngine) {
  83849. var impostor = physicsEngine.getImpostorForPhysicsObject(source);
  83850. if (impostor) {
  83851. _this.physicsImpostor = impostor.clone(_this);
  83852. }
  83853. }
  83854. // Particles
  83855. for (index = 0; index < scene.particleSystems.length; index++) {
  83856. var system = scene.particleSystems[index];
  83857. if (system.emitter === source) {
  83858. system.clone(system.name, _this);
  83859. }
  83860. }
  83861. _this.refreshBoundingInfo();
  83862. _this.computeWorldMatrix(true);
  83863. }
  83864. // Parent
  83865. if (parent !== null) {
  83866. _this.parent = parent;
  83867. }
  83868. return _this;
  83869. }
  83870. /**
  83871. * Gets the default side orientation.
  83872. * @param orientation the orientation to value to attempt to get
  83873. * @returns the default orientation
  83874. * @hidden
  83875. */
  83876. Mesh._GetDefaultSideOrientation = function (orientation) {
  83877. if (orientation == Mesh.DOUBLESIDE) {
  83878. return Mesh.DOUBLESIDE;
  83879. }
  83880. if (orientation === undefined || orientation === null) {
  83881. return Mesh.FRONTSIDE;
  83882. }
  83883. return orientation;
  83884. };
  83885. Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
  83886. /**
  83887. * An event triggered before rendering the mesh
  83888. */
  83889. get: function () {
  83890. if (!this._onBeforeRenderObservable) {
  83891. this._onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83892. }
  83893. return this._onBeforeRenderObservable;
  83894. },
  83895. enumerable: true,
  83896. configurable: true
  83897. });
  83898. Object.defineProperty(Mesh.prototype, "onBeforeBindObservable", {
  83899. /**
  83900. * An event triggered before binding the mesh
  83901. */
  83902. get: function () {
  83903. if (!this._onBeforeBindObservable) {
  83904. this._onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83905. }
  83906. return this._onBeforeBindObservable;
  83907. },
  83908. enumerable: true,
  83909. configurable: true
  83910. });
  83911. Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
  83912. /**
  83913. * An event triggered after rendering the mesh
  83914. */
  83915. get: function () {
  83916. if (!this._onAfterRenderObservable) {
  83917. this._onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83918. }
  83919. return this._onAfterRenderObservable;
  83920. },
  83921. enumerable: true,
  83922. configurable: true
  83923. });
  83924. Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
  83925. /**
  83926. * An event triggered before drawing the mesh
  83927. */
  83928. get: function () {
  83929. if (!this._onBeforeDrawObservable) {
  83930. this._onBeforeDrawObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  83931. }
  83932. return this._onBeforeDrawObservable;
  83933. },
  83934. enumerable: true,
  83935. configurable: true
  83936. });
  83937. Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
  83938. /**
  83939. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  83940. */
  83941. set: function (callback) {
  83942. if (this._onBeforeDrawObserver) {
  83943. this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver);
  83944. }
  83945. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(callback);
  83946. },
  83947. enumerable: true,
  83948. configurable: true
  83949. });
  83950. Object.defineProperty(Mesh.prototype, "morphTargetManager", {
  83951. /**
  83952. * Gets or sets the morph target manager
  83953. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  83954. */
  83955. get: function () {
  83956. return this._morphTargetManager;
  83957. },
  83958. set: function (value) {
  83959. if (this._morphTargetManager === value) {
  83960. return;
  83961. }
  83962. this._morphTargetManager = value;
  83963. this._syncGeometryWithMorphTargetManager();
  83964. },
  83965. enumerable: true,
  83966. configurable: true
  83967. });
  83968. Object.defineProperty(Mesh.prototype, "source", {
  83969. /**
  83970. * Gets the source mesh (the one used to clone this one from)
  83971. */
  83972. get: function () {
  83973. return this._source;
  83974. },
  83975. enumerable: true,
  83976. configurable: true
  83977. });
  83978. Object.defineProperty(Mesh.prototype, "isUnIndexed", {
  83979. /**
  83980. * Gets or sets a boolean indicating that this mesh does not use index buffer
  83981. */
  83982. get: function () {
  83983. return this._unIndexed;
  83984. },
  83985. set: function (value) {
  83986. if (this._unIndexed !== value) {
  83987. this._unIndexed = value;
  83988. this._markSubMeshesAsAttributesDirty();
  83989. }
  83990. },
  83991. enumerable: true,
  83992. configurable: true
  83993. });
  83994. // Methods
  83995. /**
  83996. * Gets the class name
  83997. * @returns the string "Mesh".
  83998. */
  83999. Mesh.prototype.getClassName = function () {
  84000. return "Mesh";
  84001. };
  84002. /**
  84003. * Returns a description of this mesh
  84004. * @param fullDetails define if full details about this mesh must be used
  84005. * @returns a descriptive string representing this mesh
  84006. */
  84007. Mesh.prototype.toString = function (fullDetails) {
  84008. var ret = _super.prototype.toString.call(this, fullDetails);
  84009. ret += ", n vertices: " + this.getTotalVertices();
  84010. ret += ", parent: " + (this._waitingParentId ? this._waitingParentId : (this.parent ? this.parent.name : "NONE"));
  84011. if (this.animations) {
  84012. for (var i = 0; i < this.animations.length; i++) {
  84013. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  84014. }
  84015. }
  84016. if (fullDetails) {
  84017. if (this._geometry) {
  84018. var ib = this.getIndices();
  84019. var vb = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  84020. if (vb && ib) {
  84021. ret += ", flat shading: " + (vb.length / 3 === ib.length ? "YES" : "NO");
  84022. }
  84023. }
  84024. else {
  84025. ret += ", flat shading: UNKNOWN";
  84026. }
  84027. }
  84028. return ret;
  84029. };
  84030. /** @hidden */
  84031. Mesh.prototype._unBindEffect = function () {
  84032. _super.prototype._unBindEffect.call(this);
  84033. for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
  84034. var instance = _a[_i];
  84035. instance._unBindEffect();
  84036. }
  84037. };
  84038. Object.defineProperty(Mesh.prototype, "hasLODLevels", {
  84039. /**
  84040. * Gets a boolean indicating if this mesh has LOD
  84041. */
  84042. get: function () {
  84043. return this._LODLevels.length > 0;
  84044. },
  84045. enumerable: true,
  84046. configurable: true
  84047. });
  84048. /**
  84049. * Gets the list of MeshLODLevel associated with the current mesh
  84050. * @returns an array of MeshLODLevel
  84051. */
  84052. Mesh.prototype.getLODLevels = function () {
  84053. return this._LODLevels;
  84054. };
  84055. Mesh.prototype._sortLODLevels = function () {
  84056. this._LODLevels.sort(function (a, b) {
  84057. if (a.distance < b.distance) {
  84058. return 1;
  84059. }
  84060. if (a.distance > b.distance) {
  84061. return -1;
  84062. }
  84063. return 0;
  84064. });
  84065. };
  84066. /**
  84067. * Add a mesh as LOD level triggered at the given distance.
  84068. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  84069. * @param distance The distance from the center of the object to show this level
  84070. * @param mesh The mesh to be added as LOD level (can be null)
  84071. * @return This mesh (for chaining)
  84072. */
  84073. Mesh.prototype.addLODLevel = function (distance, mesh) {
  84074. if (mesh && mesh._masterMesh) {
  84075. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("You cannot use a mesh as LOD level twice");
  84076. return this;
  84077. }
  84078. var level = new MeshLODLevel(distance, mesh);
  84079. this._LODLevels.push(level);
  84080. if (mesh) {
  84081. mesh._masterMesh = this;
  84082. }
  84083. this._sortLODLevels();
  84084. return this;
  84085. };
  84086. /**
  84087. * Returns the LOD level mesh at the passed distance or null if not found.
  84088. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  84089. * @param distance The distance from the center of the object to show this level
  84090. * @returns a Mesh or `null`
  84091. */
  84092. Mesh.prototype.getLODLevelAtDistance = function (distance) {
  84093. for (var index = 0; index < this._LODLevels.length; index++) {
  84094. var level = this._LODLevels[index];
  84095. if (level.distance === distance) {
  84096. return level.mesh;
  84097. }
  84098. }
  84099. return null;
  84100. };
  84101. /**
  84102. * Remove a mesh from the LOD array
  84103. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  84104. * @param mesh defines the mesh to be removed
  84105. * @return This mesh (for chaining)
  84106. */
  84107. Mesh.prototype.removeLODLevel = function (mesh) {
  84108. for (var index = 0; index < this._LODLevels.length; index++) {
  84109. if (this._LODLevels[index].mesh === mesh) {
  84110. this._LODLevels.splice(index, 1);
  84111. if (mesh) {
  84112. mesh._masterMesh = null;
  84113. }
  84114. }
  84115. }
  84116. this._sortLODLevels();
  84117. return this;
  84118. };
  84119. /**
  84120. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  84121. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  84122. * @param camera defines the camera to use to compute distance
  84123. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  84124. * @return This mesh (for chaining)
  84125. */
  84126. Mesh.prototype.getLOD = function (camera, boundingSphere) {
  84127. if (!this._LODLevels || this._LODLevels.length === 0) {
  84128. return this;
  84129. }
  84130. var bSphere;
  84131. if (boundingSphere) {
  84132. bSphere = boundingSphere;
  84133. }
  84134. else {
  84135. var boundingInfo = this.getBoundingInfo();
  84136. bSphere = boundingInfo.boundingSphere;
  84137. }
  84138. var distanceToCamera = bSphere.centerWorld.subtract(camera.globalPosition).length();
  84139. if (this._LODLevels[this._LODLevels.length - 1].distance > distanceToCamera) {
  84140. if (this.onLODLevelSelection) {
  84141. this.onLODLevelSelection(distanceToCamera, this, this._LODLevels[this._LODLevels.length - 1].mesh);
  84142. }
  84143. return this;
  84144. }
  84145. for (var index = 0; index < this._LODLevels.length; index++) {
  84146. var level = this._LODLevels[index];
  84147. if (level.distance < distanceToCamera) {
  84148. if (level.mesh) {
  84149. level.mesh._preActivate();
  84150. level.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
  84151. }
  84152. if (this.onLODLevelSelection) {
  84153. this.onLODLevelSelection(distanceToCamera, this, level.mesh);
  84154. }
  84155. return level.mesh;
  84156. }
  84157. }
  84158. if (this.onLODLevelSelection) {
  84159. this.onLODLevelSelection(distanceToCamera, this, this);
  84160. }
  84161. return this;
  84162. };
  84163. Object.defineProperty(Mesh.prototype, "geometry", {
  84164. /**
  84165. * Gets the mesh internal Geometry object
  84166. */
  84167. get: function () {
  84168. return this._geometry;
  84169. },
  84170. enumerable: true,
  84171. configurable: true
  84172. });
  84173. /**
  84174. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  84175. * @returns the total number of vertices
  84176. */
  84177. Mesh.prototype.getTotalVertices = function () {
  84178. if (this._geometry === null || this._geometry === undefined) {
  84179. return 0;
  84180. }
  84181. return this._geometry.getTotalVertices();
  84182. };
  84183. /**
  84184. * Returns the content of an associated vertex buffer
  84185. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  84186. * - VertexBuffer.PositionKind
  84187. * - VertexBuffer.UVKind
  84188. * - VertexBuffer.UV2Kind
  84189. * - VertexBuffer.UV3Kind
  84190. * - VertexBuffer.UV4Kind
  84191. * - VertexBuffer.UV5Kind
  84192. * - VertexBuffer.UV6Kind
  84193. * - VertexBuffer.ColorKind
  84194. * - VertexBuffer.MatricesIndicesKind
  84195. * - VertexBuffer.MatricesIndicesExtraKind
  84196. * - VertexBuffer.MatricesWeightsKind
  84197. * - VertexBuffer.MatricesWeightsExtraKind
  84198. * @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
  84199. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  84200. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  84201. */
  84202. Mesh.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  84203. if (!this._geometry) {
  84204. return null;
  84205. }
  84206. return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
  84207. };
  84208. /**
  84209. * Returns the mesh VertexBuffer object from the requested `kind`
  84210. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  84211. * - VertexBuffer.PositionKind
  84212. * - VertexBuffer.UVKind
  84213. * - VertexBuffer.UV2Kind
  84214. * - VertexBuffer.UV3Kind
  84215. * - VertexBuffer.UV4Kind
  84216. * - VertexBuffer.UV5Kind
  84217. * - VertexBuffer.UV6Kind
  84218. * - VertexBuffer.ColorKind
  84219. * - VertexBuffer.MatricesIndicesKind
  84220. * - VertexBuffer.MatricesIndicesExtraKind
  84221. * - VertexBuffer.MatricesWeightsKind
  84222. * - VertexBuffer.MatricesWeightsExtraKind
  84223. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  84224. */
  84225. Mesh.prototype.getVertexBuffer = function (kind) {
  84226. if (!this._geometry) {
  84227. return null;
  84228. }
  84229. return this._geometry.getVertexBuffer(kind);
  84230. };
  84231. /**
  84232. * Tests if a specific vertex buffer is associated with this mesh
  84233. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  84234. * - VertexBuffer.PositionKind
  84235. * - VertexBuffer.UVKind
  84236. * - VertexBuffer.UV2Kind
  84237. * - VertexBuffer.UV3Kind
  84238. * - VertexBuffer.UV4Kind
  84239. * - VertexBuffer.UV5Kind
  84240. * - VertexBuffer.UV6Kind
  84241. * - VertexBuffer.ColorKind
  84242. * - VertexBuffer.MatricesIndicesKind
  84243. * - VertexBuffer.MatricesIndicesExtraKind
  84244. * - VertexBuffer.MatricesWeightsKind
  84245. * - VertexBuffer.MatricesWeightsExtraKind
  84246. * @returns a boolean
  84247. */
  84248. Mesh.prototype.isVerticesDataPresent = function (kind) {
  84249. if (!this._geometry) {
  84250. if (this._delayInfo) {
  84251. return this._delayInfo.indexOf(kind) !== -1;
  84252. }
  84253. return false;
  84254. }
  84255. return this._geometry.isVerticesDataPresent(kind);
  84256. };
  84257. /**
  84258. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  84259. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  84260. * - VertexBuffer.PositionKind
  84261. * - VertexBuffer.UVKind
  84262. * - VertexBuffer.UV2Kind
  84263. * - VertexBuffer.UV3Kind
  84264. * - VertexBuffer.UV4Kind
  84265. * - VertexBuffer.UV5Kind
  84266. * - VertexBuffer.UV6Kind
  84267. * - VertexBuffer.ColorKind
  84268. * - VertexBuffer.MatricesIndicesKind
  84269. * - VertexBuffer.MatricesIndicesExtraKind
  84270. * - VertexBuffer.MatricesWeightsKind
  84271. * - VertexBuffer.MatricesWeightsExtraKind
  84272. * @returns a boolean
  84273. */
  84274. Mesh.prototype.isVertexBufferUpdatable = function (kind) {
  84275. if (!this._geometry) {
  84276. if (this._delayInfo) {
  84277. return this._delayInfo.indexOf(kind) !== -1;
  84278. }
  84279. return false;
  84280. }
  84281. return this._geometry.isVertexBufferUpdatable(kind);
  84282. };
  84283. /**
  84284. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  84285. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  84286. * - VertexBuffer.PositionKind
  84287. * - VertexBuffer.UVKind
  84288. * - VertexBuffer.UV2Kind
  84289. * - VertexBuffer.UV3Kind
  84290. * - VertexBuffer.UV4Kind
  84291. * - VertexBuffer.UV5Kind
  84292. * - VertexBuffer.UV6Kind
  84293. * - VertexBuffer.ColorKind
  84294. * - VertexBuffer.MatricesIndicesKind
  84295. * - VertexBuffer.MatricesIndicesExtraKind
  84296. * - VertexBuffer.MatricesWeightsKind
  84297. * - VertexBuffer.MatricesWeightsExtraKind
  84298. * @returns an array of strings
  84299. */
  84300. Mesh.prototype.getVerticesDataKinds = function () {
  84301. if (!this._geometry) {
  84302. var result = new Array();
  84303. if (this._delayInfo) {
  84304. this._delayInfo.forEach(function (kind) {
  84305. result.push(kind);
  84306. });
  84307. }
  84308. return result;
  84309. }
  84310. return this._geometry.getVerticesDataKinds();
  84311. };
  84312. /**
  84313. * Returns a positive integer : the total number of indices in this mesh geometry.
  84314. * @returns the numner of indices or zero if the mesh has no geometry.
  84315. */
  84316. Mesh.prototype.getTotalIndices = function () {
  84317. if (!this._geometry) {
  84318. return 0;
  84319. }
  84320. return this._geometry.getTotalIndices();
  84321. };
  84322. /**
  84323. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84324. * @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.
  84325. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84326. * @returns the indices array or an empty array if the mesh has no geometry
  84327. */
  84328. Mesh.prototype.getIndices = function (copyWhenShared, forceCopy) {
  84329. if (!this._geometry) {
  84330. return [];
  84331. }
  84332. return this._geometry.getIndices(copyWhenShared, forceCopy);
  84333. };
  84334. Object.defineProperty(Mesh.prototype, "isBlocked", {
  84335. get: function () {
  84336. return this._masterMesh !== null && this._masterMesh !== undefined;
  84337. },
  84338. enumerable: true,
  84339. configurable: true
  84340. });
  84341. /**
  84342. * Determine if the current mesh is ready to be rendered
  84343. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84344. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  84345. * @returns true if all associated assets are ready (material, textures, shaders)
  84346. */
  84347. Mesh.prototype.isReady = function (completeCheck, forceInstanceSupport) {
  84348. if (completeCheck === void 0) { completeCheck = false; }
  84349. if (forceInstanceSupport === void 0) { forceInstanceSupport = false; }
  84350. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  84351. return false;
  84352. }
  84353. if (!_super.prototype.isReady.call(this, completeCheck)) {
  84354. return false;
  84355. }
  84356. if (!this.subMeshes || this.subMeshes.length === 0) {
  84357. return true;
  84358. }
  84359. if (!completeCheck) {
  84360. return true;
  84361. }
  84362. var engine = this.getEngine();
  84363. var scene = this.getScene();
  84364. var hardwareInstancedRendering = forceInstanceSupport || engine.getCaps().instancedArrays && this.instances.length > 0;
  84365. this.computeWorldMatrix();
  84366. var mat = this.material || scene.defaultMaterial;
  84367. if (mat) {
  84368. if (mat._storeEffectOnSubMeshes) {
  84369. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  84370. var subMesh = _a[_i];
  84371. var effectiveMaterial = subMesh.getMaterial();
  84372. if (effectiveMaterial) {
  84373. if (effectiveMaterial._storeEffectOnSubMeshes) {
  84374. if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  84375. return false;
  84376. }
  84377. }
  84378. else {
  84379. if (!effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  84380. return false;
  84381. }
  84382. }
  84383. }
  84384. }
  84385. }
  84386. else {
  84387. if (!mat.isReady(this, hardwareInstancedRendering)) {
  84388. return false;
  84389. }
  84390. }
  84391. }
  84392. // Shadows
  84393. for (var _b = 0, _c = this._lightSources; _b < _c.length; _b++) {
  84394. var light = _c[_b];
  84395. var generator = light.getShadowGenerator();
  84396. if (generator) {
  84397. for (var _d = 0, _e = this.subMeshes; _d < _e.length; _d++) {
  84398. var subMesh = _e[_d];
  84399. if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
  84400. return false;
  84401. }
  84402. }
  84403. }
  84404. }
  84405. // LOD
  84406. for (var _f = 0, _g = this._LODLevels; _f < _g.length; _f++) {
  84407. var lod = _g[_f];
  84408. if (lod.mesh && !lod.mesh.isReady(hardwareInstancedRendering)) {
  84409. return false;
  84410. }
  84411. }
  84412. return true;
  84413. };
  84414. Object.defineProperty(Mesh.prototype, "areNormalsFrozen", {
  84415. /**
  84416. * 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.
  84417. */
  84418. get: function () {
  84419. return this._areNormalsFrozen;
  84420. },
  84421. enumerable: true,
  84422. configurable: true
  84423. });
  84424. /**
  84425. * 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.
  84426. * @returns the current mesh
  84427. */
  84428. Mesh.prototype.freezeNormals = function () {
  84429. this._areNormalsFrozen = true;
  84430. return this;
  84431. };
  84432. /**
  84433. * 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
  84434. * @returns the current mesh
  84435. */
  84436. Mesh.prototype.unfreezeNormals = function () {
  84437. this._areNormalsFrozen = false;
  84438. return this;
  84439. };
  84440. Object.defineProperty(Mesh.prototype, "overridenInstanceCount", {
  84441. /**
  84442. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  84443. */
  84444. set: function (count) {
  84445. this._instanceDataStorage.overridenInstanceCount = count;
  84446. },
  84447. enumerable: true,
  84448. configurable: true
  84449. });
  84450. // Methods
  84451. /** @hidden */
  84452. Mesh.prototype._preActivate = function () {
  84453. var sceneRenderId = this.getScene().getRenderId();
  84454. if (this._preActivateId === sceneRenderId) {
  84455. return this;
  84456. }
  84457. this._preActivateId = sceneRenderId;
  84458. this._instanceDataStorage.visibleInstances = null;
  84459. return this;
  84460. };
  84461. /** @hidden */
  84462. Mesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  84463. if (this._instanceDataStorage.visibleInstances) {
  84464. this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = renderId;
  84465. }
  84466. return this;
  84467. };
  84468. /** @hidden */
  84469. Mesh.prototype._registerInstanceForRenderId = function (instance, renderId) {
  84470. if (!this._instanceDataStorage.visibleInstances) {
  84471. this._instanceDataStorage.visibleInstances = {
  84472. defaultRenderId: renderId,
  84473. selfDefaultRenderId: this._renderId
  84474. };
  84475. }
  84476. if (!this._instanceDataStorage.visibleInstances[renderId]) {
  84477. this._instanceDataStorage.visibleInstances[renderId] = new Array();
  84478. }
  84479. this._instanceDataStorage.visibleInstances[renderId].push(instance);
  84480. return this;
  84481. };
  84482. /**
  84483. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84484. * This means the mesh underlying bounding box and sphere are recomputed.
  84485. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84486. * @returns the current mesh
  84487. */
  84488. Mesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  84489. if (applySkeleton === void 0) { applySkeleton = false; }
  84490. if (this._boundingInfo && this._boundingInfo.isLocked) {
  84491. return this;
  84492. }
  84493. var bias = this.geometry ? this.geometry.boundingBias : null;
  84494. this._refreshBoundingInfo(this._getPositionData(applySkeleton), bias);
  84495. return this;
  84496. };
  84497. /** @hidden */
  84498. Mesh.prototype._createGlobalSubMesh = function (force) {
  84499. var totalVertices = this.getTotalVertices();
  84500. if (!totalVertices || !this.getIndices()) {
  84501. return null;
  84502. }
  84503. // Check if we need to recreate the submeshes
  84504. if (this.subMeshes && this.subMeshes.length > 0) {
  84505. var ib = this.getIndices();
  84506. if (!ib) {
  84507. return null;
  84508. }
  84509. var totalIndices = ib.length;
  84510. var needToRecreate = false;
  84511. if (force) {
  84512. needToRecreate = true;
  84513. }
  84514. else {
  84515. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  84516. var submesh = _a[_i];
  84517. if (submesh.indexStart + submesh.indexCount >= totalIndices) {
  84518. needToRecreate = true;
  84519. break;
  84520. }
  84521. if (submesh.verticesStart + submesh.verticesCount >= totalVertices) {
  84522. needToRecreate = true;
  84523. break;
  84524. }
  84525. }
  84526. }
  84527. if (!needToRecreate) {
  84528. return this.subMeshes[0];
  84529. }
  84530. }
  84531. this.releaseSubMeshes();
  84532. return new _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"](0, 0, totalVertices, 0, this.getTotalIndices(), this);
  84533. };
  84534. /**
  84535. * This function will subdivide the mesh into multiple submeshes
  84536. * @param count defines the expected number of submeshes
  84537. */
  84538. Mesh.prototype.subdivide = function (count) {
  84539. if (count < 1) {
  84540. return;
  84541. }
  84542. var totalIndices = this.getTotalIndices();
  84543. var subdivisionSize = (totalIndices / count) | 0;
  84544. var offset = 0;
  84545. // Ensure that subdivisionSize is a multiple of 3
  84546. while (subdivisionSize % 3 !== 0) {
  84547. subdivisionSize++;
  84548. }
  84549. this.releaseSubMeshes();
  84550. for (var index = 0; index < count; index++) {
  84551. if (offset >= totalIndices) {
  84552. break;
  84553. }
  84554. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
  84555. offset += subdivisionSize;
  84556. }
  84557. this.synchronizeInstances();
  84558. };
  84559. /**
  84560. * Copy a FloatArray into a specific associated vertex buffer
  84561. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  84562. * - VertexBuffer.PositionKind
  84563. * - VertexBuffer.UVKind
  84564. * - VertexBuffer.UV2Kind
  84565. * - VertexBuffer.UV3Kind
  84566. * - VertexBuffer.UV4Kind
  84567. * - VertexBuffer.UV5Kind
  84568. * - VertexBuffer.UV6Kind
  84569. * - VertexBuffer.ColorKind
  84570. * - VertexBuffer.MatricesIndicesKind
  84571. * - VertexBuffer.MatricesIndicesExtraKind
  84572. * - VertexBuffer.MatricesWeightsKind
  84573. * - VertexBuffer.MatricesWeightsExtraKind
  84574. * @param data defines the data source
  84575. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  84576. * @param stride defines the data stride size (can be null)
  84577. * @returns the current mesh
  84578. */
  84579. Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  84580. if (updatable === void 0) { updatable = false; }
  84581. if (!this._geometry) {
  84582. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  84583. vertexData.set(data, kind);
  84584. var scene = this.getScene();
  84585. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  84586. }
  84587. else {
  84588. this._geometry.setVerticesData(kind, data, updatable, stride);
  84589. }
  84590. return this;
  84591. };
  84592. /**
  84593. * Flags an associated vertex buffer as updatable
  84594. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  84595. * - VertexBuffer.PositionKind
  84596. * - VertexBuffer.UVKind
  84597. * - VertexBuffer.UV2Kind
  84598. * - VertexBuffer.UV3Kind
  84599. * - VertexBuffer.UV4Kind
  84600. * - VertexBuffer.UV5Kind
  84601. * - VertexBuffer.UV6Kind
  84602. * - VertexBuffer.ColorKind
  84603. * - VertexBuffer.MatricesIndicesKind
  84604. * - VertexBuffer.MatricesIndicesExtraKind
  84605. * - VertexBuffer.MatricesWeightsKind
  84606. * - VertexBuffer.MatricesWeightsExtraKind
  84607. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  84608. */
  84609. Mesh.prototype.markVerticesDataAsUpdatable = function (kind, updatable) {
  84610. if (updatable === void 0) { updatable = true; }
  84611. var vb = this.getVertexBuffer(kind);
  84612. if (!vb || vb.isUpdatable() === updatable) {
  84613. return;
  84614. }
  84615. this.setVerticesData(kind, this.getVerticesData(kind), updatable);
  84616. };
  84617. /**
  84618. * Sets the mesh global Vertex Buffer
  84619. * @param buffer defines the buffer to use
  84620. * @returns the current mesh
  84621. */
  84622. Mesh.prototype.setVerticesBuffer = function (buffer) {
  84623. if (!this._geometry) {
  84624. this._geometry = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].CreateGeometryForMesh(this);
  84625. }
  84626. this._geometry.setVerticesBuffer(buffer);
  84627. return this;
  84628. };
  84629. /**
  84630. * Update a specific associated vertex buffer
  84631. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  84632. * - VertexBuffer.PositionKind
  84633. * - VertexBuffer.UVKind
  84634. * - VertexBuffer.UV2Kind
  84635. * - VertexBuffer.UV3Kind
  84636. * - VertexBuffer.UV4Kind
  84637. * - VertexBuffer.UV5Kind
  84638. * - VertexBuffer.UV6Kind
  84639. * - VertexBuffer.ColorKind
  84640. * - VertexBuffer.MatricesIndicesKind
  84641. * - VertexBuffer.MatricesIndicesExtraKind
  84642. * - VertexBuffer.MatricesWeightsKind
  84643. * - VertexBuffer.MatricesWeightsExtraKind
  84644. * @param data defines the data source
  84645. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  84646. * @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)
  84647. * @returns the current mesh
  84648. */
  84649. Mesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  84650. if (!this._geometry) {
  84651. return this;
  84652. }
  84653. if (!makeItUnique) {
  84654. this._geometry.updateVerticesData(kind, data, updateExtends);
  84655. }
  84656. else {
  84657. this.makeGeometryUnique();
  84658. this.updateVerticesData(kind, data, updateExtends, false);
  84659. }
  84660. return this;
  84661. };
  84662. /**
  84663. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  84664. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  84665. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  84666. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  84667. * @returns the current mesh
  84668. */
  84669. Mesh.prototype.updateMeshPositions = function (positionFunction, computeNormals) {
  84670. if (computeNormals === void 0) { computeNormals = true; }
  84671. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  84672. if (!positions) {
  84673. return this;
  84674. }
  84675. positionFunction(positions);
  84676. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions, false, false);
  84677. if (computeNormals) {
  84678. var indices = this.getIndices();
  84679. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  84680. if (!normals) {
  84681. return this;
  84682. }
  84683. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  84684. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, false, false);
  84685. }
  84686. return this;
  84687. };
  84688. /**
  84689. * Creates a un-shared specific occurence of the geometry for the mesh.
  84690. * @returns the current mesh
  84691. */
  84692. Mesh.prototype.makeGeometryUnique = function () {
  84693. if (!this._geometry) {
  84694. return this;
  84695. }
  84696. var oldGeometry = this._geometry;
  84697. var geometry = this._geometry.copy(_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId());
  84698. oldGeometry.releaseForMesh(this, true);
  84699. geometry.applyToMesh(this);
  84700. return this;
  84701. };
  84702. /**
  84703. * Set the index buffer of this mesh
  84704. * @param indices defines the source data
  84705. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  84706. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  84707. * @returns the current mesh
  84708. */
  84709. Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
  84710. if (totalVertices === void 0) { totalVertices = null; }
  84711. if (updatable === void 0) { updatable = false; }
  84712. if (!this._geometry) {
  84713. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  84714. vertexData.indices = indices;
  84715. var scene = this.getScene();
  84716. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  84717. }
  84718. else {
  84719. this._geometry.setIndices(indices, totalVertices, updatable);
  84720. }
  84721. return this;
  84722. };
  84723. /**
  84724. * Update the current index buffer
  84725. * @param indices defines the source data
  84726. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  84727. * @returns the current mesh
  84728. */
  84729. Mesh.prototype.updateIndices = function (indices, offset) {
  84730. if (!this._geometry) {
  84731. return this;
  84732. }
  84733. this._geometry.updateIndices(indices, offset);
  84734. return this;
  84735. };
  84736. /**
  84737. * Invert the geometry to move from a right handed system to a left handed one.
  84738. * @returns the current mesh
  84739. */
  84740. Mesh.prototype.toLeftHanded = function () {
  84741. if (!this._geometry) {
  84742. return this;
  84743. }
  84744. this._geometry.toLeftHanded();
  84745. return this;
  84746. };
  84747. /** @hidden */
  84748. Mesh.prototype._bind = function (subMesh, effect, fillMode) {
  84749. if (!this._geometry) {
  84750. return this;
  84751. }
  84752. var engine = this.getScene().getEngine();
  84753. // Wireframe
  84754. var indexToBind;
  84755. if (this._unIndexed) {
  84756. indexToBind = null;
  84757. }
  84758. else {
  84759. switch (fillMode) {
  84760. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode:
  84761. indexToBind = null;
  84762. break;
  84763. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode:
  84764. indexToBind = subMesh._getLinesIndexBuffer(this.getIndices(), engine);
  84765. break;
  84766. default:
  84767. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].TriangleFillMode:
  84768. indexToBind = this._unIndexed ? null : this._geometry.getIndexBuffer();
  84769. break;
  84770. }
  84771. }
  84772. // VBOs
  84773. this._geometry._bind(effect, indexToBind);
  84774. return this;
  84775. };
  84776. /** @hidden */
  84777. Mesh.prototype._draw = function (subMesh, fillMode, instancesCount, alternate) {
  84778. if (alternate === void 0) { alternate = false; }
  84779. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  84780. return this;
  84781. }
  84782. if (this._onBeforeDrawObservable) {
  84783. this._onBeforeDrawObservable.notifyObservers(this);
  84784. }
  84785. var scene = this.getScene();
  84786. var engine = scene.getEngine();
  84787. if (this._unIndexed || fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode) {
  84788. // or triangles as points
  84789. engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  84790. }
  84791. else if (fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode) {
  84792. // Triangles as wireframe
  84793. engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
  84794. }
  84795. else {
  84796. engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  84797. }
  84798. if (scene._isAlternateRenderingEnabled && !alternate) {
  84799. var effect = subMesh.effect || this._effectiveMaterial.getEffect();
  84800. if (!effect || !scene.activeCamera) {
  84801. return this;
  84802. }
  84803. scene._switchToAlternateCameraConfiguration(true);
  84804. this._effectiveMaterial.bindView(effect);
  84805. this._effectiveMaterial.bindViewProjection(effect);
  84806. engine.setViewport(scene.activeCamera._alternateCamera.viewport);
  84807. this._draw(subMesh, fillMode, instancesCount, true);
  84808. engine.setViewport(scene.activeCamera.viewport);
  84809. scene._switchToAlternateCameraConfiguration(false);
  84810. this._effectiveMaterial.bindView(effect);
  84811. this._effectiveMaterial.bindViewProjection(effect);
  84812. }
  84813. return this;
  84814. };
  84815. /**
  84816. * Registers for this mesh a javascript function called just before the rendering process
  84817. * @param func defines the function to call before rendering this mesh
  84818. * @returns the current mesh
  84819. */
  84820. Mesh.prototype.registerBeforeRender = function (func) {
  84821. this.onBeforeRenderObservable.add(func);
  84822. return this;
  84823. };
  84824. /**
  84825. * Disposes a previously registered javascript function called before the rendering
  84826. * @param func defines the function to remove
  84827. * @returns the current mesh
  84828. */
  84829. Mesh.prototype.unregisterBeforeRender = function (func) {
  84830. this.onBeforeRenderObservable.removeCallback(func);
  84831. return this;
  84832. };
  84833. /**
  84834. * Registers for this mesh a javascript function called just after the rendering is complete
  84835. * @param func defines the function to call after rendering this mesh
  84836. * @returns the current mesh
  84837. */
  84838. Mesh.prototype.registerAfterRender = function (func) {
  84839. this.onAfterRenderObservable.add(func);
  84840. return this;
  84841. };
  84842. /**
  84843. * Disposes a previously registered javascript function called after the rendering.
  84844. * @param func defines the function to remove
  84845. * @returns the current mesh
  84846. */
  84847. Mesh.prototype.unregisterAfterRender = function (func) {
  84848. this.onAfterRenderObservable.removeCallback(func);
  84849. return this;
  84850. };
  84851. /** @hidden */
  84852. Mesh.prototype._getInstancesRenderList = function (subMeshId) {
  84853. var scene = this.getScene();
  84854. var batchCache = this._instanceDataStorage.batchCache;
  84855. batchCache.mustReturn = false;
  84856. batchCache.renderSelf[subMeshId] = this.isEnabled() && this.isVisible;
  84857. batchCache.visibleInstances[subMeshId] = null;
  84858. if (this._instanceDataStorage.visibleInstances) {
  84859. var visibleInstances = this._instanceDataStorage.visibleInstances;
  84860. var currentRenderId = scene.getRenderId();
  84861. var defaultRenderId = (scene._isInIntermediateRendering() ? visibleInstances.intermediateDefaultRenderId : visibleInstances.defaultRenderId);
  84862. batchCache.visibleInstances[subMeshId] = visibleInstances[currentRenderId];
  84863. var selfRenderId = this._renderId;
  84864. if (!batchCache.visibleInstances[subMeshId] && defaultRenderId) {
  84865. batchCache.visibleInstances[subMeshId] = visibleInstances[defaultRenderId];
  84866. currentRenderId = Math.max(defaultRenderId, currentRenderId);
  84867. selfRenderId = Math.max(visibleInstances.selfDefaultRenderId, currentRenderId);
  84868. }
  84869. var visibleInstancesForSubMesh = batchCache.visibleInstances[subMeshId];
  84870. if (visibleInstancesForSubMesh && visibleInstancesForSubMesh.length) {
  84871. if (this._instanceDataStorage.renderIdForInstances[subMeshId] === currentRenderId) {
  84872. batchCache.mustReturn = true;
  84873. return batchCache;
  84874. }
  84875. if (currentRenderId !== selfRenderId) {
  84876. batchCache.renderSelf[subMeshId] = false;
  84877. }
  84878. }
  84879. this._instanceDataStorage.renderIdForInstances[subMeshId] = currentRenderId;
  84880. }
  84881. return batchCache;
  84882. };
  84883. /** @hidden */
  84884. Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
  84885. var visibleInstances = batch.visibleInstances[subMesh._id];
  84886. if (!visibleInstances) {
  84887. return this;
  84888. }
  84889. var matricesCount = visibleInstances.length + 1;
  84890. var bufferSize = matricesCount * 16 * 4;
  84891. var instanceStorage = this._instanceDataStorage;
  84892. var currentInstancesBufferSize = instanceStorage.instancesBufferSize;
  84893. var instancesBuffer = instanceStorage.instancesBuffer;
  84894. while (instanceStorage.instancesBufferSize < bufferSize) {
  84895. instanceStorage.instancesBufferSize *= 2;
  84896. }
  84897. if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  84898. instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
  84899. }
  84900. var offset = 0;
  84901. var instancesCount = 0;
  84902. var world = this.getWorldMatrix();
  84903. if (batch.renderSelf[subMesh._id]) {
  84904. world.copyToArray(instanceStorage.instancesData, offset);
  84905. offset += 16;
  84906. instancesCount++;
  84907. }
  84908. if (visibleInstances) {
  84909. for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
  84910. var instance = visibleInstances[instanceIndex];
  84911. instance.getWorldMatrix().copyToArray(instanceStorage.instancesData, offset);
  84912. offset += 16;
  84913. instancesCount++;
  84914. }
  84915. }
  84916. if (!instancesBuffer || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  84917. if (instancesBuffer) {
  84918. instancesBuffer.dispose();
  84919. }
  84920. instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_7__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
  84921. instanceStorage.instancesBuffer = instancesBuffer;
  84922. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
  84923. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
  84924. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
  84925. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
  84926. }
  84927. else {
  84928. instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
  84929. }
  84930. this._bind(subMesh, effect, fillMode);
  84931. this._draw(subMesh, fillMode, instancesCount);
  84932. engine.unbindInstanceAttributes();
  84933. return this;
  84934. };
  84935. /** @hidden */
  84936. Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
  84937. var scene = this.getScene();
  84938. var engine = scene.getEngine();
  84939. if (hardwareInstancedRendering) {
  84940. this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
  84941. }
  84942. else {
  84943. if (batch.renderSelf[subMesh._id]) {
  84944. // Draw
  84945. if (onBeforeDraw) {
  84946. onBeforeDraw(false, this.getWorldMatrix(), effectiveMaterial);
  84947. }
  84948. this._draw(subMesh, fillMode, this._instanceDataStorage.overridenInstanceCount);
  84949. }
  84950. var visibleInstancesForSubMesh = batch.visibleInstances[subMesh._id];
  84951. if (visibleInstancesForSubMesh) {
  84952. for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
  84953. var instance = visibleInstancesForSubMesh[instanceIndex];
  84954. // World
  84955. var world = instance.getWorldMatrix();
  84956. if (onBeforeDraw) {
  84957. onBeforeDraw(true, world, effectiveMaterial);
  84958. }
  84959. // Draw
  84960. this._draw(subMesh, fillMode);
  84961. }
  84962. }
  84963. }
  84964. return this;
  84965. };
  84966. /**
  84967. * 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
  84968. * @param subMesh defines the subMesh to render
  84969. * @param enableAlphaMode defines if alpha mode can be changed
  84970. * @returns the current mesh
  84971. */
  84972. Mesh.prototype.render = function (subMesh, enableAlphaMode) {
  84973. if (this._checkOcclusionQuery()) {
  84974. return this;
  84975. }
  84976. var scene = this.getScene();
  84977. // Managing instances
  84978. var batch = this._getInstancesRenderList(subMesh._id);
  84979. if (batch.mustReturn) {
  84980. return this;
  84981. }
  84982. // Checking geometry state
  84983. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  84984. return this;
  84985. }
  84986. if (this._onBeforeRenderObservable) {
  84987. this._onBeforeRenderObservable.notifyObservers(this);
  84988. }
  84989. var engine = scene.getEngine();
  84990. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  84991. // Material
  84992. var material = subMesh.getMaterial();
  84993. if (!material) {
  84994. return this;
  84995. }
  84996. this._effectiveMaterial = material;
  84997. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  84998. if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  84999. return this;
  85000. }
  85001. }
  85002. else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  85003. return this;
  85004. }
  85005. // Alpha mode
  85006. if (enableAlphaMode) {
  85007. engine.setAlphaMode(this._effectiveMaterial.alphaMode);
  85008. }
  85009. for (var _i = 0, _a = scene._beforeRenderingMeshStage; _i < _a.length; _i++) {
  85010. var step = _a[_i];
  85011. step.action(this, subMesh, batch);
  85012. }
  85013. var effect;
  85014. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  85015. effect = subMesh.effect;
  85016. }
  85017. else {
  85018. effect = this._effectiveMaterial.getEffect();
  85019. }
  85020. if (!effect) {
  85021. return this;
  85022. }
  85023. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  85024. var sideOrientation = this.overrideMaterialSideOrientation;
  85025. if (sideOrientation == null) {
  85026. sideOrientation = this._effectiveMaterial.sideOrientation;
  85027. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  85028. 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);
  85029. }
  85030. }
  85031. var reverse = this._effectiveMaterial._preBind(effect, sideOrientation);
  85032. if (this._effectiveMaterial.forceDepthWrite) {
  85033. engine.setDepthWrite(true);
  85034. }
  85035. // Bind
  85036. 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);
  85037. if (this._onBeforeBindObservable) {
  85038. this._onBeforeBindObservable.notifyObservers(this);
  85039. }
  85040. if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
  85041. this._bind(subMesh, effect, fillMode);
  85042. }
  85043. var world = effectiveMesh.getWorldMatrix();
  85044. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  85045. this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
  85046. }
  85047. else {
  85048. this._effectiveMaterial.bind(world, this);
  85049. }
  85050. if (!this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass) {
  85051. engine.setState(true, this._effectiveMaterial.zOffset, false, !reverse);
  85052. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  85053. engine.setState(true, this._effectiveMaterial.zOffset, false, reverse);
  85054. }
  85055. // Draw
  85056. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  85057. // Unbind
  85058. this._effectiveMaterial.unbind();
  85059. for (var _b = 0, _c = scene._afterRenderingMeshStage; _b < _c.length; _b++) {
  85060. var step = _c[_b];
  85061. step.action(this, subMesh, batch);
  85062. }
  85063. if (this._onAfterRenderObservable) {
  85064. this._onAfterRenderObservable.notifyObservers(this);
  85065. }
  85066. return this;
  85067. };
  85068. Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
  85069. if (isInstance && effectiveMaterial) {
  85070. effectiveMaterial.bindOnlyWorldMatrix(world);
  85071. }
  85072. };
  85073. /**
  85074. * Renormalize the mesh and patch it up if there are no weights
  85075. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  85076. * However in the case of zero weights then we set just a single influence to 1.
  85077. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  85078. */
  85079. Mesh.prototype.cleanMatrixWeights = function () {
  85080. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  85081. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind)) {
  85082. this.normalizeSkinWeightsAndExtra();
  85083. }
  85084. else {
  85085. this.normalizeSkinFourWeights();
  85086. }
  85087. }
  85088. };
  85089. // faster 4 weight version.
  85090. Mesh.prototype.normalizeSkinFourWeights = function () {
  85091. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  85092. var numWeights = matricesWeights.length;
  85093. for (var a = 0; a < numWeights; a += 4) {
  85094. // accumulate weights
  85095. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  85096. // check for invalid weight and just set it to 1.
  85097. if (t === 0) {
  85098. matricesWeights[a] = 1;
  85099. }
  85100. else {
  85101. // renormalize so everything adds to 1 use reciprical
  85102. var recip = 1 / t;
  85103. matricesWeights[a] *= recip;
  85104. matricesWeights[a + 1] *= recip;
  85105. matricesWeights[a + 2] *= recip;
  85106. matricesWeights[a + 3] *= recip;
  85107. }
  85108. }
  85109. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  85110. };
  85111. // handle special case of extra verts. (in theory gltf can handle 12 influences)
  85112. Mesh.prototype.normalizeSkinWeightsAndExtra = function () {
  85113. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  85114. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  85115. var numWeights = matricesWeights.length;
  85116. for (var a = 0; a < numWeights; a += 4) {
  85117. // accumulate weights
  85118. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  85119. t += matricesWeightsExtra[a] + matricesWeightsExtra[a + 1] + matricesWeightsExtra[a + 2] + matricesWeightsExtra[a + 3];
  85120. // check for invalid weight and just set it to 1.
  85121. if (t === 0) {
  85122. matricesWeights[a] = 1;
  85123. }
  85124. else {
  85125. // renormalize so everything adds to 1 use reciprical
  85126. var recip = 1 / t;
  85127. matricesWeights[a] *= recip;
  85128. matricesWeights[a + 1] *= recip;
  85129. matricesWeights[a + 2] *= recip;
  85130. matricesWeights[a + 3] *= recip;
  85131. // same goes for extras
  85132. matricesWeightsExtra[a] *= recip;
  85133. matricesWeightsExtra[a + 1] *= recip;
  85134. matricesWeightsExtra[a + 2] *= recip;
  85135. matricesWeightsExtra[a + 3] *= recip;
  85136. }
  85137. }
  85138. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  85139. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeightsExtra);
  85140. };
  85141. /**
  85142. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  85143. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  85144. * the user know there was an issue with importing the mesh
  85145. * @returns a validation object with skinned, valid and report string
  85146. */
  85147. Mesh.prototype.validateSkinning = function () {
  85148. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  85149. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  85150. if (matricesWeights === null || this.skeleton == null) {
  85151. return { skinned: false, valid: true, report: "not skinned" };
  85152. }
  85153. var numWeights = matricesWeights.length;
  85154. var numberNotSorted = 0;
  85155. var missingWeights = 0;
  85156. var maxUsedWeights = 0;
  85157. var numberNotNormalized = 0;
  85158. var numInfluences = matricesWeightsExtra === null ? 4 : 8;
  85159. var usedWeightCounts = new Array();
  85160. for (var a = 0; a <= numInfluences; a++) {
  85161. usedWeightCounts[a] = 0;
  85162. }
  85163. var toleranceEpsilon = 0.001;
  85164. for (var a = 0; a < numWeights; a += 4) {
  85165. var lastWeight = matricesWeights[a];
  85166. var t = lastWeight;
  85167. var usedWeights = t === 0 ? 0 : 1;
  85168. for (var b = 1; b < numInfluences; b++) {
  85169. var d = b < 4 ? matricesWeights[a + b] : matricesWeightsExtra[a + b - 4];
  85170. if (d > lastWeight) {
  85171. numberNotSorted++;
  85172. }
  85173. if (d !== 0) {
  85174. usedWeights++;
  85175. }
  85176. t += d;
  85177. lastWeight = d;
  85178. }
  85179. // count the buffer weights usage
  85180. usedWeightCounts[usedWeights]++;
  85181. // max influences
  85182. if (usedWeights > maxUsedWeights) {
  85183. maxUsedWeights = usedWeights;
  85184. }
  85185. // check for invalid weight and just set it to 1.
  85186. if (t === 0) {
  85187. missingWeights++;
  85188. }
  85189. else {
  85190. // renormalize so everything adds to 1 use reciprical
  85191. var recip = 1 / t;
  85192. var tolerance = 0;
  85193. for (b = 0; b < numInfluences; b++) {
  85194. if (b < 4) {
  85195. tolerance += Math.abs(matricesWeights[a + b] - (matricesWeights[a + b] * recip));
  85196. }
  85197. else {
  85198. tolerance += Math.abs(matricesWeightsExtra[a + b - 4] - (matricesWeightsExtra[a + b - 4] * recip));
  85199. }
  85200. }
  85201. // arbitary epsilon value for dicdating not normalized
  85202. if (tolerance > toleranceEpsilon) {
  85203. numberNotNormalized++;
  85204. }
  85205. }
  85206. }
  85207. // validate bone indices are in range of the skeleton
  85208. var numBones = this.skeleton.bones.length;
  85209. var matricesIndices = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  85210. var matricesIndicesExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind);
  85211. var numBadBoneIndices = 0;
  85212. for (var a = 0; a < numWeights; a++) {
  85213. for (var b = 0; b < numInfluences; b++) {
  85214. var index = b < 4 ? matricesIndices[b] : matricesIndicesExtra[b - 4];
  85215. if (index >= numBones || index < 0) {
  85216. numBadBoneIndices++;
  85217. }
  85218. }
  85219. }
  85220. // log mesh stats
  85221. var output = "Number of Weights = " + numWeights / 4 + "\nMaximum influences = " + maxUsedWeights +
  85222. "\nMissing Weights = " + missingWeights + "\nNot Sorted = " + numberNotSorted +
  85223. "\nNot Normalized = " + numberNotNormalized + "\nWeightCounts = [" + usedWeightCounts + "]" +
  85224. "\nNumber of bones = " + numBones + "\nBad Bone Indices = " + numBadBoneIndices;
  85225. return { skinned: true, valid: missingWeights === 0 && numberNotNormalized === 0 && numBadBoneIndices === 0, report: output };
  85226. };
  85227. /** @hidden */
  85228. Mesh.prototype._checkDelayState = function () {
  85229. var scene = this.getScene();
  85230. if (this._geometry) {
  85231. this._geometry.load(scene);
  85232. }
  85233. else if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  85234. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING;
  85235. this._queueLoad(scene);
  85236. }
  85237. return this;
  85238. };
  85239. Mesh.prototype._queueLoad = function (scene) {
  85240. var _this = this;
  85241. scene._addPendingData(this);
  85242. var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
  85243. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadFile(this.delayLoadingFile, function (data) {
  85244. if (data instanceof ArrayBuffer) {
  85245. _this._delayLoadingFunction(data, _this);
  85246. }
  85247. else {
  85248. _this._delayLoadingFunction(JSON.parse(data), _this);
  85249. }
  85250. _this.instances.forEach(function (instance) {
  85251. instance._syncSubMeshes();
  85252. });
  85253. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADED;
  85254. scene._removePendingData(_this);
  85255. }, function () { }, scene.offlineProvider, getBinaryData);
  85256. return this;
  85257. };
  85258. /**
  85259. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  85260. * A mesh is in the frustum if its bounding box intersects the frustum
  85261. * @param frustumPlanes defines the frustum to test
  85262. * @returns true if the mesh is in the frustum planes
  85263. */
  85264. Mesh.prototype.isInFrustum = function (frustumPlanes) {
  85265. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  85266. return false;
  85267. }
  85268. if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
  85269. return false;
  85270. }
  85271. this._checkDelayState();
  85272. return true;
  85273. };
  85274. /**
  85275. * Sets the mesh material by the material or multiMaterial `id` property
  85276. * @param id is a string identifying the material or the multiMaterial
  85277. * @returns the current mesh
  85278. */
  85279. Mesh.prototype.setMaterialByID = function (id) {
  85280. var materials = this.getScene().materials;
  85281. var index;
  85282. for (index = materials.length - 1; index > -1; index--) {
  85283. if (materials[index].id === id) {
  85284. this.material = materials[index];
  85285. return this;
  85286. }
  85287. }
  85288. // Multi
  85289. var multiMaterials = this.getScene().multiMaterials;
  85290. for (index = multiMaterials.length - 1; index > -1; index--) {
  85291. if (multiMaterials[index].id === id) {
  85292. this.material = multiMaterials[index];
  85293. return this;
  85294. }
  85295. }
  85296. return this;
  85297. };
  85298. /**
  85299. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  85300. * @returns an array of IAnimatable
  85301. */
  85302. Mesh.prototype.getAnimatables = function () {
  85303. var results = new Array();
  85304. if (this.material) {
  85305. results.push(this.material);
  85306. }
  85307. if (this.skeleton) {
  85308. results.push(this.skeleton);
  85309. }
  85310. return results;
  85311. };
  85312. /**
  85313. * Modifies the mesh geometry according to the passed transformation matrix.
  85314. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  85315. * The mesh normals are modified using the same transformation.
  85316. * Note that, under the hood, this method sets a new VertexBuffer each call.
  85317. * @param transform defines the transform matrix to use
  85318. * @see http://doc.babylonjs.com/resources/baking_transformations
  85319. * @returns the current mesh
  85320. */
  85321. Mesh.prototype.bakeTransformIntoVertices = function (transform) {
  85322. // Position
  85323. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  85324. return this;
  85325. }
  85326. var submeshes = this.subMeshes.splice(0);
  85327. this._resetPointsArrayCache();
  85328. var data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  85329. var temp = new Array();
  85330. var index;
  85331. for (index = 0; index < data.length; index += 3) {
  85332. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).toArray(temp, index);
  85333. }
  85334. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind).isUpdatable());
  85335. // Normals
  85336. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  85337. data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  85338. temp = [];
  85339. for (index = 0; index < data.length; index += 3) {
  85340. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).normalize().toArray(temp, index);
  85341. }
  85342. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind).isUpdatable());
  85343. }
  85344. // flip faces?
  85345. if (transform.m[0] * transform.m[5] * transform.m[10] < 0) {
  85346. this.flipFaces();
  85347. }
  85348. // Restore submeshes
  85349. this.releaseSubMeshes();
  85350. this.subMeshes = submeshes;
  85351. return this;
  85352. };
  85353. /**
  85354. * Modifies the mesh geometry according to its own current World Matrix.
  85355. * The mesh World Matrix is then reset.
  85356. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  85357. * Note that, under the hood, this method sets a new VertexBuffer each call.
  85358. * @see http://doc.babylonjs.com/resources/baking_transformations
  85359. * @returns the current mesh
  85360. */
  85361. Mesh.prototype.bakeCurrentTransformIntoVertices = function () {
  85362. this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
  85363. this.scaling.copyFromFloats(1, 1, 1);
  85364. this.position.copyFromFloats(0, 0, 0);
  85365. this.rotation.copyFromFloats(0, 0, 0);
  85366. //only if quaternion is already set
  85367. if (this.rotationQuaternion) {
  85368. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].Identity();
  85369. }
  85370. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  85371. return this;
  85372. };
  85373. Object.defineProperty(Mesh.prototype, "_positions", {
  85374. // Cache
  85375. /** @hidden */
  85376. get: function () {
  85377. if (this._geometry) {
  85378. return this._geometry._positions;
  85379. }
  85380. return null;
  85381. },
  85382. enumerable: true,
  85383. configurable: true
  85384. });
  85385. /** @hidden */
  85386. Mesh.prototype._resetPointsArrayCache = function () {
  85387. if (this._geometry) {
  85388. this._geometry._resetPointsArrayCache();
  85389. }
  85390. return this;
  85391. };
  85392. /** @hidden */
  85393. Mesh.prototype._generatePointsArray = function () {
  85394. if (this._geometry) {
  85395. return this._geometry._generatePointsArray();
  85396. }
  85397. return false;
  85398. };
  85399. /**
  85400. * Returns a new Mesh object generated from the current mesh properties.
  85401. * This method must not get confused with createInstance()
  85402. * @param name is a string, the name given to the new mesh
  85403. * @param newParent can be any Node object (default `null`)
  85404. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  85405. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  85406. * @returns a new mesh
  85407. */
  85408. Mesh.prototype.clone = function (name, newParent, doNotCloneChildren, clonePhysicsImpostor) {
  85409. if (name === void 0) { name = ""; }
  85410. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  85411. return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
  85412. };
  85413. /**
  85414. * Releases resources associated with this mesh.
  85415. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85416. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85417. */
  85418. Mesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  85419. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  85420. this.morphTargetManager = null;
  85421. if (this._geometry) {
  85422. this._geometry.releaseForMesh(this, true);
  85423. }
  85424. if (this._onBeforeDrawObservable) {
  85425. this._onBeforeDrawObservable.clear();
  85426. }
  85427. if (this._onBeforeBindObservable) {
  85428. this._onBeforeBindObservable.clear();
  85429. }
  85430. if (this._onBeforeRenderObservable) {
  85431. this._onBeforeRenderObservable.clear();
  85432. }
  85433. if (this._onAfterRenderObservable) {
  85434. this._onAfterRenderObservable.clear();
  85435. }
  85436. // Sources
  85437. if (this._scene.useClonedMeshhMap) {
  85438. if (this.meshMap) {
  85439. for (var uniqueId in this.meshMap) {
  85440. var mesh = this.meshMap[uniqueId];
  85441. if (mesh) {
  85442. mesh._source = null;
  85443. this.meshMap[uniqueId] = undefined;
  85444. }
  85445. }
  85446. }
  85447. if (this._source && this._source.meshMap) {
  85448. this._source.meshMap[this.uniqueId] = undefined;
  85449. }
  85450. }
  85451. else {
  85452. var meshes = this.getScene().meshes;
  85453. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  85454. var abstractMesh = meshes_1[_i];
  85455. var mesh = abstractMesh;
  85456. if (mesh._source && mesh._source === this) {
  85457. mesh._source = null;
  85458. }
  85459. }
  85460. }
  85461. this._source = null;
  85462. // Instances
  85463. if (this._instanceDataStorage.instancesBuffer) {
  85464. this._instanceDataStorage.instancesBuffer.dispose();
  85465. this._instanceDataStorage.instancesBuffer = null;
  85466. }
  85467. while (this.instances.length) {
  85468. this.instances[0].dispose();
  85469. }
  85470. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  85471. };
  85472. /**
  85473. * Modifies the mesh geometry according to a displacement map.
  85474. * 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.
  85475. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  85476. * @param url is a string, the URL from the image file is to be downloaded.
  85477. * @param minHeight is the lower limit of the displacement.
  85478. * @param maxHeight is the upper limit of the displacement.
  85479. * @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.
  85480. * @param uvOffset is an optional vector2 used to offset UV.
  85481. * @param uvScale is an optional vector2 used to scale UV.
  85482. * @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.
  85483. * @returns the Mesh.
  85484. */
  85485. Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess, uvOffset, uvScale, forceUpdate) {
  85486. var _this = this;
  85487. if (forceUpdate === void 0) { forceUpdate = false; }
  85488. var scene = this.getScene();
  85489. var onload = function (img) {
  85490. // Getting height map data
  85491. var canvas = document.createElement("canvas");
  85492. var context = canvas.getContext("2d");
  85493. var heightMapWidth = img.width;
  85494. var heightMapHeight = img.height;
  85495. canvas.width = heightMapWidth;
  85496. canvas.height = heightMapHeight;
  85497. context.drawImage(img, 0, 0);
  85498. // Create VertexData from map data
  85499. //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  85500. var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
  85501. _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate);
  85502. //execute success callback, if set
  85503. if (onSuccess) {
  85504. onSuccess(_this);
  85505. }
  85506. };
  85507. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  85508. return this;
  85509. };
  85510. /**
  85511. * Modifies the mesh geometry according to a displacementMap buffer.
  85512. * 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.
  85513. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  85514. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  85515. * @param heightMapWidth is the width of the buffer image.
  85516. * @param heightMapHeight is the height of the buffer image.
  85517. * @param minHeight is the lower limit of the displacement.
  85518. * @param maxHeight is the upper limit of the displacement.
  85519. * @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.
  85520. * @param uvOffset is an optional vector2 used to offset UV.
  85521. * @param uvScale is an optional vector2 used to scale UV.
  85522. * @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.
  85523. * @returns the Mesh.
  85524. */
  85525. Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate) {
  85526. if (forceUpdate === void 0) { forceUpdate = false; }
  85527. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)
  85528. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)
  85529. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  85530. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
  85531. return this;
  85532. }
  85533. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, true, true);
  85534. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  85535. var uvs = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  85536. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  85537. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  85538. var uv = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  85539. uvOffset = uvOffset || _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  85540. uvScale = uvScale || new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1, 1);
  85541. for (var index = 0; index < positions.length; index += 3) {
  85542. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(positions, index, position);
  85543. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(normals, index, normal);
  85544. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].FromArrayToRef(uvs, (index / 3) * 2, uv);
  85545. // Compute height
  85546. var u = ((Math.abs(uv.x * uvScale.x + uvOffset.x) * heightMapWidth) % heightMapWidth) | 0;
  85547. var v = ((Math.abs(uv.y * uvScale.y + uvOffset.y) * heightMapHeight) % heightMapHeight) | 0;
  85548. var pos = (u + v * heightMapWidth) * 4;
  85549. var r = buffer[pos] / 255.0;
  85550. var g = buffer[pos + 1] / 255.0;
  85551. var b = buffer[pos + 2] / 255.0;
  85552. var gradient = r * 0.3 + g * 0.59 + b * 0.11;
  85553. normal.normalize();
  85554. normal.scaleInPlace(minHeight + (maxHeight - minHeight) * gradient);
  85555. position = position.add(normal);
  85556. position.toArray(positions, index);
  85557. }
  85558. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, this.getIndices(), normals);
  85559. if (forceUpdate) {
  85560. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  85561. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  85562. }
  85563. else {
  85564. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  85565. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  85566. }
  85567. return this;
  85568. };
  85569. /**
  85570. * Modify the mesh to get a flat shading rendering.
  85571. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  85572. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  85573. * @returns current mesh
  85574. */
  85575. Mesh.prototype.convertToFlatShadedMesh = function () {
  85576. var kinds = this.getVerticesDataKinds();
  85577. var vbs = {};
  85578. var data = {};
  85579. var newdata = {};
  85580. var updatableNormals = false;
  85581. var kindIndex;
  85582. var kind;
  85583. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85584. kind = kinds[kindIndex];
  85585. var vertexBuffer = this.getVertexBuffer(kind);
  85586. if (kind === _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) {
  85587. updatableNormals = vertexBuffer.isUpdatable();
  85588. kinds.splice(kindIndex, 1);
  85589. kindIndex--;
  85590. continue;
  85591. }
  85592. vbs[kind] = vertexBuffer;
  85593. data[kind] = vbs[kind].getData();
  85594. newdata[kind] = [];
  85595. }
  85596. // Save previous submeshes
  85597. var previousSubmeshes = this.subMeshes.slice(0);
  85598. var indices = this.getIndices();
  85599. var totalIndices = this.getTotalIndices();
  85600. // Generating unique vertices per face
  85601. var index;
  85602. for (index = 0; index < totalIndices; index++) {
  85603. var vertexIndex = indices[index];
  85604. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85605. kind = kinds[kindIndex];
  85606. var stride = vbs[kind].getStrideSize();
  85607. for (var offset = 0; offset < stride; offset++) {
  85608. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  85609. }
  85610. }
  85611. }
  85612. // Updating faces & normal
  85613. var normals = [];
  85614. var positions = newdata[_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  85615. for (index = 0; index < totalIndices; index += 3) {
  85616. indices[index] = index;
  85617. indices[index + 1] = index + 1;
  85618. indices[index + 2] = index + 2;
  85619. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, index * 3);
  85620. var p2 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 1) * 3);
  85621. var p3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 2) * 3);
  85622. var p1p2 = p1.subtract(p2);
  85623. var p3p2 = p3.subtract(p2);
  85624. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Cross(p1p2, p3p2));
  85625. // Store same normals for every vertex
  85626. for (var localIndex = 0; localIndex < 3; localIndex++) {
  85627. normals.push(normal.x);
  85628. normals.push(normal.y);
  85629. normals.push(normal.z);
  85630. }
  85631. }
  85632. this.setIndices(indices);
  85633. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, updatableNormals);
  85634. // Updating vertex buffers
  85635. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85636. kind = kinds[kindIndex];
  85637. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  85638. }
  85639. // Updating submeshes
  85640. this.releaseSubMeshes();
  85641. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  85642. var previousOne = previousSubmeshes[submeshIndex];
  85643. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  85644. }
  85645. this.synchronizeInstances();
  85646. return this;
  85647. };
  85648. /**
  85649. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  85650. * In other words, more vertices, no more indices and a single bigger VBO.
  85651. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  85652. * @returns current mesh
  85653. */
  85654. Mesh.prototype.convertToUnIndexedMesh = function () {
  85655. var kinds = this.getVerticesDataKinds();
  85656. var vbs = {};
  85657. var data = {};
  85658. var newdata = {};
  85659. var kindIndex;
  85660. var kind;
  85661. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85662. kind = kinds[kindIndex];
  85663. var vertexBuffer = this.getVertexBuffer(kind);
  85664. vbs[kind] = vertexBuffer;
  85665. data[kind] = vbs[kind].getData();
  85666. newdata[kind] = [];
  85667. }
  85668. // Save previous submeshes
  85669. var previousSubmeshes = this.subMeshes.slice(0);
  85670. var indices = this.getIndices();
  85671. var totalIndices = this.getTotalIndices();
  85672. // Generating unique vertices per face
  85673. var index;
  85674. for (index = 0; index < totalIndices; index++) {
  85675. var vertexIndex = indices[index];
  85676. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85677. kind = kinds[kindIndex];
  85678. var stride = vbs[kind].getStrideSize();
  85679. for (var offset = 0; offset < stride; offset++) {
  85680. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  85681. }
  85682. }
  85683. }
  85684. // Updating indices
  85685. for (index = 0; index < totalIndices; index += 3) {
  85686. indices[index] = index;
  85687. indices[index + 1] = index + 1;
  85688. indices[index + 2] = index + 2;
  85689. }
  85690. this.setIndices(indices);
  85691. // Updating vertex buffers
  85692. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  85693. kind = kinds[kindIndex];
  85694. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  85695. }
  85696. // Updating submeshes
  85697. this.releaseSubMeshes();
  85698. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  85699. var previousOne = previousSubmeshes[submeshIndex];
  85700. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  85701. }
  85702. this._unIndexed = true;
  85703. this.synchronizeInstances();
  85704. return this;
  85705. };
  85706. /**
  85707. * Inverses facet orientations.
  85708. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  85709. * @param flipNormals will also inverts the normals
  85710. * @returns current mesh
  85711. */
  85712. Mesh.prototype.flipFaces = function (flipNormals) {
  85713. if (flipNormals === void 0) { flipNormals = false; }
  85714. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  85715. var i;
  85716. if (flipNormals && this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) && vertex_data.normals) {
  85717. for (i = 0; i < vertex_data.normals.length; i++) {
  85718. vertex_data.normals[i] *= -1;
  85719. }
  85720. }
  85721. if (vertex_data.indices) {
  85722. var temp;
  85723. for (i = 0; i < vertex_data.indices.length; i += 3) {
  85724. // reassign indices
  85725. temp = vertex_data.indices[i + 1];
  85726. vertex_data.indices[i + 1] = vertex_data.indices[i + 2];
  85727. vertex_data.indices[i + 2] = temp;
  85728. }
  85729. }
  85730. vertex_data.applyToMesh(this);
  85731. return this;
  85732. };
  85733. // Instances
  85734. /** @hidden */
  85735. Mesh._instancedMeshFactory = function (name, mesh) {
  85736. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("InstancedMesh");
  85737. };
  85738. /** @hidden */
  85739. Mesh._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  85740. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("PhysicsImpostor");
  85741. };
  85742. /**
  85743. * Creates a new InstancedMesh object from the mesh model.
  85744. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85745. * @param name defines the name of the new instance
  85746. * @returns a new InstancedMesh
  85747. */
  85748. Mesh.prototype.createInstance = function (name) {
  85749. return Mesh._instancedMeshFactory(name, this);
  85750. };
  85751. /**
  85752. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  85753. * After this call, all the mesh instances have the same submeshes than the current mesh.
  85754. * @returns the current mesh
  85755. */
  85756. Mesh.prototype.synchronizeInstances = function () {
  85757. for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
  85758. var instance = this.instances[instanceIndex];
  85759. instance._syncSubMeshes();
  85760. }
  85761. return this;
  85762. };
  85763. /**
  85764. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  85765. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  85766. * This should be used together with the simplification to avoid disappearing triangles.
  85767. * @param successCallback an optional success callback to be called after the optimization finished.
  85768. * @returns the current mesh
  85769. */
  85770. Mesh.prototype.optimizeIndices = function (successCallback) {
  85771. var _this = this;
  85772. var indices = this.getIndices();
  85773. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  85774. if (!positions || !indices) {
  85775. return this;
  85776. }
  85777. var vectorPositions = new Array();
  85778. for (var pos = 0; pos < positions.length; pos = pos + 3) {
  85779. vectorPositions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, pos));
  85780. }
  85781. var dupes = new Array();
  85782. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["AsyncLoop"].SyncAsyncForLoop(vectorPositions.length, 40, function (iteration) {
  85783. var realPos = vectorPositions.length - 1 - iteration;
  85784. var testedPosition = vectorPositions[realPos];
  85785. for (var j = 0; j < realPos; ++j) {
  85786. var againstPosition = vectorPositions[j];
  85787. if (testedPosition.equals(againstPosition)) {
  85788. dupes[realPos] = j;
  85789. break;
  85790. }
  85791. }
  85792. }, function () {
  85793. for (var i = 0; i < indices.length; ++i) {
  85794. indices[i] = dupes[indices[i]] || indices[i];
  85795. }
  85796. //indices are now reordered
  85797. var originalSubMeshes = _this.subMeshes.slice(0);
  85798. _this.setIndices(indices);
  85799. _this.subMeshes = originalSubMeshes;
  85800. if (successCallback) {
  85801. successCallback(_this);
  85802. }
  85803. });
  85804. return this;
  85805. };
  85806. /**
  85807. * Serialize current mesh
  85808. * @param serializationObject defines the object which will receive the serialization data
  85809. */
  85810. Mesh.prototype.serialize = function (serializationObject) {
  85811. serializationObject.name = this.name;
  85812. serializationObject.id = this.id;
  85813. serializationObject.type = this.getClassName();
  85814. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
  85815. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
  85816. }
  85817. serializationObject.position = this.position.asArray();
  85818. if (this.rotationQuaternion) {
  85819. serializationObject.rotationQuaternion = this.rotationQuaternion.asArray();
  85820. }
  85821. else if (this.rotation) {
  85822. serializationObject.rotation = this.rotation.asArray();
  85823. }
  85824. serializationObject.scaling = this.scaling.asArray();
  85825. if (this._postMultiplyPivotMatrix) {
  85826. serializationObject.pivotMatrix = this.getPivotMatrix().asArray();
  85827. }
  85828. else {
  85829. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  85830. }
  85831. serializationObject.isEnabled = this.isEnabled(false);
  85832. serializationObject.isVisible = this.isVisible;
  85833. serializationObject.infiniteDistance = this.infiniteDistance;
  85834. serializationObject.pickable = this.isPickable;
  85835. serializationObject.receiveShadows = this.receiveShadows;
  85836. serializationObject.billboardMode = this.billboardMode;
  85837. serializationObject.visibility = this.visibility;
  85838. serializationObject.checkCollisions = this.checkCollisions;
  85839. serializationObject.isBlocker = this.isBlocker;
  85840. // Parent
  85841. if (this.parent) {
  85842. serializationObject.parentId = this.parent.id;
  85843. }
  85844. // Geometry
  85845. serializationObject.isUnIndexed = this.isUnIndexed;
  85846. var geometry = this._geometry;
  85847. if (geometry) {
  85848. var geometryId = geometry.id;
  85849. serializationObject.geometryId = geometryId;
  85850. // SubMeshes
  85851. serializationObject.subMeshes = [];
  85852. for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
  85853. var subMesh = this.subMeshes[subIndex];
  85854. serializationObject.subMeshes.push({
  85855. materialIndex: subMesh.materialIndex,
  85856. verticesStart: subMesh.verticesStart,
  85857. verticesCount: subMesh.verticesCount,
  85858. indexStart: subMesh.indexStart,
  85859. indexCount: subMesh.indexCount
  85860. });
  85861. }
  85862. }
  85863. // Material
  85864. if (this.material) {
  85865. serializationObject.materialId = this.material.id;
  85866. }
  85867. else {
  85868. this.material = null;
  85869. }
  85870. // Morph targets
  85871. if (this.morphTargetManager) {
  85872. serializationObject.morphTargetManagerId = this.morphTargetManager.uniqueId;
  85873. }
  85874. // Skeleton
  85875. if (this.skeleton) {
  85876. serializationObject.skeletonId = this.skeleton.id;
  85877. }
  85878. // Physics
  85879. //TODO implement correct serialization for physics impostors.
  85880. var impostor = this.getPhysicsImpostor();
  85881. if (impostor) {
  85882. serializationObject.physicsMass = impostor.getParam("mass");
  85883. serializationObject.physicsFriction = impostor.getParam("friction");
  85884. serializationObject.physicsRestitution = impostor.getParam("mass");
  85885. serializationObject.physicsImpostor = impostor.type;
  85886. }
  85887. // Metadata
  85888. if (this.metadata) {
  85889. serializationObject.metadata = this.metadata;
  85890. }
  85891. // Instances
  85892. serializationObject.instances = [];
  85893. for (var index = 0; index < this.instances.length; index++) {
  85894. var instance = this.instances[index];
  85895. if (instance.doNotSerialize) {
  85896. continue;
  85897. }
  85898. var serializationInstance = {
  85899. name: instance.name,
  85900. id: instance.id,
  85901. position: instance.position.asArray(),
  85902. scaling: instance.scaling.asArray()
  85903. };
  85904. if (instance.parent) {
  85905. serializationInstance.parentId = instance.parent.id;
  85906. }
  85907. if (instance.rotationQuaternion) {
  85908. serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
  85909. }
  85910. else if (instance.rotation) {
  85911. serializationInstance.rotation = instance.rotation.asArray();
  85912. }
  85913. serializationObject.instances.push(serializationInstance);
  85914. // Animations
  85915. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(instance, serializationInstance);
  85916. serializationInstance.ranges = instance.serializeAnimationRanges();
  85917. }
  85918. //
  85919. // Animations
  85920. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  85921. serializationObject.ranges = this.serializeAnimationRanges();
  85922. // Layer mask
  85923. serializationObject.layerMask = this.layerMask;
  85924. // Alpha
  85925. serializationObject.alphaIndex = this.alphaIndex;
  85926. serializationObject.hasVertexAlpha = this.hasVertexAlpha;
  85927. // Overlay
  85928. serializationObject.overlayAlpha = this.overlayAlpha;
  85929. serializationObject.overlayColor = this.overlayColor.asArray();
  85930. serializationObject.renderOverlay = this.renderOverlay;
  85931. // Fog
  85932. serializationObject.applyFog = this.applyFog;
  85933. // Action Manager
  85934. if (this.actionManager) {
  85935. serializationObject.actions = this.actionManager.serialize(this.name);
  85936. }
  85937. };
  85938. /** @hidden */
  85939. Mesh.prototype._syncGeometryWithMorphTargetManager = function () {
  85940. if (!this.geometry) {
  85941. return;
  85942. }
  85943. this._markSubMeshesAsAttributesDirty();
  85944. var morphTargetManager = this._morphTargetManager;
  85945. if (morphTargetManager && morphTargetManager.vertexCount) {
  85946. if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
  85947. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
  85948. this.morphTargetManager = null;
  85949. return;
  85950. }
  85951. for (var index = 0; index < morphTargetManager.numInfluencers; index++) {
  85952. var morphTarget = morphTargetManager.getActiveTarget(index);
  85953. var positions = morphTarget.getPositions();
  85954. if (!positions) {
  85955. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Invalid morph target. Target must have positions.");
  85956. return;
  85957. }
  85958. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index, positions, false, 3);
  85959. var normals = morphTarget.getNormals();
  85960. if (normals) {
  85961. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index, normals, false, 3);
  85962. }
  85963. var tangents = morphTarget.getTangents();
  85964. if (tangents) {
  85965. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index, tangents, false, 3);
  85966. }
  85967. }
  85968. }
  85969. else {
  85970. var index = 0;
  85971. // Positions
  85972. while (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index)) {
  85973. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index);
  85974. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index)) {
  85975. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index);
  85976. }
  85977. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index)) {
  85978. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index);
  85979. }
  85980. index++;
  85981. }
  85982. }
  85983. };
  85984. /**
  85985. * Returns a new Mesh object parsed from the source provided.
  85986. * @param parsedMesh is the source
  85987. * @param scene defines the hosting scene
  85988. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  85989. * @returns a new Mesh
  85990. */
  85991. Mesh.Parse = function (parsedMesh, scene, rootUrl) {
  85992. var mesh;
  85993. if (parsedMesh.type && parsedMesh.type === "GroundMesh") {
  85994. mesh = Mesh._GroundMeshParser(parsedMesh, scene);
  85995. }
  85996. else {
  85997. mesh = new Mesh(parsedMesh.name, scene);
  85998. }
  85999. mesh.id = parsedMesh.id;
  86000. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  86001. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(mesh, parsedMesh.tags);
  86002. }
  86003. mesh.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.position);
  86004. if (parsedMesh.metadata !== undefined) {
  86005. mesh.metadata = parsedMesh.metadata;
  86006. }
  86007. if (parsedMesh.rotationQuaternion) {
  86008. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedMesh.rotationQuaternion);
  86009. }
  86010. else if (parsedMesh.rotation) {
  86011. mesh.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.rotation);
  86012. }
  86013. mesh.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.scaling);
  86014. if (parsedMesh.localMatrix) {
  86015. mesh.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.localMatrix));
  86016. }
  86017. else if (parsedMesh.pivotMatrix) {
  86018. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.pivotMatrix));
  86019. }
  86020. mesh.setEnabled(parsedMesh.isEnabled);
  86021. mesh.isVisible = parsedMesh.isVisible;
  86022. mesh.infiniteDistance = parsedMesh.infiniteDistance;
  86023. mesh.showBoundingBox = parsedMesh.showBoundingBox;
  86024. mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
  86025. if (parsedMesh.applyFog !== undefined) {
  86026. mesh.applyFog = parsedMesh.applyFog;
  86027. }
  86028. if (parsedMesh.pickable !== undefined) {
  86029. mesh.isPickable = parsedMesh.pickable;
  86030. }
  86031. if (parsedMesh.alphaIndex !== undefined) {
  86032. mesh.alphaIndex = parsedMesh.alphaIndex;
  86033. }
  86034. mesh.receiveShadows = parsedMesh.receiveShadows;
  86035. mesh.billboardMode = parsedMesh.billboardMode;
  86036. if (parsedMesh.visibility !== undefined) {
  86037. mesh.visibility = parsedMesh.visibility;
  86038. }
  86039. mesh.checkCollisions = parsedMesh.checkCollisions;
  86040. if (parsedMesh.isBlocker !== undefined) {
  86041. mesh.isBlocker = parsedMesh.isBlocker;
  86042. }
  86043. mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
  86044. // freezeWorldMatrix
  86045. if (parsedMesh.freezeWorldMatrix) {
  86046. mesh._waitingFreezeWorldMatrix = parsedMesh.freezeWorldMatrix;
  86047. }
  86048. // Parent
  86049. if (parsedMesh.parentId) {
  86050. mesh._waitingParentId = parsedMesh.parentId;
  86051. }
  86052. // Actions
  86053. if (parsedMesh.actions !== undefined) {
  86054. mesh._waitingActions = parsedMesh.actions;
  86055. }
  86056. // Overlay
  86057. if (parsedMesh.overlayAlpha !== undefined) {
  86058. mesh.overlayAlpha = parsedMesh.overlayAlpha;
  86059. }
  86060. if (parsedMesh.overlayColor !== undefined) {
  86061. mesh.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].FromArray(parsedMesh.overlayColor);
  86062. }
  86063. if (parsedMesh.renderOverlay !== undefined) {
  86064. mesh.renderOverlay = parsedMesh.renderOverlay;
  86065. }
  86066. // Geometry
  86067. mesh.isUnIndexed = !!parsedMesh.isUnIndexed;
  86068. mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
  86069. if (parsedMesh.delayLoadingFile) {
  86070. mesh.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED;
  86071. mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
  86072. 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));
  86073. if (parsedMesh._binaryInfo) {
  86074. mesh._binaryInfo = parsedMesh._binaryInfo;
  86075. }
  86076. mesh._delayInfo = [];
  86077. if (parsedMesh.hasUVs) {
  86078. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  86079. }
  86080. if (parsedMesh.hasUVs2) {
  86081. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  86082. }
  86083. if (parsedMesh.hasUVs3) {
  86084. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV3Kind);
  86085. }
  86086. if (parsedMesh.hasUVs4) {
  86087. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV4Kind);
  86088. }
  86089. if (parsedMesh.hasUVs5) {
  86090. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV5Kind);
  86091. }
  86092. if (parsedMesh.hasUVs6) {
  86093. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV6Kind);
  86094. }
  86095. if (parsedMesh.hasColors) {
  86096. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  86097. }
  86098. if (parsedMesh.hasMatricesIndices) {
  86099. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  86100. }
  86101. if (parsedMesh.hasMatricesWeights) {
  86102. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  86103. }
  86104. mesh._delayLoadingFunction = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry;
  86105. if (_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental) {
  86106. mesh._checkDelayState();
  86107. }
  86108. }
  86109. else {
  86110. _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry(parsedMesh, mesh);
  86111. }
  86112. // Material
  86113. if (parsedMesh.materialId) {
  86114. mesh.setMaterialByID(parsedMesh.materialId);
  86115. }
  86116. else {
  86117. mesh.material = null;
  86118. }
  86119. // Morph targets
  86120. if (parsedMesh.morphTargetManagerId > -1) {
  86121. mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);
  86122. }
  86123. // Skeleton
  86124. if (parsedMesh.skeletonId > -1) {
  86125. mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
  86126. if (parsedMesh.numBoneInfluencers) {
  86127. mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
  86128. }
  86129. }
  86130. // Animations
  86131. if (parsedMesh.animations) {
  86132. for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
  86133. var parsedAnimation = parsedMesh.animations[animationIndex];
  86134. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  86135. if (internalClass) {
  86136. mesh.animations.push(internalClass.Parse(parsedAnimation));
  86137. }
  86138. }
  86139. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(mesh, parsedMesh, scene);
  86140. }
  86141. if (parsedMesh.autoAnimate) {
  86142. scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, parsedMesh.autoAnimateSpeed || 1.0);
  86143. }
  86144. // Layer Mask
  86145. if (parsedMesh.layerMask && (!isNaN(parsedMesh.layerMask))) {
  86146. mesh.layerMask = Math.abs(parseInt(parsedMesh.layerMask));
  86147. }
  86148. else {
  86149. mesh.layerMask = 0x0FFFFFFF;
  86150. }
  86151. // Physics
  86152. if (parsedMesh.physicsImpostor) {
  86153. Mesh._PhysicsImpostorParser(scene, mesh, parsedMesh);
  86154. }
  86155. // Instances
  86156. if (parsedMesh.instances) {
  86157. for (var index = 0; index < parsedMesh.instances.length; index++) {
  86158. var parsedInstance = parsedMesh.instances[index];
  86159. var instance = mesh.createInstance(parsedInstance.name);
  86160. if (parsedInstance.id) {
  86161. instance.id = parsedInstance.id;
  86162. }
  86163. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  86164. if (parsedInstance.tags) {
  86165. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedInstance.tags);
  86166. }
  86167. else {
  86168. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedMesh.tags);
  86169. }
  86170. }
  86171. instance.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.position);
  86172. if (parsedInstance.parentId) {
  86173. instance._waitingParentId = parsedInstance.parentId;
  86174. }
  86175. if (parsedInstance.rotationQuaternion) {
  86176. instance.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedInstance.rotationQuaternion);
  86177. }
  86178. else if (parsedInstance.rotation) {
  86179. instance.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.rotation);
  86180. }
  86181. instance.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.scaling);
  86182. if (parsedInstance.checkCollisions != undefined && parsedInstance.checkCollisions != null) {
  86183. instance.checkCollisions = parsedInstance.checkCollisions;
  86184. }
  86185. if (parsedInstance.pickable != undefined && parsedInstance.pickable != null) {
  86186. instance.isPickable = parsedInstance.pickable;
  86187. }
  86188. if (parsedInstance.showBoundingBox != undefined && parsedInstance.showBoundingBox != null) {
  86189. instance.showBoundingBox = parsedInstance.showBoundingBox;
  86190. }
  86191. if (parsedInstance.showSubMeshesBoundingBox != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  86192. instance.showSubMeshesBoundingBox = parsedInstance.showSubMeshesBoundingBox;
  86193. }
  86194. if (parsedInstance.alphaIndex != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  86195. instance.alphaIndex = parsedInstance.alphaIndex;
  86196. }
  86197. // Physics
  86198. if (parsedInstance.physicsImpostor) {
  86199. Mesh._PhysicsImpostorParser(scene, instance, parsedInstance);
  86200. }
  86201. // Animation
  86202. if (parsedInstance.animations) {
  86203. for (animationIndex = 0; animationIndex < parsedInstance.animations.length; animationIndex++) {
  86204. parsedAnimation = parsedInstance.animations[animationIndex];
  86205. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  86206. if (internalClass) {
  86207. instance.animations.push(internalClass.Parse(parsedAnimation));
  86208. }
  86209. }
  86210. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(instance, parsedInstance, scene);
  86211. if (parsedInstance.autoAnimate) {
  86212. scene.beginAnimation(instance, parsedInstance.autoAnimateFrom, parsedInstance.autoAnimateTo, parsedInstance.autoAnimateLoop, parsedInstance.autoAnimateSpeed || 1.0);
  86213. }
  86214. }
  86215. }
  86216. }
  86217. return mesh;
  86218. };
  86219. /**
  86220. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  86221. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  86222. * @param name defines the name of the mesh to create
  86223. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  86224. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  86225. * @param closePath creates a seam between the first and the last points of each path of the path array
  86226. * @param offset is taken in account only if the `pathArray` is containing a single path
  86227. * @param scene defines the hosting scene
  86228. * @param updatable defines if the mesh must be flagged as updatable
  86229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86230. * @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)
  86231. * @returns a new Mesh
  86232. */
  86233. Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  86234. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86235. };
  86236. /**
  86237. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  86238. * @param name defines the name of the mesh to create
  86239. * @param radius sets the radius size (float) of the polygon (default 0.5)
  86240. * @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
  86241. * @param scene defines the hosting scene
  86242. * @param updatable defines if the mesh must be flagged as updatable
  86243. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86244. * @returns a new Mesh
  86245. */
  86246. Mesh.CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  86247. if (scene === void 0) { scene = null; }
  86248. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86249. };
  86250. /**
  86251. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  86252. * @param name defines the name of the mesh to create
  86253. * @param size sets the size (float) of each box side (default 1)
  86254. * @param scene defines the hosting scene
  86255. * @param updatable defines if the mesh must be flagged as updatable
  86256. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86257. * @returns a new Mesh
  86258. */
  86259. Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
  86260. if (scene === void 0) { scene = null; }
  86261. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86262. };
  86263. /**
  86264. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  86265. * @param name defines the name of the mesh to create
  86266. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  86267. * @param diameter sets the diameter size (float) of the sphere (default 1)
  86268. * @param scene defines the hosting scene
  86269. * @param updatable defines if the mesh must be flagged as updatable
  86270. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86271. * @returns a new Mesh
  86272. */
  86273. Mesh.CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  86274. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86275. };
  86276. /**
  86277. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  86278. * @param name defines the name of the mesh to create
  86279. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  86280. * @param diameterTop set the top cap diameter (floats, default 1)
  86281. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  86282. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  86283. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  86284. * @param scene defines the hosting scene
  86285. * @param updatable defines if the mesh must be flagged as updatable
  86286. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86287. * @returns a new Mesh
  86288. */
  86289. Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  86290. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86291. };
  86292. // Torus (Code from SharpDX.org)
  86293. /**
  86294. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  86295. * @param name defines the name of the mesh to create
  86296. * @param diameter sets the diameter size (float) of the torus (default 1)
  86297. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  86298. * @param tessellation sets the number of torus sides (postive integer, default 16)
  86299. * @param scene defines the hosting scene
  86300. * @param updatable defines if the mesh must be flagged as updatable
  86301. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86302. * @returns a new Mesh
  86303. */
  86304. Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  86305. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86306. };
  86307. /**
  86308. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  86309. * @param name defines the name of the mesh to create
  86310. * @param radius sets the global radius size (float) of the torus knot (default 2)
  86311. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  86312. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  86313. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  86314. * @param p the number of windings on X axis (positive integers, default 2)
  86315. * @param q the number of windings on Y axis (positive integers, default 3)
  86316. * @param scene defines the hosting scene
  86317. * @param updatable defines if the mesh must be flagged as updatable
  86318. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86319. * @returns a new Mesh
  86320. */
  86321. Mesh.CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  86322. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86323. };
  86324. /**
  86325. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  86326. * @param name defines the name of the mesh to create
  86327. * @param points is an array successive Vector3
  86328. * @param scene defines the hosting scene
  86329. * @param updatable defines if the mesh must be flagged as updatable
  86330. * @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).
  86331. * @returns a new Mesh
  86332. */
  86333. Mesh.CreateLines = function (name, points, scene, updatable, instance) {
  86334. if (scene === void 0) { scene = null; }
  86335. if (updatable === void 0) { updatable = false; }
  86336. if (instance === void 0) { instance = null; }
  86337. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86338. };
  86339. /**
  86340. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  86341. * @param name defines the name of the mesh to create
  86342. * @param points is an array successive Vector3
  86343. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  86344. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  86345. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  86346. * @param scene defines the hosting scene
  86347. * @param updatable defines if the mesh must be flagged as updatable
  86348. * @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)
  86349. * @returns a new Mesh
  86350. */
  86351. Mesh.CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  86352. if (scene === void 0) { scene = null; }
  86353. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86354. };
  86355. /**
  86356. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  86357. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  86358. * 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.
  86359. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86360. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86361. * Remember you can only change the shape positions, not their number when updating a polygon.
  86362. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  86363. * @param name defines the name of the mesh to create
  86364. * @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
  86365. * @param scene defines the hosting scene
  86366. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  86367. * @param updatable defines if the mesh must be flagged as updatable
  86368. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86369. * @param earcutInjection can be used to inject your own earcut reference
  86370. * @returns a new Mesh
  86371. */
  86372. Mesh.CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  86373. if (earcutInjection === void 0) { earcutInjection = earcut; }
  86374. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86375. };
  86376. /**
  86377. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  86378. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  86379. * @param name defines the name of the mesh to create
  86380. * @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
  86381. * @param depth defines the height of extrusion
  86382. * @param scene defines the hosting scene
  86383. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  86384. * @param updatable defines if the mesh must be flagged as updatable
  86385. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86386. * @param earcutInjection can be used to inject your own earcut reference
  86387. * @returns a new Mesh
  86388. */
  86389. Mesh.ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  86390. if (earcutInjection === void 0) { earcutInjection = earcut; }
  86391. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86392. };
  86393. /**
  86394. * Creates an extruded shape mesh.
  86395. * 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
  86396. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  86397. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  86398. * @param name defines the name of the mesh to create
  86399. * @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
  86400. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  86401. * @param scale is the value to scale the shape
  86402. * @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
  86403. * @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
  86404. * @param scene defines the hosting scene
  86405. * @param updatable defines if the mesh must be flagged as updatable
  86406. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86407. * @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)
  86408. * @returns a new Mesh
  86409. */
  86410. Mesh.ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  86411. if (scene === void 0) { scene = null; }
  86412. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86413. };
  86414. /**
  86415. * Creates an custom extruded shape mesh.
  86416. * The custom extrusion is a parametric shape.
  86417. * It has no predefined shape. Its final shape will depend on the input parameters.
  86418. * Please consider using the same method from the MeshBuilder class instead
  86419. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  86420. * @param name defines the name of the mesh to create
  86421. * @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
  86422. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  86423. * @param scaleFunction is a custom Javascript function called on each path point
  86424. * @param rotationFunction is a custom Javascript function called on each path point
  86425. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  86426. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  86427. * @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
  86428. * @param scene defines the hosting scene
  86429. * @param updatable defines if the mesh must be flagged as updatable
  86430. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86431. * @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)
  86432. * @returns a new Mesh
  86433. */
  86434. Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  86435. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86436. };
  86437. /**
  86438. * Creates lathe mesh.
  86439. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  86440. * Please consider using the same method from the MeshBuilder class instead
  86441. * @param name defines the name of the mesh to create
  86442. * @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
  86443. * @param radius is the radius value of the lathe
  86444. * @param tessellation is the side number of the lathe.
  86445. * @param scene defines the hosting scene
  86446. * @param updatable defines if the mesh must be flagged as updatable
  86447. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86448. * @returns a new Mesh
  86449. */
  86450. Mesh.CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  86451. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86452. };
  86453. /**
  86454. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  86455. * @param name defines the name of the mesh to create
  86456. * @param size sets the size (float) of both sides of the plane at once (default 1)
  86457. * @param scene defines the hosting scene
  86458. * @param updatable defines if the mesh must be flagged as updatable
  86459. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86460. * @returns a new Mesh
  86461. */
  86462. Mesh.CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  86463. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86464. };
  86465. /**
  86466. * Creates a ground mesh.
  86467. * Please consider using the same method from the MeshBuilder class instead
  86468. * @param name defines the name of the mesh to create
  86469. * @param width set the width of the ground
  86470. * @param height set the height of the ground
  86471. * @param subdivisions sets the number of subdivisions per side
  86472. * @param scene defines the hosting scene
  86473. * @param updatable defines if the mesh must be flagged as updatable
  86474. * @returns a new Mesh
  86475. */
  86476. Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  86477. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86478. };
  86479. /**
  86480. * Creates a tiled ground mesh.
  86481. * Please consider using the same method from the MeshBuilder class instead
  86482. * @param name defines the name of the mesh to create
  86483. * @param xmin set the ground minimum X coordinate
  86484. * @param zmin set the ground minimum Y coordinate
  86485. * @param xmax set the ground maximum X coordinate
  86486. * @param zmax set the ground maximum Z coordinate
  86487. * @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
  86488. * @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
  86489. * @param scene defines the hosting scene
  86490. * @param updatable defines if the mesh must be flagged as updatable
  86491. * @returns a new Mesh
  86492. */
  86493. Mesh.CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  86494. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86495. };
  86496. /**
  86497. * Creates a ground mesh from a height map.
  86498. * Please consider using the same method from the MeshBuilder class instead
  86499. * @see http://doc.babylonjs.com/babylon101/height_map
  86500. * @param name defines the name of the mesh to create
  86501. * @param url sets the URL of the height map image resource
  86502. * @param width set the ground width size
  86503. * @param height set the ground height size
  86504. * @param subdivisions sets the number of subdivision per side
  86505. * @param minHeight is the minimum altitude on the ground
  86506. * @param maxHeight is the maximum altitude on the ground
  86507. * @param scene defines the hosting scene
  86508. * @param updatable defines if the mesh must be flagged as updatable
  86509. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  86510. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  86511. * @returns a new Mesh
  86512. */
  86513. Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  86514. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86515. };
  86516. /**
  86517. * Creates a tube mesh.
  86518. * The tube is a parametric shape.
  86519. * It has no predefined shape. Its final shape will depend on the input parameters.
  86520. * Please consider using the same method from the MeshBuilder class instead
  86521. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  86522. * @param name defines the name of the mesh to create
  86523. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  86524. * @param radius sets the tube radius size
  86525. * @param tessellation is the number of sides on the tubular surface
  86526. * @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
  86527. * @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
  86528. * @param scene defines the hosting scene
  86529. * @param updatable defines if the mesh must be flagged as updatable
  86530. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86531. * @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)
  86532. * @returns a new Mesh
  86533. */
  86534. Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  86535. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86536. };
  86537. /**
  86538. * Creates a polyhedron mesh.
  86539. * Please consider using the same method from the MeshBuilder class instead.
  86540. * * 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
  86541. * * The parameter `size` (positive float, default 1) sets the polygon size
  86542. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  86543. * * 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`
  86544. * * 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
  86545. * * 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)`)
  86546. * * 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
  86547. * * 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
  86548. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86549. * * 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
  86550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86551. * @param name defines the name of the mesh to create
  86552. * @param options defines the options used to create the mesh
  86553. * @param scene defines the hosting scene
  86554. * @returns a new Mesh
  86555. */
  86556. Mesh.CreatePolyhedron = function (name, options, scene) {
  86557. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86558. };
  86559. /**
  86560. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  86561. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  86562. * * 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`)
  86563. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  86564. * * 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
  86565. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86566. * * 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
  86567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86568. * @param name defines the name of the mesh
  86569. * @param options defines the options used to create the mesh
  86570. * @param scene defines the hosting scene
  86571. * @returns a new Mesh
  86572. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  86573. */
  86574. Mesh.CreateIcoSphere = function (name, options, scene) {
  86575. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86576. };
  86577. /**
  86578. * Creates a decal mesh.
  86579. * Please consider using the same method from the MeshBuilder class instead.
  86580. * A decal is a mesh usually applied as a model onto the surface of another mesh
  86581. * @param name defines the name of the mesh
  86582. * @param sourceMesh defines the mesh receiving the decal
  86583. * @param position sets the position of the decal in world coordinates
  86584. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  86585. * @param size sets the decal scaling
  86586. * @param angle sets the angle to rotate the decal
  86587. * @returns a new Mesh
  86588. */
  86589. Mesh.CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  86590. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86591. };
  86592. // Skeletons
  86593. /**
  86594. * Prepare internal position array for software CPU skinning
  86595. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  86596. */
  86597. Mesh.prototype.setPositionsForCPUSkinning = function () {
  86598. if (!this._sourcePositions) {
  86599. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  86600. if (!source) {
  86601. return this._sourcePositions;
  86602. }
  86603. this._sourcePositions = new Float32Array(source);
  86604. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  86605. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, source, true);
  86606. }
  86607. }
  86608. return this._sourcePositions;
  86609. };
  86610. /**
  86611. * Prepare internal normal array for software CPU skinning
  86612. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  86613. */
  86614. Mesh.prototype.setNormalsForCPUSkinning = function () {
  86615. if (!this._sourceNormals) {
  86616. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  86617. if (!source) {
  86618. return this._sourceNormals;
  86619. }
  86620. this._sourceNormals = new Float32Array(source);
  86621. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  86622. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, source, true);
  86623. }
  86624. }
  86625. return this._sourceNormals;
  86626. };
  86627. /**
  86628. * Updates the vertex buffer by applying transformation from the bones
  86629. * @param skeleton defines the skeleton to apply to current mesh
  86630. * @returns the current mesh
  86631. */
  86632. Mesh.prototype.applySkeleton = function (skeleton) {
  86633. if (!this.geometry) {
  86634. return this;
  86635. }
  86636. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) {
  86637. return this;
  86638. }
  86639. this.geometry._softwareSkinningFrameId = this.getScene().getFrameId();
  86640. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  86641. return this;
  86642. }
  86643. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  86644. return this;
  86645. }
  86646. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind)) {
  86647. return this;
  86648. }
  86649. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  86650. return this;
  86651. }
  86652. if (!this._sourcePositions) {
  86653. var submeshes = this.subMeshes.slice();
  86654. this.setPositionsForCPUSkinning();
  86655. this.subMeshes = submeshes;
  86656. }
  86657. if (!this._sourceNormals) {
  86658. this.setNormalsForCPUSkinning();
  86659. }
  86660. // positionsData checks for not being Float32Array will only pass at most once
  86661. var positionsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  86662. if (!positionsData) {
  86663. return this;
  86664. }
  86665. if (!(positionsData instanceof Float32Array)) {
  86666. positionsData = new Float32Array(positionsData);
  86667. }
  86668. // normalsData checks for not being Float32Array will only pass at most once
  86669. var normalsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  86670. if (!normalsData) {
  86671. return this;
  86672. }
  86673. if (!(normalsData instanceof Float32Array)) {
  86674. normalsData = new Float32Array(normalsData);
  86675. }
  86676. var matricesIndicesData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  86677. var matricesWeightsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  86678. if (!matricesWeightsData || !matricesIndicesData) {
  86679. return this;
  86680. }
  86681. var needExtras = this.numBoneInfluencers > 4;
  86682. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  86683. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  86684. var skeletonMatrices = skeleton.getTransformMatrices(this);
  86685. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  86686. var finalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  86687. var tempMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  86688. var matWeightIdx = 0;
  86689. var inf;
  86690. for (var index = 0; index < positionsData.length; index += 3, matWeightIdx += 4) {
  86691. var weight;
  86692. for (inf = 0; inf < 4; inf++) {
  86693. weight = matricesWeightsData[matWeightIdx + inf];
  86694. if (weight > 0) {
  86695. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  86696. finalMatrix.addToSelf(tempMatrix);
  86697. }
  86698. }
  86699. if (needExtras) {
  86700. for (inf = 0; inf < 4; inf++) {
  86701. weight = matricesWeightsExtraData[matWeightIdx + inf];
  86702. if (weight > 0) {
  86703. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  86704. finalMatrix.addToSelf(tempMatrix);
  86705. }
  86706. }
  86707. }
  86708. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinatesFromFloatsToRef(this._sourcePositions[index], this._sourcePositions[index + 1], this._sourcePositions[index + 2], finalMatrix, tempVector3);
  86709. tempVector3.toArray(positionsData, index);
  86710. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalFromFloatsToRef(this._sourceNormals[index], this._sourceNormals[index + 1], this._sourceNormals[index + 2], finalMatrix, tempVector3);
  86711. tempVector3.toArray(normalsData, index);
  86712. finalMatrix.reset();
  86713. }
  86714. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positionsData);
  86715. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normalsData);
  86716. return this;
  86717. };
  86718. // Tools
  86719. /**
  86720. * 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
  86721. * @param meshes defines the list of meshes to scan
  86722. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  86723. */
  86724. Mesh.MinMax = function (meshes) {
  86725. var minVector = null;
  86726. var maxVector = null;
  86727. meshes.forEach(function (mesh) {
  86728. var boundingInfo = mesh.getBoundingInfo();
  86729. var boundingBox = boundingInfo.boundingBox;
  86730. if (!minVector || !maxVector) {
  86731. minVector = boundingBox.minimumWorld;
  86732. maxVector = boundingBox.maximumWorld;
  86733. }
  86734. else {
  86735. minVector.minimizeInPlace(boundingBox.minimumWorld);
  86736. maxVector.maximizeInPlace(boundingBox.maximumWorld);
  86737. }
  86738. });
  86739. if (!minVector || !maxVector) {
  86740. return {
  86741. min: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero(),
  86742. max: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero()
  86743. };
  86744. }
  86745. return {
  86746. min: minVector,
  86747. max: maxVector
  86748. };
  86749. };
  86750. /**
  86751. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  86752. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  86753. * @returns a vector3
  86754. */
  86755. Mesh.Center = function (meshesOrMinMaxVector) {
  86756. var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
  86757. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Center(minMaxVector.min, minMaxVector.max);
  86758. };
  86759. /**
  86760. * Merge the array of meshes into a single mesh for performance reasons.
  86761. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  86762. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  86763. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  86764. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  86765. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  86766. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  86767. * @returns a new mesh
  86768. */
  86769. Mesh.MergeMeshes = function (meshes, disposeSource, allow32BitsIndices, meshSubclass, subdivideWithSubMeshes, multiMultiMaterials) {
  86770. if (disposeSource === void 0) { disposeSource = true; }
  86771. var index;
  86772. if (!allow32BitsIndices) {
  86773. var totalVertices = 0;
  86774. // Counting vertices
  86775. for (index = 0; index < meshes.length; index++) {
  86776. if (meshes[index]) {
  86777. totalVertices += meshes[index].getTotalVertices();
  86778. if (totalVertices > 65536) {
  86779. _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");
  86780. return null;
  86781. }
  86782. }
  86783. }
  86784. }
  86785. if (multiMultiMaterials) {
  86786. var newMultiMaterial = null;
  86787. var subIndex;
  86788. var matIndex;
  86789. subdivideWithSubMeshes = false;
  86790. }
  86791. var materialArray = new Array();
  86792. var materialIndexArray = new Array();
  86793. // Merge
  86794. var vertexData = null;
  86795. var otherVertexData;
  86796. var indiceArray = new Array();
  86797. var source = null;
  86798. for (index = 0; index < meshes.length; index++) {
  86799. if (meshes[index]) {
  86800. var mesh = meshes[index];
  86801. var wm = mesh.computeWorldMatrix(true);
  86802. otherVertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(mesh, true, true);
  86803. otherVertexData.transform(wm);
  86804. if (vertexData) {
  86805. vertexData.merge(otherVertexData, allow32BitsIndices);
  86806. }
  86807. else {
  86808. vertexData = otherVertexData;
  86809. source = mesh;
  86810. }
  86811. if (subdivideWithSubMeshes) {
  86812. indiceArray.push(mesh.getTotalIndices());
  86813. }
  86814. if (multiMultiMaterials) {
  86815. if (mesh.material) {
  86816. var material = mesh.material;
  86817. if (material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"]) {
  86818. for (matIndex = 0; matIndex < material.subMaterials.length; matIndex++) {
  86819. if (materialArray.indexOf(material.subMaterials[matIndex]) < 0) {
  86820. materialArray.push(material.subMaterials[matIndex]);
  86821. }
  86822. }
  86823. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  86824. materialIndexArray.push(materialArray.indexOf(material.subMaterials[mesh.subMeshes[subIndex].materialIndex]));
  86825. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  86826. }
  86827. }
  86828. else {
  86829. if (materialArray.indexOf(material) < 0) {
  86830. materialArray.push(material);
  86831. }
  86832. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  86833. materialIndexArray.push(materialArray.indexOf(material));
  86834. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  86835. }
  86836. }
  86837. }
  86838. else {
  86839. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  86840. materialIndexArray.push(0);
  86841. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  86842. }
  86843. }
  86844. }
  86845. }
  86846. }
  86847. source = source;
  86848. if (!meshSubclass) {
  86849. meshSubclass = new Mesh(source.name + "_merged", source.getScene());
  86850. }
  86851. vertexData.applyToMesh(meshSubclass);
  86852. // Setting properties
  86853. meshSubclass.checkCollisions = source.checkCollisions;
  86854. // Cleaning
  86855. if (disposeSource) {
  86856. for (index = 0; index < meshes.length; index++) {
  86857. if (meshes[index]) {
  86858. meshes[index].dispose();
  86859. }
  86860. }
  86861. }
  86862. // Subdivide
  86863. if (subdivideWithSubMeshes || multiMultiMaterials) {
  86864. //-- removal of global submesh
  86865. meshSubclass.releaseSubMeshes();
  86866. index = 0;
  86867. var offset = 0;
  86868. //-- apply subdivision according to index table
  86869. while (index < indiceArray.length) {
  86870. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
  86871. offset += indiceArray[index];
  86872. index++;
  86873. }
  86874. }
  86875. if (multiMultiMaterials) {
  86876. newMultiMaterial = new _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"](source.name + "_merged", source.getScene());
  86877. newMultiMaterial.subMaterials = materialArray;
  86878. for (subIndex = 0; subIndex < meshSubclass.subMeshes.length; subIndex++) {
  86879. meshSubclass.subMeshes[subIndex].materialIndex = materialIndexArray[subIndex];
  86880. }
  86881. meshSubclass.material = newMultiMaterial;
  86882. }
  86883. else {
  86884. meshSubclass.material = source.material;
  86885. }
  86886. return meshSubclass;
  86887. };
  86888. /** @hidden */
  86889. Mesh.prototype.addInstance = function (instance) {
  86890. instance._indexInSourceMeshInstanceArray = this.instances.length;
  86891. this.instances.push(instance);
  86892. };
  86893. /** @hidden */
  86894. Mesh.prototype.removeInstance = function (instance) {
  86895. // Remove from mesh
  86896. var index = instance._indexInSourceMeshInstanceArray;
  86897. if (index != -1) {
  86898. if (index !== this.instances.length - 1) {
  86899. var last = this.instances[this.instances.length - 1];
  86900. this.instances[index] = last;
  86901. last._indexInSourceMeshInstanceArray = index;
  86902. }
  86903. instance._indexInSourceMeshInstanceArray = -1;
  86904. this.instances.pop();
  86905. }
  86906. };
  86907. // Consts
  86908. /**
  86909. * Mesh side orientation : usually the external or front surface
  86910. */
  86911. Mesh.FRONTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].FRONTSIDE;
  86912. /**
  86913. * Mesh side orientation : usually the internal or back surface
  86914. */
  86915. Mesh.BACKSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].BACKSIDE;
  86916. /**
  86917. * Mesh side orientation : both internal and external or front and back surfaces
  86918. */
  86919. Mesh.DOUBLESIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DOUBLESIDE;
  86920. /**
  86921. * Mesh side orientation : by default, `FRONTSIDE`
  86922. */
  86923. Mesh.DEFAULTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DEFAULTSIDE;
  86924. /**
  86925. * Mesh cap setting : no cap
  86926. */
  86927. Mesh.NO_CAP = 0;
  86928. /**
  86929. * Mesh cap setting : one cap at the beginning of the mesh
  86930. */
  86931. Mesh.CAP_START = 1;
  86932. /**
  86933. * Mesh cap setting : one cap at the end of the mesh
  86934. */
  86935. Mesh.CAP_END = 2;
  86936. /**
  86937. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  86938. */
  86939. Mesh.CAP_ALL = 3;
  86940. // Statics
  86941. /** @hidden */
  86942. Mesh._GroundMeshParser = function (parsedMesh, scene) {
  86943. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("GroundMesh");
  86944. };
  86945. return Mesh;
  86946. }(_abstractMesh__WEBPACK_IMPORTED_MODULE_10__["AbstractMesh"]));
  86947. /***/ }),
  86948. /***/ "./Meshes/mesh.vertexData.ts":
  86949. /*!***********************************!*\
  86950. !*** ./Meshes/mesh.vertexData.ts ***!
  86951. \***********************************/
  86952. /*! exports provided: VertexData */
  86953. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86954. "use strict";
  86955. __webpack_require__.r(__webpack_exports__);
  86956. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return VertexData; });
  86957. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  86958. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  86959. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  86960. /**
  86961. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86962. */
  86963. var VertexData = /** @class */ (function () {
  86964. function VertexData() {
  86965. }
  86966. /**
  86967. * Uses the passed data array to set the set the values for the specified kind of data
  86968. * @param data a linear array of floating numbers
  86969. * @param kind the type of data that is being set, eg positions, colors etc
  86970. */
  86971. VertexData.prototype.set = function (data, kind) {
  86972. switch (kind) {
  86973. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
  86974. this.positions = data;
  86975. break;
  86976. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind:
  86977. this.normals = data;
  86978. break;
  86979. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind:
  86980. this.tangents = data;
  86981. break;
  86982. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind:
  86983. this.uvs = data;
  86984. break;
  86985. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind:
  86986. this.uvs2 = data;
  86987. break;
  86988. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind:
  86989. this.uvs3 = data;
  86990. break;
  86991. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind:
  86992. this.uvs4 = data;
  86993. break;
  86994. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind:
  86995. this.uvs5 = data;
  86996. break;
  86997. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind:
  86998. this.uvs6 = data;
  86999. break;
  87000. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind:
  87001. this.colors = data;
  87002. break;
  87003. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind:
  87004. this.matricesIndices = data;
  87005. break;
  87006. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind:
  87007. this.matricesWeights = data;
  87008. break;
  87009. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind:
  87010. this.matricesIndicesExtra = data;
  87011. break;
  87012. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind:
  87013. this.matricesWeightsExtra = data;
  87014. break;
  87015. }
  87016. };
  87017. /**
  87018. * Associates the vertexData to the passed Mesh.
  87019. * Sets it as updatable or not (default `false`)
  87020. * @param mesh the mesh the vertexData is applied to
  87021. * @param updatable when used and having the value true allows new data to update the vertexData
  87022. * @returns the VertexData
  87023. */
  87024. VertexData.prototype.applyToMesh = function (mesh, updatable) {
  87025. this._applyTo(mesh, updatable);
  87026. return this;
  87027. };
  87028. /**
  87029. * Associates the vertexData to the passed Geometry.
  87030. * Sets it as updatable or not (default `false`)
  87031. * @param geometry the geometry the vertexData is applied to
  87032. * @param updatable when used and having the value true allows new data to update the vertexData
  87033. * @returns VertexData
  87034. */
  87035. VertexData.prototype.applyToGeometry = function (geometry, updatable) {
  87036. this._applyTo(geometry, updatable);
  87037. return this;
  87038. };
  87039. /**
  87040. * Updates the associated mesh
  87041. * @param mesh the mesh to be updated
  87042. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87043. * @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
  87044. * @returns VertexData
  87045. */
  87046. VertexData.prototype.updateMesh = function (mesh) {
  87047. this._update(mesh);
  87048. return this;
  87049. };
  87050. /**
  87051. * Updates the associated geometry
  87052. * @param geometry the geometry to be updated
  87053. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87054. * @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
  87055. * @returns VertexData.
  87056. */
  87057. VertexData.prototype.updateGeometry = function (geometry) {
  87058. this._update(geometry);
  87059. return this;
  87060. };
  87061. VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
  87062. if (updatable === void 0) { updatable = false; }
  87063. if (this.positions) {
  87064. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updatable);
  87065. }
  87066. if (this.normals) {
  87067. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updatable);
  87068. }
  87069. if (this.tangents) {
  87070. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updatable);
  87071. }
  87072. if (this.uvs) {
  87073. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updatable);
  87074. }
  87075. if (this.uvs2) {
  87076. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updatable);
  87077. }
  87078. if (this.uvs3) {
  87079. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updatable);
  87080. }
  87081. if (this.uvs4) {
  87082. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updatable);
  87083. }
  87084. if (this.uvs5) {
  87085. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updatable);
  87086. }
  87087. if (this.uvs6) {
  87088. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updatable);
  87089. }
  87090. if (this.colors) {
  87091. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updatable);
  87092. }
  87093. if (this.matricesIndices) {
  87094. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updatable);
  87095. }
  87096. if (this.matricesWeights) {
  87097. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updatable);
  87098. }
  87099. if (this.matricesIndicesExtra) {
  87100. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
  87101. }
  87102. if (this.matricesWeightsExtra) {
  87103. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
  87104. }
  87105. if (this.indices) {
  87106. meshOrGeometry.setIndices(this.indices, null, updatable);
  87107. }
  87108. else {
  87109. meshOrGeometry.setIndices([], null);
  87110. }
  87111. return this;
  87112. };
  87113. VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
  87114. if (this.positions) {
  87115. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updateExtends, makeItUnique);
  87116. }
  87117. if (this.normals) {
  87118. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updateExtends, makeItUnique);
  87119. }
  87120. if (this.tangents) {
  87121. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updateExtends, makeItUnique);
  87122. }
  87123. if (this.uvs) {
  87124. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updateExtends, makeItUnique);
  87125. }
  87126. if (this.uvs2) {
  87127. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updateExtends, makeItUnique);
  87128. }
  87129. if (this.uvs3) {
  87130. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updateExtends, makeItUnique);
  87131. }
  87132. if (this.uvs4) {
  87133. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updateExtends, makeItUnique);
  87134. }
  87135. if (this.uvs5) {
  87136. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updateExtends, makeItUnique);
  87137. }
  87138. if (this.uvs6) {
  87139. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updateExtends, makeItUnique);
  87140. }
  87141. if (this.colors) {
  87142. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updateExtends, makeItUnique);
  87143. }
  87144. if (this.matricesIndices) {
  87145. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
  87146. }
  87147. if (this.matricesWeights) {
  87148. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
  87149. }
  87150. if (this.matricesIndicesExtra) {
  87151. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
  87152. }
  87153. if (this.matricesWeightsExtra) {
  87154. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
  87155. }
  87156. if (this.indices) {
  87157. meshOrGeometry.setIndices(this.indices, null);
  87158. }
  87159. return this;
  87160. };
  87161. /**
  87162. * Transforms each position and each normal of the vertexData according to the passed Matrix
  87163. * @param matrix the transforming matrix
  87164. * @returns the VertexData
  87165. */
  87166. VertexData.prototype.transform = function (matrix) {
  87167. var flip = matrix.m[0] * matrix.m[5] * matrix.m[10] < 0;
  87168. var transformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87169. var index;
  87170. if (this.positions) {
  87171. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87172. for (index = 0; index < this.positions.length; index += 3) {
  87173. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.positions, index, position);
  87174. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(position, matrix, transformed);
  87175. this.positions[index] = transformed.x;
  87176. this.positions[index + 1] = transformed.y;
  87177. this.positions[index + 2] = transformed.z;
  87178. }
  87179. }
  87180. if (this.normals) {
  87181. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87182. for (index = 0; index < this.normals.length; index += 3) {
  87183. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.normals, index, normal);
  87184. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(normal, matrix, transformed);
  87185. this.normals[index] = transformed.x;
  87186. this.normals[index + 1] = transformed.y;
  87187. this.normals[index + 2] = transformed.z;
  87188. }
  87189. }
  87190. if (this.tangents) {
  87191. var tangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  87192. var tangentTransformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  87193. for (index = 0; index < this.tangents.length; index += 4) {
  87194. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArrayToRef(this.tangents, index, tangent);
  87195. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].TransformNormalToRef(tangent, matrix, tangentTransformed);
  87196. this.tangents[index] = tangentTransformed.x;
  87197. this.tangents[index + 1] = tangentTransformed.y;
  87198. this.tangents[index + 2] = tangentTransformed.z;
  87199. this.tangents[index + 3] = tangentTransformed.w;
  87200. }
  87201. }
  87202. if (flip && this.indices) {
  87203. for (index = 0; index < this.indices.length; index += 3) {
  87204. var tmp = this.indices[index + 1];
  87205. this.indices[index + 1] = this.indices[index + 2];
  87206. this.indices[index + 2] = tmp;
  87207. }
  87208. }
  87209. return this;
  87210. };
  87211. /**
  87212. * Merges the passed VertexData into the current one
  87213. * @param other the VertexData to be merged into the current one
  87214. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  87215. * @returns the modified VertexData
  87216. */
  87217. VertexData.prototype.merge = function (other, use32BitsIndices) {
  87218. if (use32BitsIndices === void 0) { use32BitsIndices = false; }
  87219. this._validate();
  87220. other._validate();
  87221. if (!this.normals !== !other.normals ||
  87222. !this.tangents !== !other.tangents ||
  87223. !this.uvs !== !other.uvs ||
  87224. !this.uvs2 !== !other.uvs2 ||
  87225. !this.uvs3 !== !other.uvs3 ||
  87226. !this.uvs4 !== !other.uvs4 ||
  87227. !this.uvs5 !== !other.uvs5 ||
  87228. !this.uvs6 !== !other.uvs6 ||
  87229. !this.colors !== !other.colors ||
  87230. !this.matricesIndices !== !other.matricesIndices ||
  87231. !this.matricesWeights !== !other.matricesWeights ||
  87232. !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
  87233. !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
  87234. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  87235. }
  87236. if (other.indices) {
  87237. if (!this.indices) {
  87238. this.indices = [];
  87239. }
  87240. var offset = this.positions ? this.positions.length / 3 : 0;
  87241. var isSrcTypedArray = this.indices.BYTES_PER_ELEMENT !== undefined;
  87242. if (isSrcTypedArray) {
  87243. var len = this.indices.length + other.indices.length;
  87244. var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(len) : new Uint16Array(len);
  87245. temp.set(this.indices);
  87246. var decal = this.indices.length;
  87247. for (var index = 0; index < other.indices.length; index++) {
  87248. temp[decal + index] = other.indices[index] + offset;
  87249. }
  87250. this.indices = temp;
  87251. }
  87252. else {
  87253. for (var index = 0; index < other.indices.length; index++) {
  87254. this.indices.push(other.indices[index] + offset);
  87255. }
  87256. }
  87257. }
  87258. this.positions = this._mergeElement(this.positions, other.positions);
  87259. this.normals = this._mergeElement(this.normals, other.normals);
  87260. this.tangents = this._mergeElement(this.tangents, other.tangents);
  87261. this.uvs = this._mergeElement(this.uvs, other.uvs);
  87262. this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
  87263. this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
  87264. this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
  87265. this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
  87266. this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
  87267. this.colors = this._mergeElement(this.colors, other.colors);
  87268. this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
  87269. this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
  87270. this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
  87271. this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
  87272. return this;
  87273. };
  87274. VertexData.prototype._mergeElement = function (source, other) {
  87275. if (!source) {
  87276. return other;
  87277. }
  87278. if (!other) {
  87279. return source;
  87280. }
  87281. var len = other.length + source.length;
  87282. var isSrcTypedArray = source instanceof Float32Array;
  87283. var isOthTypedArray = other instanceof Float32Array;
  87284. // use non-loop method when the source is Float32Array
  87285. if (isSrcTypedArray) {
  87286. var ret32 = new Float32Array(len);
  87287. ret32.set(source);
  87288. ret32.set(other, source.length);
  87289. return ret32;
  87290. // source is number[], when other is also use concat
  87291. }
  87292. else if (!isOthTypedArray) {
  87293. return source.concat(other);
  87294. // source is a number[], but other is a Float32Array, loop required
  87295. }
  87296. else {
  87297. var ret = source.slice(0); // copy source to a separate array
  87298. for (var i = 0, len = other.length; i < len; i++) {
  87299. ret.push(other[i]);
  87300. }
  87301. return ret;
  87302. }
  87303. };
  87304. VertexData.prototype._validate = function () {
  87305. if (!this.positions) {
  87306. throw new Error("Positions are required");
  87307. }
  87308. var getElementCount = function (kind, values) {
  87309. var stride = _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].DeduceStride(kind);
  87310. if ((values.length % stride) !== 0) {
  87311. throw new Error("The " + kind + "s array count must be a multiple of " + stride);
  87312. }
  87313. return values.length / stride;
  87314. };
  87315. var positionsElementCount = getElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions);
  87316. var validateElementCount = function (kind, values) {
  87317. var elementCount = getElementCount(kind, values);
  87318. if (elementCount !== positionsElementCount) {
  87319. throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
  87320. }
  87321. };
  87322. if (this.normals) {
  87323. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals);
  87324. }
  87325. if (this.tangents) {
  87326. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents);
  87327. }
  87328. if (this.uvs) {
  87329. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs);
  87330. }
  87331. if (this.uvs2) {
  87332. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2);
  87333. }
  87334. if (this.uvs3) {
  87335. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3);
  87336. }
  87337. if (this.uvs4) {
  87338. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4);
  87339. }
  87340. if (this.uvs5) {
  87341. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5);
  87342. }
  87343. if (this.uvs6) {
  87344. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6);
  87345. }
  87346. if (this.colors) {
  87347. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors);
  87348. }
  87349. if (this.matricesIndices) {
  87350. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices);
  87351. }
  87352. if (this.matricesWeights) {
  87353. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights);
  87354. }
  87355. if (this.matricesIndicesExtra) {
  87356. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra);
  87357. }
  87358. if (this.matricesWeightsExtra) {
  87359. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra);
  87360. }
  87361. };
  87362. /**
  87363. * Serializes the VertexData
  87364. * @returns a serialized object
  87365. */
  87366. VertexData.prototype.serialize = function () {
  87367. var serializationObject = this.serialize();
  87368. if (this.positions) {
  87369. serializationObject.positions = this.positions;
  87370. }
  87371. if (this.normals) {
  87372. serializationObject.normals = this.normals;
  87373. }
  87374. if (this.tangents) {
  87375. serializationObject.tangents = this.tangents;
  87376. }
  87377. if (this.uvs) {
  87378. serializationObject.uvs = this.uvs;
  87379. }
  87380. if (this.uvs2) {
  87381. serializationObject.uvs2 = this.uvs2;
  87382. }
  87383. if (this.uvs3) {
  87384. serializationObject.uvs3 = this.uvs3;
  87385. }
  87386. if (this.uvs4) {
  87387. serializationObject.uvs4 = this.uvs4;
  87388. }
  87389. if (this.uvs5) {
  87390. serializationObject.uvs5 = this.uvs5;
  87391. }
  87392. if (this.uvs6) {
  87393. serializationObject.uvs6 = this.uvs6;
  87394. }
  87395. if (this.colors) {
  87396. serializationObject.colors = this.colors;
  87397. }
  87398. if (this.matricesIndices) {
  87399. serializationObject.matricesIndices = this.matricesIndices;
  87400. serializationObject.matricesIndices._isExpanded = true;
  87401. }
  87402. if (this.matricesWeights) {
  87403. serializationObject.matricesWeights = this.matricesWeights;
  87404. }
  87405. if (this.matricesIndicesExtra) {
  87406. serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
  87407. serializationObject.matricesIndicesExtra._isExpanded = true;
  87408. }
  87409. if (this.matricesWeightsExtra) {
  87410. serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
  87411. }
  87412. serializationObject.indices = this.indices;
  87413. return serializationObject;
  87414. };
  87415. // Statics
  87416. /**
  87417. * Extracts the vertexData from a mesh
  87418. * @param mesh the mesh from which to extract the VertexData
  87419. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  87420. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87421. * @returns the object VertexData associated to the passed mesh
  87422. */
  87423. VertexData.ExtractFromMesh = function (mesh, copyWhenShared, forceCopy) {
  87424. return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
  87425. };
  87426. /**
  87427. * Extracts the vertexData from the geometry
  87428. * @param geometry the geometry from which to extract the VertexData
  87429. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  87430. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87431. * @returns the object VertexData associated to the passed mesh
  87432. */
  87433. VertexData.ExtractFromGeometry = function (geometry, copyWhenShared, forceCopy) {
  87434. return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
  87435. };
  87436. VertexData._ExtractFrom = function (meshOrGeometry, copyWhenShared, forceCopy) {
  87437. var result = new VertexData();
  87438. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind)) {
  87439. result.positions = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, copyWhenShared, forceCopy);
  87440. }
  87441. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  87442. result.normals = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, copyWhenShared, forceCopy);
  87443. }
  87444. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind)) {
  87445. result.tangents = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, copyWhenShared, forceCopy);
  87446. }
  87447. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  87448. result.uvs = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, copyWhenShared, forceCopy);
  87449. }
  87450. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  87451. result.uvs2 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, copyWhenShared, forceCopy);
  87452. }
  87453. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind)) {
  87454. result.uvs3 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, copyWhenShared, forceCopy);
  87455. }
  87456. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind)) {
  87457. result.uvs4 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, copyWhenShared, forceCopy);
  87458. }
  87459. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind)) {
  87460. result.uvs5 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, copyWhenShared, forceCopy);
  87461. }
  87462. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind)) {
  87463. result.uvs6 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, copyWhenShared, forceCopy);
  87464. }
  87465. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind)) {
  87466. result.colors = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, copyWhenShared, forceCopy);
  87467. }
  87468. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind)) {
  87469. result.matricesIndices = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, copyWhenShared, forceCopy);
  87470. }
  87471. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind)) {
  87472. result.matricesWeights = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, copyWhenShared, forceCopy);
  87473. }
  87474. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind)) {
  87475. result.matricesIndicesExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, copyWhenShared, forceCopy);
  87476. }
  87477. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind)) {
  87478. result.matricesWeightsExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, copyWhenShared, forceCopy);
  87479. }
  87480. result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
  87481. return result;
  87482. };
  87483. /**
  87484. * Creates the VertexData for a Ribbon
  87485. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  87486. * * pathArray array of paths, each of which an array of successive Vector3
  87487. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  87488. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  87489. * * 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
  87490. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87491. * * 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)
  87492. * * 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)
  87493. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  87494. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  87495. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  87496. * @returns the VertexData of the ribbon
  87497. */
  87498. VertexData.CreateRibbon = function (options) {
  87499. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ribbonBuilder");
  87500. };
  87501. /**
  87502. * Creates the VertexData for a box
  87503. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87504. * * size sets the width, height and depth of the box to the value of size, optional default 1
  87505. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  87506. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  87507. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  87508. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87509. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87510. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87511. * * 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)
  87512. * * 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)
  87513. * @returns the VertexData of the box
  87514. */
  87515. VertexData.CreateBox = function (options) {
  87516. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("boxBuilder");
  87517. };
  87518. /**
  87519. * Creates the VertexData for an ellipsoid, defaults to a sphere
  87520. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87521. * * segments sets the number of horizontal strips optional, default 32
  87522. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  87523. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  87524. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  87525. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  87526. * * 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
  87527. * * 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
  87528. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87529. * * 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)
  87530. * * 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)
  87531. * @returns the VertexData of the ellipsoid
  87532. */
  87533. VertexData.CreateSphere = function (options) {
  87534. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("sphereBuilder");
  87535. };
  87536. /**
  87537. * Creates the VertexData for a cylinder, cone or prism
  87538. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87539. * * height sets the height (y direction) of the cylinder, optional, default 2
  87540. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  87541. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  87542. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  87543. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87544. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  87545. * * 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
  87546. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87547. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87548. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  87549. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  87550. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87551. * * 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)
  87552. * * 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)
  87553. * @returns the VertexData of the cylinder, cone or prism
  87554. */
  87555. VertexData.CreateCylinder = function (options) {
  87556. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("cylinderBuilder");
  87557. };
  87558. /**
  87559. * Creates the VertexData for a torus
  87560. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87561. * * diameter the diameter of the torus, optional default 1
  87562. * * thickness the diameter of the tube forming the torus, optional default 0.5
  87563. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87564. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87565. * * 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)
  87566. * * 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)
  87567. * @returns the VertexData of the torus
  87568. */
  87569. VertexData.CreateTorus = function (options) {
  87570. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusBuilder");
  87571. };
  87572. /**
  87573. * Creates the VertexData of the LineSystem
  87574. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  87575. * - lines an array of lines, each line being an array of successive Vector3
  87576. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  87577. * @returns the VertexData of the LineSystem
  87578. */
  87579. VertexData.CreateLineSystem = function (options) {
  87580. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  87581. };
  87582. /**
  87583. * Create the VertexData for a DashedLines
  87584. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  87585. * - points an array successive Vector3
  87586. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  87587. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  87588. * - dashNb the intended total number of dashes, optional, default 200
  87589. * @returns the VertexData for the DashedLines
  87590. */
  87591. VertexData.CreateDashedLines = function (options) {
  87592. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  87593. };
  87594. /**
  87595. * Creates the VertexData for a Ground
  87596. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87597. * - width the width (x direction) of the ground, optional, default 1
  87598. * - height the height (z direction) of the ground, optional, default 1
  87599. * - subdivisions the number of subdivisions per side, optional, default 1
  87600. * @returns the VertexData of the Ground
  87601. */
  87602. VertexData.CreateGround = function (options) {
  87603. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  87604. };
  87605. /**
  87606. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  87607. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87608. * * xmin the ground minimum X coordinate, optional, default -1
  87609. * * zmin the ground minimum Z coordinate, optional, default -1
  87610. * * xmax the ground maximum X coordinate, optional, default 1
  87611. * * zmax the ground maximum Z coordinate, optional, default 1
  87612. * * 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}
  87613. * * 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}
  87614. * @returns the VertexData of the TiledGround
  87615. */
  87616. VertexData.CreateTiledGround = function (options) {
  87617. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  87618. };
  87619. /**
  87620. * Creates the VertexData of the Ground designed from a heightmap
  87621. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  87622. * * width the width (x direction) of the ground
  87623. * * height the height (z direction) of the ground
  87624. * * subdivisions the number of subdivisions per side
  87625. * * minHeight the minimum altitude on the ground, optional, default 0
  87626. * * maxHeight the maximum altitude on the ground, optional default 1
  87627. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  87628. * * buffer the array holding the image color data
  87629. * * bufferWidth the width of image
  87630. * * bufferHeight the height of image
  87631. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  87632. * @returns the VertexData of the Ground designed from a heightmap
  87633. */
  87634. VertexData.CreateGroundFromHeightMap = function (options) {
  87635. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  87636. };
  87637. /**
  87638. * Creates the VertexData for a Plane
  87639. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  87640. * * size sets the width and height of the plane to the value of size, optional default 1
  87641. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  87642. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  87643. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87644. * * 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)
  87645. * * 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)
  87646. * @returns the VertexData of the box
  87647. */
  87648. VertexData.CreatePlane = function (options) {
  87649. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("planeBuilder");
  87650. };
  87651. /**
  87652. * Creates the VertexData of the Disc or regular Polygon
  87653. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  87654. * * radius the radius of the disc, optional default 0.5
  87655. * * tessellation the number of polygon sides, optional, default 64
  87656. * * 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
  87657. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87658. * * 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)
  87659. * * 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)
  87660. * @returns the VertexData of the box
  87661. */
  87662. VertexData.CreateDisc = function (options) {
  87663. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("discBuilder");
  87664. };
  87665. /**
  87666. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  87667. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  87668. * @param polygon a mesh built from polygonTriangulation.build()
  87669. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87670. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87671. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87672. * @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)
  87673. * @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)
  87674. * @returns the VertexData of the Polygon
  87675. */
  87676. VertexData.CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  87677. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polygonBuilder");
  87678. };
  87679. /**
  87680. * Creates the VertexData of the IcoSphere
  87681. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  87682. * * radius the radius of the IcoSphere, optional default 1
  87683. * * radiusX allows stretching in the x direction, optional, default radius
  87684. * * radiusY allows stretching in the y direction, optional, default radius
  87685. * * radiusZ allows stretching in the z direction, optional, default radius
  87686. * * flat when true creates a flat shaded mesh, optional, default true
  87687. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87688. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87689. * * 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)
  87690. * * 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)
  87691. * @returns the VertexData of the IcoSphere
  87692. */
  87693. VertexData.CreateIcoSphere = function (options) {
  87694. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("icoSphereBuilder");
  87695. };
  87696. // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
  87697. /**
  87698. * Creates the VertexData for a Polyhedron
  87699. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  87700. * * type provided types are:
  87701. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  87702. * * 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)
  87703. * * size the size of the IcoSphere, optional default 1
  87704. * * sizeX allows stretching in the x direction, optional, default size
  87705. * * sizeY allows stretching in the y direction, optional, default size
  87706. * * sizeZ allows stretching in the z direction, optional, default size
  87707. * * 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
  87708. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87709. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87710. * * flat when true creates a flat shaded mesh, optional, default true
  87711. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87712. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87713. * * 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)
  87714. * * 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)
  87715. * @returns the VertexData of the Polyhedron
  87716. */
  87717. VertexData.CreatePolyhedron = function (options) {
  87718. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polyhedronBuilder");
  87719. };
  87720. // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  87721. /**
  87722. * Creates the VertexData for a TorusKnot
  87723. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  87724. * * radius the radius of the torus knot, optional, default 2
  87725. * * tube the thickness of the tube, optional, default 0.5
  87726. * * radialSegments the number of sides on each tube segments, optional, default 32
  87727. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  87728. * * p the number of windings around the z axis, optional, default 2
  87729. * * q the number of windings around the x axis, optional, default 3
  87730. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87731. * * 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)
  87732. * * 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)
  87733. * @returns the VertexData of the Torus Knot
  87734. */
  87735. VertexData.CreateTorusKnot = function (options) {
  87736. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusKnotBuilder");
  87737. };
  87738. // Tools
  87739. /**
  87740. * Compute normals for given positions and indices
  87741. * @param positions an array of vertex positions, [...., x, y, z, ......]
  87742. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  87743. * @param normals an array of vertex normals, [...., x, y, z, ......]
  87744. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  87745. * * facetNormals : optional array of facet normals (vector3)
  87746. * * facetPositions : optional array of facet positions (vector3)
  87747. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  87748. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  87749. * * bInfo : optional bounding info, required for facetPartitioning computation
  87750. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  87751. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  87752. * * useRightHandedSystem: optional boolean to for right handed system computation
  87753. * * depthSort : optional boolean to enable the facet depth sort computation
  87754. * * distanceTo : optional Vector3 to compute the facet depth from this location
  87755. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  87756. */
  87757. VertexData.ComputeNormals = function (positions, indices, normals, options) {
  87758. // temporary scalar variables
  87759. var index = 0; // facet index
  87760. var p1p2x = 0.0; // p1p2 vector x coordinate
  87761. var p1p2y = 0.0; // p1p2 vector y coordinate
  87762. var p1p2z = 0.0; // p1p2 vector z coordinate
  87763. var p3p2x = 0.0; // p3p2 vector x coordinate
  87764. var p3p2y = 0.0; // p3p2 vector y coordinate
  87765. var p3p2z = 0.0; // p3p2 vector z coordinate
  87766. var faceNormalx = 0.0; // facet normal x coordinate
  87767. var faceNormaly = 0.0; // facet normal y coordinate
  87768. var faceNormalz = 0.0; // facet normal z coordinate
  87769. var length = 0.0; // facet normal length before normalization
  87770. var v1x = 0; // vector1 x index in the positions array
  87771. var v1y = 0; // vector1 y index in the positions array
  87772. var v1z = 0; // vector1 z index in the positions array
  87773. var v2x = 0; // vector2 x index in the positions array
  87774. var v2y = 0; // vector2 y index in the positions array
  87775. var v2z = 0; // vector2 z index in the positions array
  87776. var v3x = 0; // vector3 x index in the positions array
  87777. var v3y = 0; // vector3 y index in the positions array
  87778. var v3z = 0; // vector3 z index in the positions array
  87779. var computeFacetNormals = false;
  87780. var computeFacetPositions = false;
  87781. var computeFacetPartitioning = false;
  87782. var computeDepthSort = false;
  87783. var faceNormalSign = 1;
  87784. var ratio = 0;
  87785. var distanceTo = null;
  87786. if (options) {
  87787. computeFacetNormals = (options.facetNormals) ? true : false;
  87788. computeFacetPositions = (options.facetPositions) ? true : false;
  87789. computeFacetPartitioning = (options.facetPartitioning) ? true : false;
  87790. faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
  87791. ratio = options.ratio || 0;
  87792. computeDepthSort = (options.depthSort) ? true : false;
  87793. distanceTo = (options.distanceTo);
  87794. if (computeDepthSort) {
  87795. if (distanceTo === undefined) {
  87796. distanceTo = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87797. }
  87798. var depthSortedFacets = options.depthSortedFacets;
  87799. }
  87800. }
  87801. // facetPartitioning reinit if needed
  87802. var xSubRatio = 0;
  87803. var ySubRatio = 0;
  87804. var zSubRatio = 0;
  87805. var subSq = 0;
  87806. if (computeFacetPartitioning && options && options.bbSize) {
  87807. var ox = 0; // X partitioning index for facet position
  87808. var oy = 0; // Y partinioning index for facet position
  87809. var oz = 0; // Z partinioning index for facet position
  87810. var b1x = 0; // X partitioning index for facet v1 vertex
  87811. var b1y = 0; // Y partitioning index for facet v1 vertex
  87812. var b1z = 0; // z partitioning index for facet v1 vertex
  87813. var b2x = 0; // X partitioning index for facet v2 vertex
  87814. var b2y = 0; // Y partitioning index for facet v2 vertex
  87815. var b2z = 0; // Z partitioning index for facet v2 vertex
  87816. var b3x = 0; // X partitioning index for facet v3 vertex
  87817. var b3y = 0; // Y partitioning index for facet v3 vertex
  87818. var b3z = 0; // Z partitioning index for facet v3 vertex
  87819. var block_idx_o = 0; // facet barycenter block index
  87820. var block_idx_v1 = 0; // v1 vertex block index
  87821. var block_idx_v2 = 0; // v2 vertex block index
  87822. var block_idx_v3 = 0; // v3 vertex block index
  87823. var bbSizeMax = (options.bbSize.x > options.bbSize.y) ? options.bbSize.x : options.bbSize.y;
  87824. bbSizeMax = (bbSizeMax > options.bbSize.z) ? bbSizeMax : options.bbSize.z;
  87825. xSubRatio = options.subDiv.X * ratio / options.bbSize.x;
  87826. ySubRatio = options.subDiv.Y * ratio / options.bbSize.y;
  87827. zSubRatio = options.subDiv.Z * ratio / options.bbSize.z;
  87828. subSq = options.subDiv.max * options.subDiv.max;
  87829. options.facetPartitioning.length = 0;
  87830. }
  87831. // reset the normals
  87832. for (index = 0; index < positions.length; index++) {
  87833. normals[index] = 0.0;
  87834. }
  87835. // Loop : 1 indice triplet = 1 facet
  87836. var nbFaces = (indices.length / 3) | 0;
  87837. for (index = 0; index < nbFaces; index++) {
  87838. // get the indexes of the coordinates of each vertex of the facet
  87839. v1x = indices[index * 3] * 3;
  87840. v1y = v1x + 1;
  87841. v1z = v1x + 2;
  87842. v2x = indices[index * 3 + 1] * 3;
  87843. v2y = v2x + 1;
  87844. v2z = v2x + 2;
  87845. v3x = indices[index * 3 + 2] * 3;
  87846. v3y = v3x + 1;
  87847. v3z = v3x + 2;
  87848. p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
  87849. p1p2y = positions[v1y] - positions[v2y];
  87850. p1p2z = positions[v1z] - positions[v2z];
  87851. p3p2x = positions[v3x] - positions[v2x];
  87852. p3p2y = positions[v3y] - positions[v2y];
  87853. p3p2z = positions[v3z] - positions[v2z];
  87854. // compute the face normal with the cross product
  87855. faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
  87856. faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
  87857. faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
  87858. // normalize this normal and store it in the array facetData
  87859. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  87860. length = (length === 0) ? 1.0 : length;
  87861. faceNormalx /= length;
  87862. faceNormaly /= length;
  87863. faceNormalz /= length;
  87864. if (computeFacetNormals && options) {
  87865. options.facetNormals[index].x = faceNormalx;
  87866. options.facetNormals[index].y = faceNormaly;
  87867. options.facetNormals[index].z = faceNormalz;
  87868. }
  87869. if (computeFacetPositions && options) {
  87870. // compute and the facet barycenter coordinates in the array facetPositions
  87871. options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
  87872. options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
  87873. options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
  87874. }
  87875. if (computeFacetPartitioning && options) {
  87876. // store the facet indexes in arrays in the main facetPartitioning array :
  87877. // compute each facet vertex (+ facet barycenter) index in the partiniong array
  87878. ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
  87879. oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
  87880. oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
  87881. b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  87882. b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  87883. b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  87884. b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  87885. b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  87886. b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  87887. b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  87888. b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  87889. b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  87890. block_idx_v1 = b1x + options.subDiv.max * b1y + subSq * b1z;
  87891. block_idx_v2 = b2x + options.subDiv.max * b2y + subSq * b2z;
  87892. block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
  87893. block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
  87894. options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
  87895. options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
  87896. options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
  87897. options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
  87898. // push each facet index in each block containing the vertex
  87899. options.facetPartitioning[block_idx_v1].push(index);
  87900. if (block_idx_v2 != block_idx_v1) {
  87901. options.facetPartitioning[block_idx_v2].push(index);
  87902. }
  87903. if (!(block_idx_v3 == block_idx_v2 || block_idx_v3 == block_idx_v1)) {
  87904. options.facetPartitioning[block_idx_v3].push(index);
  87905. }
  87906. if (!(block_idx_o == block_idx_v1 || block_idx_o == block_idx_v2 || block_idx_o == block_idx_v3)) {
  87907. options.facetPartitioning[block_idx_o].push(index);
  87908. }
  87909. }
  87910. if (computeDepthSort && options && options.facetPositions) {
  87911. var dsf = depthSortedFacets[index];
  87912. dsf.ind = index * 3;
  87913. dsf.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(options.facetPositions[index], distanceTo);
  87914. }
  87915. // compute the normals anyway
  87916. normals[v1x] += faceNormalx; // accumulate all the normals per face
  87917. normals[v1y] += faceNormaly;
  87918. normals[v1z] += faceNormalz;
  87919. normals[v2x] += faceNormalx;
  87920. normals[v2y] += faceNormaly;
  87921. normals[v2z] += faceNormalz;
  87922. normals[v3x] += faceNormalx;
  87923. normals[v3y] += faceNormaly;
  87924. normals[v3z] += faceNormalz;
  87925. }
  87926. // last normalization of each normal
  87927. for (index = 0; index < normals.length / 3; index++) {
  87928. faceNormalx = normals[index * 3];
  87929. faceNormaly = normals[index * 3 + 1];
  87930. faceNormalz = normals[index * 3 + 2];
  87931. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  87932. length = (length === 0) ? 1.0 : length;
  87933. faceNormalx /= length;
  87934. faceNormaly /= length;
  87935. faceNormalz /= length;
  87936. normals[index * 3] = faceNormalx;
  87937. normals[index * 3 + 1] = faceNormaly;
  87938. normals[index * 3 + 2] = faceNormalz;
  87939. }
  87940. };
  87941. /** @hidden */
  87942. VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
  87943. var li = indices.length;
  87944. var ln = normals.length;
  87945. var i;
  87946. var n;
  87947. sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
  87948. switch (sideOrientation) {
  87949. case VertexData.FRONTSIDE:
  87950. // nothing changed
  87951. break;
  87952. case VertexData.BACKSIDE:
  87953. var tmp;
  87954. // indices
  87955. for (i = 0; i < li; i += 3) {
  87956. tmp = indices[i];
  87957. indices[i] = indices[i + 2];
  87958. indices[i + 2] = tmp;
  87959. }
  87960. // normals
  87961. for (n = 0; n < ln; n++) {
  87962. normals[n] = -normals[n];
  87963. }
  87964. break;
  87965. case VertexData.DOUBLESIDE:
  87966. // positions
  87967. var lp = positions.length;
  87968. var l = lp / 3;
  87969. for (var p = 0; p < lp; p++) {
  87970. positions[lp + p] = positions[p];
  87971. }
  87972. // indices
  87973. for (i = 0; i < li; i += 3) {
  87974. indices[i + li] = indices[i + 2] + l;
  87975. indices[i + 1 + li] = indices[i + 1] + l;
  87976. indices[i + 2 + li] = indices[i] + l;
  87977. }
  87978. // normals
  87979. for (n = 0; n < ln; n++) {
  87980. normals[ln + n] = -normals[n];
  87981. }
  87982. // uvs
  87983. var lu = uvs.length;
  87984. var u = 0;
  87985. for (u = 0; u < lu; u++) {
  87986. uvs[u + lu] = uvs[u];
  87987. }
  87988. frontUVs = frontUVs ? frontUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  87989. backUVs = backUVs ? backUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  87990. u = 0;
  87991. for (i = 0; i < lu / 2; i++) {
  87992. uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
  87993. uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
  87994. uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
  87995. uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
  87996. u += 2;
  87997. }
  87998. break;
  87999. }
  88000. };
  88001. /**
  88002. * Applies VertexData created from the imported parameters to the geometry
  88003. * @param parsedVertexData the parsed data from an imported file
  88004. * @param geometry the geometry to apply the VertexData to
  88005. */
  88006. VertexData.ImportVertexData = function (parsedVertexData, geometry) {
  88007. var vertexData = new VertexData();
  88008. // positions
  88009. var positions = parsedVertexData.positions;
  88010. if (positions) {
  88011. vertexData.set(positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  88012. }
  88013. // normals
  88014. var normals = parsedVertexData.normals;
  88015. if (normals) {
  88016. vertexData.set(normals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  88017. }
  88018. // tangents
  88019. var tangents = parsedVertexData.tangents;
  88020. if (tangents) {
  88021. vertexData.set(tangents, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind);
  88022. }
  88023. // uvs
  88024. var uvs = parsedVertexData.uvs;
  88025. if (uvs) {
  88026. vertexData.set(uvs, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  88027. }
  88028. // uv2s
  88029. var uv2s = parsedVertexData.uv2s;
  88030. if (uv2s) {
  88031. vertexData.set(uv2s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  88032. }
  88033. // uv3s
  88034. var uv3s = parsedVertexData.uv3s;
  88035. if (uv3s) {
  88036. vertexData.set(uv3s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind);
  88037. }
  88038. // uv4s
  88039. var uv4s = parsedVertexData.uv4s;
  88040. if (uv4s) {
  88041. vertexData.set(uv4s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind);
  88042. }
  88043. // uv5s
  88044. var uv5s = parsedVertexData.uv5s;
  88045. if (uv5s) {
  88046. vertexData.set(uv5s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind);
  88047. }
  88048. // uv6s
  88049. var uv6s = parsedVertexData.uv6s;
  88050. if (uv6s) {
  88051. vertexData.set(uv6s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind);
  88052. }
  88053. // colors
  88054. var colors = parsedVertexData.colors;
  88055. if (colors) {
  88056. vertexData.set(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(colors, positions.length / 3), _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  88057. }
  88058. // matricesIndices
  88059. var matricesIndices = parsedVertexData.matricesIndices;
  88060. if (matricesIndices) {
  88061. vertexData.set(matricesIndices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  88062. }
  88063. // matricesWeights
  88064. var matricesWeights = parsedVertexData.matricesWeights;
  88065. if (matricesWeights) {
  88066. vertexData.set(matricesWeights, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  88067. }
  88068. // indices
  88069. var indices = parsedVertexData.indices;
  88070. if (indices) {
  88071. vertexData.indices = indices;
  88072. }
  88073. geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
  88074. };
  88075. /**
  88076. * Mesh side orientation : usually the external or front surface
  88077. */
  88078. VertexData.FRONTSIDE = 0;
  88079. /**
  88080. * Mesh side orientation : usually the internal or back surface
  88081. */
  88082. VertexData.BACKSIDE = 1;
  88083. /**
  88084. * Mesh side orientation : both internal and external or front and back surfaces
  88085. */
  88086. VertexData.DOUBLESIDE = 2;
  88087. /**
  88088. * Mesh side orientation : by default, `FRONTSIDE`
  88089. */
  88090. VertexData.DEFAULTSIDE = 0;
  88091. return VertexData;
  88092. }());
  88093. /***/ }),
  88094. /***/ "./Meshes/meshBuilder.ts":
  88095. /*!*******************************!*\
  88096. !*** ./Meshes/meshBuilder.ts ***!
  88097. \*******************************/
  88098. /*! exports provided: MeshBuilder */
  88099. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88100. "use strict";
  88101. __webpack_require__.r(__webpack_exports__);
  88102. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return MeshBuilder; });
  88103. /* harmony import */ var _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Builders/ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  88104. /* harmony import */ var _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  88105. /* harmony import */ var _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  88106. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  88107. /* harmony import */ var _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  88108. /* harmony import */ var _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  88109. /* harmony import */ var _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Builders/torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  88110. /* harmony import */ var _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  88111. /* harmony import */ var _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Builders/polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  88112. /* harmony import */ var _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  88113. /* harmony import */ var _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Builders/latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  88114. /* harmony import */ var _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  88115. /* harmony import */ var _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  88116. /* harmony import */ var _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Builders/tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  88117. /* harmony import */ var _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  88118. /* harmony import */ var _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Builders/icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  88119. /* harmony import */ var _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  88120. /**
  88121. * Class containing static functions to help procedurally build meshes
  88122. */
  88123. var MeshBuilder = /** @class */ (function () {
  88124. function MeshBuilder() {
  88125. }
  88126. /**
  88127. * Creates a box mesh
  88128. * * The parameter `size` sets the size (float) of each box side (default 1)
  88129. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  88130. * * 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)
  88131. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  88132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88133. * * 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
  88134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88135. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  88136. * @param name defines the name of the mesh
  88137. * @param options defines the options used to create the mesh
  88138. * @param scene defines the hosting scene
  88139. * @returns the box mesh
  88140. */
  88141. MeshBuilder.CreateBox = function (name, options, scene) {
  88142. if (scene === void 0) { scene = null; }
  88143. return _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(name, options, scene);
  88144. };
  88145. /**
  88146. * Creates a sphere mesh
  88147. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  88148. * * 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`)
  88149. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  88150. * * 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
  88151. * * 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)
  88152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88153. * * 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
  88154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88155. * @param name defines the name of the mesh
  88156. * @param options defines the options used to create the mesh
  88157. * @param scene defines the hosting scene
  88158. * @returns the sphere mesh
  88159. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  88160. */
  88161. MeshBuilder.CreateSphere = function (name, options, scene) {
  88162. return _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere(name, options, scene);
  88163. };
  88164. /**
  88165. * Creates a plane polygonal mesh. By default, this is a disc
  88166. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  88167. * * 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
  88168. * * 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
  88169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88170. * * 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
  88171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88172. * @param name defines the name of the mesh
  88173. * @param options defines the options used to create the mesh
  88174. * @param scene defines the hosting scene
  88175. * @returns the plane polygonal mesh
  88176. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  88177. */
  88178. MeshBuilder.CreateDisc = function (name, options, scene) {
  88179. if (scene === void 0) { scene = null; }
  88180. return _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"].CreateDisc(name, options, scene);
  88181. };
  88182. /**
  88183. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  88184. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  88185. * * 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`)
  88186. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  88187. * * 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
  88188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  88190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88191. * @param name defines the name of the mesh
  88192. * @param options defines the options used to create the mesh
  88193. * @param scene defines the hosting scene
  88194. * @returns the icosahedron mesh
  88195. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  88196. */
  88197. MeshBuilder.CreateIcoSphere = function (name, options, scene) {
  88198. return _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"].CreateIcoSphere(name, options, scene);
  88199. };
  88200. /**
  88201. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  88202. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  88203. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  88204. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  88205. * * 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
  88206. * * 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
  88207. * * 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
  88208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88209. * * 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
  88210. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88211. * * 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
  88212. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  88213. * * 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
  88214. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  88215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88216. * @param name defines the name of the mesh
  88217. * @param options defines the options used to create the mesh
  88218. * @param scene defines the hosting scene
  88219. * @returns the ribbon mesh
  88220. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  88221. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88222. */
  88223. MeshBuilder.CreateRibbon = function (name, options, scene) {
  88224. if (scene === void 0) { scene = null; }
  88225. return _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"].CreateRibbon(name, options, scene);
  88226. };
  88227. /**
  88228. * Creates a cylinder or a cone mesh
  88229. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  88230. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  88231. * * 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.
  88232. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  88233. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  88234. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  88235. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  88236. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  88237. * * 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).
  88238. * * 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
  88239. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  88240. * * 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
  88241. * * 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.
  88242. * * If `enclose` is false, a ring surface is one element.
  88243. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  88244. * * 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
  88245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88246. * * 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
  88247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88248. * @param name defines the name of the mesh
  88249. * @param options defines the options used to create the mesh
  88250. * @param scene defines the hosting scene
  88251. * @returns the cylinder mesh
  88252. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  88253. */
  88254. MeshBuilder.CreateCylinder = function (name, options, scene) {
  88255. return _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder(name, options, scene);
  88256. };
  88257. /**
  88258. * Creates a torus mesh
  88259. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  88260. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  88261. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  88262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88263. * * 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
  88264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88265. * @param name defines the name of the mesh
  88266. * @param options defines the options used to create the mesh
  88267. * @param scene defines the hosting scene
  88268. * @returns the torus mesh
  88269. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  88270. */
  88271. MeshBuilder.CreateTorus = function (name, options, scene) {
  88272. return _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"].CreateTorus(name, options, scene);
  88273. };
  88274. /**
  88275. * Creates a torus knot mesh
  88276. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  88277. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  88278. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  88279. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  88280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88281. * * 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
  88282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88283. * @param name defines the name of the mesh
  88284. * @param options defines the options used to create the mesh
  88285. * @param scene defines the hosting scene
  88286. * @returns the torus knot mesh
  88287. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  88288. */
  88289. MeshBuilder.CreateTorusKnot = function (name, options, scene) {
  88290. return _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"].CreateTorusKnot(name, options, scene);
  88291. };
  88292. /**
  88293. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  88294. * * 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
  88295. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  88296. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  88297. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  88298. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  88299. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  88300. * * 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
  88301. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  88302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88303. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  88304. * @param name defines the name of the new line system
  88305. * @param options defines the options used to create the line system
  88306. * @param scene defines the hosting scene
  88307. * @returns a new line system mesh
  88308. */
  88309. MeshBuilder.CreateLineSystem = function (name, options, scene) {
  88310. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLineSystem(name, options, scene);
  88311. };
  88312. /**
  88313. * Creates a line mesh
  88314. * 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
  88315. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  88316. * * The parameter `points` is an array successive Vector3
  88317. * * 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
  88318. * * The optional parameter `colors` is an array of successive Color4, one per line point
  88319. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  88320. * * When updating an instance, remember that only point positions can change, not the number of points
  88321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88322. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  88323. * @param name defines the name of the new line system
  88324. * @param options defines the options used to create the line system
  88325. * @param scene defines the hosting scene
  88326. * @returns a new line mesh
  88327. */
  88328. MeshBuilder.CreateLines = function (name, options, scene) {
  88329. if (scene === void 0) { scene = null; }
  88330. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines(name, options, scene);
  88331. };
  88332. /**
  88333. * Creates a dashed line mesh
  88334. * * 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
  88335. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  88336. * * The parameter `points` is an array successive Vector3
  88337. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  88338. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  88339. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  88340. * * 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
  88341. * * When updating an instance, remember that only point positions can change, not the number of points
  88342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88343. * @param name defines the name of the mesh
  88344. * @param options defines the options used to create the mesh
  88345. * @param scene defines the hosting scene
  88346. * @returns the dashed line mesh
  88347. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  88348. */
  88349. MeshBuilder.CreateDashedLines = function (name, options, scene) {
  88350. if (scene === void 0) { scene = null; }
  88351. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateDashedLines(name, options, scene);
  88352. };
  88353. /**
  88354. * 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.
  88355. * * 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.
  88356. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  88357. * * 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.
  88358. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  88359. * * 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
  88360. * * 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
  88361. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  88362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88363. * * 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
  88364. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  88365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88366. * @param name defines the name of the mesh
  88367. * @param options defines the options used to create the mesh
  88368. * @param scene defines the hosting scene
  88369. * @returns the extruded shape mesh
  88370. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88371. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88372. */
  88373. MeshBuilder.ExtrudeShape = function (name, options, scene) {
  88374. if (scene === void 0) { scene = null; }
  88375. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShape(name, options, scene);
  88376. };
  88377. /**
  88378. * Creates an custom extruded shape mesh.
  88379. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  88380. * * 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.
  88381. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  88382. * * 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
  88383. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  88384. * * 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
  88385. * * It must returns a float value that will be the scale value applied to the shape on each path point
  88386. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  88387. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  88388. * * 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
  88389. * * 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
  88390. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  88391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  88393. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88395. * @param name defines the name of the mesh
  88396. * @param options defines the options used to create the mesh
  88397. * @param scene defines the hosting scene
  88398. * @returns the custom extruded shape mesh
  88399. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  88400. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88401. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88402. */
  88403. MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  88404. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShapeCustom(name, options, scene);
  88405. };
  88406. /**
  88407. * Creates lathe mesh.
  88408. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  88409. * * 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
  88410. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  88411. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  88412. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  88413. * * 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
  88414. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  88415. * * 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
  88416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88417. * * 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
  88418. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88420. * @param name defines the name of the mesh
  88421. * @param options defines the options used to create the mesh
  88422. * @param scene defines the hosting scene
  88423. * @returns the lathe mesh
  88424. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  88425. */
  88426. MeshBuilder.CreateLathe = function (name, options, scene) {
  88427. return _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"].CreateLathe(name, options, scene);
  88428. };
  88429. /**
  88430. * Creates a plane mesh
  88431. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  88432. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  88433. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  88434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88435. * * 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
  88436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88437. * @param name defines the name of the mesh
  88438. * @param options defines the options used to create the mesh
  88439. * @param scene defines the hosting scene
  88440. * @returns the plane mesh
  88441. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  88442. */
  88443. MeshBuilder.CreatePlane = function (name, options, scene) {
  88444. return _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"].CreatePlane(name, options, scene);
  88445. };
  88446. /**
  88447. * Creates a ground mesh
  88448. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  88449. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  88450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88451. * @param name defines the name of the mesh
  88452. * @param options defines the options used to create the mesh
  88453. * @param scene defines the hosting scene
  88454. * @returns the ground mesh
  88455. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  88456. */
  88457. MeshBuilder.CreateGround = function (name, options, scene) {
  88458. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGround(name, options, scene);
  88459. };
  88460. /**
  88461. * Creates a tiled ground mesh
  88462. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  88463. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  88464. * * 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
  88465. * * 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
  88466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88467. * @param name defines the name of the mesh
  88468. * @param options defines the options used to create the mesh
  88469. * @param scene defines the hosting scene
  88470. * @returns the tiled ground mesh
  88471. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  88472. */
  88473. MeshBuilder.CreateTiledGround = function (name, options, scene) {
  88474. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateTiledGround(name, options, scene);
  88475. };
  88476. /**
  88477. * Creates a ground mesh from a height map
  88478. * * The parameter `url` sets the URL of the height map image resource.
  88479. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  88480. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  88481. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  88482. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  88483. * * 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.
  88484. * * 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).
  88485. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  88486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88487. * @param name defines the name of the mesh
  88488. * @param url defines the url to the height map
  88489. * @param options defines the options used to create the mesh
  88490. * @param scene defines the hosting scene
  88491. * @returns the ground mesh
  88492. * @see https://doc.babylonjs.com/babylon101/height_map
  88493. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  88494. */
  88495. MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  88496. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGroundFromHeightMap(name, url, options, scene);
  88497. };
  88498. /**
  88499. * Creates a polygon mesh
  88500. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  88501. * * 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
  88502. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88504. * * 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)
  88505. * * Remember you can only change the shape positions, not their number when updating a polygon
  88506. * @param name defines the name of the mesh
  88507. * @param options defines the options used to create the mesh
  88508. * @param scene defines the hosting scene
  88509. * @param earcutInjection can be used to inject your own earcut reference
  88510. * @returns the polygon mesh
  88511. */
  88512. MeshBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  88513. if (earcutInjection === void 0) { earcutInjection = earcut; }
  88514. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].CreatePolygon(name, options, scene, earcutInjection);
  88515. };
  88516. /**
  88517. * Creates an extruded polygon mesh, with depth in the Y direction.
  88518. * * 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)
  88519. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  88520. * @param name defines the name of the mesh
  88521. * @param options defines the options used to create the mesh
  88522. * @param scene defines the hosting scene
  88523. * @param earcutInjection can be used to inject your own earcut reference
  88524. * @returns the polygon mesh
  88525. */
  88526. MeshBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  88527. if (earcutInjection === void 0) { earcutInjection = earcut; }
  88528. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].ExtrudePolygon(name, options, scene, earcutInjection);
  88529. };
  88530. /**
  88531. * Creates a tube mesh.
  88532. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  88533. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  88534. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  88535. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  88536. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  88537. * * 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)
  88538. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  88539. * * 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
  88540. * * 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
  88541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88542. * * 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
  88543. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88545. * @param name defines the name of the mesh
  88546. * @param options defines the options used to create the mesh
  88547. * @param scene defines the hosting scene
  88548. * @returns the tube mesh
  88549. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88550. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  88551. */
  88552. MeshBuilder.CreateTube = function (name, options, scene) {
  88553. return _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"].CreateTube(name, options, scene);
  88554. };
  88555. /**
  88556. * Creates a polyhedron mesh
  88557. * * 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
  88558. * * The parameter `size` (positive float, default 1) sets the polygon size
  88559. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  88560. * * 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`
  88561. * * 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
  88562. * * 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)`)
  88563. * * 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
  88564. * * 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
  88565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88566. * * 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
  88567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88568. * @param name defines the name of the mesh
  88569. * @param options defines the options used to create the mesh
  88570. * @param scene defines the hosting scene
  88571. * @returns the polyhedron mesh
  88572. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  88573. */
  88574. MeshBuilder.CreatePolyhedron = function (name, options, scene) {
  88575. return _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"].CreatePolyhedron(name, options, scene);
  88576. };
  88577. /**
  88578. * Creates a decal mesh.
  88579. * 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
  88580. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  88581. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  88582. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  88583. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  88584. * @param name defines the name of the mesh
  88585. * @param sourceMesh defines the mesh where the decal must be applied
  88586. * @param options defines the options used to create the mesh
  88587. * @param scene defines the hosting scene
  88588. * @returns the decal mesh
  88589. * @see https://doc.babylonjs.com/how_to/decals
  88590. */
  88591. MeshBuilder.CreateDecal = function (name, sourceMesh, options) {
  88592. return _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"].CreateDecal(name, sourceMesh, options);
  88593. };
  88594. return MeshBuilder;
  88595. }());
  88596. /***/ }),
  88597. /***/ "./Meshes/meshSimplification.ts":
  88598. /*!**************************************!*\
  88599. !*** ./Meshes/meshSimplification.ts ***!
  88600. \**************************************/
  88601. /*! exports provided: SimplificationSettings, SimplificationQueue, SimplificationType */
  88602. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88603. "use strict";
  88604. __webpack_require__.r(__webpack_exports__);
  88605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return SimplificationSettings; });
  88606. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return SimplificationQueue; });
  88607. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return SimplificationType; });
  88608. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  88609. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  88610. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  88611. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  88612. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  88613. /**
  88614. * Class used to specify simplification options
  88615. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88616. */
  88617. var SimplificationSettings = /** @class */ (function () {
  88618. /**
  88619. * Creates a SimplificationSettings
  88620. * @param quality expected quality
  88621. * @param distance distance when this optimized version should be used
  88622. * @param optimizeMesh already optimized mesh
  88623. */
  88624. function SimplificationSettings(
  88625. /** expected quality */
  88626. quality,
  88627. /** distance when this optimized version should be used */
  88628. distance,
  88629. /** already optimized mesh */
  88630. optimizeMesh) {
  88631. this.quality = quality;
  88632. this.distance = distance;
  88633. this.optimizeMesh = optimizeMesh;
  88634. }
  88635. return SimplificationSettings;
  88636. }());
  88637. /**
  88638. * Queue used to order the simplification tasks
  88639. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88640. */
  88641. var SimplificationQueue = /** @class */ (function () {
  88642. /**
  88643. * Creates a new queue
  88644. */
  88645. function SimplificationQueue() {
  88646. this.running = false;
  88647. this._simplificationArray = [];
  88648. }
  88649. /**
  88650. * Adds a new simplification task
  88651. * @param task defines a task to add
  88652. */
  88653. SimplificationQueue.prototype.addTask = function (task) {
  88654. this._simplificationArray.push(task);
  88655. };
  88656. /**
  88657. * Execute next task
  88658. */
  88659. SimplificationQueue.prototype.executeNext = function () {
  88660. var task = this._simplificationArray.pop();
  88661. if (task) {
  88662. this.running = true;
  88663. this.runSimplification(task);
  88664. }
  88665. else {
  88666. this.running = false;
  88667. }
  88668. };
  88669. /**
  88670. * Execute a simplification task
  88671. * @param task defines the task to run
  88672. */
  88673. SimplificationQueue.prototype.runSimplification = function (task) {
  88674. var _this = this;
  88675. if (task.parallelProcessing) {
  88676. //parallel simplifier
  88677. task.settings.forEach(function (setting) {
  88678. var simplifier = _this.getSimplifier(task);
  88679. simplifier.simplify(setting, function (newMesh) {
  88680. task.mesh.addLODLevel(setting.distance, newMesh);
  88681. newMesh.isVisible = true;
  88682. //check if it is the last
  88683. if (setting.quality === task.settings[task.settings.length - 1].quality && task.successCallback) {
  88684. //all done, run the success callback.
  88685. task.successCallback();
  88686. }
  88687. _this.executeNext();
  88688. });
  88689. });
  88690. }
  88691. else {
  88692. //single simplifier.
  88693. var simplifier = this.getSimplifier(task);
  88694. var runDecimation = function (setting, callback) {
  88695. simplifier.simplify(setting, function (newMesh) {
  88696. task.mesh.addLODLevel(setting.distance, newMesh);
  88697. newMesh.isVisible = true;
  88698. //run the next quality level
  88699. callback();
  88700. });
  88701. };
  88702. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(task.settings.length, function (loop) {
  88703. runDecimation(task.settings[loop.index], function () {
  88704. loop.executeNext();
  88705. });
  88706. }, function () {
  88707. //execution ended, run the success callback.
  88708. if (task.successCallback) {
  88709. task.successCallback();
  88710. }
  88711. _this.executeNext();
  88712. });
  88713. }
  88714. };
  88715. SimplificationQueue.prototype.getSimplifier = function (task) {
  88716. switch (task.simplificationType) {
  88717. case SimplificationType.QUADRATIC:
  88718. default:
  88719. return new QuadraticErrorSimplification(task.mesh);
  88720. }
  88721. };
  88722. return SimplificationQueue;
  88723. }());
  88724. /**
  88725. * The implemented types of simplification
  88726. * At the moment only Quadratic Error Decimation is implemented
  88727. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88728. */
  88729. var SimplificationType;
  88730. (function (SimplificationType) {
  88731. /** Quadratic error decimation */
  88732. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  88733. })(SimplificationType || (SimplificationType = {}));
  88734. var DecimationTriangle = /** @class */ (function () {
  88735. function DecimationTriangle(vertices) {
  88736. this.vertices = vertices;
  88737. this.error = new Array(4);
  88738. this.deleted = false;
  88739. this.isDirty = false;
  88740. this.deletePending = false;
  88741. this.borderFactor = 0;
  88742. }
  88743. return DecimationTriangle;
  88744. }());
  88745. var DecimationVertex = /** @class */ (function () {
  88746. function DecimationVertex(position, id) {
  88747. this.position = position;
  88748. this.id = id;
  88749. this.isBorder = true;
  88750. this.q = new QuadraticMatrix();
  88751. this.triangleCount = 0;
  88752. this.triangleStart = 0;
  88753. this.originalOffsets = [];
  88754. }
  88755. DecimationVertex.prototype.updatePosition = function (newPosition) {
  88756. this.position.copyFrom(newPosition);
  88757. };
  88758. return DecimationVertex;
  88759. }());
  88760. var QuadraticMatrix = /** @class */ (function () {
  88761. function QuadraticMatrix(data) {
  88762. this.data = new Array(10);
  88763. for (var i = 0; i < 10; ++i) {
  88764. if (data && data[i]) {
  88765. this.data[i] = data[i];
  88766. }
  88767. else {
  88768. this.data[i] = 0;
  88769. }
  88770. }
  88771. }
  88772. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  88773. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
  88774. this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
  88775. this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  88776. return det;
  88777. };
  88778. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  88779. for (var i = 0; i < 10; ++i) {
  88780. this.data[i] += matrix.data[i];
  88781. }
  88782. };
  88783. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  88784. for (var i = 0; i < 10; ++i) {
  88785. this.data[i] += data[i];
  88786. }
  88787. };
  88788. QuadraticMatrix.prototype.add = function (matrix) {
  88789. var m = new QuadraticMatrix();
  88790. for (var i = 0; i < 10; ++i) {
  88791. m.data[i] = this.data[i] + matrix.data[i];
  88792. }
  88793. return m;
  88794. };
  88795. QuadraticMatrix.FromData = function (a, b, c, d) {
  88796. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  88797. };
  88798. //returning an array to avoid garbage collection
  88799. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  88800. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  88801. };
  88802. return QuadraticMatrix;
  88803. }());
  88804. var Reference = /** @class */ (function () {
  88805. function Reference(vertexId, triangleId) {
  88806. this.vertexId = vertexId;
  88807. this.triangleId = triangleId;
  88808. }
  88809. return Reference;
  88810. }());
  88811. /**
  88812. * An implementation of the Quadratic Error simplification algorithm.
  88813. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  88814. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  88815. * @author RaananW
  88816. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  88817. */
  88818. var QuadraticErrorSimplification = /** @class */ (function () {
  88819. function QuadraticErrorSimplification(_mesh) {
  88820. this._mesh = _mesh;
  88821. this.syncIterations = 5000;
  88822. this.aggressiveness = 7;
  88823. this.decimationIterations = 100;
  88824. this.boundingBoxEpsilon = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"];
  88825. }
  88826. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  88827. var _this = this;
  88828. this.initDecimatedMesh();
  88829. //iterating through the submeshes array, one after the other.
  88830. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this._mesh.subMeshes.length, function (loop) {
  88831. _this.initWithMesh(loop.index, function () {
  88832. _this.runDecimation(settings, loop.index, function () {
  88833. loop.executeNext();
  88834. });
  88835. }, settings.optimizeMesh);
  88836. }, function () {
  88837. setTimeout(function () {
  88838. successCallback(_this._reconstructedMesh);
  88839. }, 0);
  88840. });
  88841. };
  88842. QuadraticErrorSimplification.prototype.runDecimation = function (settings, submeshIndex, successCallback) {
  88843. var _this = this;
  88844. var targetCount = ~~(this.triangles.length * settings.quality);
  88845. var deletedTriangles = 0;
  88846. var triangleCount = this.triangles.length;
  88847. var iterationFunction = function (iteration, callback) {
  88848. setTimeout(function () {
  88849. if (iteration % 5 === 0) {
  88850. _this.updateMesh(iteration === 0);
  88851. }
  88852. for (var i = 0; i < _this.triangles.length; ++i) {
  88853. _this.triangles[i].isDirty = false;
  88854. }
  88855. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  88856. var trianglesIterator = function (i) {
  88857. var tIdx = ~~(((_this.triangles.length / 2) + i) % _this.triangles.length);
  88858. var t = _this.triangles[tIdx];
  88859. if (!t) {
  88860. return;
  88861. }
  88862. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  88863. return;
  88864. }
  88865. for (var j = 0; j < 3; ++j) {
  88866. if (t.error[j] < threshold) {
  88867. var deleted0 = [];
  88868. var deleted1 = [];
  88869. var v0 = t.vertices[j];
  88870. var v1 = t.vertices[(j + 1) % 3];
  88871. if (v0.isBorder || v1.isBorder) {
  88872. continue;
  88873. }
  88874. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88875. // var n = Vector3.Zero();
  88876. // var uv = Vector2.Zero();
  88877. // var color = new Color4(0, 0, 0, 1);
  88878. _this.calculateError(v0, v1, p);
  88879. var delTr = new Array();
  88880. if (_this.isFlipped(v0, v1, p, deleted0, delTr)) {
  88881. continue;
  88882. }
  88883. if (_this.isFlipped(v1, v0, p, deleted1, delTr)) {
  88884. continue;
  88885. }
  88886. if (deleted0.indexOf(true) < 0 || deleted1.indexOf(true) < 0) {
  88887. continue;
  88888. }
  88889. var uniqueArray = new Array();
  88890. delTr.forEach(function (deletedT) {
  88891. if (uniqueArray.indexOf(deletedT) === -1) {
  88892. deletedT.deletePending = true;
  88893. uniqueArray.push(deletedT);
  88894. }
  88895. });
  88896. if (uniqueArray.length % 2 !== 0) {
  88897. continue;
  88898. }
  88899. v0.q = v1.q.add(v0.q);
  88900. v0.updatePosition(p);
  88901. var tStart = _this.references.length;
  88902. deletedTriangles = _this.updateTriangles(v0, v0, deleted0, deletedTriangles);
  88903. deletedTriangles = _this.updateTriangles(v0, v1, deleted1, deletedTriangles);
  88904. var tCount = _this.references.length - tStart;
  88905. if (tCount <= v0.triangleCount) {
  88906. if (tCount) {
  88907. for (var c = 0; c < tCount; c++) {
  88908. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  88909. }
  88910. }
  88911. }
  88912. else {
  88913. v0.triangleStart = tStart;
  88914. }
  88915. v0.triangleCount = tCount;
  88916. break;
  88917. }
  88918. }
  88919. };
  88920. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
  88921. }, 0);
  88922. };
  88923. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this.decimationIterations, function (loop) {
  88924. if (triangleCount - deletedTriangles <= targetCount) {
  88925. loop.breakLoop();
  88926. }
  88927. else {
  88928. iterationFunction(loop.index, function () {
  88929. loop.executeNext();
  88930. });
  88931. }
  88932. }, function () {
  88933. setTimeout(function () {
  88934. //reconstruct this part of the mesh
  88935. _this.reconstructMesh(submeshIndex);
  88936. successCallback();
  88937. }, 0);
  88938. });
  88939. };
  88940. QuadraticErrorSimplification.prototype.initWithMesh = function (submeshIndex, callback, optimizeMesh) {
  88941. var _this = this;
  88942. this.vertices = [];
  88943. this.triangles = [];
  88944. var positionData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  88945. var indices = this._mesh.getIndices();
  88946. var submesh = this._mesh.subMeshes[submeshIndex];
  88947. var findInVertices = function (positionToSearch) {
  88948. if (optimizeMesh) {
  88949. for (var ii = 0; ii < _this.vertices.length; ++ii) {
  88950. if (_this.vertices[ii].position.equals(positionToSearch)) {
  88951. return _this.vertices[ii];
  88952. }
  88953. }
  88954. }
  88955. return null;
  88956. };
  88957. var vertexReferences = [];
  88958. var vertexInit = function (i) {
  88959. if (!positionData) {
  88960. return;
  88961. }
  88962. var offset = i + submesh.verticesStart;
  88963. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positionData, offset * 3);
  88964. var vertex = findInVertices(position) || new DecimationVertex(position, _this.vertices.length);
  88965. vertex.originalOffsets.push(offset);
  88966. if (vertex.id === _this.vertices.length) {
  88967. _this.vertices.push(vertex);
  88968. }
  88969. vertexReferences.push(vertex.id);
  88970. };
  88971. //var totalVertices = mesh.getTotalVertices();
  88972. var totalVertices = submesh.verticesCount;
  88973. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(totalVertices, (this.syncIterations / 4) >> 0, vertexInit, function () {
  88974. var indicesInit = function (i) {
  88975. if (!indices) {
  88976. return;
  88977. }
  88978. var offset = (submesh.indexStart / 3) + i;
  88979. var pos = (offset * 3);
  88980. var i0 = indices[pos + 0];
  88981. var i1 = indices[pos + 1];
  88982. var i2 = indices[pos + 2];
  88983. var v0 = _this.vertices[vertexReferences[i0 - submesh.verticesStart]];
  88984. var v1 = _this.vertices[vertexReferences[i1 - submesh.verticesStart]];
  88985. var v2 = _this.vertices[vertexReferences[i2 - submesh.verticesStart]];
  88986. var triangle = new DecimationTriangle([v0, v1, v2]);
  88987. triangle.originalOffset = pos;
  88988. _this.triangles.push(triangle);
  88989. };
  88990. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(submesh.indexCount / 3, _this.syncIterations, indicesInit, function () {
  88991. _this.init(callback);
  88992. });
  88993. });
  88994. };
  88995. QuadraticErrorSimplification.prototype.init = function (callback) {
  88996. var _this = this;
  88997. var triangleInit1 = function (i) {
  88998. var t = _this.triangles[i];
  88999. 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();
  89000. for (var j = 0; j < 3; j++) {
  89001. 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))));
  89002. }
  89003. };
  89004. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  89005. var triangleInit2 = function (i) {
  89006. var t = _this.triangles[i];
  89007. for (var j = 0; j < 3; ++j) {
  89008. t.error[j] = _this.calculateError(t.vertices[j], t.vertices[(j + 1) % 3]);
  89009. }
  89010. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  89011. };
  89012. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  89013. callback();
  89014. });
  89015. });
  89016. };
  89017. QuadraticErrorSimplification.prototype.reconstructMesh = function (submeshIndex) {
  89018. var newTriangles = [];
  89019. var i;
  89020. for (i = 0; i < this.vertices.length; ++i) {
  89021. this.vertices[i].triangleCount = 0;
  89022. }
  89023. var t;
  89024. var j;
  89025. for (i = 0; i < this.triangles.length; ++i) {
  89026. if (!this.triangles[i].deleted) {
  89027. t = this.triangles[i];
  89028. for (j = 0; j < 3; ++j) {
  89029. t.vertices[j].triangleCount = 1;
  89030. }
  89031. newTriangles.push(t);
  89032. }
  89033. }
  89034. var newPositionData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind) || []);
  89035. var newNormalData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind) || []);
  89036. var newUVsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind) || []);
  89037. var newColorsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind) || []);
  89038. var normalData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  89039. var uvs = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  89040. var colorsData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  89041. var vertexCount = 0;
  89042. for (i = 0; i < this.vertices.length; ++i) {
  89043. var vertex = this.vertices[i];
  89044. vertex.id = vertexCount;
  89045. if (vertex.triangleCount) {
  89046. vertex.originalOffsets.forEach(function (originalOffset) {
  89047. if (!normalData) {
  89048. return;
  89049. }
  89050. newPositionData.push(vertex.position.x);
  89051. newPositionData.push(vertex.position.y);
  89052. newPositionData.push(vertex.position.z);
  89053. newNormalData.push(normalData[originalOffset * 3]);
  89054. newNormalData.push(normalData[(originalOffset * 3) + 1]);
  89055. newNormalData.push(normalData[(originalOffset * 3) + 2]);
  89056. if (uvs && uvs.length) {
  89057. newUVsData.push(uvs[(originalOffset * 2)]);
  89058. newUVsData.push(uvs[(originalOffset * 2) + 1]);
  89059. }
  89060. else if (colorsData && colorsData.length) {
  89061. newColorsData.push(colorsData[(originalOffset * 4)]);
  89062. newColorsData.push(colorsData[(originalOffset * 4) + 1]);
  89063. newColorsData.push(colorsData[(originalOffset * 4) + 2]);
  89064. newColorsData.push(colorsData[(originalOffset * 4) + 3]);
  89065. }
  89066. ++vertexCount;
  89067. });
  89068. }
  89069. }
  89070. var startingIndex = this._reconstructedMesh.getTotalIndices();
  89071. var startingVertex = this._reconstructedMesh.getTotalVertices();
  89072. var submeshesArray = this._reconstructedMesh.subMeshes;
  89073. this._reconstructedMesh.subMeshes = [];
  89074. var newIndicesArray = this._reconstructedMesh.getIndices(); //[];
  89075. var originalIndices = this._mesh.getIndices();
  89076. for (i = 0; i < newTriangles.length; ++i) {
  89077. t = newTriangles[i]; //now get the new referencing point for each vertex
  89078. [0, 1, 2].forEach(function (idx) {
  89079. var id = originalIndices[t.originalOffset + idx];
  89080. var offset = t.vertices[idx].originalOffsets.indexOf(id);
  89081. if (offset < 0) {
  89082. offset = 0;
  89083. }
  89084. newIndicesArray.push(t.vertices[idx].id + offset + startingVertex);
  89085. });
  89086. }
  89087. //overwriting the old vertex buffers and indices.
  89088. this._reconstructedMesh.setIndices(newIndicesArray);
  89089. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, newPositionData);
  89090. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, newNormalData);
  89091. if (newUVsData.length > 0) {
  89092. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, newUVsData);
  89093. }
  89094. if (newColorsData.length > 0) {
  89095. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, newColorsData);
  89096. }
  89097. //create submesh
  89098. var originalSubmesh = this._mesh.subMeshes[submeshIndex];
  89099. if (submeshIndex > 0) {
  89100. this._reconstructedMesh.subMeshes = [];
  89101. submeshesArray.forEach(function (submesh) {
  89102. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(submesh.materialIndex, submesh.verticesStart, submesh.verticesCount, /* 0, newPositionData.length/3, */ submesh.indexStart, submesh.indexCount, submesh.getMesh());
  89103. });
  89104. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(originalSubmesh.materialIndex, startingVertex, vertexCount, /* 0, newPositionData.length / 3, */ startingIndex, newTriangles.length * 3, this._reconstructedMesh);
  89105. }
  89106. };
  89107. QuadraticErrorSimplification.prototype.initDecimatedMesh = function () {
  89108. this._reconstructedMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this._mesh.name + "Decimated", this._mesh.getScene());
  89109. this._reconstructedMesh.material = this._mesh.material;
  89110. this._reconstructedMesh.parent = this._mesh.parent;
  89111. this._reconstructedMesh.isVisible = false;
  89112. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
  89113. };
  89114. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, vertex2, point, deletedArray, delTr) {
  89115. for (var i = 0; i < vertex1.triangleCount; ++i) {
  89116. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  89117. if (t.deleted) {
  89118. continue;
  89119. }
  89120. var s = this.references[vertex1.triangleStart + i].vertexId;
  89121. var v1 = t.vertices[(s + 1) % 3];
  89122. var v2 = t.vertices[(s + 2) % 3];
  89123. if ((v1 === vertex2 || v2 === vertex2)) {
  89124. deletedArray[i] = true;
  89125. delTr.push(t);
  89126. continue;
  89127. }
  89128. var d1 = v1.position.subtract(point);
  89129. d1 = d1.normalize();
  89130. var d2 = v2.position.subtract(point);
  89131. d2 = d2.normalize();
  89132. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(d1, d2)) > 0.999) {
  89133. return true;
  89134. }
  89135. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(d1, d2).normalize();
  89136. deletedArray[i] = false;
  89137. if (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, t.normal) < 0.2) {
  89138. return true;
  89139. }
  89140. }
  89141. return false;
  89142. };
  89143. QuadraticErrorSimplification.prototype.updateTriangles = function (origVertex, vertex, deletedArray, deletedTriangles) {
  89144. var newDeleted = deletedTriangles;
  89145. for (var i = 0; i < vertex.triangleCount; ++i) {
  89146. var ref = this.references[vertex.triangleStart + i];
  89147. var t = this.triangles[ref.triangleId];
  89148. if (t.deleted) {
  89149. continue;
  89150. }
  89151. if (deletedArray[i] && t.deletePending) {
  89152. t.deleted = true;
  89153. newDeleted++;
  89154. continue;
  89155. }
  89156. t.vertices[ref.vertexId] = origVertex;
  89157. t.isDirty = true;
  89158. t.error[0] = this.calculateError(t.vertices[0], t.vertices[1]) + (t.borderFactor / 2);
  89159. t.error[1] = this.calculateError(t.vertices[1], t.vertices[2]) + (t.borderFactor / 2);
  89160. t.error[2] = this.calculateError(t.vertices[2], t.vertices[0]) + (t.borderFactor / 2);
  89161. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  89162. this.references.push(ref);
  89163. }
  89164. return newDeleted;
  89165. };
  89166. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  89167. for (var i = 0; i < this.vertices.length; ++i) {
  89168. var vCount = [];
  89169. var vId = [];
  89170. var v = this.vertices[i];
  89171. var j;
  89172. for (j = 0; j < v.triangleCount; ++j) {
  89173. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  89174. for (var ii = 0; ii < 3; ii++) {
  89175. var ofs = 0;
  89176. var vv = triangle.vertices[ii];
  89177. while (ofs < vCount.length) {
  89178. if (vId[ofs] === vv.id) {
  89179. break;
  89180. }
  89181. ++ofs;
  89182. }
  89183. if (ofs === vCount.length) {
  89184. vCount.push(1);
  89185. vId.push(vv.id);
  89186. }
  89187. else {
  89188. vCount[ofs]++;
  89189. }
  89190. }
  89191. }
  89192. for (j = 0; j < vCount.length; ++j) {
  89193. if (vCount[j] === 1) {
  89194. this.vertices[vId[j]].isBorder = true;
  89195. }
  89196. else {
  89197. this.vertices[vId[j]].isBorder = false;
  89198. }
  89199. }
  89200. }
  89201. };
  89202. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  89203. if (identifyBorders === void 0) { identifyBorders = false; }
  89204. var i;
  89205. if (!identifyBorders) {
  89206. var newTrianglesVector = [];
  89207. for (i = 0; i < this.triangles.length; ++i) {
  89208. if (!this.triangles[i].deleted) {
  89209. newTrianglesVector.push(this.triangles[i]);
  89210. }
  89211. }
  89212. this.triangles = newTrianglesVector;
  89213. }
  89214. for (i = 0; i < this.vertices.length; ++i) {
  89215. this.vertices[i].triangleCount = 0;
  89216. this.vertices[i].triangleStart = 0;
  89217. }
  89218. var t;
  89219. var j;
  89220. var v;
  89221. for (i = 0; i < this.triangles.length; ++i) {
  89222. t = this.triangles[i];
  89223. for (j = 0; j < 3; ++j) {
  89224. v = t.vertices[j];
  89225. v.triangleCount++;
  89226. }
  89227. }
  89228. var tStart = 0;
  89229. for (i = 0; i < this.vertices.length; ++i) {
  89230. this.vertices[i].triangleStart = tStart;
  89231. tStart += this.vertices[i].triangleCount;
  89232. this.vertices[i].triangleCount = 0;
  89233. }
  89234. var newReferences = new Array(this.triangles.length * 3);
  89235. for (i = 0; i < this.triangles.length; ++i) {
  89236. t = this.triangles[i];
  89237. for (j = 0; j < 3; ++j) {
  89238. v = t.vertices[j];
  89239. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  89240. v.triangleCount++;
  89241. }
  89242. }
  89243. this.references = newReferences;
  89244. if (identifyBorders) {
  89245. this.identifyBorder();
  89246. }
  89247. };
  89248. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  89249. var x = point.x;
  89250. var y = point.y;
  89251. var z = point.z;
  89252. 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
  89253. + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  89254. };
  89255. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult) {
  89256. var q = vertex1.q.add(vertex2.q);
  89257. var border = vertex1.isBorder && vertex2.isBorder;
  89258. var error = 0;
  89259. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  89260. if (qDet !== 0 && !border) {
  89261. if (!pointResult) {
  89262. pointResult = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89263. }
  89264. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  89265. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  89266. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  89267. error = this.vertexError(q, pointResult);
  89268. }
  89269. else {
  89270. var p3 = (vertex1.position.add(vertex2.position)).divide(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](2, 2, 2));
  89271. //var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new Vector3(2, 2, 2)).normalize();
  89272. var error1 = this.vertexError(q, vertex1.position);
  89273. var error2 = this.vertexError(q, vertex2.position);
  89274. var error3 = this.vertexError(q, p3);
  89275. error = Math.min(error1, error2, error3);
  89276. if (error === error1) {
  89277. if (pointResult) {
  89278. pointResult.copyFrom(vertex1.position);
  89279. }
  89280. }
  89281. else if (error === error2) {
  89282. if (pointResult) {
  89283. pointResult.copyFrom(vertex2.position);
  89284. }
  89285. }
  89286. else {
  89287. if (pointResult) {
  89288. pointResult.copyFrom(p3);
  89289. }
  89290. }
  89291. }
  89292. return error;
  89293. };
  89294. return QuadraticErrorSimplification;
  89295. }());
  89296. /***/ }),
  89297. /***/ "./Meshes/meshSimplificationSceneComponent.ts":
  89298. /*!****************************************************!*\
  89299. !*** ./Meshes/meshSimplificationSceneComponent.ts ***!
  89300. \****************************************************/
  89301. /*! exports provided: SimplicationQueueSceneComponent */
  89302. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89303. "use strict";
  89304. __webpack_require__.r(__webpack_exports__);
  89305. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return SimplicationQueueSceneComponent; });
  89306. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  89307. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  89308. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  89309. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  89310. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "simplificationQueue", {
  89311. get: function () {
  89312. if (!this._simplificationQueue) {
  89313. this._simplificationQueue = new _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationQueue"]();
  89314. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE);
  89315. if (!component) {
  89316. component = new SimplicationQueueSceneComponent(this);
  89317. this._addComponent(component);
  89318. }
  89319. }
  89320. return this._simplificationQueue;
  89321. },
  89322. set: function (value) {
  89323. this._simplificationQueue = value;
  89324. },
  89325. enumerable: true,
  89326. configurable: true
  89327. });
  89328. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
  89329. if (parallelProcessing === void 0) { parallelProcessing = true; }
  89330. if (simplificationType === void 0) { simplificationType = _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationType"].QUADRATIC; }
  89331. this.getScene().simplificationQueue.addTask({
  89332. settings: settings,
  89333. parallelProcessing: parallelProcessing,
  89334. mesh: this,
  89335. simplificationType: simplificationType,
  89336. successCallback: successCallback
  89337. });
  89338. return this;
  89339. };
  89340. /**
  89341. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  89342. * created in a scene
  89343. */
  89344. var SimplicationQueueSceneComponent = /** @class */ (function () {
  89345. /**
  89346. * Creates a new instance of the component for the given scene
  89347. * @param scene Defines the scene to register the component in
  89348. */
  89349. function SimplicationQueueSceneComponent(scene) {
  89350. /**
  89351. * The component name helpfull to identify the component in the list of scene components.
  89352. */
  89353. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE;
  89354. this.scene = scene;
  89355. }
  89356. /**
  89357. * Registers the component in a given scene
  89358. */
  89359. SimplicationQueueSceneComponent.prototype.register = function () {
  89360. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
  89361. };
  89362. /**
  89363. * Rebuilds the elements related to this component in case of
  89364. * context lost for instance.
  89365. */
  89366. SimplicationQueueSceneComponent.prototype.rebuild = function () {
  89367. // Nothing to do for this component
  89368. };
  89369. /**
  89370. * Disposes the component and the associated ressources
  89371. */
  89372. SimplicationQueueSceneComponent.prototype.dispose = function () {
  89373. // Nothing to do for this component
  89374. };
  89375. SimplicationQueueSceneComponent.prototype._beforeCameraUpdate = function () {
  89376. if (this.scene._simplificationQueue && !this.scene._simplificationQueue.running) {
  89377. this.scene._simplificationQueue.executeNext();
  89378. }
  89379. };
  89380. return SimplicationQueueSceneComponent;
  89381. }());
  89382. /***/ }),
  89383. /***/ "./Meshes/polygonMesh.ts":
  89384. /*!*******************************!*\
  89385. !*** ./Meshes/polygonMesh.ts ***!
  89386. \*******************************/
  89387. /*! exports provided: Polygon, PolygonMeshBuilder */
  89388. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89389. "use strict";
  89390. __webpack_require__.r(__webpack_exports__);
  89391. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return Polygon; });
  89392. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return PolygonMeshBuilder; });
  89393. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  89394. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  89395. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  89396. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  89397. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  89398. /**
  89399. * Vector2 wth index property
  89400. */
  89401. var IndexedVector2 = /** @class */ (function (_super) {
  89402. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IndexedVector2, _super);
  89403. function IndexedVector2(original,
  89404. /** Index of the vector2 */
  89405. index) {
  89406. var _this = _super.call(this, original.x, original.y) || this;
  89407. _this.index = index;
  89408. return _this;
  89409. }
  89410. return IndexedVector2;
  89411. }(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"]));
  89412. /**
  89413. * Defines points to create a polygon
  89414. */
  89415. var PolygonPoints = /** @class */ (function () {
  89416. function PolygonPoints() {
  89417. this.elements = new Array();
  89418. }
  89419. PolygonPoints.prototype.add = function (originalPoints) {
  89420. var _this = this;
  89421. var result = new Array();
  89422. originalPoints.forEach(function (point) {
  89423. if (result.length === 0 || !point.equalsWithEpsilon(result[0])) {
  89424. var newPoint = new IndexedVector2(point, _this.elements.length);
  89425. result.push(newPoint);
  89426. _this.elements.push(newPoint);
  89427. }
  89428. });
  89429. return result;
  89430. };
  89431. PolygonPoints.prototype.computeBounds = function () {
  89432. var lmin = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  89433. var lmax = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  89434. this.elements.forEach(function (point) {
  89435. // x
  89436. if (point.x < lmin.x) {
  89437. lmin.x = point.x;
  89438. }
  89439. else if (point.x > lmax.x) {
  89440. lmax.x = point.x;
  89441. }
  89442. // y
  89443. if (point.y < lmin.y) {
  89444. lmin.y = point.y;
  89445. }
  89446. else if (point.y > lmax.y) {
  89447. lmax.y = point.y;
  89448. }
  89449. });
  89450. return {
  89451. min: lmin,
  89452. max: lmax,
  89453. width: lmax.x - lmin.x,
  89454. height: lmax.y - lmin.y
  89455. };
  89456. };
  89457. return PolygonPoints;
  89458. }());
  89459. /**
  89460. * Polygon
  89461. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  89462. */
  89463. var Polygon = /** @class */ (function () {
  89464. function Polygon() {
  89465. }
  89466. /**
  89467. * Creates a rectangle
  89468. * @param xmin bottom X coord
  89469. * @param ymin bottom Y coord
  89470. * @param xmax top X coord
  89471. * @param ymax top Y coord
  89472. * @returns points that make the resulting rectation
  89473. */
  89474. Polygon.Rectangle = function (xmin, ymin, xmax, ymax) {
  89475. return [
  89476. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymin),
  89477. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymin),
  89478. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymax),
  89479. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymax)
  89480. ];
  89481. };
  89482. /**
  89483. * Creates a circle
  89484. * @param radius radius of circle
  89485. * @param cx scale in x
  89486. * @param cy scale in y
  89487. * @param numberOfSides number of sides that make up the circle
  89488. * @returns points that make the resulting circle
  89489. */
  89490. Polygon.Circle = function (radius, cx, cy, numberOfSides) {
  89491. if (cx === void 0) { cx = 0; }
  89492. if (cy === void 0) { cy = 0; }
  89493. if (numberOfSides === void 0) { numberOfSides = 32; }
  89494. var result = new Array();
  89495. var angle = 0;
  89496. var increment = (Math.PI * 2) / numberOfSides;
  89497. for (var i = 0; i < numberOfSides; i++) {
  89498. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius));
  89499. angle -= increment;
  89500. }
  89501. return result;
  89502. };
  89503. /**
  89504. * Creates a polygon from input string
  89505. * @param input Input polygon data
  89506. * @returns the parsed points
  89507. */
  89508. Polygon.Parse = function (input) {
  89509. var floats = input.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function (val) { return (!isNaN(val)); });
  89510. var i, result = [];
  89511. for (i = 0; i < (floats.length & 0x7FFFFFFE); i += 2) {
  89512. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](floats[i], floats[i + 1]));
  89513. }
  89514. return result;
  89515. };
  89516. /**
  89517. * Starts building a polygon from x and y coordinates
  89518. * @param x x coordinate
  89519. * @param y y coordinate
  89520. * @returns the started path2
  89521. */
  89522. Polygon.StartingAt = function (x, y) {
  89523. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"].StartingAt(x, y);
  89524. };
  89525. return Polygon;
  89526. }());
  89527. /**
  89528. * Builds a polygon
  89529. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  89530. */
  89531. var PolygonMeshBuilder = /** @class */ (function () {
  89532. /**
  89533. * Creates a PolygonMeshBuilder
  89534. * @param name name of the builder
  89535. * @param contours Path of the polygon
  89536. * @param scene scene to add to
  89537. * @param earcutInjection can be used to inject your own earcut reference
  89538. */
  89539. function PolygonMeshBuilder(name, contours, scene, earcutInjection) {
  89540. if (earcutInjection === void 0) { earcutInjection = earcut; }
  89541. this._points = new PolygonPoints();
  89542. this._outlinepoints = new PolygonPoints();
  89543. this._holes = new Array();
  89544. this._epoints = new Array();
  89545. this._eholes = new Array();
  89546. this.bjsEarcut = earcutInjection;
  89547. this._name = name;
  89548. this._scene = scene;
  89549. var points;
  89550. if (contours instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"]) {
  89551. points = contours.getPoints();
  89552. }
  89553. else {
  89554. points = contours;
  89555. }
  89556. this._addToepoint(points);
  89557. this._points.add(points);
  89558. this._outlinepoints.add(points);
  89559. if (typeof this.bjsEarcut === 'undefined') {
  89560. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Earcut was not found, the polygon will not be built.");
  89561. }
  89562. }
  89563. PolygonMeshBuilder.prototype._addToepoint = function (points) {
  89564. for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
  89565. var p = points_1[_i];
  89566. this._epoints.push(p.x, p.y);
  89567. }
  89568. };
  89569. /**
  89570. * Adds a whole within the polygon
  89571. * @param hole Array of points defining the hole
  89572. * @returns this
  89573. */
  89574. PolygonMeshBuilder.prototype.addHole = function (hole) {
  89575. this._points.add(hole);
  89576. var holepoints = new PolygonPoints();
  89577. holepoints.add(hole);
  89578. this._holes.push(holepoints);
  89579. this._eholes.push(this._epoints.length / 2);
  89580. this._addToepoint(hole);
  89581. return this;
  89582. };
  89583. /**
  89584. * Creates the polygon
  89585. * @param updatable If the mesh should be updatable
  89586. * @param depth The depth of the mesh created
  89587. * @returns the created mesh
  89588. */
  89589. PolygonMeshBuilder.prototype.build = function (updatable, depth) {
  89590. var _this = this;
  89591. if (updatable === void 0) { updatable = false; }
  89592. if (depth === void 0) { depth = 0; }
  89593. var result = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this._name, this._scene);
  89594. var normals = new Array();
  89595. var positions = new Array();
  89596. var uvs = new Array();
  89597. var bounds = this._points.computeBounds();
  89598. this._points.elements.forEach(function (p) {
  89599. normals.push(0, 1.0, 0);
  89600. positions.push(p.x, 0, p.y);
  89601. uvs.push((p.x - bounds.min.x) / bounds.width, (p.y - bounds.min.y) / bounds.height);
  89602. });
  89603. var indices = new Array();
  89604. var res = this.bjsEarcut(this._epoints, this._eholes, 2);
  89605. for (var i = 0; i < res.length; i++) {
  89606. indices.push(res[i]);
  89607. }
  89608. if (depth > 0) {
  89609. var positionscount = (positions.length / 3); //get the current pointcount
  89610. this._points.elements.forEach(function (p) {
  89611. normals.push(0, -1.0, 0);
  89612. positions.push(p.x, -depth, p.y);
  89613. uvs.push(1 - (p.x - bounds.min.x) / bounds.width, 1 - (p.y - bounds.min.y) / bounds.height);
  89614. });
  89615. var totalCount = indices.length;
  89616. for (var i = 0; i < totalCount; i += 3) {
  89617. var i0 = indices[i + 0];
  89618. var i1 = indices[i + 1];
  89619. var i2 = indices[i + 2];
  89620. indices.push(i2 + positionscount);
  89621. indices.push(i1 + positionscount);
  89622. indices.push(i0 + positionscount);
  89623. }
  89624. //Add the sides
  89625. this.addSide(positions, normals, uvs, indices, bounds, this._outlinepoints, depth, false);
  89626. this._holes.forEach(function (hole) {
  89627. _this.addSide(positions, normals, uvs, indices, bounds, hole, depth, true);
  89628. });
  89629. }
  89630. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, updatable);
  89631. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, updatable);
  89632. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, uvs, updatable);
  89633. result.setIndices(indices);
  89634. return result;
  89635. };
  89636. /**
  89637. * Adds a side to the polygon
  89638. * @param positions points that make the polygon
  89639. * @param normals normals of the polygon
  89640. * @param uvs uvs of the polygon
  89641. * @param indices indices of the polygon
  89642. * @param bounds bounds of the polygon
  89643. * @param points points of the polygon
  89644. * @param depth depth of the polygon
  89645. * @param flip flip of the polygon
  89646. */
  89647. PolygonMeshBuilder.prototype.addSide = function (positions, normals, uvs, indices, bounds, points, depth, flip) {
  89648. var StartIndex = positions.length / 3;
  89649. var ulength = 0;
  89650. for (var i = 0; i < points.elements.length; i++) {
  89651. var p = points.elements[i];
  89652. var p1;
  89653. if ((i + 1) > points.elements.length - 1) {
  89654. p1 = points.elements[0];
  89655. }
  89656. else {
  89657. p1 = points.elements[i + 1];
  89658. }
  89659. positions.push(p.x, 0, p.y);
  89660. positions.push(p.x, -depth, p.y);
  89661. positions.push(p1.x, 0, p1.y);
  89662. positions.push(p1.x, -depth, p1.y);
  89663. var v1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p.x, 0, p.y);
  89664. var v2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p1.x, 0, p1.y);
  89665. var v3 = v2.subtract(v1);
  89666. var v4 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0);
  89667. var vn = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(v3, v4);
  89668. vn = vn.normalize();
  89669. uvs.push(ulength / bounds.width, 0);
  89670. uvs.push(ulength / bounds.width, 1);
  89671. ulength += v3.length();
  89672. uvs.push((ulength / bounds.width), 0);
  89673. uvs.push((ulength / bounds.width), 1);
  89674. if (!flip) {
  89675. normals.push(-vn.x, -vn.y, -vn.z);
  89676. normals.push(-vn.x, -vn.y, -vn.z);
  89677. normals.push(-vn.x, -vn.y, -vn.z);
  89678. normals.push(-vn.x, -vn.y, -vn.z);
  89679. indices.push(StartIndex);
  89680. indices.push(StartIndex + 1);
  89681. indices.push(StartIndex + 2);
  89682. indices.push(StartIndex + 1);
  89683. indices.push(StartIndex + 3);
  89684. indices.push(StartIndex + 2);
  89685. }
  89686. else {
  89687. normals.push(vn.x, vn.y, vn.z);
  89688. normals.push(vn.x, vn.y, vn.z);
  89689. normals.push(vn.x, vn.y, vn.z);
  89690. normals.push(vn.x, vn.y, vn.z);
  89691. indices.push(StartIndex);
  89692. indices.push(StartIndex + 2);
  89693. indices.push(StartIndex + 1);
  89694. indices.push(StartIndex + 1);
  89695. indices.push(StartIndex + 2);
  89696. indices.push(StartIndex + 3);
  89697. }
  89698. StartIndex += 4;
  89699. }
  89700. };
  89701. return PolygonMeshBuilder;
  89702. }());
  89703. /***/ }),
  89704. /***/ "./Meshes/subMesh.ts":
  89705. /*!***************************!*\
  89706. !*** ./Meshes/subMesh.ts ***!
  89707. \***************************/
  89708. /*! exports provided: BaseSubMesh, SubMesh */
  89709. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89710. "use strict";
  89711. __webpack_require__.r(__webpack_exports__);
  89712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return BaseSubMesh; });
  89713. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return SubMesh; });
  89714. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  89715. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  89716. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  89717. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  89718. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  89719. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  89720. /**
  89721. * Base class for submeshes
  89722. */
  89723. var BaseSubMesh = /** @class */ (function () {
  89724. function BaseSubMesh() {
  89725. }
  89726. Object.defineProperty(BaseSubMesh.prototype, "effect", {
  89727. /**
  89728. * Gets associated effect
  89729. */
  89730. get: function () {
  89731. return this._materialEffect;
  89732. },
  89733. enumerable: true,
  89734. configurable: true
  89735. });
  89736. /**
  89737. * Sets associated effect (effect used to render this submesh)
  89738. * @param effect defines the effect to associate with
  89739. * @param defines defines the set of defines used to compile this effect
  89740. */
  89741. BaseSubMesh.prototype.setEffect = function (effect, defines) {
  89742. if (defines === void 0) { defines = null; }
  89743. if (this._materialEffect === effect) {
  89744. if (!effect) {
  89745. this._materialDefines = null;
  89746. }
  89747. return;
  89748. }
  89749. this._materialDefines = defines;
  89750. this._materialEffect = effect;
  89751. };
  89752. return BaseSubMesh;
  89753. }());
  89754. /**
  89755. * Defines a subdivision inside a mesh
  89756. */
  89757. var SubMesh = /** @class */ (function (_super) {
  89758. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SubMesh, _super);
  89759. /**
  89760. * Creates a new submesh
  89761. * @param materialIndex defines the material index to use
  89762. * @param verticesStart defines vertex index start
  89763. * @param verticesCount defines vertices count
  89764. * @param indexStart defines index start
  89765. * @param indexCount defines indices count
  89766. * @param mesh defines the parent mesh
  89767. * @param renderingMesh defines an optional rendering mesh
  89768. * @param createBoundingBox defines if bounding box should be created for this submesh
  89769. */
  89770. function SubMesh(
  89771. /** the material index to use */
  89772. materialIndex,
  89773. /** vertex index start */
  89774. verticesStart,
  89775. /** vertices count */
  89776. verticesCount,
  89777. /** index start */
  89778. indexStart,
  89779. /** indices count */
  89780. indexCount, mesh, renderingMesh, createBoundingBox) {
  89781. if (createBoundingBox === void 0) { createBoundingBox = true; }
  89782. var _this = _super.call(this) || this;
  89783. _this.materialIndex = materialIndex;
  89784. _this.verticesStart = verticesStart;
  89785. _this.verticesCount = verticesCount;
  89786. _this.indexStart = indexStart;
  89787. _this.indexCount = indexCount;
  89788. /** @hidden */
  89789. _this._renderId = 0;
  89790. _this._mesh = mesh;
  89791. _this._renderingMesh = renderingMesh || mesh;
  89792. mesh.subMeshes.push(_this);
  89793. _this._trianglePlanes = [];
  89794. _this._id = mesh.subMeshes.length - 1;
  89795. if (createBoundingBox) {
  89796. _this.refreshBoundingInfo();
  89797. mesh.computeWorldMatrix(true);
  89798. }
  89799. return _this;
  89800. }
  89801. /**
  89802. * Add a new submesh to a mesh
  89803. * @param materialIndex defines the material index to use
  89804. * @param verticesStart defines vertex index start
  89805. * @param verticesCount defines vertices count
  89806. * @param indexStart defines index start
  89807. * @param indexCount defines indices count
  89808. * @param mesh defines the parent mesh
  89809. * @param renderingMesh defines an optional rendering mesh
  89810. * @param createBoundingBox defines if bounding box should be created for this submesh
  89811. * @returns the new submesh
  89812. */
  89813. SubMesh.AddToMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
  89814. if (createBoundingBox === void 0) { createBoundingBox = true; }
  89815. return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
  89816. };
  89817. Object.defineProperty(SubMesh.prototype, "IsGlobal", {
  89818. /**
  89819. * Returns true if this submesh covers the entire parent mesh
  89820. * @ignorenaming
  89821. */
  89822. get: function () {
  89823. return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
  89824. },
  89825. enumerable: true,
  89826. configurable: true
  89827. });
  89828. /**
  89829. * Returns the submesh BoudingInfo object
  89830. * @returns current bounding info (or mesh's one if the submesh is global)
  89831. */
  89832. SubMesh.prototype.getBoundingInfo = function () {
  89833. if (this.IsGlobal) {
  89834. return this._mesh.getBoundingInfo();
  89835. }
  89836. return this._boundingInfo;
  89837. };
  89838. /**
  89839. * Sets the submesh BoundingInfo
  89840. * @param boundingInfo defines the new bounding info to use
  89841. * @returns the SubMesh
  89842. */
  89843. SubMesh.prototype.setBoundingInfo = function (boundingInfo) {
  89844. this._boundingInfo = boundingInfo;
  89845. return this;
  89846. };
  89847. /**
  89848. * Returns the mesh of the current submesh
  89849. * @return the parent mesh
  89850. */
  89851. SubMesh.prototype.getMesh = function () {
  89852. return this._mesh;
  89853. };
  89854. /**
  89855. * Returns the rendering mesh of the submesh
  89856. * @returns the rendering mesh (could be different from parent mesh)
  89857. */
  89858. SubMesh.prototype.getRenderingMesh = function () {
  89859. return this._renderingMesh;
  89860. };
  89861. /**
  89862. * Returns the submesh material
  89863. * @returns null or the current material
  89864. */
  89865. SubMesh.prototype.getMaterial = function () {
  89866. var rootMaterial = this._renderingMesh.material;
  89867. if (rootMaterial === null || rootMaterial === undefined) {
  89868. return this._mesh.getScene().defaultMaterial;
  89869. }
  89870. else if (rootMaterial.getSubMaterial) {
  89871. var multiMaterial = rootMaterial;
  89872. var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
  89873. if (this._currentMaterial !== effectiveMaterial) {
  89874. this._currentMaterial = effectiveMaterial;
  89875. this._materialDefines = null;
  89876. }
  89877. return effectiveMaterial;
  89878. }
  89879. return rootMaterial;
  89880. };
  89881. // Methods
  89882. /**
  89883. * Sets a new updated BoundingInfo object to the submesh
  89884. * @returns the SubMesh
  89885. */
  89886. SubMesh.prototype.refreshBoundingInfo = function () {
  89887. this._lastColliderWorldVertices = null;
  89888. if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
  89889. return this;
  89890. }
  89891. var data = this._renderingMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  89892. if (!data) {
  89893. this._boundingInfo = this._mesh.getBoundingInfo();
  89894. return this;
  89895. }
  89896. var indices = this._renderingMesh.getIndices();
  89897. var extend;
  89898. //is this the only submesh?
  89899. if (this.indexStart === 0 && this.indexCount === indices.length) {
  89900. var boundingInfo = this._renderingMesh.getBoundingInfo();
  89901. //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
  89902. extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };
  89903. }
  89904. else {
  89905. extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  89906. }
  89907. if (this._boundingInfo) {
  89908. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  89909. }
  89910. else {
  89911. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](extend.minimum, extend.maximum);
  89912. }
  89913. return this;
  89914. };
  89915. /** @hidden */
  89916. SubMesh.prototype._checkCollision = function (collider) {
  89917. var boundingInfo = this.getBoundingInfo();
  89918. return boundingInfo._checkCollision(collider);
  89919. };
  89920. /**
  89921. * Updates the submesh BoundingInfo
  89922. * @param world defines the world matrix to use to update the bounding info
  89923. * @returns the submesh
  89924. */
  89925. SubMesh.prototype.updateBoundingInfo = function (world) {
  89926. var boundingInfo = this.getBoundingInfo();
  89927. if (!boundingInfo) {
  89928. this.refreshBoundingInfo();
  89929. boundingInfo = this.getBoundingInfo();
  89930. }
  89931. boundingInfo.update(world);
  89932. return this;
  89933. };
  89934. /**
  89935. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  89936. * @param frustumPlanes defines the frustum planes
  89937. * @returns true if the submesh is intersecting with the frustum
  89938. */
  89939. SubMesh.prototype.isInFrustum = function (frustumPlanes) {
  89940. var boundingInfo = this.getBoundingInfo();
  89941. if (!boundingInfo) {
  89942. return false;
  89943. }
  89944. return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
  89945. };
  89946. /**
  89947. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  89948. * @param frustumPlanes defines the frustum planes
  89949. * @returns true if the submesh is inside the frustum
  89950. */
  89951. SubMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  89952. var boundingInfo = this.getBoundingInfo();
  89953. if (!boundingInfo) {
  89954. return false;
  89955. }
  89956. return boundingInfo.isCompletelyInFrustum(frustumPlanes);
  89957. };
  89958. /**
  89959. * Renders the submesh
  89960. * @param enableAlphaMode defines if alpha needs to be used
  89961. * @returns the submesh
  89962. */
  89963. SubMesh.prototype.render = function (enableAlphaMode) {
  89964. this._renderingMesh.render(this, enableAlphaMode);
  89965. return this;
  89966. };
  89967. /**
  89968. * @hidden
  89969. */
  89970. SubMesh.prototype._getLinesIndexBuffer = function (indices, engine) {
  89971. if (!this._linesIndexBuffer) {
  89972. var linesIndices = [];
  89973. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  89974. linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
  89975. }
  89976. this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
  89977. this._linesIndexCount = linesIndices.length;
  89978. }
  89979. return this._linesIndexBuffer;
  89980. };
  89981. /**
  89982. * Checks if the submesh intersects with a ray
  89983. * @param ray defines the ray to test
  89984. * @returns true is the passed ray intersects the submesh bounding box
  89985. */
  89986. SubMesh.prototype.canIntersects = function (ray) {
  89987. var boundingInfo = this.getBoundingInfo();
  89988. if (!boundingInfo) {
  89989. return false;
  89990. }
  89991. return ray.intersectsBox(boundingInfo.boundingBox);
  89992. };
  89993. /**
  89994. * Intersects current submesh with a ray
  89995. * @param ray defines the ray to test
  89996. * @param positions defines mesh's positions array
  89997. * @param indices defines mesh's indices array
  89998. * @param fastCheck defines if only bounding info should be used
  89999. * @returns intersection info or null if no intersection
  90000. */
  90001. SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck) {
  90002. var material = this.getMaterial();
  90003. if (!material) {
  90004. return null;
  90005. }
  90006. switch (material.fillMode) {
  90007. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_PointListDrawMode:
  90008. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineListDrawMode:
  90009. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineLoopDrawMode:
  90010. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineStripDrawMode:
  90011. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleFanDrawMode:
  90012. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleStripDrawMode:
  90013. return null;
  90014. }
  90015. // LineMesh first as it's also a Mesh...
  90016. if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
  90017. return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  90018. }
  90019. return this._intersectTriangles(ray, positions, indices, fastCheck);
  90020. };
  90021. /** @hidden */
  90022. SubMesh.prototype._intersectLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  90023. var intersectInfo = null;
  90024. // Line test
  90025. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {
  90026. var p0 = positions[indices[index]];
  90027. var p1 = positions[indices[index + 1]];
  90028. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  90029. if (length < 0) {
  90030. continue;
  90031. }
  90032. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  90033. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](null, null, length);
  90034. intersectInfo.faceId = index / 2;
  90035. if (fastCheck) {
  90036. break;
  90037. }
  90038. }
  90039. }
  90040. return intersectInfo;
  90041. };
  90042. /** @hidden */
  90043. SubMesh.prototype._intersectTriangles = function (ray, positions, indices, fastCheck) {
  90044. var intersectInfo = null;
  90045. // Triangles test
  90046. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  90047. var p0 = positions[indices[index]];
  90048. var p1 = positions[indices[index + 1]];
  90049. var p2 = positions[indices[index + 2]];
  90050. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  90051. if (currentIntersectInfo) {
  90052. if (currentIntersectInfo.distance < 0) {
  90053. continue;
  90054. }
  90055. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  90056. intersectInfo = currentIntersectInfo;
  90057. intersectInfo.faceId = index / 3;
  90058. if (fastCheck) {
  90059. break;
  90060. }
  90061. }
  90062. }
  90063. }
  90064. return intersectInfo;
  90065. };
  90066. /** @hidden */
  90067. SubMesh.prototype._rebuild = function () {
  90068. if (this._linesIndexBuffer) {
  90069. this._linesIndexBuffer = null;
  90070. }
  90071. };
  90072. // Clone
  90073. /**
  90074. * Creates a new submesh from the passed mesh
  90075. * @param newMesh defines the new hosting mesh
  90076. * @param newRenderingMesh defines an optional rendering mesh
  90077. * @returns the new submesh
  90078. */
  90079. SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
  90080. var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
  90081. if (!this.IsGlobal) {
  90082. var boundingInfo = this.getBoundingInfo();
  90083. if (!boundingInfo) {
  90084. return result;
  90085. }
  90086. result._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](boundingInfo.minimum, boundingInfo.maximum);
  90087. }
  90088. return result;
  90089. };
  90090. // Dispose
  90091. /**
  90092. * Release associated resources
  90093. */
  90094. SubMesh.prototype.dispose = function () {
  90095. if (this._linesIndexBuffer) {
  90096. this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
  90097. this._linesIndexBuffer = null;
  90098. }
  90099. // Remove from mesh
  90100. var index = this._mesh.subMeshes.indexOf(this);
  90101. this._mesh.subMeshes.splice(index, 1);
  90102. };
  90103. /**
  90104. * Gets the class name
  90105. * @returns the string "SubMesh".
  90106. */
  90107. SubMesh.prototype.getClassName = function () {
  90108. return "SubMesh";
  90109. };
  90110. // Statics
  90111. /**
  90112. * Creates a new submesh from indices data
  90113. * @param materialIndex the index of the main mesh material
  90114. * @param startIndex the index where to start the copy in the mesh indices array
  90115. * @param indexCount the number of indices to copy then from the startIndex
  90116. * @param mesh the main mesh to create the submesh from
  90117. * @param renderingMesh the optional rendering mesh
  90118. * @returns a new submesh
  90119. */
  90120. SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
  90121. var minVertexIndex = Number.MAX_VALUE;
  90122. var maxVertexIndex = -Number.MAX_VALUE;
  90123. var whatWillRender = (renderingMesh || mesh);
  90124. var indices = whatWillRender.getIndices();
  90125. for (var index = startIndex; index < startIndex + indexCount; index++) {
  90126. var vertexIndex = indices[index];
  90127. if (vertexIndex < minVertexIndex) {
  90128. minVertexIndex = vertexIndex;
  90129. }
  90130. if (vertexIndex > maxVertexIndex) {
  90131. maxVertexIndex = vertexIndex;
  90132. }
  90133. }
  90134. return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
  90135. };
  90136. return SubMesh;
  90137. }(BaseSubMesh));
  90138. /***/ }),
  90139. /***/ "./Meshes/transformNode.ts":
  90140. /*!*********************************!*\
  90141. !*** ./Meshes/transformNode.ts ***!
  90142. \*********************************/
  90143. /*! exports provided: TransformNode */
  90144. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90145. "use strict";
  90146. __webpack_require__.r(__webpack_exports__);
  90147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return TransformNode; });
  90148. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  90149. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  90150. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  90151. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  90152. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  90153. /**
  90154. * 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.
  90155. * @see https://doc.babylonjs.com/how_to/transformnode
  90156. */
  90157. var TransformNode = /** @class */ (function (_super) {
  90158. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformNode, _super);
  90159. function TransformNode(name, scene, isPure) {
  90160. if (scene === void 0) { scene = null; }
  90161. if (isPure === void 0) { isPure = true; }
  90162. var _this = _super.call(this, name, scene) || this;
  90163. _this._forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  90164. _this._forwardInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  90165. _this._up = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0);
  90166. _this._right = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  90167. _this._rightInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-1, 0, 0);
  90168. // Properties
  90169. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90170. _this._rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90171. _this._scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].One();
  90172. _this._isDirty = false;
  90173. /**
  90174. * Set the billboard mode. Default is 0.
  90175. *
  90176. * | Value | Type | Description |
  90177. * | --- | --- | --- |
  90178. * | 0 | BILLBOARDMODE_NONE | |
  90179. * | 1 | BILLBOARDMODE_X | |
  90180. * | 2 | BILLBOARDMODE_Y | |
  90181. * | 4 | BILLBOARDMODE_Z | |
  90182. * | 7 | BILLBOARDMODE_ALL | |
  90183. *
  90184. */
  90185. _this.billboardMode = TransformNode.BILLBOARDMODE_NONE;
  90186. /**
  90187. * 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
  90188. */
  90189. _this.scalingDeterminant = 1;
  90190. /**
  90191. * Sets the distance of the object to max, often used by skybox
  90192. */
  90193. _this.infiniteDistance = false;
  90194. /**
  90195. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  90196. * By default the system will update normals to compensate
  90197. */
  90198. _this.ignoreNonUniformScaling = false;
  90199. /** @hidden */
  90200. _this._localMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  90201. _this._absolutePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90202. _this._pivotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  90203. _this._postMultiplyPivotMatrix = false;
  90204. _this._isWorldMatrixFrozen = false;
  90205. /** @hidden */
  90206. _this._indexInSceneTransformNodesArray = -1;
  90207. /**
  90208. * An event triggered after the world matrix is updated
  90209. */
  90210. _this.onAfterWorldMatrixUpdateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  90211. _this._nonUniformScaling = false;
  90212. if (isPure) {
  90213. _this.getScene().addTransformNode(_this);
  90214. }
  90215. return _this;
  90216. }
  90217. /**
  90218. * Gets a string identifying the name of the class
  90219. * @returns "TransformNode" string
  90220. */
  90221. TransformNode.prototype.getClassName = function () {
  90222. return "TransformNode";
  90223. };
  90224. Object.defineProperty(TransformNode.prototype, "position", {
  90225. /**
  90226. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  90227. */
  90228. get: function () {
  90229. return this._position;
  90230. },
  90231. set: function (newPosition) {
  90232. this._position = newPosition;
  90233. this._isDirty = true;
  90234. },
  90235. enumerable: true,
  90236. configurable: true
  90237. });
  90238. Object.defineProperty(TransformNode.prototype, "rotation", {
  90239. /**
  90240. * 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)).
  90241. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  90242. */
  90243. get: function () {
  90244. return this._rotation;
  90245. },
  90246. set: function (newRotation) {
  90247. this._rotation = newRotation;
  90248. this._isDirty = true;
  90249. },
  90250. enumerable: true,
  90251. configurable: true
  90252. });
  90253. Object.defineProperty(TransformNode.prototype, "scaling", {
  90254. /**
  90255. * 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)).
  90256. */
  90257. get: function () {
  90258. return this._scaling;
  90259. },
  90260. set: function (newScaling) {
  90261. this._scaling = newScaling;
  90262. this._isDirty = true;
  90263. },
  90264. enumerable: true,
  90265. configurable: true
  90266. });
  90267. Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
  90268. /**
  90269. * 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).
  90270. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  90271. */
  90272. get: function () {
  90273. return this._rotationQuaternion;
  90274. },
  90275. set: function (quaternion) {
  90276. this._rotationQuaternion = quaternion;
  90277. //reset the rotation vector.
  90278. if (quaternion) {
  90279. this.rotation.setAll(0.0);
  90280. }
  90281. },
  90282. enumerable: true,
  90283. configurable: true
  90284. });
  90285. Object.defineProperty(TransformNode.prototype, "forward", {
  90286. /**
  90287. * The forward direction of that transform in world space.
  90288. */
  90289. get: function () {
  90290. 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()));
  90291. },
  90292. enumerable: true,
  90293. configurable: true
  90294. });
  90295. Object.defineProperty(TransformNode.prototype, "up", {
  90296. /**
  90297. * The up direction of that transform in world space.
  90298. */
  90299. get: function () {
  90300. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this._up, this.getWorldMatrix()));
  90301. },
  90302. enumerable: true,
  90303. configurable: true
  90304. });
  90305. Object.defineProperty(TransformNode.prototype, "right", {
  90306. /**
  90307. * The right direction of that transform in world space.
  90308. */
  90309. get: function () {
  90310. 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()));
  90311. },
  90312. enumerable: true,
  90313. configurable: true
  90314. });
  90315. /**
  90316. * Copies the parameter passed Matrix into the mesh Pose matrix.
  90317. * @param matrix the matrix to copy the pose from
  90318. * @returns this TransformNode.
  90319. */
  90320. TransformNode.prototype.updatePoseMatrix = function (matrix) {
  90321. this._poseMatrix.copyFrom(matrix);
  90322. return this;
  90323. };
  90324. /**
  90325. * Returns the mesh Pose matrix.
  90326. * @returns the pose matrix
  90327. */
  90328. TransformNode.prototype.getPoseMatrix = function () {
  90329. return this._poseMatrix;
  90330. };
  90331. /** @hidden */
  90332. TransformNode.prototype._isSynchronized = function () {
  90333. if (this._isDirty) {
  90334. return false;
  90335. }
  90336. if (this.billboardMode !== this._cache.billboardMode || this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  90337. return false;
  90338. }
  90339. if (this._cache.pivotMatrixUpdated) {
  90340. return false;
  90341. }
  90342. if (this.infiniteDistance) {
  90343. return false;
  90344. }
  90345. if (!this._cache.position.equals(this._position)) {
  90346. return false;
  90347. }
  90348. if (this._rotationQuaternion) {
  90349. if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion)) {
  90350. return false;
  90351. }
  90352. }
  90353. if (!this._cache.rotation.equals(this._rotation)) {
  90354. return false;
  90355. }
  90356. if (!this._cache.scaling.equals(this._scaling)) {
  90357. return false;
  90358. }
  90359. return true;
  90360. };
  90361. /** @hidden */
  90362. TransformNode.prototype._initCache = function () {
  90363. _super.prototype._initCache.call(this);
  90364. this._cache.localMatrixUpdated = false;
  90365. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90366. this._cache.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90367. this._cache.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90368. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](0, 0, 0, 0);
  90369. this._cache.billboardMode = -1;
  90370. this._cache.infiniteDistance = false;
  90371. };
  90372. /**
  90373. * Flag the transform node as dirty (Forcing it to update everything)
  90374. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  90375. * @returns this transform node
  90376. */
  90377. TransformNode.prototype.markAsDirty = function (property) {
  90378. if (property === "rotation") {
  90379. this.rotationQuaternion = null;
  90380. }
  90381. this._currentRenderId = Number.MAX_VALUE;
  90382. this._isDirty = true;
  90383. return this;
  90384. };
  90385. Object.defineProperty(TransformNode.prototype, "absolutePosition", {
  90386. /**
  90387. * Returns the current mesh absolute position.
  90388. * Returns a Vector3.
  90389. */
  90390. get: function () {
  90391. return this._absolutePosition;
  90392. },
  90393. enumerable: true,
  90394. configurable: true
  90395. });
  90396. /**
  90397. * Sets a new matrix to apply before all other transformation
  90398. * @param matrix defines the transform matrix
  90399. * @returns the current TransformNode
  90400. */
  90401. TransformNode.prototype.setPreTransformMatrix = function (matrix) {
  90402. return this.setPivotMatrix(matrix, false);
  90403. };
  90404. /**
  90405. * Sets a new pivot matrix to the current node
  90406. * @param matrix defines the new pivot matrix to use
  90407. * @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
  90408. * @returns the current TransformNode
  90409. */
  90410. TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
  90411. if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
  90412. this._pivotMatrix.copyFrom(matrix);
  90413. this._cache.pivotMatrixUpdated = true;
  90414. this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
  90415. if (this._postMultiplyPivotMatrix) {
  90416. if (!this._pivotMatrixInverse) {
  90417. this._pivotMatrixInverse = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._pivotMatrix);
  90418. }
  90419. else {
  90420. this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
  90421. }
  90422. }
  90423. return this;
  90424. };
  90425. /**
  90426. * Returns the mesh pivot matrix.
  90427. * Default : Identity.
  90428. * @returns the matrix
  90429. */
  90430. TransformNode.prototype.getPivotMatrix = function () {
  90431. return this._pivotMatrix;
  90432. };
  90433. /**
  90434. * Prevents the World matrix to be computed any longer.
  90435. * @returns the TransformNode.
  90436. */
  90437. TransformNode.prototype.freezeWorldMatrix = function () {
  90438. this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
  90439. this.computeWorldMatrix(true);
  90440. this._isWorldMatrixFrozen = true;
  90441. return this;
  90442. };
  90443. /**
  90444. * Allows back the World matrix computation.
  90445. * @returns the TransformNode.
  90446. */
  90447. TransformNode.prototype.unfreezeWorldMatrix = function () {
  90448. this._isWorldMatrixFrozen = false;
  90449. this.computeWorldMatrix(true);
  90450. return this;
  90451. };
  90452. Object.defineProperty(TransformNode.prototype, "isWorldMatrixFrozen", {
  90453. /**
  90454. * True if the World matrix has been frozen.
  90455. */
  90456. get: function () {
  90457. return this._isWorldMatrixFrozen;
  90458. },
  90459. enumerable: true,
  90460. configurable: true
  90461. });
  90462. /**
  90463. * Retuns the mesh absolute position in the World.
  90464. * @returns a Vector3.
  90465. */
  90466. TransformNode.prototype.getAbsolutePosition = function () {
  90467. this.computeWorldMatrix();
  90468. return this._absolutePosition;
  90469. };
  90470. /**
  90471. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  90472. * @param absolutePosition the absolute position to set
  90473. * @returns the TransformNode.
  90474. */
  90475. TransformNode.prototype.setAbsolutePosition = function (absolutePosition) {
  90476. if (!absolutePosition) {
  90477. return this;
  90478. }
  90479. var absolutePositionX;
  90480. var absolutePositionY;
  90481. var absolutePositionZ;
  90482. if (absolutePosition.x === undefined) {
  90483. if (arguments.length < 3) {
  90484. return this;
  90485. }
  90486. absolutePositionX = arguments[0];
  90487. absolutePositionY = arguments[1];
  90488. absolutePositionZ = arguments[2];
  90489. }
  90490. else {
  90491. absolutePositionX = absolutePosition.x;
  90492. absolutePositionY = absolutePosition.y;
  90493. absolutePositionZ = absolutePosition.z;
  90494. }
  90495. if (this.parent) {
  90496. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90497. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  90498. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
  90499. }
  90500. else {
  90501. this.position.x = absolutePositionX;
  90502. this.position.y = absolutePositionY;
  90503. this.position.z = absolutePositionZ;
  90504. }
  90505. return this;
  90506. };
  90507. /**
  90508. * Sets the mesh position in its local space.
  90509. * @param vector3 the position to set in localspace
  90510. * @returns the TransformNode.
  90511. */
  90512. TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
  90513. this.computeWorldMatrix();
  90514. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(vector3, this._localMatrix);
  90515. return this;
  90516. };
  90517. /**
  90518. * Returns the mesh position in the local space from the current World matrix values.
  90519. * @returns a new Vector3.
  90520. */
  90521. TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
  90522. this.computeWorldMatrix();
  90523. var invLocalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90524. this._localMatrix.invertToRef(invLocalWorldMatrix);
  90525. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.position, invLocalWorldMatrix);
  90526. };
  90527. /**
  90528. * Translates the mesh along the passed Vector3 in its local space.
  90529. * @param vector3 the distance to translate in localspace
  90530. * @returns the TransformNode.
  90531. */
  90532. TransformNode.prototype.locallyTranslate = function (vector3) {
  90533. this.computeWorldMatrix(true);
  90534. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(vector3, this._localMatrix);
  90535. return this;
  90536. };
  90537. /**
  90538. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  90539. * @param targetPoint the position (must be in same space as current mesh) to look at
  90540. * @param yawCor optional yaw (y-axis) correction in radians
  90541. * @param pitchCor optional pitch (x-axis) correction in radians
  90542. * @param rollCor optional roll (z-axis) correction in radians
  90543. * @param space the choosen space of the target
  90544. * @returns the TransformNode.
  90545. */
  90546. TransformNode.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor, space) {
  90547. if (yawCor === void 0) { yawCor = 0; }
  90548. if (pitchCor === void 0) { pitchCor = 0; }
  90549. if (rollCor === void 0) { rollCor = 0; }
  90550. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  90551. var dv = TransformNode._lookAtVectorCache;
  90552. var pos = space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL ? this.position : this.getAbsolutePosition();
  90553. targetPoint.subtractToRef(pos, dv);
  90554. this.setDirection(dv, yawCor, pitchCor, rollCor);
  90555. // Correct for parent's rotation offset
  90556. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD && this.parent) {
  90557. if (this.rotationQuaternion) {
  90558. // Get local rotation matrix of the looking object
  90559. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90560. this.rotationQuaternion.toRotationMatrix(rotationMatrix);
  90561. // Offset rotation by parent's inverted rotation matrix to correct in world space
  90562. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  90563. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  90564. parentRotationMatrix.invert();
  90565. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  90566. this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
  90567. }
  90568. else {
  90569. // Get local rotation matrix of the looking object
  90570. var quaternionRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  90571. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, quaternionRotation);
  90572. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90573. quaternionRotation.toRotationMatrix(rotationMatrix);
  90574. // Offset rotation by parent's inverted rotation matrix to correct in world space
  90575. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  90576. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  90577. parentRotationMatrix.invert();
  90578. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  90579. quaternionRotation.fromRotationMatrix(rotationMatrix);
  90580. quaternionRotation.toEulerAnglesToRef(this.rotation);
  90581. }
  90582. }
  90583. return this;
  90584. };
  90585. /**
  90586. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  90587. * This Vector3 is expressed in the World space.
  90588. * @param localAxis axis to rotate
  90589. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  90590. */
  90591. TransformNode.prototype.getDirection = function (localAxis) {
  90592. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90593. this.getDirectionToRef(localAxis, result);
  90594. return result;
  90595. };
  90596. /**
  90597. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  90598. * localAxis is expressed in the mesh local space.
  90599. * result is computed in the Wordl space from the mesh World matrix.
  90600. * @param localAxis axis to rotate
  90601. * @param result the resulting transformnode
  90602. * @returns this TransformNode.
  90603. */
  90604. TransformNode.prototype.getDirectionToRef = function (localAxis, result) {
  90605. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  90606. return this;
  90607. };
  90608. /**
  90609. * Sets this transform node rotation to the given local axis.
  90610. * @param localAxis the axis in local space
  90611. * @param yawCor optional yaw (y-axis) correction in radians
  90612. * @param pitchCor optional pitch (x-axis) correction in radians
  90613. * @param rollCor optional roll (z-axis) correction in radians
  90614. * @returns this TransformNode
  90615. */
  90616. TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
  90617. if (yawCor === void 0) { yawCor = 0; }
  90618. if (pitchCor === void 0) { pitchCor = 0; }
  90619. if (rollCor === void 0) { rollCor = 0; }
  90620. var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
  90621. var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
  90622. var pitch = -Math.atan2(localAxis.y, len);
  90623. if (this.rotationQuaternion) {
  90624. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
  90625. }
  90626. else {
  90627. this.rotation.x = pitch + pitchCor;
  90628. this.rotation.y = yaw + yawCor;
  90629. this.rotation.z = rollCor;
  90630. }
  90631. return this;
  90632. };
  90633. /**
  90634. * Sets a new pivot point to the current node
  90635. * @param point defines the new pivot point to use
  90636. * @param space defines if the point is in world or local space (local by default)
  90637. * @returns the current TransformNode
  90638. */
  90639. TransformNode.prototype.setPivotPoint = function (point, space) {
  90640. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  90641. if (this.getScene().getRenderId() == 0) {
  90642. this.computeWorldMatrix(true);
  90643. }
  90644. var wm = this.getWorldMatrix();
  90645. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD) {
  90646. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90647. wm.invertToRef(tmat);
  90648. point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(point, tmat);
  90649. }
  90650. return this.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(-point.x, -point.y, -point.z), true);
  90651. };
  90652. /**
  90653. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  90654. * @returns the pivot point
  90655. */
  90656. TransformNode.prototype.getPivotPoint = function () {
  90657. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90658. this.getPivotPointToRef(point);
  90659. return point;
  90660. };
  90661. /**
  90662. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  90663. * @param result the vector3 to store the result
  90664. * @returns this TransformNode.
  90665. */
  90666. TransformNode.prototype.getPivotPointToRef = function (result) {
  90667. result.x = -this._pivotMatrix.m[12];
  90668. result.y = -this._pivotMatrix.m[13];
  90669. result.z = -this._pivotMatrix.m[14];
  90670. return this;
  90671. };
  90672. /**
  90673. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  90674. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  90675. */
  90676. TransformNode.prototype.getAbsolutePivotPoint = function () {
  90677. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90678. this.getAbsolutePivotPointToRef(point);
  90679. return point;
  90680. };
  90681. /**
  90682. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  90683. * @param result vector3 to store the result
  90684. * @returns this TransformNode.
  90685. */
  90686. TransformNode.prototype.getAbsolutePivotPointToRef = function (result) {
  90687. result.x = this._pivotMatrix.m[12];
  90688. result.y = this._pivotMatrix.m[13];
  90689. result.z = this._pivotMatrix.m[14];
  90690. this.getPivotPointToRef(result);
  90691. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
  90692. return this;
  90693. };
  90694. /**
  90695. * Defines the passed node as the parent of the current node.
  90696. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  90697. * @param node the node ot set as the parent
  90698. * @returns this TransformNode.
  90699. */
  90700. TransformNode.prototype.setParent = function (node) {
  90701. if (!node && !this.parent) {
  90702. return this;
  90703. }
  90704. var quatRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  90705. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  90706. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  90707. if (!node) {
  90708. if (this.parent && this.parent.computeWorldMatrix) {
  90709. this.parent.computeWorldMatrix(true);
  90710. }
  90711. this.computeWorldMatrix(true);
  90712. this.getWorldMatrix().decompose(scale, quatRotation, position);
  90713. }
  90714. else {
  90715. var diffMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90716. var invParentMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  90717. this.computeWorldMatrix(true);
  90718. node.computeWorldMatrix(true);
  90719. node.getWorldMatrix().invertToRef(invParentMatrix);
  90720. this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
  90721. diffMatrix.decompose(scale, quatRotation, position);
  90722. }
  90723. if (this.rotationQuaternion) {
  90724. this.rotationQuaternion.copyFrom(quatRotation);
  90725. }
  90726. else {
  90727. quatRotation.toEulerAnglesToRef(this.rotation);
  90728. }
  90729. this.scaling.copyFrom(scale);
  90730. this.position.copyFrom(position);
  90731. this.parent = node;
  90732. return this;
  90733. };
  90734. Object.defineProperty(TransformNode.prototype, "nonUniformScaling", {
  90735. /**
  90736. * True if the scaling property of this object is non uniform eg. (1,2,1)
  90737. */
  90738. get: function () {
  90739. return this._nonUniformScaling;
  90740. },
  90741. enumerable: true,
  90742. configurable: true
  90743. });
  90744. /** @hidden */
  90745. TransformNode.prototype._updateNonUniformScalingState = function (value) {
  90746. if (this._nonUniformScaling === value) {
  90747. return false;
  90748. }
  90749. this._nonUniformScaling = value;
  90750. return true;
  90751. };
  90752. /**
  90753. * Attach the current TransformNode to another TransformNode associated with a bone
  90754. * @param bone Bone affecting the TransformNode
  90755. * @param affectedTransformNode TransformNode associated with the bone
  90756. * @returns this object
  90757. */
  90758. TransformNode.prototype.attachToBone = function (bone, affectedTransformNode) {
  90759. this._transformToBoneReferal = affectedTransformNode;
  90760. this.parent = bone;
  90761. if (bone.getWorldMatrix().determinant() < 0) {
  90762. this.scalingDeterminant *= -1;
  90763. }
  90764. return this;
  90765. };
  90766. /**
  90767. * Detach the transform node if its associated with a bone
  90768. * @returns this object
  90769. */
  90770. TransformNode.prototype.detachFromBone = function () {
  90771. if (!this.parent) {
  90772. return this;
  90773. }
  90774. if (this.parent.getWorldMatrix().determinant() < 0) {
  90775. this.scalingDeterminant *= -1;
  90776. }
  90777. this._transformToBoneReferal = null;
  90778. this.parent = null;
  90779. return this;
  90780. };
  90781. /**
  90782. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  90783. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  90784. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  90785. * The passed axis is also normalized.
  90786. * @param axis the axis to rotate around
  90787. * @param amount the amount to rotate in radians
  90788. * @param space Space to rotate in (Default: local)
  90789. * @returns the TransformNode.
  90790. */
  90791. TransformNode.prototype.rotate = function (axis, amount, space) {
  90792. axis.normalize();
  90793. if (!this.rotationQuaternion) {
  90794. this.rotationQuaternion = this.rotation.toQuaternion();
  90795. this.rotation.setAll(0);
  90796. }
  90797. var rotationQuaternion;
  90798. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  90799. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  90800. this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
  90801. }
  90802. else {
  90803. if (this.parent) {
  90804. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  90805. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  90806. axis = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(axis, invertParentWorldMatrix);
  90807. }
  90808. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  90809. rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  90810. }
  90811. return this;
  90812. };
  90813. /**
  90814. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  90815. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  90816. * The passed axis is also normalized. .
  90817. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  90818. * @param point the point to rotate around
  90819. * @param axis the axis to rotate around
  90820. * @param amount the amount to rotate in radians
  90821. * @returns the TransformNode
  90822. */
  90823. TransformNode.prototype.rotateAround = function (point, axis, amount) {
  90824. axis.normalize();
  90825. if (!this.rotationQuaternion) {
  90826. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  90827. this.rotation.setAll(0);
  90828. }
  90829. var tmpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  90830. var finalScale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  90831. var finalTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[2];
  90832. var finalRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  90833. var translationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]; // T
  90834. var translationMatrixInv = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]; // T'
  90835. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]; // R
  90836. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[3]; // T' x R x T
  90837. point.subtractToRef(this.position, tmpVector);
  90838. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
  90839. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
  90840. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(axis, amount, rotationMatrix); // R
  90841. translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
  90842. finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
  90843. finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
  90844. this.position.addInPlace(finalTranslation);
  90845. finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  90846. return this;
  90847. };
  90848. /**
  90849. * Translates the mesh along the axis vector for the passed distance in the given space.
  90850. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  90851. * @param axis the axis to translate in
  90852. * @param distance the distance to translate
  90853. * @param space Space to rotate in (Default: local)
  90854. * @returns the TransformNode.
  90855. */
  90856. TransformNode.prototype.translate = function (axis, distance, space) {
  90857. var displacementVector = axis.scale(distance);
  90858. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  90859. var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
  90860. this.setPositionWithLocalVector(tempV3);
  90861. }
  90862. else {
  90863. this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
  90864. }
  90865. return this;
  90866. };
  90867. /**
  90868. * Adds a rotation step to the mesh current rotation.
  90869. * x, y, z are Euler angles expressed in radians.
  90870. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  90871. * This means this rotation is made in the mesh local space only.
  90872. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  90873. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  90874. * ```javascript
  90875. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  90876. * ```
  90877. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  90878. * 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.
  90879. * @param x Rotation to add
  90880. * @param y Rotation to add
  90881. * @param z Rotation to add
  90882. * @returns the TransformNode.
  90883. */
  90884. TransformNode.prototype.addRotation = function (x, y, z) {
  90885. var rotationQuaternion;
  90886. if (this.rotationQuaternion) {
  90887. rotationQuaternion = this.rotationQuaternion;
  90888. }
  90889. else {
  90890. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[1];
  90891. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
  90892. }
  90893. var accumulation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  90894. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(y, x, z, accumulation);
  90895. rotationQuaternion.multiplyInPlace(accumulation);
  90896. if (!this.rotationQuaternion) {
  90897. rotationQuaternion.toEulerAnglesToRef(this.rotation);
  90898. }
  90899. return this;
  90900. };
  90901. /**
  90902. * Computes the world matrix of the node
  90903. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90904. * @returns the world matrix
  90905. */
  90906. TransformNode.prototype.computeWorldMatrix = function (force) {
  90907. if (this._isWorldMatrixFrozen) {
  90908. return this._worldMatrix;
  90909. }
  90910. if (!force && this.isSynchronized()) {
  90911. this._currentRenderId = this.getScene().getRenderId();
  90912. return this._worldMatrix;
  90913. }
  90914. this._updateCache();
  90915. this._cache.position.copyFrom(this.position);
  90916. this._cache.scaling.copyFrom(this.scaling);
  90917. this._cache.pivotMatrixUpdated = false;
  90918. this._cache.billboardMode = this.billboardMode;
  90919. this._cache.infiniteDistance = this.infiniteDistance;
  90920. this._currentRenderId = this.getScene().getRenderId();
  90921. this._childRenderId = this.getScene().getRenderId();
  90922. this._isDirty = false;
  90923. // Scaling
  90924. _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]);
  90925. // Rotation
  90926. //rotate, if quaternion is set and rotation was used
  90927. if (this.rotationQuaternion) {
  90928. var len = this.rotation.length();
  90929. if (len) {
  90930. this.rotationQuaternion.multiplyInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z));
  90931. this.rotation.copyFromFloats(0, 0, 0);
  90932. }
  90933. }
  90934. if (this.rotationQuaternion) {
  90935. this.rotationQuaternion.toRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  90936. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  90937. }
  90938. else {
  90939. _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]);
  90940. this._cache.rotation.copyFrom(this.rotation);
  90941. }
  90942. // Translation
  90943. var camera = this.getScene().activeCamera;
  90944. if (this.infiniteDistance && !this.parent && camera) {
  90945. var cameraWorldMatrix = camera.getWorldMatrix();
  90946. var cameraGlobalPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
  90947. _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]);
  90948. }
  90949. else {
  90950. _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]);
  90951. }
  90952. // Composing transformations
  90953. this._pivotMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4]);
  90954. _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]);
  90955. // Billboarding (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
  90956. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE && camera) {
  90957. if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
  90958. // Need to decompose each rotation here
  90959. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[3];
  90960. if (this.parent && this.parent.getWorldMatrix) {
  90961. if (this._transformToBoneReferal) {
  90962. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  90963. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6], currentPosition);
  90964. }
  90965. else {
  90966. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), currentPosition);
  90967. }
  90968. }
  90969. else {
  90970. currentPosition.copyFrom(this.position);
  90971. }
  90972. currentPosition.subtractInPlace(camera.globalPosition);
  90973. var finalEuler = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[4].copyFromFloats(0, 0, 0);
  90974. if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) === TransformNode.BILLBOARDMODE_X) {
  90975. finalEuler.x = Math.atan2(-currentPosition.y, currentPosition.z);
  90976. }
  90977. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) === TransformNode.BILLBOARDMODE_Y) {
  90978. finalEuler.y = Math.atan2(currentPosition.x, currentPosition.z);
  90979. }
  90980. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) === TransformNode.BILLBOARDMODE_Z) {
  90981. finalEuler.z = Math.atan2(currentPosition.y, currentPosition.x);
  90982. }
  90983. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(finalEuler.y, finalEuler.x, finalEuler.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  90984. }
  90985. else {
  90986. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(camera.getViewMatrix());
  90987. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].setTranslationFromFloats(0, 0, 0);
  90988. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  90989. }
  90990. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5]);
  90991. _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]);
  90992. }
  90993. // Post multiply inverse of pivotMatrix
  90994. if (this._postMultiplyPivotMatrix) {
  90995. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].multiplyToRef(this._pivotMatrixInverse, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5]);
  90996. }
  90997. // Local world
  90998. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2], this._localMatrix);
  90999. // Parent
  91000. if (this.parent && this.parent.getWorldMatrix) {
  91001. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  91002. if (this._transformToBoneReferal) {
  91003. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  91004. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  91005. }
  91006. else {
  91007. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].copyFrom(this.parent.getWorldMatrix());
  91008. }
  91009. this._localMatrix.getTranslationToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5]);
  91010. _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]);
  91011. this._worldMatrix.copyFrom(this._localMatrix);
  91012. this._worldMatrix.setTranslation(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5]);
  91013. }
  91014. else {
  91015. if (this._transformToBoneReferal) {
  91016. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  91017. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
  91018. }
  91019. else {
  91020. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  91021. }
  91022. }
  91023. this._markSyncedWithParent();
  91024. }
  91025. else {
  91026. this._worldMatrix.copyFrom(this._localMatrix);
  91027. }
  91028. // Normal matrix
  91029. if (!this.ignoreNonUniformScaling) {
  91030. if (this.scaling.isNonUniform) {
  91031. this._updateNonUniformScalingState(true);
  91032. }
  91033. else if (this.parent && this.parent._nonUniformScaling) {
  91034. this._updateNonUniformScalingState(this.parent._nonUniformScaling);
  91035. }
  91036. else {
  91037. this._updateNonUniformScalingState(false);
  91038. }
  91039. }
  91040. else {
  91041. this._updateNonUniformScalingState(false);
  91042. }
  91043. this._afterComputeWorldMatrix();
  91044. // Absolute position
  91045. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
  91046. // Callbacks
  91047. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
  91048. if (!this._poseMatrix) {
  91049. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._worldMatrix);
  91050. }
  91051. // Cache the determinant
  91052. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  91053. return this._worldMatrix;
  91054. };
  91055. TransformNode.prototype._afterComputeWorldMatrix = function () {
  91056. };
  91057. /**
  91058. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  91059. * @param func callback function to add
  91060. *
  91061. * @returns the TransformNode.
  91062. */
  91063. TransformNode.prototype.registerAfterWorldMatrixUpdate = function (func) {
  91064. this.onAfterWorldMatrixUpdateObservable.add(func);
  91065. return this;
  91066. };
  91067. /**
  91068. * Removes a registered callback function.
  91069. * @param func callback function to remove
  91070. * @returns the TransformNode.
  91071. */
  91072. TransformNode.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
  91073. this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
  91074. return this;
  91075. };
  91076. /**
  91077. * Gets the position of the current mesh in camera space
  91078. * @param camera defines the camera to use
  91079. * @returns a position
  91080. */
  91081. TransformNode.prototype.getPositionInCameraSpace = function (camera) {
  91082. if (camera === void 0) { camera = null; }
  91083. if (!camera) {
  91084. camera = this.getScene().activeCamera;
  91085. }
  91086. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
  91087. };
  91088. /**
  91089. * Returns the distance from the mesh to the active camera
  91090. * @param camera defines the camera to use
  91091. * @returns the distance
  91092. */
  91093. TransformNode.prototype.getDistanceToCamera = function (camera) {
  91094. if (camera === void 0) { camera = null; }
  91095. if (!camera) {
  91096. camera = this.getScene().activeCamera;
  91097. }
  91098. return this.absolutePosition.subtract(camera.position).length();
  91099. };
  91100. /**
  91101. * Clone the current transform node
  91102. * @param name Name of the new clone
  91103. * @param newParent New parent for the clone
  91104. * @param doNotCloneChildren Do not clone children hierarchy
  91105. * @returns the new transform node
  91106. */
  91107. TransformNode.prototype.clone = function (name, newParent, doNotCloneChildren) {
  91108. var _this = this;
  91109. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TransformNode(name, _this.getScene()); }, this);
  91110. result.name = name;
  91111. result.id = name;
  91112. if (newParent) {
  91113. result.parent = newParent;
  91114. }
  91115. if (!doNotCloneChildren) {
  91116. // Children
  91117. var directDescendants = this.getDescendants(true);
  91118. for (var index = 0; index < directDescendants.length; index++) {
  91119. var child = directDescendants[index];
  91120. if (child.clone) {
  91121. child.clone(name + "." + child.name, result);
  91122. }
  91123. }
  91124. }
  91125. return result;
  91126. };
  91127. /**
  91128. * Serializes the objects information.
  91129. * @param currentSerializationObject defines the object to serialize in
  91130. * @returns the serialized object
  91131. */
  91132. TransformNode.prototype.serialize = function (currentSerializationObject) {
  91133. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, currentSerializationObject);
  91134. serializationObject.type = this.getClassName();
  91135. // Parent
  91136. if (this.parent) {
  91137. serializationObject.parentId = this.parent.id;
  91138. }
  91139. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  91140. serializationObject.isEnabled = this.isEnabled();
  91141. // Parent
  91142. if (this.parent) {
  91143. serializationObject.parentId = this.parent.id;
  91144. }
  91145. return serializationObject;
  91146. };
  91147. // Statics
  91148. /**
  91149. * Returns a new TransformNode object parsed from the source provided.
  91150. * @param parsedTransformNode is the source.
  91151. * @param scene the scne the object belongs to
  91152. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  91153. * @returns a new TransformNode object parsed from the source provided.
  91154. */
  91155. TransformNode.Parse = function (parsedTransformNode, scene, rootUrl) {
  91156. var transformNode = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TransformNode(parsedTransformNode.name, scene); }, parsedTransformNode, scene, rootUrl);
  91157. if (parsedTransformNode.localMatrix) {
  91158. transformNode.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.localMatrix));
  91159. }
  91160. else if (parsedTransformNode.pivotMatrix) {
  91161. transformNode.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.pivotMatrix));
  91162. }
  91163. transformNode.setEnabled(parsedTransformNode.isEnabled);
  91164. // Parent
  91165. if (parsedTransformNode.parentId) {
  91166. transformNode._waitingParentId = parsedTransformNode.parentId;
  91167. }
  91168. return transformNode;
  91169. };
  91170. /**
  91171. * Get all child-transformNodes of this node
  91172. * @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
  91173. * @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
  91174. * @returns an array of TransformNode
  91175. */
  91176. TransformNode.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
  91177. var results = [];
  91178. this._getDescendants(results, directDescendantsOnly, function (node) {
  91179. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  91180. });
  91181. return results;
  91182. };
  91183. /**
  91184. * Releases resources associated with this transform node.
  91185. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91186. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91187. */
  91188. TransformNode.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  91189. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  91190. // Animations
  91191. this.getScene().stopAnimation(this);
  91192. // Remove from scene
  91193. this.getScene().removeTransformNode(this);
  91194. this.onAfterWorldMatrixUpdateObservable.clear();
  91195. if (doNotRecurse) {
  91196. var transformNodes = this.getChildTransformNodes(true);
  91197. for (var _i = 0, transformNodes_1 = transformNodes; _i < transformNodes_1.length; _i++) {
  91198. var transformNode = transformNodes_1[_i];
  91199. transformNode.parent = null;
  91200. transformNode.computeWorldMatrix(true);
  91201. }
  91202. }
  91203. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  91204. };
  91205. // Statics
  91206. /**
  91207. * Object will not rotate to face the camera
  91208. */
  91209. TransformNode.BILLBOARDMODE_NONE = 0;
  91210. /**
  91211. * Object will rotate to face the camera but only on the x axis
  91212. */
  91213. TransformNode.BILLBOARDMODE_X = 1;
  91214. /**
  91215. * Object will rotate to face the camera but only on the y axis
  91216. */
  91217. TransformNode.BILLBOARDMODE_Y = 2;
  91218. /**
  91219. * Object will rotate to face the camera but only on the z axis
  91220. */
  91221. TransformNode.BILLBOARDMODE_Z = 4;
  91222. /**
  91223. * Object will rotate to face the camera
  91224. */
  91225. TransformNode.BILLBOARDMODE_ALL = 7;
  91226. TransformNode._lookAtVectorCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  91227. TransformNode._rotationAxisCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  91228. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91229. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  91230. ], TransformNode.prototype, "_position", void 0);
  91231. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91232. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("rotation")
  91233. ], TransformNode.prototype, "_rotation", void 0);
  91234. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91235. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsQuaternion"])("rotationQuaternion")
  91236. ], TransformNode.prototype, "_rotationQuaternion", void 0);
  91237. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91238. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("scaling")
  91239. ], TransformNode.prototype, "_scaling", void 0);
  91240. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91241. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91242. ], TransformNode.prototype, "billboardMode", void 0);
  91243. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91244. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91245. ], TransformNode.prototype, "scalingDeterminant", void 0);
  91246. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91247. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91248. ], TransformNode.prototype, "infiniteDistance", void 0);
  91249. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91250. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91251. ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
  91252. return TransformNode;
  91253. }(_node__WEBPACK_IMPORTED_MODULE_4__["Node"]));
  91254. /***/ }),
  91255. /***/ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts":
  91256. /*!***************************************************************!*\
  91257. !*** ./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts ***!
  91258. \***************************************************************/
  91259. /*! exports provided: CubeMapToSphericalPolynomialTools */
  91260. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91261. "use strict";
  91262. __webpack_require__.r(__webpack_exports__);
  91263. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return CubeMapToSphericalPolynomialTools; });
  91264. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  91265. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  91266. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  91267. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  91268. var FileFaceOrientation = /** @class */ (function () {
  91269. function FileFaceOrientation(name, worldAxisForNormal, worldAxisForFileX, worldAxisForFileY) {
  91270. this.name = name;
  91271. this.worldAxisForNormal = worldAxisForNormal;
  91272. this.worldAxisForFileX = worldAxisForFileX;
  91273. this.worldAxisForFileY = worldAxisForFileY;
  91274. }
  91275. return FileFaceOrientation;
  91276. }());
  91277. /**
  91278. * Helper class dealing with the extraction of spherical polynomial dataArray
  91279. * from a cube map.
  91280. */
  91281. var CubeMapToSphericalPolynomialTools = /** @class */ (function () {
  91282. function CubeMapToSphericalPolynomialTools() {
  91283. }
  91284. /**
  91285. * Converts a texture to the according Spherical Polynomial data.
  91286. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91287. *
  91288. * @param texture The texture to extract the information from.
  91289. * @return The Spherical Polynomial data.
  91290. */
  91291. CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial = function (texture) {
  91292. if (!texture.isCube) {
  91293. // Only supports cube Textures currently.
  91294. return null;
  91295. }
  91296. var size = texture.getSize().width;
  91297. var right = texture.readPixels(0);
  91298. var left = texture.readPixels(1);
  91299. var up;
  91300. var down;
  91301. if (texture.isRenderTarget) {
  91302. up = texture.readPixels(3);
  91303. down = texture.readPixels(2);
  91304. }
  91305. else {
  91306. up = texture.readPixels(2);
  91307. down = texture.readPixels(3);
  91308. }
  91309. var front = texture.readPixels(4);
  91310. var back = texture.readPixels(5);
  91311. var gammaSpace = texture.gammaSpace;
  91312. // Always read as RGBA.
  91313. var format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA;
  91314. var type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  91315. if (texture.textureType && texture.textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  91316. type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_FLOAT;
  91317. }
  91318. var cubeInfo = {
  91319. size: size,
  91320. right: right,
  91321. left: left,
  91322. up: up,
  91323. down: down,
  91324. front: front,
  91325. back: back,
  91326. format: format,
  91327. type: type,
  91328. gammaSpace: gammaSpace,
  91329. };
  91330. return this.ConvertCubeMapToSphericalPolynomial(cubeInfo);
  91331. };
  91332. /**
  91333. * Converts a cubemap to the according Spherical Polynomial data.
  91334. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91335. *
  91336. * @param cubeInfo The Cube map to extract the information from.
  91337. * @return The Spherical Polynomial data.
  91338. */
  91339. CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial = function (cubeInfo) {
  91340. var sphericalHarmonics = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]();
  91341. var totalSolidAngle = 0.0;
  91342. // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.
  91343. var du = 2.0 / cubeInfo.size;
  91344. var dv = du;
  91345. // The (u,v) of the first texel is half a texel from the corner (-1,-1).
  91346. var minUV = du * 0.5 - 1.0;
  91347. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  91348. var fileFace = this.FileFaces[faceIndex];
  91349. var dataArray = cubeInfo[fileFace.name];
  91350. var v = minUV;
  91351. // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).
  91352. // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.
  91353. // Because SP is still linear, so summation is fine in that basis.
  91354. var stride = cubeInfo.format === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA ? 4 : 3;
  91355. for (var y = 0; y < cubeInfo.size; y++) {
  91356. var u = minUV;
  91357. for (var x = 0; x < cubeInfo.size; x++) {
  91358. // World direction (not normalised)
  91359. var worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);
  91360. worldDirection.normalize();
  91361. var deltaSolidAngle = Math.pow(1.0 + u * u + v * v, -3.0 / 2.0);
  91362. var r = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 0];
  91363. var g = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 1];
  91364. var b = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 2];
  91365. // Handle Integer types.
  91366. if (cubeInfo.type === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  91367. r /= 255;
  91368. g /= 255;
  91369. b /= 255;
  91370. }
  91371. // Handle Gamma space textures.
  91372. if (cubeInfo.gammaSpace) {
  91373. r = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  91374. g = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  91375. b = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  91376. }
  91377. var color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](r, g, b);
  91378. sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
  91379. totalSolidAngle += deltaSolidAngle;
  91380. u += du;
  91381. }
  91382. v += dv;
  91383. }
  91384. }
  91385. // Solid angle for entire sphere is 4*pi
  91386. var sphereSolidAngle = 4.0 * Math.PI;
  91387. // Adjust the solid angle to allow for how many faces we processed.
  91388. var facesProcessed = 6.0;
  91389. var expectedSolidAngle = sphereSolidAngle * facesProcessed / 6.0;
  91390. // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.
  91391. // This is needed because the numerical integration over the cube uses a
  91392. // small angle approximation of solid angle for each texel (see deltaSolidAngle),
  91393. // and also to compensate for accumulative error due to float precision in the summation.
  91394. var correctionFactor = expectedSolidAngle / totalSolidAngle;
  91395. sphericalHarmonics.scale(correctionFactor);
  91396. sphericalHarmonics.convertIncidentRadianceToIrradiance();
  91397. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  91398. return _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  91399. };
  91400. CubeMapToSphericalPolynomialTools.FileFaces = [
  91401. 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)),
  91402. 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)),
  91403. 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)),
  91404. 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)),
  91405. 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)),
  91406. 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
  91407. ];
  91408. return CubeMapToSphericalPolynomialTools;
  91409. }());
  91410. /***/ }),
  91411. /***/ "./Misc/HighDynamicRange/hdr.ts":
  91412. /*!**************************************!*\
  91413. !*** ./Misc/HighDynamicRange/hdr.ts ***!
  91414. \**************************************/
  91415. /*! exports provided: HDRTools */
  91416. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91417. "use strict";
  91418. __webpack_require__.r(__webpack_exports__);
  91419. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return HDRTools; });
  91420. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  91421. /**
  91422. * This groups tools to convert HDR texture to native colors array.
  91423. */
  91424. var HDRTools = /** @class */ (function () {
  91425. function HDRTools() {
  91426. }
  91427. HDRTools.Ldexp = function (mantissa, exponent) {
  91428. if (exponent > 1023) {
  91429. return mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023);
  91430. }
  91431. if (exponent < -1074) {
  91432. return mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074);
  91433. }
  91434. return mantissa * Math.pow(2, exponent);
  91435. };
  91436. HDRTools.Rgbe2float = function (float32array, red, green, blue, exponent, index) {
  91437. if (exponent > 0) { /*nonzero pixel*/
  91438. exponent = this.Ldexp(1.0, exponent - (128 + 8));
  91439. float32array[index + 0] = red * exponent;
  91440. float32array[index + 1] = green * exponent;
  91441. float32array[index + 2] = blue * exponent;
  91442. }
  91443. else {
  91444. float32array[index + 0] = 0;
  91445. float32array[index + 1] = 0;
  91446. float32array[index + 2] = 0;
  91447. }
  91448. };
  91449. HDRTools.readStringLine = function (uint8array, startIndex) {
  91450. var line = "";
  91451. var character = "";
  91452. for (var i = startIndex; i < uint8array.length - startIndex; i++) {
  91453. character = String.fromCharCode(uint8array[i]);
  91454. if (character == "\n") {
  91455. break;
  91456. }
  91457. line += character;
  91458. }
  91459. return line;
  91460. };
  91461. /**
  91462. * Reads header information from an RGBE texture stored in a native array.
  91463. * More information on this format are available here:
  91464. * https://en.wikipedia.org/wiki/RGBE_image_format
  91465. *
  91466. * @param uint8array The binary file stored in native array.
  91467. * @return The header information.
  91468. */
  91469. HDRTools.RGBE_ReadHeader = function (uint8array) {
  91470. var height = 0;
  91471. var width = 0;
  91472. var line = this.readStringLine(uint8array, 0);
  91473. if (line[0] != '#' || line[1] != '?') {
  91474. throw "Bad HDR Format.";
  91475. }
  91476. var endOfHeader = false;
  91477. var findFormat = false;
  91478. var lineIndex = 0;
  91479. do {
  91480. lineIndex += (line.length + 1);
  91481. line = this.readStringLine(uint8array, lineIndex);
  91482. if (line == "FORMAT=32-bit_rle_rgbe") {
  91483. findFormat = true;
  91484. }
  91485. else if (line.length == 0) {
  91486. endOfHeader = true;
  91487. }
  91488. } while (!endOfHeader);
  91489. if (!findFormat) {
  91490. throw "HDR Bad header format, unsupported FORMAT";
  91491. }
  91492. lineIndex += (line.length + 1);
  91493. line = this.readStringLine(uint8array, lineIndex);
  91494. var sizeRegexp = /^\-Y (.*) \+X (.*)$/g;
  91495. var match = sizeRegexp.exec(line);
  91496. // TODO. Support +Y and -X if needed.
  91497. if (!match || match.length < 3) {
  91498. throw "HDR Bad header format, no size";
  91499. }
  91500. width = parseInt(match[2]);
  91501. height = parseInt(match[1]);
  91502. if (width < 8 || width > 0x7fff) {
  91503. throw "HDR Bad header format, unsupported size";
  91504. }
  91505. lineIndex += (line.length + 1);
  91506. return {
  91507. height: height,
  91508. width: width,
  91509. dataPosition: lineIndex
  91510. };
  91511. };
  91512. /**
  91513. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  91514. * This RGBE texture needs to store the information as a panorama.
  91515. *
  91516. * More information on this format are available here:
  91517. * https://en.wikipedia.org/wiki/RGBE_image_format
  91518. *
  91519. * @param buffer The binary file stored in an array buffer.
  91520. * @param size The expected size of the extracted cubemap.
  91521. * @return The Cube Map information.
  91522. */
  91523. HDRTools.GetCubeMapTextureData = function (buffer, size) {
  91524. var uint8array = new Uint8Array(buffer);
  91525. var hdrInfo = this.RGBE_ReadHeader(uint8array);
  91526. var data = this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  91527. var cubeMapData = _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(data, hdrInfo.width, hdrInfo.height, size);
  91528. return cubeMapData;
  91529. };
  91530. /**
  91531. * Returns the pixels data extracted from an RGBE texture.
  91532. * This pixels will be stored left to right up to down in the R G B order in one array.
  91533. *
  91534. * More information on this format are available here:
  91535. * https://en.wikipedia.org/wiki/RGBE_image_format
  91536. *
  91537. * @param uint8array The binary file stored in an array buffer.
  91538. * @param hdrInfo The header information of the file.
  91539. * @return The pixels data in RGB right to left up to down order.
  91540. */
  91541. HDRTools.RGBE_ReadPixels = function (uint8array, hdrInfo) {
  91542. // Keep for multi format supports.
  91543. return this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  91544. };
  91545. HDRTools.RGBE_ReadPixels_RLE = function (uint8array, hdrInfo) {
  91546. var num_scanlines = hdrInfo.height;
  91547. var scanline_width = hdrInfo.width;
  91548. var a, b, c, d, count;
  91549. var dataIndex = hdrInfo.dataPosition;
  91550. var index = 0, endIndex = 0, i = 0;
  91551. var scanLineArrayBuffer = new ArrayBuffer(scanline_width * 4); // four channel R G B E
  91552. var scanLineArray = new Uint8Array(scanLineArrayBuffer);
  91553. // 3 channels of 4 bytes per pixel in float.
  91554. var resultBuffer = new ArrayBuffer(hdrInfo.width * hdrInfo.height * 4 * 3);
  91555. var resultArray = new Float32Array(resultBuffer);
  91556. // read in each successive scanline
  91557. while (num_scanlines > 0) {
  91558. a = uint8array[dataIndex++];
  91559. b = uint8array[dataIndex++];
  91560. c = uint8array[dataIndex++];
  91561. d = uint8array[dataIndex++];
  91562. if (a != 2 || b != 2 || (c & 0x80)) {
  91563. // this file is not run length encoded
  91564. throw "HDR Bad header format, not RLE";
  91565. }
  91566. if (((c << 8) | d) != scanline_width) {
  91567. throw "HDR Bad header format, wrong scan line width";
  91568. }
  91569. index = 0;
  91570. // read each of the four channels for the scanline into the buffer
  91571. for (i = 0; i < 4; i++) {
  91572. endIndex = (i + 1) * scanline_width;
  91573. while (index < endIndex) {
  91574. a = uint8array[dataIndex++];
  91575. b = uint8array[dataIndex++];
  91576. if (a > 128) {
  91577. // a run of the same value
  91578. count = a - 128;
  91579. if ((count == 0) || (count > endIndex - index)) {
  91580. throw "HDR Bad Format, bad scanline data (run)";
  91581. }
  91582. while (count-- > 0) {
  91583. scanLineArray[index++] = b;
  91584. }
  91585. }
  91586. else {
  91587. // a non-run
  91588. count = a;
  91589. if ((count == 0) || (count > endIndex - index)) {
  91590. throw "HDR Bad Format, bad scanline data (non-run)";
  91591. }
  91592. scanLineArray[index++] = b;
  91593. if (--count > 0) {
  91594. for (var j = 0; j < count; j++) {
  91595. scanLineArray[index++] = uint8array[dataIndex++];
  91596. }
  91597. }
  91598. }
  91599. }
  91600. }
  91601. // now convert data from buffer into floats
  91602. for (i = 0; i < scanline_width; i++) {
  91603. a = scanLineArray[i];
  91604. b = scanLineArray[i + scanline_width];
  91605. c = scanLineArray[i + 2 * scanline_width];
  91606. d = scanLineArray[i + 3 * scanline_width];
  91607. this.Rgbe2float(resultArray, a, b, c, d, (hdrInfo.height - num_scanlines) * scanline_width * 3 + i * 3);
  91608. }
  91609. num_scanlines--;
  91610. }
  91611. return resultArray;
  91612. };
  91613. return HDRTools;
  91614. }());
  91615. /***/ }),
  91616. /***/ "./Misc/HighDynamicRange/index.ts":
  91617. /*!****************************************!*\
  91618. !*** ./Misc/HighDynamicRange/index.ts ***!
  91619. \****************************************/
  91620. /*! exports provided: CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  91621. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91622. "use strict";
  91623. __webpack_require__.r(__webpack_exports__);
  91624. /* harmony import */ var _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  91625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  91626. /* harmony import */ var _hdr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hdr */ "./Misc/HighDynamicRange/hdr.ts");
  91627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _hdr__WEBPACK_IMPORTED_MODULE_1__["HDRTools"]; });
  91628. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  91629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__["PanoramaToCubeMapTools"]; });
  91630. /***/ }),
  91631. /***/ "./Misc/HighDynamicRange/panoramaToCubemap.ts":
  91632. /*!****************************************************!*\
  91633. !*** ./Misc/HighDynamicRange/panoramaToCubemap.ts ***!
  91634. \****************************************************/
  91635. /*! exports provided: PanoramaToCubeMapTools */
  91636. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91637. "use strict";
  91638. __webpack_require__.r(__webpack_exports__);
  91639. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return PanoramaToCubeMapTools; });
  91640. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  91641. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  91642. /**
  91643. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  91644. */
  91645. var PanoramaToCubeMapTools = /** @class */ (function () {
  91646. function PanoramaToCubeMapTools() {
  91647. }
  91648. /**
  91649. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  91650. *
  91651. * @param float32Array The source data.
  91652. * @param inputWidth The width of the input panorama.
  91653. * @param inputHeight The height of the input panorama.
  91654. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  91655. * @return The cubemap data
  91656. */
  91657. PanoramaToCubeMapTools.ConvertPanoramaToCubemap = function (float32Array, inputWidth, inputHeight, size) {
  91658. if (!float32Array) {
  91659. throw "ConvertPanoramaToCubemap: input cannot be null";
  91660. }
  91661. if (float32Array.length != inputWidth * inputHeight * 3) {
  91662. throw "ConvertPanoramaToCubemap: input size is wrong";
  91663. }
  91664. var textureFront = this.CreateCubemapTexture(size, this.FACE_FRONT, float32Array, inputWidth, inputHeight);
  91665. var textureBack = this.CreateCubemapTexture(size, this.FACE_BACK, float32Array, inputWidth, inputHeight);
  91666. var textureLeft = this.CreateCubemapTexture(size, this.FACE_LEFT, float32Array, inputWidth, inputHeight);
  91667. var textureRight = this.CreateCubemapTexture(size, this.FACE_RIGHT, float32Array, inputWidth, inputHeight);
  91668. var textureUp = this.CreateCubemapTexture(size, this.FACE_UP, float32Array, inputWidth, inputHeight);
  91669. var textureDown = this.CreateCubemapTexture(size, this.FACE_DOWN, float32Array, inputWidth, inputHeight);
  91670. return {
  91671. front: textureFront,
  91672. back: textureBack,
  91673. left: textureLeft,
  91674. right: textureRight,
  91675. up: textureUp,
  91676. down: textureDown,
  91677. size: size,
  91678. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT,
  91679. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGB,
  91680. gammaSpace: false,
  91681. };
  91682. };
  91683. PanoramaToCubeMapTools.CreateCubemapTexture = function (texSize, faceData, float32Array, inputWidth, inputHeight) {
  91684. var buffer = new ArrayBuffer(texSize * texSize * 4 * 3);
  91685. var textureArray = new Float32Array(buffer);
  91686. var rotDX1 = faceData[1].subtract(faceData[0]).scale(1 / texSize);
  91687. var rotDX2 = faceData[3].subtract(faceData[2]).scale(1 / texSize);
  91688. var dy = 1 / texSize;
  91689. var fy = 0;
  91690. for (var y = 0; y < texSize; y++) {
  91691. var xv1 = faceData[0];
  91692. var xv2 = faceData[2];
  91693. for (var x = 0; x < texSize; x++) {
  91694. var v = xv2.subtract(xv1).scale(fy).add(xv1);
  91695. v.normalize();
  91696. var color = this.CalcProjectionSpherical(v, float32Array, inputWidth, inputHeight);
  91697. // 3 channels per pixels
  91698. textureArray[y * texSize * 3 + (x * 3) + 0] = color.r;
  91699. textureArray[y * texSize * 3 + (x * 3) + 1] = color.g;
  91700. textureArray[y * texSize * 3 + (x * 3) + 2] = color.b;
  91701. xv1 = xv1.add(rotDX1);
  91702. xv2 = xv2.add(rotDX2);
  91703. }
  91704. fy += dy;
  91705. }
  91706. return textureArray;
  91707. };
  91708. PanoramaToCubeMapTools.CalcProjectionSpherical = function (vDir, float32Array, inputWidth, inputHeight) {
  91709. var theta = Math.atan2(vDir.z, vDir.x);
  91710. var phi = Math.acos(vDir.y);
  91711. while (theta < -Math.PI) {
  91712. theta += 2 * Math.PI;
  91713. }
  91714. while (theta > Math.PI) {
  91715. theta -= 2 * Math.PI;
  91716. }
  91717. var dx = theta / Math.PI;
  91718. var dy = phi / Math.PI;
  91719. // recenter.
  91720. dx = dx * 0.5 + 0.5;
  91721. var px = Math.round(dx * inputWidth);
  91722. if (px < 0) {
  91723. px = 0;
  91724. }
  91725. else if (px >= inputWidth) {
  91726. px = inputWidth - 1;
  91727. }
  91728. var py = Math.round(dy * inputHeight);
  91729. if (py < 0) {
  91730. py = 0;
  91731. }
  91732. else if (py >= inputHeight) {
  91733. py = inputHeight - 1;
  91734. }
  91735. var inputY = (inputHeight - py - 1);
  91736. var r = float32Array[inputY * inputWidth * 3 + (px * 3) + 0];
  91737. var g = float32Array[inputY * inputWidth * 3 + (px * 3) + 1];
  91738. var b = float32Array[inputY * inputWidth * 3 + (px * 3) + 2];
  91739. return {
  91740. r: r,
  91741. g: g,
  91742. b: b
  91743. };
  91744. };
  91745. PanoramaToCubeMapTools.FACE_FRONT = [
  91746. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  91747. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  91748. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  91749. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0)
  91750. ];
  91751. PanoramaToCubeMapTools.FACE_BACK = [
  91752. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  91753. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  91754. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0),
  91755. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0)
  91756. ];
  91757. PanoramaToCubeMapTools.FACE_RIGHT = [
  91758. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  91759. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  91760. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  91761. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  91762. ];
  91763. PanoramaToCubeMapTools.FACE_LEFT = [
  91764. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  91765. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  91766. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  91767. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0)
  91768. ];
  91769. PanoramaToCubeMapTools.FACE_DOWN = [
  91770. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  91771. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  91772. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  91773. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  91774. ];
  91775. PanoramaToCubeMapTools.FACE_UP = [
  91776. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  91777. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  91778. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  91779. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0)
  91780. ];
  91781. return PanoramaToCubeMapTools;
  91782. }());
  91783. /***/ }),
  91784. /***/ "./Misc/andOrNotEvaluator.ts":
  91785. /*!***********************************!*\
  91786. !*** ./Misc/andOrNotEvaluator.ts ***!
  91787. \***********************************/
  91788. /*! exports provided: AndOrNotEvaluator */
  91789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91790. "use strict";
  91791. __webpack_require__.r(__webpack_exports__);
  91792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return AndOrNotEvaluator; });
  91793. /**
  91794. * Class used to evalaute queries containing `and` and `or` operators
  91795. */
  91796. var AndOrNotEvaluator = /** @class */ (function () {
  91797. function AndOrNotEvaluator() {
  91798. }
  91799. /**
  91800. * Evaluate a query
  91801. * @param query defines the query to evaluate
  91802. * @param evaluateCallback defines the callback used to filter result
  91803. * @returns true if the query matches
  91804. */
  91805. AndOrNotEvaluator.Eval = function (query, evaluateCallback) {
  91806. if (!query.match(/\([^\(\)]*\)/g)) {
  91807. query = AndOrNotEvaluator._HandleParenthesisContent(query, evaluateCallback);
  91808. }
  91809. else {
  91810. query = query.replace(/\([^\(\)]*\)/g, function (r) {
  91811. // remove parenthesis
  91812. r = r.slice(1, r.length - 1);
  91813. return AndOrNotEvaluator._HandleParenthesisContent(r, evaluateCallback);
  91814. });
  91815. }
  91816. if (query === "true") {
  91817. return true;
  91818. }
  91819. if (query === "false") {
  91820. return false;
  91821. }
  91822. return AndOrNotEvaluator.Eval(query, evaluateCallback);
  91823. };
  91824. AndOrNotEvaluator._HandleParenthesisContent = function (parenthesisContent, evaluateCallback) {
  91825. evaluateCallback = evaluateCallback || (function (r) {
  91826. return r === "true" ? true : false;
  91827. });
  91828. var result;
  91829. var or = parenthesisContent.split("||");
  91830. for (var i in or) {
  91831. if (or.hasOwnProperty(i)) {
  91832. var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
  91833. var and = ori.split("&&");
  91834. if (and.length > 1) {
  91835. for (var j = 0; j < and.length; ++j) {
  91836. var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
  91837. if (andj !== "true" && andj !== "false") {
  91838. if (andj[0] === "!") {
  91839. result = !evaluateCallback(andj.substring(1));
  91840. }
  91841. else {
  91842. result = evaluateCallback(andj);
  91843. }
  91844. }
  91845. else {
  91846. result = andj === "true" ? true : false;
  91847. }
  91848. if (!result) { // no need to continue since 'false && ... && ...' will always return false
  91849. ori = "false";
  91850. break;
  91851. }
  91852. }
  91853. }
  91854. if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
  91855. result = true;
  91856. break;
  91857. }
  91858. // result equals false (or undefined)
  91859. if (ori !== "true" && ori !== "false") {
  91860. if (ori[0] === "!") {
  91861. result = !evaluateCallback(ori.substring(1));
  91862. }
  91863. else {
  91864. result = evaluateCallback(ori);
  91865. }
  91866. }
  91867. else {
  91868. result = ori === "true" ? true : false;
  91869. }
  91870. }
  91871. }
  91872. // the whole parenthesis scope is replaced by 'true' or 'false'
  91873. return result ? "true" : "false";
  91874. };
  91875. AndOrNotEvaluator._SimplifyNegation = function (booleanString) {
  91876. booleanString = booleanString.replace(/^[\s!]+/, function (r) {
  91877. // remove whitespaces
  91878. r = r.replace(/[\s]/g, function () { return ""; });
  91879. return r.length % 2 ? "!" : "";
  91880. });
  91881. booleanString = booleanString.trim();
  91882. if (booleanString === "!true") {
  91883. booleanString = "false";
  91884. }
  91885. else if (booleanString === "!false") {
  91886. booleanString = "true";
  91887. }
  91888. return booleanString;
  91889. };
  91890. return AndOrNotEvaluator;
  91891. }());
  91892. /***/ }),
  91893. /***/ "./Misc/arrayTools.ts":
  91894. /*!****************************!*\
  91895. !*** ./Misc/arrayTools.ts ***!
  91896. \****************************/
  91897. /*! exports provided: ArrayTools */
  91898. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91899. "use strict";
  91900. __webpack_require__.r(__webpack_exports__);
  91901. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayTools", function() { return ArrayTools; });
  91902. /**
  91903. * Class containing a set of static utilities functions for arrays.
  91904. */
  91905. var ArrayTools = /** @class */ (function () {
  91906. function ArrayTools() {
  91907. }
  91908. /**
  91909. * Returns an array of the given size filled with element built from the given constructor and the paramters
  91910. * @param size the number of element to construct and put in the array
  91911. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  91912. * @returns a new array filled with new objects
  91913. */
  91914. ArrayTools.BuildArray = function (size, itemBuilder) {
  91915. var a = [];
  91916. for (var i = 0; i < size; ++i) {
  91917. a.push(itemBuilder());
  91918. }
  91919. return a;
  91920. };
  91921. return ArrayTools;
  91922. }());
  91923. /***/ }),
  91924. /***/ "./Misc/assetsManager.ts":
  91925. /*!*******************************!*\
  91926. !*** ./Misc/assetsManager.ts ***!
  91927. \*******************************/
  91928. /*! exports provided: AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager */
  91929. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91930. "use strict";
  91931. __webpack_require__.r(__webpack_exports__);
  91932. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return AssetTaskState; });
  91933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return AbstractAssetTask; });
  91934. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return AssetsProgressEvent; });
  91935. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return MeshAssetTask; });
  91936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return TextFileAssetTask; });
  91937. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return BinaryFileAssetTask; });
  91938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return ImageAssetTask; });
  91939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return TextureAssetTask; });
  91940. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return CubeTextureAssetTask; });
  91941. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return HDRCubeTextureAssetTask; });
  91942. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return AssetsManager; });
  91943. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  91944. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  91945. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  91946. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  91947. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  91948. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  91949. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  91950. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  91951. /**
  91952. * Defines the list of states available for a task inside a AssetsManager
  91953. */
  91954. var AssetTaskState;
  91955. (function (AssetTaskState) {
  91956. /**
  91957. * Initialization
  91958. */
  91959. AssetTaskState[AssetTaskState["INIT"] = 0] = "INIT";
  91960. /**
  91961. * Running
  91962. */
  91963. AssetTaskState[AssetTaskState["RUNNING"] = 1] = "RUNNING";
  91964. /**
  91965. * Done
  91966. */
  91967. AssetTaskState[AssetTaskState["DONE"] = 2] = "DONE";
  91968. /**
  91969. * Error
  91970. */
  91971. AssetTaskState[AssetTaskState["ERROR"] = 3] = "ERROR";
  91972. })(AssetTaskState || (AssetTaskState = {}));
  91973. /**
  91974. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  91975. */
  91976. var AbstractAssetTask = /** @class */ (function () {
  91977. /**
  91978. * Creates a new AssetsManager
  91979. * @param name defines the name of the task
  91980. */
  91981. function AbstractAssetTask(
  91982. /**
  91983. * Task name
  91984. */ name) {
  91985. this.name = name;
  91986. this._isCompleted = false;
  91987. this._taskState = AssetTaskState.INIT;
  91988. }
  91989. Object.defineProperty(AbstractAssetTask.prototype, "isCompleted", {
  91990. /**
  91991. * Get if the task is completed
  91992. */
  91993. get: function () {
  91994. return this._isCompleted;
  91995. },
  91996. enumerable: true,
  91997. configurable: true
  91998. });
  91999. Object.defineProperty(AbstractAssetTask.prototype, "taskState", {
  92000. /**
  92001. * Gets the current state of the task
  92002. */
  92003. get: function () {
  92004. return this._taskState;
  92005. },
  92006. enumerable: true,
  92007. configurable: true
  92008. });
  92009. Object.defineProperty(AbstractAssetTask.prototype, "errorObject", {
  92010. /**
  92011. * Gets the current error object (if task is in error)
  92012. */
  92013. get: function () {
  92014. return this._errorObject;
  92015. },
  92016. enumerable: true,
  92017. configurable: true
  92018. });
  92019. /**
  92020. * Internal only
  92021. * @hidden
  92022. */
  92023. AbstractAssetTask.prototype._setErrorObject = function (message, exception) {
  92024. if (this._errorObject) {
  92025. return;
  92026. }
  92027. this._errorObject = {
  92028. message: message,
  92029. exception: exception
  92030. };
  92031. };
  92032. /**
  92033. * Execute the current task
  92034. * @param scene defines the scene where you want your assets to be loaded
  92035. * @param onSuccess is a callback called when the task is successfully executed
  92036. * @param onError is a callback called if an error occurs
  92037. */
  92038. AbstractAssetTask.prototype.run = function (scene, onSuccess, onError) {
  92039. var _this = this;
  92040. this._taskState = AssetTaskState.RUNNING;
  92041. this.runTask(scene, function () {
  92042. _this.onDoneCallback(onSuccess, onError);
  92043. }, function (msg, exception) {
  92044. _this.onErrorCallback(onError, msg, exception);
  92045. });
  92046. };
  92047. /**
  92048. * Execute the current task
  92049. * @param scene defines the scene where you want your assets to be loaded
  92050. * @param onSuccess is a callback called when the task is successfully executed
  92051. * @param onError is a callback called if an error occurs
  92052. */
  92053. AbstractAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92054. throw new Error("runTask is not implemented");
  92055. };
  92056. /**
  92057. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  92058. * This can be used with failed tasks that have the reason for failure fixed.
  92059. */
  92060. AbstractAssetTask.prototype.reset = function () {
  92061. this._taskState = AssetTaskState.INIT;
  92062. };
  92063. AbstractAssetTask.prototype.onErrorCallback = function (onError, message, exception) {
  92064. this._taskState = AssetTaskState.ERROR;
  92065. this._errorObject = {
  92066. message: message,
  92067. exception: exception
  92068. };
  92069. if (this.onError) {
  92070. this.onError(this, message, exception);
  92071. }
  92072. onError();
  92073. };
  92074. AbstractAssetTask.prototype.onDoneCallback = function (onSuccess, onError) {
  92075. try {
  92076. this._taskState = AssetTaskState.DONE;
  92077. this._isCompleted = true;
  92078. if (this.onSuccess) {
  92079. this.onSuccess(this);
  92080. }
  92081. onSuccess();
  92082. }
  92083. catch (e) {
  92084. this.onErrorCallback(onError, "Task is done, error executing success callback(s)", e);
  92085. }
  92086. };
  92087. return AbstractAssetTask;
  92088. }());
  92089. /**
  92090. * Class used to share progress information about assets loading
  92091. */
  92092. var AssetsProgressEvent = /** @class */ (function () {
  92093. /**
  92094. * Creates a AssetsProgressEvent
  92095. * @param remainingCount defines the number of remaining tasks to process
  92096. * @param totalCount defines the total number of tasks
  92097. * @param task defines the task that was just processed
  92098. */
  92099. function AssetsProgressEvent(remainingCount, totalCount, task) {
  92100. this.remainingCount = remainingCount;
  92101. this.totalCount = totalCount;
  92102. this.task = task;
  92103. }
  92104. return AssetsProgressEvent;
  92105. }());
  92106. /**
  92107. * Define a task used by AssetsManager to load meshes
  92108. */
  92109. var MeshAssetTask = /** @class */ (function (_super) {
  92110. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshAssetTask, _super);
  92111. /**
  92112. * Creates a new MeshAssetTask
  92113. * @param name defines the name of the task
  92114. * @param meshesNames defines the list of mesh's names you want to load
  92115. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  92116. * @param sceneFilename defines the filename of the scene to load from
  92117. */
  92118. function MeshAssetTask(
  92119. /**
  92120. * Defines the name of the task
  92121. */
  92122. name,
  92123. /**
  92124. * Defines the list of mesh's names you want to load
  92125. */
  92126. meshesNames,
  92127. /**
  92128. * Defines the root url to use as a base to load your meshes and associated resources
  92129. */
  92130. rootUrl,
  92131. /**
  92132. * Defines the filename of the scene to load from
  92133. */
  92134. sceneFilename) {
  92135. var _this = _super.call(this, name) || this;
  92136. _this.name = name;
  92137. _this.meshesNames = meshesNames;
  92138. _this.rootUrl = rootUrl;
  92139. _this.sceneFilename = sceneFilename;
  92140. return _this;
  92141. }
  92142. /**
  92143. * Execute the current task
  92144. * @param scene defines the scene where you want your assets to be loaded
  92145. * @param onSuccess is a callback called when the task is successfully executed
  92146. * @param onError is a callback called if an error occurs
  92147. */
  92148. MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92149. var _this = this;
  92150. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  92151. _this.loadedMeshes = meshes;
  92152. _this.loadedParticleSystems = particleSystems;
  92153. _this.loadedSkeletons = skeletons;
  92154. _this.loadedAnimationGroups = animationGroups;
  92155. onSuccess();
  92156. }, null, function (scene, message, exception) {
  92157. onError(message, exception);
  92158. });
  92159. };
  92160. return MeshAssetTask;
  92161. }(AbstractAssetTask));
  92162. /**
  92163. * Define a task used by AssetsManager to load text content
  92164. */
  92165. var TextFileAssetTask = /** @class */ (function (_super) {
  92166. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextFileAssetTask, _super);
  92167. /**
  92168. * Creates a new TextFileAssetTask object
  92169. * @param name defines the name of the task
  92170. * @param url defines the location of the file to load
  92171. */
  92172. function TextFileAssetTask(
  92173. /**
  92174. * Defines the name of the task
  92175. */
  92176. name,
  92177. /**
  92178. * Defines the location of the file to load
  92179. */
  92180. url) {
  92181. var _this = _super.call(this, name) || this;
  92182. _this.name = name;
  92183. _this.url = url;
  92184. return _this;
  92185. }
  92186. /**
  92187. * Execute the current task
  92188. * @param scene defines the scene where you want your assets to be loaded
  92189. * @param onSuccess is a callback called when the task is successfully executed
  92190. * @param onError is a callback called if an error occurs
  92191. */
  92192. TextFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92193. var _this = this;
  92194. scene._loadFile(this.url, function (data) {
  92195. _this.text = data;
  92196. onSuccess();
  92197. }, undefined, false, false, function (request, exception) {
  92198. if (request) {
  92199. onError(request.status + " " + request.statusText, exception);
  92200. }
  92201. });
  92202. };
  92203. return TextFileAssetTask;
  92204. }(AbstractAssetTask));
  92205. /**
  92206. * Define a task used by AssetsManager to load binary data
  92207. */
  92208. var BinaryFileAssetTask = /** @class */ (function (_super) {
  92209. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BinaryFileAssetTask, _super);
  92210. /**
  92211. * Creates a new BinaryFileAssetTask object
  92212. * @param name defines the name of the new task
  92213. * @param url defines the location of the file to load
  92214. */
  92215. function BinaryFileAssetTask(
  92216. /**
  92217. * Defines the name of the task
  92218. */
  92219. name,
  92220. /**
  92221. * Defines the location of the file to load
  92222. */
  92223. url) {
  92224. var _this = _super.call(this, name) || this;
  92225. _this.name = name;
  92226. _this.url = url;
  92227. return _this;
  92228. }
  92229. /**
  92230. * Execute the current task
  92231. * @param scene defines the scene where you want your assets to be loaded
  92232. * @param onSuccess is a callback called when the task is successfully executed
  92233. * @param onError is a callback called if an error occurs
  92234. */
  92235. BinaryFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92236. var _this = this;
  92237. scene._loadFile(this.url, function (data) {
  92238. _this.data = data;
  92239. onSuccess();
  92240. }, undefined, true, true, function (request, exception) {
  92241. if (request) {
  92242. onError(request.status + " " + request.statusText, exception);
  92243. }
  92244. });
  92245. };
  92246. return BinaryFileAssetTask;
  92247. }(AbstractAssetTask));
  92248. /**
  92249. * Define a task used by AssetsManager to load images
  92250. */
  92251. var ImageAssetTask = /** @class */ (function (_super) {
  92252. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageAssetTask, _super);
  92253. /**
  92254. * Creates a new ImageAssetTask
  92255. * @param name defines the name of the task
  92256. * @param url defines the location of the image to load
  92257. */
  92258. function ImageAssetTask(
  92259. /**
  92260. * Defines the name of the task
  92261. */
  92262. name,
  92263. /**
  92264. * Defines the location of the image to load
  92265. */
  92266. url) {
  92267. var _this = _super.call(this, name) || this;
  92268. _this.name = name;
  92269. _this.url = url;
  92270. return _this;
  92271. }
  92272. /**
  92273. * Execute the current task
  92274. * @param scene defines the scene where you want your assets to be loaded
  92275. * @param onSuccess is a callback called when the task is successfully executed
  92276. * @param onError is a callback called if an error occurs
  92277. */
  92278. ImageAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92279. var _this = this;
  92280. var img = new Image();
  92281. _tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(this.url, img);
  92282. img.onload = function () {
  92283. _this.image = img;
  92284. onSuccess();
  92285. };
  92286. img.onerror = function (err) {
  92287. onError("Error loading image", err);
  92288. };
  92289. img.src = this.url;
  92290. };
  92291. return ImageAssetTask;
  92292. }(AbstractAssetTask));
  92293. /**
  92294. * Define a task used by AssetsManager to load 2D textures
  92295. */
  92296. var TextureAssetTask = /** @class */ (function (_super) {
  92297. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureAssetTask, _super);
  92298. /**
  92299. * Creates a new TextureAssetTask object
  92300. * @param name defines the name of the task
  92301. * @param url defines the location of the file to load
  92302. * @param noMipmap defines if mipmap should not be generated (default is false)
  92303. * @param invertY defines if texture must be inverted on Y axis (default is false)
  92304. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  92305. */
  92306. function TextureAssetTask(
  92307. /**
  92308. * Defines the name of the task
  92309. */
  92310. name,
  92311. /**
  92312. * Defines the location of the file to load
  92313. */
  92314. url,
  92315. /**
  92316. * Defines if mipmap should not be generated (default is false)
  92317. */
  92318. noMipmap,
  92319. /**
  92320. * Defines if texture must be inverted on Y axis (default is false)
  92321. */
  92322. invertY,
  92323. /**
  92324. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  92325. */
  92326. samplingMode) {
  92327. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  92328. var _this = _super.call(this, name) || this;
  92329. _this.name = name;
  92330. _this.url = url;
  92331. _this.noMipmap = noMipmap;
  92332. _this.invertY = invertY;
  92333. _this.samplingMode = samplingMode;
  92334. return _this;
  92335. }
  92336. /**
  92337. * Execute the current task
  92338. * @param scene defines the scene where you want your assets to be loaded
  92339. * @param onSuccess is a callback called when the task is successfully executed
  92340. * @param onError is a callback called if an error occurs
  92341. */
  92342. TextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92343. var onload = function () {
  92344. onSuccess();
  92345. };
  92346. var onerror = function (message, exception) {
  92347. onError(message, exception);
  92348. };
  92349. this.texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this.url, scene, this.noMipmap, this.invertY, this.samplingMode, onload, onerror);
  92350. };
  92351. return TextureAssetTask;
  92352. }(AbstractAssetTask));
  92353. /**
  92354. * Define a task used by AssetsManager to load cube textures
  92355. */
  92356. var CubeTextureAssetTask = /** @class */ (function (_super) {
  92357. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTextureAssetTask, _super);
  92358. /**
  92359. * Creates a new CubeTextureAssetTask
  92360. * @param name defines the name of the task
  92361. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  92362. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  92363. * @param noMipmap defines if mipmaps should not be generated (default is false)
  92364. * @param files defines the explicit list of files (undefined by default)
  92365. */
  92366. function CubeTextureAssetTask(
  92367. /**
  92368. * Defines the name of the task
  92369. */
  92370. name,
  92371. /**
  92372. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  92373. */
  92374. url,
  92375. /**
  92376. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  92377. */
  92378. extensions,
  92379. /**
  92380. * Defines if mipmaps should not be generated (default is false)
  92381. */
  92382. noMipmap,
  92383. /**
  92384. * Defines the explicit list of files (undefined by default)
  92385. */
  92386. files) {
  92387. var _this = _super.call(this, name) || this;
  92388. _this.name = name;
  92389. _this.url = url;
  92390. _this.extensions = extensions;
  92391. _this.noMipmap = noMipmap;
  92392. _this.files = files;
  92393. return _this;
  92394. }
  92395. /**
  92396. * Execute the current task
  92397. * @param scene defines the scene where you want your assets to be loaded
  92398. * @param onSuccess is a callback called when the task is successfully executed
  92399. * @param onError is a callback called if an error occurs
  92400. */
  92401. CubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92402. var onload = function () {
  92403. onSuccess();
  92404. };
  92405. var onerror = function (message, exception) {
  92406. onError(message, exception);
  92407. };
  92408. this.texture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__["CubeTexture"](this.url, scene, this.extensions, this.noMipmap, this.files, onload, onerror);
  92409. };
  92410. return CubeTextureAssetTask;
  92411. }(AbstractAssetTask));
  92412. /**
  92413. * Define a task used by AssetsManager to load HDR cube textures
  92414. */
  92415. var HDRCubeTextureAssetTask = /** @class */ (function (_super) {
  92416. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTextureAssetTask, _super);
  92417. /**
  92418. * Creates a new HDRCubeTextureAssetTask object
  92419. * @param name defines the name of the task
  92420. * @param url defines the location of the file to load
  92421. * @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.
  92422. * @param noMipmap defines if mipmaps should not be generated (default is false)
  92423. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  92424. * @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)
  92425. * @param reserved Internal use only
  92426. */
  92427. function HDRCubeTextureAssetTask(
  92428. /**
  92429. * Defines the name of the task
  92430. */
  92431. name,
  92432. /**
  92433. * Defines the location of the file to load
  92434. */
  92435. url,
  92436. /**
  92437. * Defines the desired size (the more it increases the longer the generation will be)
  92438. */
  92439. size,
  92440. /**
  92441. * Defines if mipmaps should not be generated (default is false)
  92442. */
  92443. noMipmap,
  92444. /**
  92445. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  92446. */
  92447. generateHarmonics,
  92448. /**
  92449. * 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)
  92450. */
  92451. gammaSpace,
  92452. /**
  92453. * Internal Use Only
  92454. */
  92455. reserved) {
  92456. if (noMipmap === void 0) { noMipmap = false; }
  92457. if (generateHarmonics === void 0) { generateHarmonics = true; }
  92458. if (gammaSpace === void 0) { gammaSpace = false; }
  92459. if (reserved === void 0) { reserved = false; }
  92460. var _this = _super.call(this, name) || this;
  92461. _this.name = name;
  92462. _this.url = url;
  92463. _this.size = size;
  92464. _this.noMipmap = noMipmap;
  92465. _this.generateHarmonics = generateHarmonics;
  92466. _this.gammaSpace = gammaSpace;
  92467. _this.reserved = reserved;
  92468. return _this;
  92469. }
  92470. /**
  92471. * Execute the current task
  92472. * @param scene defines the scene where you want your assets to be loaded
  92473. * @param onSuccess is a callback called when the task is successfully executed
  92474. * @param onError is a callback called if an error occurs
  92475. */
  92476. HDRCubeTextureAssetTask.prototype.run = function (scene, onSuccess, onError) {
  92477. var onload = function () {
  92478. onSuccess();
  92479. };
  92480. var onerror = function (message, exception) {
  92481. onError(message, exception);
  92482. };
  92483. 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);
  92484. };
  92485. return HDRCubeTextureAssetTask;
  92486. }(AbstractAssetTask));
  92487. /**
  92488. * This class can be used to easily import assets into a scene
  92489. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  92490. */
  92491. var AssetsManager = /** @class */ (function () {
  92492. /**
  92493. * Creates a new AssetsManager
  92494. * @param scene defines the scene to work on
  92495. */
  92496. function AssetsManager(scene) {
  92497. this._isLoading = false;
  92498. this._tasks = new Array();
  92499. this._waitingTasksCount = 0;
  92500. this._totalTasksCount = 0;
  92501. /**
  92502. * Observable called when all tasks are processed
  92503. */
  92504. this.onTaskSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92505. /**
  92506. * Observable called when a task had an error
  92507. */
  92508. this.onTaskErrorObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92509. /**
  92510. * Observable called when a task is successful
  92511. */
  92512. this.onTasksDoneObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92513. /**
  92514. * Observable called when a task is done (whatever the result is)
  92515. */
  92516. this.onProgressObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  92517. /**
  92518. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  92519. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92520. */
  92521. this.useDefaultLoadingScreen = true;
  92522. this._scene = scene;
  92523. }
  92524. /**
  92525. * Add a MeshAssetTask to the list of active tasks
  92526. * @param taskName defines the name of the new task
  92527. * @param meshesNames defines the name of meshes to load
  92528. * @param rootUrl defines the root url to use to locate files
  92529. * @param sceneFilename defines the filename of the scene file
  92530. * @returns a new MeshAssetTask object
  92531. */
  92532. AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
  92533. var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
  92534. this._tasks.push(task);
  92535. return task;
  92536. };
  92537. /**
  92538. * Add a TextFileAssetTask to the list of active tasks
  92539. * @param taskName defines the name of the new task
  92540. * @param url defines the url of the file to load
  92541. * @returns a new TextFileAssetTask object
  92542. */
  92543. AssetsManager.prototype.addTextFileTask = function (taskName, url) {
  92544. var task = new TextFileAssetTask(taskName, url);
  92545. this._tasks.push(task);
  92546. return task;
  92547. };
  92548. /**
  92549. * Add a BinaryFileAssetTask to the list of active tasks
  92550. * @param taskName defines the name of the new task
  92551. * @param url defines the url of the file to load
  92552. * @returns a new BinaryFileAssetTask object
  92553. */
  92554. AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
  92555. var task = new BinaryFileAssetTask(taskName, url);
  92556. this._tasks.push(task);
  92557. return task;
  92558. };
  92559. /**
  92560. * Add a ImageAssetTask to the list of active tasks
  92561. * @param taskName defines the name of the new task
  92562. * @param url defines the url of the file to load
  92563. * @returns a new ImageAssetTask object
  92564. */
  92565. AssetsManager.prototype.addImageTask = function (taskName, url) {
  92566. var task = new ImageAssetTask(taskName, url);
  92567. this._tasks.push(task);
  92568. return task;
  92569. };
  92570. /**
  92571. * Add a TextureAssetTask to the list of active tasks
  92572. * @param taskName defines the name of the new task
  92573. * @param url defines the url of the file to load
  92574. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  92575. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  92576. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  92577. * @returns a new TextureAssetTask object
  92578. */
  92579. AssetsManager.prototype.addTextureTask = function (taskName, url, noMipmap, invertY, samplingMode) {
  92580. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  92581. var task = new TextureAssetTask(taskName, url, noMipmap, invertY, samplingMode);
  92582. this._tasks.push(task);
  92583. return task;
  92584. };
  92585. /**
  92586. * Add a CubeTextureAssetTask to the list of active tasks
  92587. * @param taskName defines the name of the new task
  92588. * @param url defines the url of the file to load
  92589. * @param extensions defines the extension to use to load the cube map (can be null)
  92590. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  92591. * @param files defines the list of files to load (can be null)
  92592. * @returns a new CubeTextureAssetTask object
  92593. */
  92594. AssetsManager.prototype.addCubeTextureTask = function (taskName, url, extensions, noMipmap, files) {
  92595. var task = new CubeTextureAssetTask(taskName, url, extensions, noMipmap, files);
  92596. this._tasks.push(task);
  92597. return task;
  92598. };
  92599. /**
  92600. *
  92601. * Add a HDRCubeTextureAssetTask to the list of active tasks
  92602. * @param taskName defines the name of the new task
  92603. * @param url defines the url of the file to load
  92604. * @param size defines the size you want for the cubemap (can be null)
  92605. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  92606. * @param generateHarmonics defines if you want to automatically generate (true by default)
  92607. * @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)
  92608. * @param reserved Internal use only
  92609. * @returns a new HDRCubeTextureAssetTask object
  92610. */
  92611. AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
  92612. if (noMipmap === void 0) { noMipmap = false; }
  92613. if (generateHarmonics === void 0) { generateHarmonics = true; }
  92614. if (gammaSpace === void 0) { gammaSpace = false; }
  92615. if (reserved === void 0) { reserved = false; }
  92616. var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
  92617. this._tasks.push(task);
  92618. return task;
  92619. };
  92620. /**
  92621. * Remove a task from the assets manager.
  92622. * @param task the task to remove
  92623. */
  92624. AssetsManager.prototype.removeTask = function (task) {
  92625. var index = this._tasks.indexOf(task);
  92626. if (index > -1) {
  92627. this._tasks.splice(index, 1);
  92628. }
  92629. };
  92630. AssetsManager.prototype._decreaseWaitingTasksCount = function (task) {
  92631. this._waitingTasksCount--;
  92632. try {
  92633. if (this.onProgress) {
  92634. this.onProgress(this._waitingTasksCount, this._totalTasksCount, task);
  92635. }
  92636. this.onProgressObservable.notifyObservers(new AssetsProgressEvent(this._waitingTasksCount, this._totalTasksCount, task));
  92637. }
  92638. catch (e) {
  92639. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running progress callbacks.");
  92640. console.log(e);
  92641. }
  92642. if (this._waitingTasksCount === 0) {
  92643. try {
  92644. if (this.onFinish) {
  92645. this.onFinish(this._tasks);
  92646. }
  92647. // Let's remove successfull tasks
  92648. var currentTasks = this._tasks.slice();
  92649. for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
  92650. var task = currentTasks_1[_i];
  92651. if (task.taskState === AssetTaskState.DONE) {
  92652. var index = this._tasks.indexOf(task);
  92653. if (index > -1) {
  92654. this._tasks.splice(index, 1);
  92655. }
  92656. }
  92657. }
  92658. this.onTasksDoneObservable.notifyObservers(this._tasks);
  92659. }
  92660. catch (e) {
  92661. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running tasks-done callbacks.");
  92662. console.log(e);
  92663. }
  92664. this._isLoading = false;
  92665. this._scene.getEngine().hideLoadingUI();
  92666. }
  92667. };
  92668. AssetsManager.prototype._runTask = function (task) {
  92669. var _this = this;
  92670. var done = function () {
  92671. try {
  92672. if (_this.onTaskSuccess) {
  92673. _this.onTaskSuccess(task);
  92674. }
  92675. _this.onTaskSuccessObservable.notifyObservers(task);
  92676. _this._decreaseWaitingTasksCount(task);
  92677. }
  92678. catch (e) {
  92679. error("Error executing task success callbacks", e);
  92680. }
  92681. };
  92682. var error = function (message, exception) {
  92683. task._setErrorObject(message, exception);
  92684. if (_this.onTaskError) {
  92685. _this.onTaskError(task);
  92686. }
  92687. _this.onTaskErrorObservable.notifyObservers(task);
  92688. _this._decreaseWaitingTasksCount(task);
  92689. };
  92690. task.run(this._scene, done, error);
  92691. };
  92692. /**
  92693. * Reset the AssetsManager and remove all tasks
  92694. * @return the current instance of the AssetsManager
  92695. */
  92696. AssetsManager.prototype.reset = function () {
  92697. this._isLoading = false;
  92698. this._tasks = new Array();
  92699. return this;
  92700. };
  92701. /**
  92702. * Start the loading process
  92703. * @return the current instance of the AssetsManager
  92704. */
  92705. AssetsManager.prototype.load = function () {
  92706. if (this._isLoading) {
  92707. return this;
  92708. }
  92709. this._isLoading = true;
  92710. this._waitingTasksCount = this._tasks.length;
  92711. this._totalTasksCount = this._tasks.length;
  92712. if (this._waitingTasksCount === 0) {
  92713. this._isLoading = false;
  92714. if (this.onFinish) {
  92715. this.onFinish(this._tasks);
  92716. }
  92717. this.onTasksDoneObservable.notifyObservers(this._tasks);
  92718. return this;
  92719. }
  92720. if (this.useDefaultLoadingScreen) {
  92721. this._scene.getEngine().displayLoadingUI();
  92722. }
  92723. for (var index = 0; index < this._tasks.length; index++) {
  92724. var task = this._tasks[index];
  92725. if (task.taskState === AssetTaskState.INIT) {
  92726. this._runTask(task);
  92727. }
  92728. }
  92729. return this;
  92730. };
  92731. return AssetsManager;
  92732. }());
  92733. /***/ }),
  92734. /***/ "./Misc/dds.ts":
  92735. /*!*********************!*\
  92736. !*** ./Misc/dds.ts ***!
  92737. \*********************/
  92738. /*! exports provided: DDSTools */
  92739. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92740. "use strict";
  92741. __webpack_require__.r(__webpack_exports__);
  92742. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return DDSTools; });
  92743. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  92744. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  92745. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  92746. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  92747. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  92748. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  92749. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  92750. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  92751. // Based on demo done by Brandon Jones - http://media.tojicode.com/webgl-samples/dds.html
  92752. // All values and structures referenced from:
  92753. // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
  92754. var DDS_MAGIC = 0x20534444;
  92755. var
  92756. //DDSD_CAPS = 0x1,
  92757. //DDSD_HEIGHT = 0x2,
  92758. //DDSD_WIDTH = 0x4,
  92759. //DDSD_PITCH = 0x8,
  92760. //DDSD_PIXELFORMAT = 0x1000,
  92761. DDSD_MIPMAPCOUNT = 0x20000;
  92762. //DDSD_LINEARSIZE = 0x80000,
  92763. //DDSD_DEPTH = 0x800000;
  92764. // var DDSCAPS_COMPLEX = 0x8,
  92765. // DDSCAPS_MIPMAP = 0x400000,
  92766. // DDSCAPS_TEXTURE = 0x1000;
  92767. var DDSCAPS2_CUBEMAP = 0x200;
  92768. // DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
  92769. // DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
  92770. // DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
  92771. // DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
  92772. // DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
  92773. // DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
  92774. // DDSCAPS2_VOLUME = 0x200000;
  92775. var
  92776. //DDPF_ALPHAPIXELS = 0x1,
  92777. //DDPF_ALPHA = 0x2,
  92778. DDPF_FOURCC = 0x4, DDPF_RGB = 0x40,
  92779. //DDPF_YUV = 0x200,
  92780. DDPF_LUMINANCE = 0x20000;
  92781. function FourCCToInt32(value) {
  92782. return value.charCodeAt(0) +
  92783. (value.charCodeAt(1) << 8) +
  92784. (value.charCodeAt(2) << 16) +
  92785. (value.charCodeAt(3) << 24);
  92786. }
  92787. function Int32ToFourCC(value) {
  92788. return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
  92789. }
  92790. var FOURCC_DXT1 = FourCCToInt32("DXT1");
  92791. var FOURCC_DXT3 = FourCCToInt32("DXT3");
  92792. var FOURCC_DXT5 = FourCCToInt32("DXT5");
  92793. var FOURCC_DX10 = FourCCToInt32("DX10");
  92794. var FOURCC_D3DFMT_R16G16B16A16F = 113;
  92795. var FOURCC_D3DFMT_R32G32B32A32F = 116;
  92796. var DXGI_FORMAT_R16G16B16A16_FLOAT = 10;
  92797. var DXGI_FORMAT_B8G8R8X8_UNORM = 88;
  92798. var headerLengthInt = 31; // The header length in 32 bit ints
  92799. // Offsets into the header array
  92800. var off_magic = 0;
  92801. var off_size = 1;
  92802. var off_flags = 2;
  92803. var off_height = 3;
  92804. var off_width = 4;
  92805. var off_mipmapCount = 7;
  92806. var off_pfFlags = 20;
  92807. var off_pfFourCC = 21;
  92808. var off_RGBbpp = 22;
  92809. var off_RMask = 23;
  92810. var off_GMask = 24;
  92811. var off_BMask = 25;
  92812. var off_AMask = 26;
  92813. // var off_caps1 = 27;
  92814. var off_caps2 = 28;
  92815. // var off_caps3 = 29;
  92816. // var off_caps4 = 30;
  92817. var off_dxgiFormat = 32;
  92818. /**
  92819. * Class used to provide DDS decompression tools
  92820. */
  92821. var DDSTools = /** @class */ (function () {
  92822. function DDSTools() {
  92823. }
  92824. /**
  92825. * Gets DDS information from an array buffer
  92826. * @param arrayBuffer defines the array buffer to read data from
  92827. * @returns the DDS information
  92828. */
  92829. DDSTools.GetDDSInfo = function (arrayBuffer) {
  92830. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  92831. var extendedHeader = new Int32Array(arrayBuffer, 0, headerLengthInt + 4);
  92832. var mipmapCount = 1;
  92833. if (header[off_flags] & DDSD_MIPMAPCOUNT) {
  92834. mipmapCount = Math.max(1, header[off_mipmapCount]);
  92835. }
  92836. var fourCC = header[off_pfFourCC];
  92837. var dxgiFormat = (fourCC === FOURCC_DX10) ? extendedHeader[off_dxgiFormat] : 0;
  92838. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  92839. switch (fourCC) {
  92840. case FOURCC_D3DFMT_R16G16B16A16F:
  92841. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  92842. break;
  92843. case FOURCC_D3DFMT_R32G32B32A32F:
  92844. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  92845. break;
  92846. case FOURCC_DX10:
  92847. if (dxgiFormat === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  92848. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  92849. break;
  92850. }
  92851. }
  92852. return {
  92853. width: header[off_width],
  92854. height: header[off_height],
  92855. mipmapCount: mipmapCount,
  92856. isFourCC: (header[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  92857. isRGB: (header[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  92858. isLuminance: (header[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  92859. isCube: (header[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  92860. isCompressed: (fourCC === FOURCC_DXT1 || fourCC === FOURCC_DXT3 || fourCC === FOURCC_DXT5),
  92861. dxgiFormat: dxgiFormat,
  92862. textureType: textureType
  92863. };
  92864. };
  92865. DDSTools._ToHalfFloat = function (value) {
  92866. if (!DDSTools._FloatView) {
  92867. DDSTools._FloatView = new Float32Array(1);
  92868. DDSTools._Int32View = new Int32Array(DDSTools._FloatView.buffer);
  92869. }
  92870. DDSTools._FloatView[0] = value;
  92871. var x = DDSTools._Int32View[0];
  92872. var bits = (x >> 16) & 0x8000; /* Get the sign */
  92873. var m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */
  92874. var e = (x >> 23) & 0xff; /* Using int is faster here */
  92875. /* If zero, or denormal, or exponent underflows too much for a denormal
  92876. * half, return signed zero. */
  92877. if (e < 103) {
  92878. return bits;
  92879. }
  92880. /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
  92881. if (e > 142) {
  92882. bits |= 0x7c00;
  92883. /* If exponent was 0xff and one mantissa bit was set, it means NaN,
  92884. * not Inf, so make sure we set one mantissa bit too. */
  92885. bits |= ((e == 255) ? 0 : 1) && (x & 0x007fffff);
  92886. return bits;
  92887. }
  92888. /* If exponent underflows but not too much, return a denormal */
  92889. if (e < 113) {
  92890. m |= 0x0800;
  92891. /* Extra rounding may overflow and set mantissa to 0 and exponent
  92892. * to 1, which is OK. */
  92893. bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  92894. return bits;
  92895. }
  92896. bits |= ((e - 112) << 10) | (m >> 1);
  92897. bits += m & 1;
  92898. return bits;
  92899. };
  92900. DDSTools._FromHalfFloat = function (value) {
  92901. var s = (value & 0x8000) >> 15;
  92902. var e = (value & 0x7C00) >> 10;
  92903. var f = value & 0x03FF;
  92904. if (e === 0) {
  92905. return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
  92906. }
  92907. else if (e == 0x1F) {
  92908. return f ? NaN : ((s ? -1 : 1) * Infinity);
  92909. }
  92910. return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + (f / Math.pow(2, 10)));
  92911. };
  92912. DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92913. var destArray = new Float32Array(dataLength);
  92914. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  92915. var index = 0;
  92916. for (var y = 0; y < height; y++) {
  92917. for (var x = 0; x < width; x++) {
  92918. var srcPos = (x + y * width) * 4;
  92919. destArray[index] = DDSTools._FromHalfFloat(srcData[srcPos]);
  92920. destArray[index + 1] = DDSTools._FromHalfFloat(srcData[srcPos + 1]);
  92921. destArray[index + 2] = DDSTools._FromHalfFloat(srcData[srcPos + 2]);
  92922. if (DDSTools.StoreLODInAlphaChannel) {
  92923. destArray[index + 3] = lod;
  92924. }
  92925. else {
  92926. destArray[index + 3] = DDSTools._FromHalfFloat(srcData[srcPos + 3]);
  92927. }
  92928. index += 4;
  92929. }
  92930. }
  92931. return destArray;
  92932. };
  92933. DDSTools._GetHalfFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92934. if (DDSTools.StoreLODInAlphaChannel) {
  92935. var destArray = new Uint16Array(dataLength);
  92936. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  92937. var index = 0;
  92938. for (var y = 0; y < height; y++) {
  92939. for (var x = 0; x < width; x++) {
  92940. var srcPos = (x + y * width) * 4;
  92941. destArray[index] = srcData[srcPos];
  92942. destArray[index + 1] = srcData[srcPos + 1];
  92943. destArray[index + 2] = srcData[srcPos + 2];
  92944. destArray[index + 3] = DDSTools._ToHalfFloat(lod);
  92945. index += 4;
  92946. }
  92947. }
  92948. return destArray;
  92949. }
  92950. return new Uint16Array(arrayBuffer, dataOffset, dataLength);
  92951. };
  92952. DDSTools._GetFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92953. if (DDSTools.StoreLODInAlphaChannel) {
  92954. var destArray = new Float32Array(dataLength);
  92955. var srcData = new Float32Array(arrayBuffer, dataOffset);
  92956. var index = 0;
  92957. for (var y = 0; y < height; y++) {
  92958. for (var x = 0; x < width; x++) {
  92959. var srcPos = (x + y * width) * 4;
  92960. destArray[index] = srcData[srcPos];
  92961. destArray[index + 1] = srcData[srcPos + 1];
  92962. destArray[index + 2] = srcData[srcPos + 2];
  92963. destArray[index + 3] = lod;
  92964. index += 4;
  92965. }
  92966. }
  92967. return destArray;
  92968. }
  92969. return new Float32Array(arrayBuffer, dataOffset, dataLength);
  92970. };
  92971. DDSTools._GetFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92972. var destArray = new Uint8Array(dataLength);
  92973. var srcData = new Float32Array(arrayBuffer, dataOffset);
  92974. var index = 0;
  92975. for (var y = 0; y < height; y++) {
  92976. for (var x = 0; x < width; x++) {
  92977. var srcPos = (x + y * width) * 4;
  92978. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos]) * 255;
  92979. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 1]) * 255;
  92980. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 2]) * 255;
  92981. if (DDSTools.StoreLODInAlphaChannel) {
  92982. destArray[index + 3] = lod;
  92983. }
  92984. else {
  92985. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 3]) * 255;
  92986. }
  92987. index += 4;
  92988. }
  92989. }
  92990. return destArray;
  92991. };
  92992. DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  92993. var destArray = new Uint8Array(dataLength);
  92994. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  92995. var index = 0;
  92996. for (var y = 0; y < height; y++) {
  92997. for (var x = 0; x < width; x++) {
  92998. var srcPos = (x + y * width) * 4;
  92999. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos])) * 255;
  93000. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 1])) * 255;
  93001. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 2])) * 255;
  93002. if (DDSTools.StoreLODInAlphaChannel) {
  93003. destArray[index + 3] = lod;
  93004. }
  93005. else {
  93006. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 3])) * 255;
  93007. }
  93008. index += 4;
  93009. }
  93010. }
  93011. return destArray;
  93012. };
  93013. DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
  93014. var byteArray = new Uint8Array(dataLength);
  93015. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  93016. var index = 0;
  93017. for (var y = 0; y < height; y++) {
  93018. for (var x = 0; x < width; x++) {
  93019. var srcPos = (x + y * width) * 4;
  93020. byteArray[index] = srcData[srcPos + rOffset];
  93021. byteArray[index + 1] = srcData[srcPos + gOffset];
  93022. byteArray[index + 2] = srcData[srcPos + bOffset];
  93023. byteArray[index + 3] = srcData[srcPos + aOffset];
  93024. index += 4;
  93025. }
  93026. }
  93027. return byteArray;
  93028. };
  93029. DDSTools._ExtractLongWordOrder = function (value) {
  93030. if (value === 0 || value === 255 || value === -16777216) {
  93031. return 0;
  93032. }
  93033. return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
  93034. };
  93035. DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
  93036. var byteArray = new Uint8Array(dataLength);
  93037. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  93038. var index = 0;
  93039. for (var y = 0; y < height; y++) {
  93040. for (var x = 0; x < width; x++) {
  93041. var srcPos = (x + y * width) * 3;
  93042. byteArray[index] = srcData[srcPos + rOffset];
  93043. byteArray[index + 1] = srcData[srcPos + gOffset];
  93044. byteArray[index + 2] = srcData[srcPos + bOffset];
  93045. index += 3;
  93046. }
  93047. }
  93048. return byteArray;
  93049. };
  93050. DDSTools._GetLuminanceArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
  93051. var byteArray = new Uint8Array(dataLength);
  93052. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  93053. var index = 0;
  93054. for (var y = 0; y < height; y++) {
  93055. for (var x = 0; x < width; x++) {
  93056. var srcPos = (x + y * width);
  93057. byteArray[index] = srcData[srcPos];
  93058. index++;
  93059. }
  93060. }
  93061. return byteArray;
  93062. };
  93063. /**
  93064. * Uploads DDS Levels to a Babylon Texture
  93065. * @hidden
  93066. */
  93067. DDSTools.UploadDDSLevels = function (engine, texture, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
  93068. if (lodIndex === void 0) { lodIndex = -1; }
  93069. var sphericalPolynomialFaces = null;
  93070. if (info.sphericalPolynomial) {
  93071. sphericalPolynomialFaces = new Array();
  93072. }
  93073. var ext = engine.getCaps().s3tc;
  93074. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  93075. var fourCC, width, height, dataLength = 0, dataOffset;
  93076. var byteArray, mipmapCount, mip;
  93077. var internalCompressedFormat = 0;
  93078. var blockBytes = 1;
  93079. if (header[off_magic] !== DDS_MAGIC) {
  93080. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Invalid magic number in DDS header");
  93081. return;
  93082. }
  93083. if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
  93084. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  93085. return;
  93086. }
  93087. if (info.isCompressed && !ext) {
  93088. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Compressed textures are not supported on this platform.");
  93089. return;
  93090. }
  93091. var bpp = header[off_RGBbpp];
  93092. dataOffset = header[off_size] + 4;
  93093. var computeFormats = false;
  93094. if (info.isFourCC) {
  93095. fourCC = header[off_pfFourCC];
  93096. switch (fourCC) {
  93097. case FOURCC_DXT1:
  93098. blockBytes = 8;
  93099. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  93100. break;
  93101. case FOURCC_DXT3:
  93102. blockBytes = 16;
  93103. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  93104. break;
  93105. case FOURCC_DXT5:
  93106. blockBytes = 16;
  93107. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  93108. break;
  93109. case FOURCC_D3DFMT_R16G16B16A16F:
  93110. computeFormats = true;
  93111. break;
  93112. case FOURCC_D3DFMT_R32G32B32A32F:
  93113. computeFormats = true;
  93114. break;
  93115. case FOURCC_DX10:
  93116. // There is an additionnal header so dataOffset need to be changed
  93117. dataOffset += 5 * 4; // 5 uints
  93118. var supported = false;
  93119. switch (info.dxgiFormat) {
  93120. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  93121. computeFormats = true;
  93122. supported = true;
  93123. break;
  93124. case DXGI_FORMAT_B8G8R8X8_UNORM:
  93125. info.isRGB = true;
  93126. info.isFourCC = false;
  93127. bpp = 32;
  93128. supported = true;
  93129. break;
  93130. }
  93131. if (supported) {
  93132. break;
  93133. }
  93134. default:
  93135. console.error("Unsupported FourCC code:", Int32ToFourCC(fourCC));
  93136. return;
  93137. }
  93138. }
  93139. var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
  93140. var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
  93141. var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
  93142. var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
  93143. if (computeFormats) {
  93144. internalCompressedFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
  93145. }
  93146. mipmapCount = 1;
  93147. if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
  93148. mipmapCount = Math.max(1, header[off_mipmapCount]);
  93149. }
  93150. for (var face = 0; face < faces; face++) {
  93151. width = header[off_width];
  93152. height = header[off_height];
  93153. for (mip = 0; mip < mipmapCount; ++mip) {
  93154. if (lodIndex === -1 || lodIndex === mip) {
  93155. // In case of fixed LOD, if the lod has just been uploaded, early exit.
  93156. var i = (lodIndex === -1) ? mip : 0;
  93157. if (!info.isCompressed && info.isFourCC) {
  93158. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  93159. dataLength = width * height * 4;
  93160. var floatArray = null;
  93161. if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
  93162. if (bpp === 128) {
  93163. floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93164. if (sphericalPolynomialFaces && i == 0) {
  93165. sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  93166. }
  93167. }
  93168. else if (bpp === 64) {
  93169. floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93170. if (sphericalPolynomialFaces && i == 0) {
  93171. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  93172. }
  93173. }
  93174. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93175. }
  93176. else {
  93177. if (bpp === 128) {
  93178. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  93179. floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93180. if (sphericalPolynomialFaces && i == 0) {
  93181. sphericalPolynomialFaces.push(floatArray);
  93182. }
  93183. }
  93184. else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
  93185. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  93186. floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93187. if (sphericalPolynomialFaces && i == 0) {
  93188. sphericalPolynomialFaces.push(floatArray);
  93189. }
  93190. }
  93191. else { // 64
  93192. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  93193. floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93194. if (sphericalPolynomialFaces && i == 0) {
  93195. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  93196. }
  93197. }
  93198. }
  93199. if (floatArray) {
  93200. engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
  93201. }
  93202. }
  93203. else if (info.isRGB) {
  93204. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93205. if (bpp === 24) {
  93206. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB;
  93207. dataLength = width * height * 3;
  93208. byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  93209. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  93210. }
  93211. else { // 32
  93212. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  93213. dataLength = width * height * 4;
  93214. byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  93215. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  93216. }
  93217. }
  93218. else if (info.isLuminance) {
  93219. var unpackAlignment = engine._getUnpackAlignement();
  93220. var unpaddedRowSize = width;
  93221. var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
  93222. dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
  93223. byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  93224. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE;
  93225. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93226. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  93227. }
  93228. else {
  93229. dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
  93230. byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
  93231. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93232. engine._uploadCompressedDataToTextureDirectly(texture, internalCompressedFormat, width, height, byteArray, face, i);
  93233. }
  93234. }
  93235. dataOffset += bpp ? (width * height * (bpp / 8)) : dataLength;
  93236. width *= 0.5;
  93237. height *= 0.5;
  93238. width = Math.max(1.0, width);
  93239. height = Math.max(1.0, height);
  93240. }
  93241. if (currentFace !== undefined) {
  93242. // Loading a single face
  93243. break;
  93244. }
  93245. }
  93246. if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
  93247. info.sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial({
  93248. size: header[off_width],
  93249. right: sphericalPolynomialFaces[0],
  93250. left: sphericalPolynomialFaces[1],
  93251. up: sphericalPolynomialFaces[2],
  93252. down: sphericalPolynomialFaces[3],
  93253. front: sphericalPolynomialFaces[4],
  93254. back: sphericalPolynomialFaces[5],
  93255. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA,
  93256. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT,
  93257. gammaSpace: false,
  93258. });
  93259. }
  93260. else {
  93261. info.sphericalPolynomial = undefined;
  93262. }
  93263. };
  93264. /**
  93265. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  93266. */
  93267. DDSTools.StoreLODInAlphaChannel = false;
  93268. return DDSTools;
  93269. }());
  93270. /**
  93271. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  93272. * @param rootUrl defines the url where the file to load is located
  93273. * @param scene defines the current scene
  93274. * @param lodScale defines scale to apply to the mip map selection
  93275. * @param lodOffset defines offset to apply to the mip map selection
  93276. * @param onLoad defines an optional callback raised when the texture is loaded
  93277. * @param onError defines an optional callback raised if there is an issue to load the texture
  93278. * @param format defines the format of the data
  93279. * @param forcedExtension defines the extension to use to pick the right loader
  93280. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  93281. * @returns the cube texture as an InternalTexture
  93282. */
  93283. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createPrefilteredCubeTexture = function (rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, createPolynomials) {
  93284. var _this = this;
  93285. if (onLoad === void 0) { onLoad = null; }
  93286. if (onError === void 0) { onError = null; }
  93287. if (forcedExtension === void 0) { forcedExtension = null; }
  93288. if (createPolynomials === void 0) { createPolynomials = true; }
  93289. var callback = function (loadData) {
  93290. if (!loadData) {
  93291. if (onLoad) {
  93292. onLoad(null);
  93293. }
  93294. return;
  93295. }
  93296. var texture = loadData.texture;
  93297. if (!createPolynomials) {
  93298. texture._sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__["SphericalPolynomial"]();
  93299. }
  93300. else if (loadData.info.sphericalPolynomial) {
  93301. texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
  93302. }
  93303. texture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBEPREFILTERED;
  93304. if (_this.getCaps().textureLOD) {
  93305. // Do not add extra process if texture lod is supported.
  93306. if (onLoad) {
  93307. onLoad(texture);
  93308. }
  93309. return;
  93310. }
  93311. var mipSlices = 3;
  93312. var gl = _this._gl;
  93313. var width = loadData.width;
  93314. if (!width) {
  93315. return;
  93316. }
  93317. var textures = [];
  93318. for (var i = 0; i < mipSlices; i++) {
  93319. //compute LOD from even spacing in smoothness (matching shader calculation)
  93320. var smoothness = i / (mipSlices - 1);
  93321. var roughness = 1 - smoothness;
  93322. var minLODIndex = lodOffset; // roughness = 0
  93323. var maxLODIndex = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) * lodScale + lodOffset; // roughness = 1
  93324. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  93325. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  93326. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  93327. glTextureFromLod.type = texture.type;
  93328. glTextureFromLod.format = texture.format;
  93329. glTextureFromLod.width = Math.pow(2, Math.max(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) - mipmapIndex, 0));
  93330. glTextureFromLod.height = glTextureFromLod.width;
  93331. glTextureFromLod.isCube = true;
  93332. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
  93333. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  93334. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  93335. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  93336. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  93337. if (loadData.isDDS) {
  93338. var info = loadData.info;
  93339. var data = loadData.data;
  93340. _this._unpackFlipY(info.isCompressed);
  93341. DDSTools.UploadDDSLevels(_this, glTextureFromLod, data, info, true, 6, mipmapIndex);
  93342. }
  93343. else {
  93344. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("DDS is the only prefiltered cube map supported so far.");
  93345. }
  93346. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  93347. // Wrap in a base texture for easy binding.
  93348. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__["BaseTexture"](scene);
  93349. lodTexture.isCube = true;
  93350. lodTexture._texture = glTextureFromLod;
  93351. glTextureFromLod.isReady = true;
  93352. textures.push(lodTexture);
  93353. }
  93354. texture._lodTextureHigh = textures[2];
  93355. texture._lodTextureMid = textures[1];
  93356. texture._lodTextureLow = textures[0];
  93357. if (onLoad) {
  93358. onLoad(texture);
  93359. }
  93360. };
  93361. return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);
  93362. };
  93363. /***/ }),
  93364. /***/ "./Misc/decorators.ts":
  93365. /*!****************************!*\
  93366. !*** ./Misc/decorators.ts ***!
  93367. \****************************/
  93368. /*! exports provided: expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper */
  93369. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93370. "use strict";
  93371. __webpack_require__.r(__webpack_exports__);
  93372. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return expandToProperty; });
  93373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; });
  93374. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return serializeAsTexture; });
  93375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return serializeAsColor3; });
  93376. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return serializeAsFresnelParameters; });
  93377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return serializeAsVector2; });
  93378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return serializeAsVector3; });
  93379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return serializeAsMeshReference; });
  93380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return serializeAsColorCurves; });
  93381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return serializeAsColor4; });
  93382. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return serializeAsImageProcessingConfiguration; });
  93383. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return serializeAsQuaternion; });
  93384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return serializeAsCameraReference; });
  93385. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return SerializationHelper; });
  93386. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  93387. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  93388. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  93389. var __decoratorInitialStore = {};
  93390. var __mergedStore = {};
  93391. var _copySource = function (creationFunction, source, instanciate) {
  93392. var destination = creationFunction();
  93393. // Tags
  93394. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  93395. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  93396. }
  93397. var classStore = getMergedStore(destination);
  93398. // Properties
  93399. for (var property in classStore) {
  93400. var propertyDescriptor = classStore[property];
  93401. var sourceProperty = source[property];
  93402. var propertyType = propertyDescriptor.type;
  93403. if (sourceProperty !== undefined && sourceProperty !== null && property !== "uniqueId") {
  93404. switch (propertyType) {
  93405. case 0: // Value
  93406. case 6: // Mesh reference
  93407. case 11: // Camera reference
  93408. destination[property] = sourceProperty;
  93409. break;
  93410. case 1: // Texture
  93411. destination[property] = (instanciate || sourceProperty.isRenderTarget) ? sourceProperty : sourceProperty.clone();
  93412. break;
  93413. case 2: // Color3
  93414. case 3: // FresnelParameters
  93415. case 4: // Vector2
  93416. case 5: // Vector3
  93417. case 7: // Color Curves
  93418. case 10: // Quaternion
  93419. destination[property] = instanciate ? sourceProperty : sourceProperty.clone();
  93420. break;
  93421. }
  93422. }
  93423. }
  93424. return destination;
  93425. };
  93426. function getDirectStore(target) {
  93427. var classKey = target.getClassName();
  93428. if (!__decoratorInitialStore[classKey]) {
  93429. __decoratorInitialStore[classKey] = {};
  93430. }
  93431. return __decoratorInitialStore[classKey];
  93432. }
  93433. /**
  93434. * Return the list of properties flagged as serializable
  93435. * @param target: host object
  93436. */
  93437. function getMergedStore(target) {
  93438. var classKey = target.getClassName();
  93439. if (__mergedStore[classKey]) {
  93440. return __mergedStore[classKey];
  93441. }
  93442. __mergedStore[classKey] = {};
  93443. var store = __mergedStore[classKey];
  93444. var currentTarget = target;
  93445. var currentKey = classKey;
  93446. while (currentKey) {
  93447. var initialStore = __decoratorInitialStore[currentKey];
  93448. for (var property in initialStore) {
  93449. store[property] = initialStore[property];
  93450. }
  93451. var parent_1 = void 0;
  93452. var done = false;
  93453. do {
  93454. parent_1 = Object.getPrototypeOf(currentTarget);
  93455. if (!parent_1.getClassName) {
  93456. done = true;
  93457. break;
  93458. }
  93459. if (parent_1.getClassName() !== currentKey) {
  93460. break;
  93461. }
  93462. currentTarget = parent_1;
  93463. } while (parent_1);
  93464. if (done) {
  93465. break;
  93466. }
  93467. currentKey = parent_1.getClassName();
  93468. currentTarget = parent_1;
  93469. }
  93470. return store;
  93471. }
  93472. function generateSerializableMember(type, sourceName) {
  93473. return function (target, propertyKey) {
  93474. var classStore = getDirectStore(target);
  93475. if (!classStore[propertyKey]) {
  93476. classStore[propertyKey] = { type: type, sourceName: sourceName };
  93477. }
  93478. };
  93479. }
  93480. function generateExpandMember(setCallback, targetKey) {
  93481. if (targetKey === void 0) { targetKey = null; }
  93482. return function (target, propertyKey) {
  93483. var key = targetKey || ("_" + propertyKey);
  93484. Object.defineProperty(target, propertyKey, {
  93485. get: function () {
  93486. return this[key];
  93487. },
  93488. set: function (value) {
  93489. if (this[key] === value) {
  93490. return;
  93491. }
  93492. this[key] = value;
  93493. target[setCallback].apply(this);
  93494. },
  93495. enumerable: true,
  93496. configurable: true
  93497. });
  93498. };
  93499. }
  93500. function expandToProperty(callback, targetKey) {
  93501. if (targetKey === void 0) { targetKey = null; }
  93502. return generateExpandMember(callback, targetKey);
  93503. }
  93504. function serialize(sourceName) {
  93505. return generateSerializableMember(0, sourceName); // value member
  93506. }
  93507. function serializeAsTexture(sourceName) {
  93508. return generateSerializableMember(1, sourceName); // texture member
  93509. }
  93510. function serializeAsColor3(sourceName) {
  93511. return generateSerializableMember(2, sourceName); // color3 member
  93512. }
  93513. function serializeAsFresnelParameters(sourceName) {
  93514. return generateSerializableMember(3, sourceName); // fresnel parameters member
  93515. }
  93516. function serializeAsVector2(sourceName) {
  93517. return generateSerializableMember(4, sourceName); // vector2 member
  93518. }
  93519. function serializeAsVector3(sourceName) {
  93520. return generateSerializableMember(5, sourceName); // vector3 member
  93521. }
  93522. function serializeAsMeshReference(sourceName) {
  93523. return generateSerializableMember(6, sourceName); // mesh reference member
  93524. }
  93525. function serializeAsColorCurves(sourceName) {
  93526. return generateSerializableMember(7, sourceName); // color curves
  93527. }
  93528. function serializeAsColor4(sourceName) {
  93529. return generateSerializableMember(8, sourceName); // color 4
  93530. }
  93531. function serializeAsImageProcessingConfiguration(sourceName) {
  93532. return generateSerializableMember(9, sourceName); // image processing
  93533. }
  93534. function serializeAsQuaternion(sourceName) {
  93535. return generateSerializableMember(10, sourceName); // quaternion member
  93536. }
  93537. /**
  93538. * Decorator used to define property that can be serialized as reference to a camera
  93539. * @param sourceName defines the name of the property to decorate
  93540. */
  93541. function serializeAsCameraReference(sourceName) {
  93542. return generateSerializableMember(11, sourceName); // camera reference member
  93543. }
  93544. /**
  93545. * Class used to help serialization objects
  93546. */
  93547. var SerializationHelper = /** @class */ (function () {
  93548. function SerializationHelper() {
  93549. }
  93550. /**
  93551. * Appends the serialized animations from the source animations
  93552. * @param source Source containing the animations
  93553. * @param destination Target to store the animations
  93554. */
  93555. SerializationHelper.AppendSerializedAnimations = function (source, destination) {
  93556. if (source.animations) {
  93557. destination.animations = [];
  93558. for (var animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {
  93559. var animation = source.animations[animationIndex];
  93560. destination.animations.push(animation.serialize());
  93561. }
  93562. }
  93563. };
  93564. /**
  93565. * Static function used to serialized a specific entity
  93566. * @param entity defines the entity to serialize
  93567. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93568. * @returns a JSON compatible object representing the serialization of the entity
  93569. */
  93570. SerializationHelper.Serialize = function (entity, serializationObject) {
  93571. if (!serializationObject) {
  93572. serializationObject = {};
  93573. }
  93574. // Tags
  93575. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  93576. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].GetTags(entity);
  93577. }
  93578. var serializedProperties = getMergedStore(entity);
  93579. // Properties
  93580. for (var property in serializedProperties) {
  93581. var propertyDescriptor = serializedProperties[property];
  93582. var targetPropertyName = propertyDescriptor.sourceName || property;
  93583. var propertyType = propertyDescriptor.type;
  93584. var sourceProperty = entity[property];
  93585. if (sourceProperty !== undefined && sourceProperty !== null) {
  93586. switch (propertyType) {
  93587. case 0: // Value
  93588. serializationObject[targetPropertyName] = sourceProperty;
  93589. break;
  93590. case 1: // Texture
  93591. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93592. break;
  93593. case 2: // Color3
  93594. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93595. break;
  93596. case 3: // FresnelParameters
  93597. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93598. break;
  93599. case 4: // Vector2
  93600. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93601. break;
  93602. case 5: // Vector3
  93603. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93604. break;
  93605. case 6: // Mesh reference
  93606. serializationObject[targetPropertyName] = sourceProperty.id;
  93607. break;
  93608. case 7: // Color Curves
  93609. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93610. break;
  93611. case 8: // Color 4
  93612. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93613. break;
  93614. case 9: // Image Processing
  93615. serializationObject[targetPropertyName] = sourceProperty.serialize();
  93616. break;
  93617. case 10: // Quaternion
  93618. serializationObject[targetPropertyName] = sourceProperty.asArray();
  93619. break;
  93620. case 11: // Camera reference
  93621. serializationObject[targetPropertyName] = sourceProperty.id;
  93622. break;
  93623. }
  93624. }
  93625. }
  93626. return serializationObject;
  93627. };
  93628. /**
  93629. * Creates a new entity from a serialization data object
  93630. * @param creationFunction defines a function used to instanciated the new entity
  93631. * @param source defines the source serialization data
  93632. * @param scene defines the hosting scene
  93633. * @param rootUrl defines the root url for resources
  93634. * @returns a new entity
  93635. */
  93636. SerializationHelper.Parse = function (creationFunction, source, scene, rootUrl) {
  93637. if (rootUrl === void 0) { rootUrl = null; }
  93638. var destination = creationFunction();
  93639. if (!rootUrl) {
  93640. rootUrl = "";
  93641. }
  93642. // Tags
  93643. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  93644. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  93645. }
  93646. var classStore = getMergedStore(destination);
  93647. // Properties
  93648. for (var property in classStore) {
  93649. var propertyDescriptor = classStore[property];
  93650. var sourceProperty = source[propertyDescriptor.sourceName || property];
  93651. var propertyType = propertyDescriptor.type;
  93652. if (sourceProperty !== undefined && sourceProperty !== null) {
  93653. var dest = destination;
  93654. switch (propertyType) {
  93655. case 0: // Value
  93656. dest[property] = sourceProperty;
  93657. break;
  93658. case 1: // Texture
  93659. if (scene) {
  93660. dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);
  93661. }
  93662. break;
  93663. case 2: // Color3
  93664. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(sourceProperty);
  93665. break;
  93666. case 3: // FresnelParameters
  93667. dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);
  93668. break;
  93669. case 4: // Vector2
  93670. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(sourceProperty);
  93671. break;
  93672. case 5: // Vector3
  93673. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(sourceProperty);
  93674. break;
  93675. case 6: // Mesh reference
  93676. if (scene) {
  93677. dest[property] = scene.getLastMeshByID(sourceProperty);
  93678. }
  93679. break;
  93680. case 7: // Color Curves
  93681. dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);
  93682. break;
  93683. case 8: // Color 4
  93684. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(sourceProperty);
  93685. break;
  93686. case 9: // Image Processing
  93687. dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);
  93688. break;
  93689. case 10: // Quaternion
  93690. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(sourceProperty);
  93691. break;
  93692. case 11: // Camera reference
  93693. if (scene) {
  93694. dest[property] = scene.getCameraByID(sourceProperty);
  93695. }
  93696. break;
  93697. }
  93698. }
  93699. }
  93700. return destination;
  93701. };
  93702. /**
  93703. * Clones an object
  93704. * @param creationFunction defines the function used to instanciate the new object
  93705. * @param source defines the source object
  93706. * @returns the cloned object
  93707. */
  93708. SerializationHelper.Clone = function (creationFunction, source) {
  93709. return _copySource(creationFunction, source, false);
  93710. };
  93711. /**
  93712. * Instanciates a new object based on a source one (some data will be shared between both object)
  93713. * @param creationFunction defines the function used to instanciate the new object
  93714. * @param source defines the source object
  93715. * @returns the new object
  93716. */
  93717. SerializationHelper.Instanciate = function (creationFunction, source) {
  93718. return _copySource(creationFunction, source, true);
  93719. };
  93720. /** hidden */
  93721. SerializationHelper._ImageProcessingConfigurationParser = function (sourceProperty) {
  93722. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ImageProcessingConfiguration");
  93723. };
  93724. /** hidden */
  93725. SerializationHelper._FresnelParametersParser = function (sourceProperty) {
  93726. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("FresnelParameters");
  93727. };
  93728. /** hidden */
  93729. SerializationHelper._ColorCurvesParser = function (sourceProperty) {
  93730. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ColorCurves");
  93731. };
  93732. /** hidden */
  93733. SerializationHelper._TextureParser = function (sourceProperty, scene, rootUrl) {
  93734. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("Texture");
  93735. };
  93736. return SerializationHelper;
  93737. }());
  93738. /***/ }),
  93739. /***/ "./Misc/deepCopier.ts":
  93740. /*!****************************!*\
  93741. !*** ./Misc/deepCopier.ts ***!
  93742. \****************************/
  93743. /*! exports provided: DeepCopier */
  93744. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93745. "use strict";
  93746. __webpack_require__.r(__webpack_exports__);
  93747. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return DeepCopier; });
  93748. var cloneValue = function (source, destinationObject) {
  93749. if (!source) {
  93750. return null;
  93751. }
  93752. if (source.getClassName && source.getClassName() === "Mesh") {
  93753. return null;
  93754. }
  93755. if (source.getClassName && source.getClassName() === "SubMesh") {
  93756. return source.clone(destinationObject);
  93757. }
  93758. else if (source.clone) {
  93759. return source.clone();
  93760. }
  93761. return null;
  93762. };
  93763. /**
  93764. * Class containing a set of static utilities functions for deep copy.
  93765. */
  93766. var DeepCopier = /** @class */ (function () {
  93767. function DeepCopier() {
  93768. }
  93769. /**
  93770. * Tries to copy an object by duplicating every property
  93771. * @param source defines the source object
  93772. * @param destination defines the target object
  93773. * @param doNotCopyList defines a list of properties to avoid
  93774. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  93775. */
  93776. DeepCopier.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  93777. for (var prop in source) {
  93778. if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
  93779. continue;
  93780. }
  93781. if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {
  93782. continue;
  93783. }
  93784. var sourceValue = source[prop];
  93785. var typeOfSourceValue = typeof sourceValue;
  93786. if (typeOfSourceValue === "function") {
  93787. continue;
  93788. }
  93789. try {
  93790. if (typeOfSourceValue === "object") {
  93791. if (sourceValue instanceof Array) {
  93792. destination[prop] = [];
  93793. if (sourceValue.length > 0) {
  93794. if (typeof sourceValue[0] == "object") {
  93795. for (var index = 0; index < sourceValue.length; index++) {
  93796. var clonedValue = cloneValue(sourceValue[index], destination);
  93797. if (destination[prop].indexOf(clonedValue) === -1) { // Test if auto inject was not done
  93798. destination[prop].push(clonedValue);
  93799. }
  93800. }
  93801. }
  93802. else {
  93803. destination[prop] = sourceValue.slice(0);
  93804. }
  93805. }
  93806. }
  93807. else {
  93808. destination[prop] = cloneValue(sourceValue, destination);
  93809. }
  93810. }
  93811. else {
  93812. destination[prop] = sourceValue;
  93813. }
  93814. }
  93815. catch (e) {
  93816. // Just ignore error (it could be because of a read-only property)
  93817. }
  93818. }
  93819. };
  93820. return DeepCopier;
  93821. }());
  93822. /***/ }),
  93823. /***/ "./Misc/deferred.ts":
  93824. /*!**************************!*\
  93825. !*** ./Misc/deferred.ts ***!
  93826. \**************************/
  93827. /*! exports provided: Deferred */
  93828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93829. "use strict";
  93830. __webpack_require__.r(__webpack_exports__);
  93831. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return Deferred; });
  93832. /**
  93833. * Wrapper class for promise with external resolve and reject.
  93834. */
  93835. var Deferred = /** @class */ (function () {
  93836. /**
  93837. * Constructor for this deferred object.
  93838. */
  93839. function Deferred() {
  93840. var _this = this;
  93841. this.promise = new Promise(function (resolve, reject) {
  93842. _this._resolve = resolve;
  93843. _this._reject = reject;
  93844. });
  93845. }
  93846. Object.defineProperty(Deferred.prototype, "resolve", {
  93847. /**
  93848. * The resolve method of the promise associated with this deferred object.
  93849. */
  93850. get: function () {
  93851. return this._resolve;
  93852. },
  93853. enumerable: true,
  93854. configurable: true
  93855. });
  93856. Object.defineProperty(Deferred.prototype, "reject", {
  93857. /**
  93858. * The reject method of the promise associated with this deferred object.
  93859. */
  93860. get: function () {
  93861. return this._reject;
  93862. },
  93863. enumerable: true,
  93864. configurable: true
  93865. });
  93866. return Deferred;
  93867. }());
  93868. /***/ }),
  93869. /***/ "./Misc/devTools.ts":
  93870. /*!**************************!*\
  93871. !*** ./Misc/devTools.ts ***!
  93872. \**************************/
  93873. /*! exports provided: _DevTools */
  93874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93875. "use strict";
  93876. __webpack_require__.r(__webpack_exports__);
  93877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DevTools", function() { return _DevTools; });
  93878. /** @hidden */
  93879. var _DevTools = /** @class */ (function () {
  93880. function _DevTools() {
  93881. }
  93882. _DevTools.WarnImport = function (name) {
  93883. return name + " needs to be imported before as it contains a side-effect required by your code.";
  93884. };
  93885. return _DevTools;
  93886. }());
  93887. /***/ }),
  93888. /***/ "./Misc/domManagement.ts":
  93889. /*!*******************************!*\
  93890. !*** ./Misc/domManagement.ts ***!
  93891. \*******************************/
  93892. /*! exports provided: DomManagement */
  93893. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93894. "use strict";
  93895. __webpack_require__.r(__webpack_exports__);
  93896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomManagement", function() { return DomManagement; });
  93897. /**
  93898. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  93899. * Babylon.js
  93900. */
  93901. var DomManagement = /** @class */ (function () {
  93902. function DomManagement() {
  93903. }
  93904. /**
  93905. * Checks if the window object exists
  93906. * @returns true if the window object exists
  93907. */
  93908. DomManagement.IsWindowObjectExist = function () {
  93909. return (typeof window) !== "undefined";
  93910. };
  93911. /**
  93912. * Extracts text content from a DOM element hierarchy
  93913. * @param element defines the root element
  93914. * @returns a string
  93915. */
  93916. DomManagement.GetDOMTextContent = function (element) {
  93917. var result = "";
  93918. var child = element.firstChild;
  93919. while (child) {
  93920. if (child.nodeType === 3) {
  93921. result += child.textContent;
  93922. }
  93923. child = (child.nextSibling);
  93924. }
  93925. return result;
  93926. };
  93927. return DomManagement;
  93928. }());
  93929. /***/ }),
  93930. /***/ "./Misc/environmentTextureTools.ts":
  93931. /*!*****************************************!*\
  93932. !*** ./Misc/environmentTextureTools.ts ***!
  93933. \*****************************************/
  93934. /*! exports provided: EnvironmentTextureTools */
  93935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93936. "use strict";
  93937. __webpack_require__.r(__webpack_exports__);
  93938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return EnvironmentTextureTools; });
  93939. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  93940. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  93941. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  93942. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  93943. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  93944. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  93945. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  93946. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  93947. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  93948. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  93949. /* harmony import */ var _Shaders_rgbdEncode_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/rgbdEncode.fragment */ "./Shaders/rgbdEncode.fragment.ts");
  93950. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  93951. /**
  93952. * Sets of helpers addressing the serialization and deserialization of environment texture
  93953. * stored in a BabylonJS env file.
  93954. * Those files are usually stored as .env files.
  93955. */
  93956. var EnvironmentTextureTools = /** @class */ (function () {
  93957. function EnvironmentTextureTools() {
  93958. }
  93959. /**
  93960. * Gets the environment info from an env file.
  93961. * @param data The array buffer containing the .env bytes.
  93962. * @returns the environment file info (the json header) if successfully parsed.
  93963. */
  93964. EnvironmentTextureTools.GetEnvInfo = function (data) {
  93965. var dataView = new DataView(data);
  93966. var pos = 0;
  93967. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  93968. if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
  93969. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error('Not a babylon environment map');
  93970. return null;
  93971. }
  93972. }
  93973. // Read json manifest - collect characters up to null terminator
  93974. var manifestString = '';
  93975. var charCode = 0x00;
  93976. while ((charCode = dataView.getUint8(pos++))) {
  93977. manifestString += String.fromCharCode(charCode);
  93978. }
  93979. var manifest = JSON.parse(manifestString);
  93980. if (manifest.specular) {
  93981. // Extend the header with the position of the payload.
  93982. manifest.specular.specularDataPosition = pos;
  93983. // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
  93984. manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
  93985. }
  93986. return manifest;
  93987. };
  93988. /**
  93989. * Creates an environment texture from a loaded cube texture.
  93990. * @param texture defines the cube texture to convert in env file
  93991. * @return a promise containing the environment data if succesfull.
  93992. */
  93993. EnvironmentTextureTools.CreateEnvTextureAsync = function (texture) {
  93994. var _this = this;
  93995. var internalTexture = texture.getInternalTexture();
  93996. if (!internalTexture) {
  93997. return Promise.reject("The cube texture is invalid.");
  93998. }
  93999. if (!texture._prefiltered) {
  94000. return Promise.reject("The cube texture is invalid (not prefiltered).");
  94001. }
  94002. var engine = internalTexture.getEngine();
  94003. if (engine && engine.premultipliedAlpha) {
  94004. return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
  94005. }
  94006. if (texture.textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  94007. return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
  94008. }
  94009. var canvas = engine.getRenderingCanvas();
  94010. if (!canvas) {
  94011. return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
  94012. }
  94013. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  94014. if (!engine.getCaps().textureFloatRender) {
  94015. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  94016. if (!engine.getCaps().textureHalfFloatRender) {
  94017. return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
  94018. }
  94019. }
  94020. var cubeWidth = internalTexture.width;
  94021. var hostingScene = new _scene__WEBPACK_IMPORTED_MODULE_7__["Scene"](engine);
  94022. var specularTextures = {};
  94023. var promises = [];
  94024. // Read and collect all mipmaps data from the cube.
  94025. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(internalTexture.width);
  94026. mipmapsCount = Math.round(mipmapsCount);
  94027. var _loop_1 = function (i) {
  94028. var faceWidth = Math.pow(2, mipmapsCount - i);
  94029. var _loop_2 = function (face) {
  94030. var data = texture.readPixels(face, i);
  94031. // Creates a temp texture with the face data.
  94032. 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);
  94033. // And rgbdEncode them.
  94034. var promise = new Promise(function (resolve, reject) {
  94035. 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);
  94036. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  94037. rgbdPostProcess.onApply = function (effect) {
  94038. effect._bindTexture("textureSampler", tempTexture);
  94039. };
  94040. // As the process needs to happen on the main canvas, keep track of the current size
  94041. var currentW = engine.getRenderWidth();
  94042. var currentH = engine.getRenderHeight();
  94043. // Set the desired size for the texture
  94044. engine.setSize(faceWidth, faceWidth);
  94045. hostingScene.postProcessManager.directRender([rgbdPostProcess], null);
  94046. // Reading datas from WebGL
  94047. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToBlob(canvas, function (blob) {
  94048. var fileReader = new FileReader();
  94049. fileReader.onload = function (event) {
  94050. var arrayBuffer = event.target.result;
  94051. specularTextures[i * 6 + face] = arrayBuffer;
  94052. resolve();
  94053. };
  94054. fileReader.readAsArrayBuffer(blob);
  94055. });
  94056. // Reapply the previous canvas size
  94057. engine.setSize(currentW, currentH);
  94058. });
  94059. });
  94060. promises.push(promise);
  94061. };
  94062. // All faces of the cube.
  94063. for (var face = 0; face < 6; face++) {
  94064. _loop_2(face);
  94065. }
  94066. };
  94067. for (var i = 0; i <= mipmapsCount; i++) {
  94068. _loop_1(i);
  94069. }
  94070. // Once all the textures haves been collected as RGBD stored in PNGs
  94071. return Promise.all(promises).then(function () {
  94072. // We can delete the hosting scene keeping track of all the creation objects
  94073. hostingScene.dispose();
  94074. // Creates the json header for the env texture
  94075. var info = {
  94076. version: 1,
  94077. width: cubeWidth,
  94078. irradiance: _this._CreateEnvTextureIrradiance(texture),
  94079. specular: {
  94080. mipmaps: [],
  94081. lodGenerationScale: texture.lodGenerationScale
  94082. }
  94083. };
  94084. // Sets the specular image data information
  94085. var position = 0;
  94086. for (var i = 0; i <= mipmapsCount; i++) {
  94087. for (var face = 0; face < 6; face++) {
  94088. var byteLength = specularTextures[i * 6 + face].byteLength;
  94089. info.specular.mipmaps.push({
  94090. length: byteLength,
  94091. position: position
  94092. });
  94093. position += byteLength;
  94094. }
  94095. }
  94096. // Encode the JSON as an array buffer
  94097. var infoString = JSON.stringify(info);
  94098. var infoBuffer = new ArrayBuffer(infoString.length + 1);
  94099. var infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.
  94100. for (var i = 0, strLen = infoString.length; i < strLen; i++) {
  94101. infoView[i] = infoString.charCodeAt(i);
  94102. }
  94103. // Ends up with a null terminator for easier parsing
  94104. infoView[infoString.length] = 0x00;
  94105. // Computes the final required size and creates the storage
  94106. var totalSize = EnvironmentTextureTools._MagicBytes.length + position + infoBuffer.byteLength;
  94107. var finalBuffer = new ArrayBuffer(totalSize);
  94108. var finalBufferView = new Uint8Array(finalBuffer);
  94109. var dataView = new DataView(finalBuffer);
  94110. // Copy the magic bytes identifying the file in
  94111. var pos = 0;
  94112. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  94113. dataView.setUint8(pos++, EnvironmentTextureTools._MagicBytes[i]);
  94114. }
  94115. // Add the json info
  94116. finalBufferView.set(new Uint8Array(infoBuffer), pos);
  94117. pos += infoBuffer.byteLength;
  94118. // Finally inserts the texture data
  94119. for (var i = 0; i <= mipmapsCount; i++) {
  94120. for (var face = 0; face < 6; face++) {
  94121. var dataBuffer = specularTextures[i * 6 + face];
  94122. finalBufferView.set(new Uint8Array(dataBuffer), pos);
  94123. pos += dataBuffer.byteLength;
  94124. }
  94125. }
  94126. // Voila
  94127. return finalBuffer;
  94128. });
  94129. };
  94130. /**
  94131. * Creates a JSON representation of the spherical data.
  94132. * @param texture defines the texture containing the polynomials
  94133. * @return the JSON representation of the spherical info
  94134. */
  94135. EnvironmentTextureTools._CreateEnvTextureIrradiance = function (texture) {
  94136. var polynmials = texture.sphericalPolynomial;
  94137. if (polynmials == null) {
  94138. return null;
  94139. }
  94140. return {
  94141. x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],
  94142. y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],
  94143. z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],
  94144. xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],
  94145. yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],
  94146. zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],
  94147. yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],
  94148. zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],
  94149. xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z]
  94150. };
  94151. };
  94152. /**
  94153. * Uploads the texture info contained in the env file to the GPU.
  94154. * @param texture defines the internal texture to upload to
  94155. * @param arrayBuffer defines the buffer cotaining the data to load
  94156. * @param info defines the texture info retrieved through the GetEnvInfo method
  94157. * @returns a promise
  94158. */
  94159. EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
  94160. if (info.version !== 1) {
  94161. throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
  94162. }
  94163. var specularInfo = info.specular;
  94164. if (!specularInfo) {
  94165. // Nothing else parsed so far
  94166. return Promise.resolve();
  94167. }
  94168. // Double checks the enclosed info
  94169. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(info.width);
  94170. mipmapsCount = Math.round(mipmapsCount) + 1;
  94171. if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
  94172. throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
  94173. }
  94174. texture._lodGenerationScale = specularInfo.lodGenerationScale;
  94175. var imageData = new Array(mipmapsCount);
  94176. for (var i = 0; i < mipmapsCount; i++) {
  94177. imageData[i] = new Array(6);
  94178. for (var face = 0; face < 6; face++) {
  94179. var imageInfo = specularInfo.mipmaps[i * 6 + face];
  94180. imageData[i][face] = new Uint8Array(arrayBuffer, specularInfo.specularDataPosition + imageInfo.position, imageInfo.length);
  94181. }
  94182. }
  94183. return EnvironmentTextureTools.UploadLevelsAsync(texture, imageData);
  94184. };
  94185. /**
  94186. * Uploads the levels of image data to the GPU.
  94187. * @param texture defines the internal texture to upload to
  94188. * @param imageData defines the array buffer views of image data [mipmap][face]
  94189. * @returns a promise
  94190. */
  94191. EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
  94192. if (!_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsExponentOfTwo(texture.width)) {
  94193. throw new Error("Texture size must be a power of two");
  94194. }
  94195. var mipmapsCount = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(texture.width)) + 1;
  94196. // Gets everything ready.
  94197. var engine = texture.getEngine();
  94198. var expandTexture = false;
  94199. var generateNonLODTextures = false;
  94200. var rgbdPostProcess = null;
  94201. var cubeRtt = null;
  94202. var lodTextures = null;
  94203. var caps = engine.getCaps();
  94204. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  94205. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  94206. texture.generateMipMaps = true;
  94207. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, texture);
  94208. // Add extra process if texture lod is not supported
  94209. if (!caps.textureLOD) {
  94210. expandTexture = false;
  94211. generateNonLODTextures = true;
  94212. lodTextures = {};
  94213. }
  94214. // in webgl 1 there are no ways to either render or copy lod level information for float textures.
  94215. else if (engine.webGLVersion < 2) {
  94216. expandTexture = false;
  94217. }
  94218. // If half float available we can uncompress the texture
  94219. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  94220. expandTexture = true;
  94221. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  94222. }
  94223. // If full float available we can uncompress the texture
  94224. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  94225. expandTexture = true;
  94226. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  94227. }
  94228. // Expand the texture if possible
  94229. if (expandTexture) {
  94230. // Simply run through the decode PP
  94231. 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);
  94232. texture._isRGBD = false;
  94233. texture.invertY = false;
  94234. cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {
  94235. generateDepthBuffer: false,
  94236. generateMipMaps: true,
  94237. generateStencilBuffer: false,
  94238. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE,
  94239. type: texture.type,
  94240. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA
  94241. });
  94242. }
  94243. else {
  94244. texture._isRGBD = true;
  94245. texture.invertY = true;
  94246. // In case of missing support, applies the same patch than DDS files.
  94247. if (generateNonLODTextures) {
  94248. var mipSlices = 3;
  94249. var scale = texture._lodGenerationScale;
  94250. var offset = texture._lodGenerationOffset;
  94251. for (var i = 0; i < mipSlices; i++) {
  94252. //compute LOD from even spacing in smoothness (matching shader calculation)
  94253. var smoothness = i / (mipSlices - 1);
  94254. var roughness = 1 - smoothness;
  94255. var minLODIndex = offset; // roughness = 0
  94256. var maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)
  94257. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  94258. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  94259. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](engine, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  94260. glTextureFromLod.isCube = true;
  94261. glTextureFromLod.invertY = true;
  94262. glTextureFromLod.generateMipMaps = false;
  94263. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR, glTextureFromLod);
  94264. // Wrap in a base texture for easy binding.
  94265. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"](null);
  94266. lodTexture.isCube = true;
  94267. lodTexture._texture = glTextureFromLod;
  94268. lodTextures[mipmapIndex] = lodTexture;
  94269. switch (i) {
  94270. case 0:
  94271. texture._lodTextureLow = lodTexture;
  94272. break;
  94273. case 1:
  94274. texture._lodTextureMid = lodTexture;
  94275. break;
  94276. case 2:
  94277. texture._lodTextureHigh = lodTexture;
  94278. break;
  94279. }
  94280. }
  94281. }
  94282. }
  94283. var promises = [];
  94284. var _loop_3 = function (i) {
  94285. var _loop_4 = function (face) {
  94286. // Constructs an image element from image data
  94287. var bytes = imageData[i][face];
  94288. var blob = new Blob([bytes], { type: 'image/png' });
  94289. var url = URL.createObjectURL(blob);
  94290. var image = new Image();
  94291. image.src = url;
  94292. // Enqueue promise to upload to the texture.
  94293. var promise = new Promise(function (resolve, reject) {
  94294. image.onload = function () {
  94295. if (expandTexture) {
  94296. var tempTexture_1 = engine.createTexture(null, true, true, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, function (message) {
  94297. reject(message);
  94298. }, image);
  94299. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  94300. // Uncompress the data to a RTT
  94301. rgbdPostProcess.onApply = function (effect) {
  94302. effect._bindTexture("textureSampler", tempTexture_1);
  94303. effect.setFloat2("scale", 1, 1);
  94304. };
  94305. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);
  94306. // Cleanup
  94307. engine.restoreDefaultFramebuffer();
  94308. tempTexture_1.dispose();
  94309. window.URL.revokeObjectURL(url);
  94310. resolve();
  94311. });
  94312. }
  94313. else {
  94314. engine._uploadImageToTexture(texture, image, face, i);
  94315. // Upload the face to the non lod texture support
  94316. if (generateNonLODTextures) {
  94317. var lodTexture = lodTextures[i];
  94318. if (lodTexture) {
  94319. engine._uploadImageToTexture(lodTexture._texture, image, face, 0);
  94320. }
  94321. }
  94322. resolve();
  94323. }
  94324. };
  94325. image.onerror = function (error) {
  94326. reject(error);
  94327. };
  94328. });
  94329. promises.push(promise);
  94330. };
  94331. // All faces
  94332. for (var face = 0; face < 6; face++) {
  94333. _loop_4(face);
  94334. }
  94335. };
  94336. // All mipmaps up to provided number of images
  94337. for (var i = 0; i < imageData.length; i++) {
  94338. _loop_3(i);
  94339. }
  94340. // Fill remaining mipmaps with black textures.
  94341. if (imageData.length < mipmapsCount) {
  94342. var data = void 0;
  94343. var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
  94344. var dataLength = size * size * 4;
  94345. switch (texture.type) {
  94346. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT: {
  94347. data = new Uint8Array(dataLength);
  94348. break;
  94349. }
  94350. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT: {
  94351. data = new Uint16Array(dataLength);
  94352. break;
  94353. }
  94354. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT: {
  94355. data = new Float32Array(dataLength);
  94356. break;
  94357. }
  94358. }
  94359. for (var i = imageData.length; i < mipmapsCount; i++) {
  94360. for (var face = 0; face < 6; face++) {
  94361. engine._uploadArrayBufferViewToTexture(texture, data, face, i);
  94362. }
  94363. }
  94364. }
  94365. // Once all done, finishes the cleanup and return
  94366. return Promise.all(promises).then(function () {
  94367. // Release temp RTT.
  94368. if (cubeRtt) {
  94369. engine._releaseFramebufferObjects(cubeRtt);
  94370. cubeRtt._swapAndDie(texture);
  94371. }
  94372. // Release temp Post Process.
  94373. if (rgbdPostProcess) {
  94374. rgbdPostProcess.dispose();
  94375. }
  94376. // Flag internal texture as ready in case they are in use.
  94377. if (generateNonLODTextures) {
  94378. if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {
  94379. texture._lodTextureHigh._texture.isReady = true;
  94380. }
  94381. if (texture._lodTextureMid && texture._lodTextureMid._texture) {
  94382. texture._lodTextureMid._texture.isReady = true;
  94383. }
  94384. if (texture._lodTextureLow && texture._lodTextureLow._texture) {
  94385. texture._lodTextureLow._texture.isReady = true;
  94386. }
  94387. }
  94388. });
  94389. };
  94390. /**
  94391. * Uploads spherical polynomials information to the texture.
  94392. * @param texture defines the texture we are trying to upload the information to
  94393. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  94394. */
  94395. EnvironmentTextureTools.UploadEnvSpherical = function (texture, info) {
  94396. if (info.version !== 1) {
  94397. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn('Unsupported babylon environment map version "' + info.version + '"');
  94398. }
  94399. var irradianceInfo = info.irradiance;
  94400. if (!irradianceInfo) {
  94401. return;
  94402. }
  94403. var sp = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["SphericalPolynomial"]();
  94404. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.x, 0, sp.x);
  94405. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.y, 0, sp.y);
  94406. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.z, 0, sp.z);
  94407. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xx, 0, sp.xx);
  94408. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yy, 0, sp.yy);
  94409. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zz, 0, sp.zz);
  94410. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yz, 0, sp.yz);
  94411. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zx, 0, sp.zx);
  94412. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xy, 0, sp.xy);
  94413. texture._sphericalPolynomial = sp;
  94414. };
  94415. /** @hidden */
  94416. EnvironmentTextureTools._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  94417. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  94418. internalTexture._bufferViewArrayArray = data;
  94419. internalTexture._lodGenerationScale = lodScale;
  94420. internalTexture._lodGenerationOffset = lodOffset;
  94421. internalTexture._sphericalPolynomial = sphericalPolynomial;
  94422. return EnvironmentTextureTools.UploadLevelsAsync(internalTexture, data).then(function () {
  94423. internalTexture.isReady = true;
  94424. });
  94425. };
  94426. /**
  94427. * Magic number identifying the env file.
  94428. */
  94429. EnvironmentTextureTools._MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];
  94430. return EnvironmentTextureTools;
  94431. }());
  94432. // References the dependencies.
  94433. _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"]._UpdateRGBDAsync = EnvironmentTextureTools._UpdateRGBDAsync;
  94434. /***/ }),
  94435. /***/ "./Misc/filesInput.ts":
  94436. /*!****************************!*\
  94437. !*** ./Misc/filesInput.ts ***!
  94438. \****************************/
  94439. /*! exports provided: FilesInput */
  94440. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94441. "use strict";
  94442. __webpack_require__.r(__webpack_exports__);
  94443. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return FilesInput; });
  94444. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  94445. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  94446. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  94447. /**
  94448. * Class used to help managing file picking and drag'n'drop
  94449. */
  94450. var FilesInput = /** @class */ (function () {
  94451. /**
  94452. * Creates a new FilesInput
  94453. * @param engine defines the rendering engine
  94454. * @param scene defines the hosting scene
  94455. * @param sceneLoadedCallback callback called when scene is loaded
  94456. * @param progressCallback callback called to track progress
  94457. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  94458. * @param textureLoadingCallback callback called when a texture is loading
  94459. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  94460. * @param onReloadCallback callback called when a reload is requested
  94461. * @param errorCallback callback call if an error occurs
  94462. */
  94463. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  94464. /**
  94465. * Callback called when a file is processed
  94466. */
  94467. this.onProcessFileCallback = function () { return true; };
  94468. this._engine = engine;
  94469. this._currentScene = scene;
  94470. this._sceneLoadedCallback = sceneLoadedCallback;
  94471. this._progressCallback = progressCallback;
  94472. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  94473. this._textureLoadingCallback = textureLoadingCallback;
  94474. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  94475. this._onReloadCallback = onReloadCallback;
  94476. this._errorCallback = errorCallback;
  94477. }
  94478. Object.defineProperty(FilesInput, "FilesToLoad", {
  94479. /**
  94480. * List of files ready to be loaded
  94481. */
  94482. get: function () {
  94483. return _filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad;
  94484. },
  94485. enumerable: true,
  94486. configurable: true
  94487. });
  94488. /**
  94489. * Calls this function to listen to drag'n'drop events on a specific DOM element
  94490. * @param elementToMonitor defines the DOM element to track
  94491. */
  94492. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  94493. var _this = this;
  94494. if (elementToMonitor) {
  94495. this._elementToMonitor = elementToMonitor;
  94496. this._dragEnterHandler = function (e) { _this.drag(e); };
  94497. this._dragOverHandler = function (e) { _this.drag(e); };
  94498. this._dropHandler = function (e) { _this.drop(e); };
  94499. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  94500. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  94501. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  94502. }
  94503. };
  94504. /**
  94505. * Release all associated resources
  94506. */
  94507. FilesInput.prototype.dispose = function () {
  94508. if (!this._elementToMonitor) {
  94509. return;
  94510. }
  94511. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  94512. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  94513. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  94514. };
  94515. FilesInput.prototype.renderFunction = function () {
  94516. if (this._additionalRenderLoopLogicCallback) {
  94517. this._additionalRenderLoopLogicCallback();
  94518. }
  94519. if (this._currentScene) {
  94520. if (this._textureLoadingCallback) {
  94521. var remaining = this._currentScene.getWaitingItemsCount();
  94522. if (remaining > 0) {
  94523. this._textureLoadingCallback(remaining);
  94524. }
  94525. }
  94526. this._currentScene.render();
  94527. }
  94528. };
  94529. FilesInput.prototype.drag = function (e) {
  94530. e.stopPropagation();
  94531. e.preventDefault();
  94532. };
  94533. FilesInput.prototype.drop = function (eventDrop) {
  94534. eventDrop.stopPropagation();
  94535. eventDrop.preventDefault();
  94536. this.loadFiles(eventDrop);
  94537. };
  94538. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  94539. var _this = this;
  94540. var reader = folder.createReader();
  94541. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  94542. reader.readEntries(function (entries) {
  94543. remaining.count += entries.length;
  94544. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  94545. var entry = entries_1[_i];
  94546. if (entry.isFile) {
  94547. entry.file(function (file) {
  94548. file.correctName = relativePath + file.name;
  94549. files.push(file);
  94550. if (--remaining.count === 0) {
  94551. callback();
  94552. }
  94553. });
  94554. }
  94555. else if (entry.isDirectory) {
  94556. _this._traverseFolder(entry, files, remaining, callback);
  94557. }
  94558. }
  94559. if (--remaining.count) {
  94560. callback();
  94561. }
  94562. });
  94563. };
  94564. FilesInput.prototype._processFiles = function (files) {
  94565. for (var i = 0; i < files.length; i++) {
  94566. var name = files[i].correctName.toLowerCase();
  94567. var extension = name.split('.').pop();
  94568. if (!this.onProcessFileCallback(files[i], name, extension)) {
  94569. continue;
  94570. }
  94571. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  94572. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  94573. this._sceneFileToLoad = files[i];
  94574. }
  94575. FilesInput.FilesToLoad[name] = files[i];
  94576. }
  94577. };
  94578. /**
  94579. * Load files from a drop event
  94580. * @param event defines the drop event to use as source
  94581. */
  94582. FilesInput.prototype.loadFiles = function (event) {
  94583. var _this = this;
  94584. // Handling data transfer via drag'n'drop
  94585. if (event && event.dataTransfer && event.dataTransfer.files) {
  94586. this._filesToLoad = event.dataTransfer.files;
  94587. }
  94588. // Handling files from input files
  94589. if (event && event.target && event.target.files) {
  94590. this._filesToLoad = event.target.files;
  94591. }
  94592. if (!this._filesToLoad || this._filesToLoad.length === 0) {
  94593. return;
  94594. }
  94595. if (this._startingProcessingFilesCallback) {
  94596. this._startingProcessingFilesCallback(this._filesToLoad);
  94597. }
  94598. if (this._filesToLoad && this._filesToLoad.length > 0) {
  94599. var files_1 = new Array();
  94600. var folders = [];
  94601. var items = event.dataTransfer ? event.dataTransfer.items : null;
  94602. for (var i = 0; i < this._filesToLoad.length; i++) {
  94603. var fileToLoad = this._filesToLoad[i];
  94604. var name_1 = fileToLoad.name.toLowerCase();
  94605. var entry = void 0;
  94606. fileToLoad.correctName = name_1;
  94607. if (items) {
  94608. var item = items[i];
  94609. if (item.getAsEntry) {
  94610. entry = item.getAsEntry();
  94611. }
  94612. else if (item.webkitGetAsEntry) {
  94613. entry = item.webkitGetAsEntry();
  94614. }
  94615. }
  94616. if (!entry) {
  94617. files_1.push(fileToLoad);
  94618. }
  94619. else {
  94620. if (entry.isDirectory) {
  94621. folders.push(entry);
  94622. }
  94623. else {
  94624. files_1.push(fileToLoad);
  94625. }
  94626. }
  94627. }
  94628. if (folders.length === 0) {
  94629. this._processFiles(files_1);
  94630. this._processReload();
  94631. }
  94632. else {
  94633. var remaining = { count: folders.length };
  94634. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  94635. var folder = folders_1[_i];
  94636. this._traverseFolder(folder, files_1, remaining, function () {
  94637. _this._processFiles(files_1);
  94638. if (remaining.count === 0) {
  94639. _this._processReload();
  94640. }
  94641. });
  94642. }
  94643. }
  94644. }
  94645. };
  94646. FilesInput.prototype._processReload = function () {
  94647. if (this._onReloadCallback) {
  94648. this._onReloadCallback(this._sceneFileToLoad);
  94649. }
  94650. else {
  94651. this.reload();
  94652. }
  94653. };
  94654. /**
  94655. * Reload the current scene from the loaded files
  94656. */
  94657. FilesInput.prototype.reload = function () {
  94658. var _this = this;
  94659. // If a scene file has been provided
  94660. if (this._sceneFileToLoad) {
  94661. if (this._currentScene) {
  94662. if (_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].errorsCount > 0) {
  94663. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].ClearLogCache();
  94664. }
  94665. this._engine.stopRenderLoop();
  94666. }
  94667. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
  94668. if (_this._progressCallback) {
  94669. _this._progressCallback(progress);
  94670. }
  94671. }).then(function (scene) {
  94672. if (_this._currentScene) {
  94673. _this._currentScene.dispose();
  94674. }
  94675. _this._currentScene = scene;
  94676. if (_this._sceneLoadedCallback) {
  94677. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  94678. }
  94679. // Wait for textures and shaders to be ready
  94680. _this._currentScene.executeWhenReady(function () {
  94681. _this._engine.runRenderLoop(function () {
  94682. _this.renderFunction();
  94683. });
  94684. });
  94685. }).catch(function (error) {
  94686. if (_this._errorCallback) {
  94687. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
  94688. }
  94689. });
  94690. }
  94691. else {
  94692. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Please provide a valid .babylon file.");
  94693. }
  94694. };
  94695. return FilesInput;
  94696. }());
  94697. /***/ }),
  94698. /***/ "./Misc/filesInputStore.ts":
  94699. /*!*********************************!*\
  94700. !*** ./Misc/filesInputStore.ts ***!
  94701. \*********************************/
  94702. /*! exports provided: FilesInputStore */
  94703. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94704. "use strict";
  94705. __webpack_require__.r(__webpack_exports__);
  94706. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return FilesInputStore; });
  94707. /**
  94708. * Class used to help managing file picking and drag'n'drop
  94709. * File Storage
  94710. */
  94711. var FilesInputStore = /** @class */ (function () {
  94712. function FilesInputStore() {
  94713. }
  94714. /**
  94715. * List of files ready to be loaded
  94716. */
  94717. FilesInputStore.FilesToLoad = {};
  94718. return FilesInputStore;
  94719. }());
  94720. /***/ }),
  94721. /***/ "./Misc/index.ts":
  94722. /*!***********************!*\
  94723. !*** ./Misc/index.ts ***!
  94724. \***********************/
  94725. /*! 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 */
  94726. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94727. "use strict";
  94728. __webpack_require__.r(__webpack_exports__);
  94729. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  94730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  94731. /* harmony import */ var _assetsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetsManager */ "./Misc/assetsManager.ts");
  94732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetTaskState"]; });
  94733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AbstractAssetTask"]; });
  94734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsProgressEvent"]; });
  94735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["MeshAssetTask"]; });
  94736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextFileAssetTask"]; });
  94737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["BinaryFileAssetTask"]; });
  94738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["ImageAssetTask"]; });
  94739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextureAssetTask"]; });
  94740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["CubeTextureAssetTask"]; });
  94741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["HDRCubeTextureAssetTask"]; });
  94742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsManager"]; });
  94743. /* harmony import */ var _dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dds */ "./Misc/dds.ts");
  94744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"]; });
  94745. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  94746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["expandToProperty"]; });
  94747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"]; });
  94748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsTexture"]; });
  94749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor3"]; });
  94750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsFresnelParameters"]; });
  94751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector2"]; });
  94752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector3"]; });
  94753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMeshReference"]; });
  94754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColorCurves"]; });
  94755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor4"]; });
  94756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsImageProcessingConfiguration"]; });
  94757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsQuaternion"]; });
  94758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsCameraReference"]; });
  94759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]; });
  94760. /* harmony import */ var _deferred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deferred */ "./Misc/deferred.ts");
  94761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _deferred__WEBPACK_IMPORTED_MODULE_4__["Deferred"]; });
  94762. /* harmony import */ var _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  94763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__["EnvironmentTextureTools"]; });
  94764. /* harmony import */ var _filesInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./filesInput */ "./Misc/filesInput.ts");
  94765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _filesInput__WEBPACK_IMPORTED_MODULE_6__["FilesInput"]; });
  94766. /* harmony import */ var _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./HighDynamicRange/index */ "./Misc/HighDynamicRange/index.ts");
  94767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"]; });
  94768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["HDRTools"]; });
  94769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["PanoramaToCubeMapTools"]; });
  94770. /* harmony import */ var _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  94771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__["KhronosTextureContainer"]; });
  94772. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  94773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["EventState"]; });
  94774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observer"]; });
  94775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["MultiObserver"]; });
  94776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observable"]; });
  94777. /* harmony import */ var _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./performanceMonitor */ "./Misc/performanceMonitor.ts");
  94778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["PerformanceMonitor"]; });
  94779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["RollingAverage"]; });
  94780. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  94781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _promise__WEBPACK_IMPORTED_MODULE_11__["PromisePolyfill"]; });
  94782. /* harmony import */ var _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./sceneOptimizer */ "./Misc/sceneOptimizer.ts");
  94783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimization"]; });
  94784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["TextureOptimization"]; });
  94785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["HardwareScalingOptimization"]; });
  94786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ShadowsOptimization"]; });
  94787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["PostProcessesOptimization"]; });
  94788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["LensFlaresOptimization"]; });
  94789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["CustomOptimization"]; });
  94790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ParticlesOptimization"]; });
  94791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["RenderTargetsOptimization"]; });
  94792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["MergeMeshesOptimization"]; });
  94793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizerOptions"]; });
  94794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizer"]; });
  94795. /* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
  94796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__["SceneSerializer"]; });
  94797. /* harmony import */ var _smartArray__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./smartArray */ "./Misc/smartArray.ts");
  94798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArray"]; });
  94799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArrayNoDuplicate"]; });
  94800. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  94801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _stringDictionary__WEBPACK_IMPORTED_MODULE_15__["StringDictionary"]; });
  94802. /* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./tags */ "./Misc/tags.ts");
  94803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _tags__WEBPACK_IMPORTED_MODULE_16__["Tags"]; });
  94804. /* harmony import */ var _textureTools__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./textureTools */ "./Misc/textureTools.ts");
  94805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _textureTools__WEBPACK_IMPORTED_MODULE_17__["TextureTools"]; });
  94806. /* harmony import */ var _tga__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./tga */ "./Misc/tga.ts");
  94807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _tga__WEBPACK_IMPORTED_MODULE_18__["TGATools"]; });
  94808. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  94809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["ColorGradient"]; });
  94810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Color3Gradient"]; });
  94811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["FactorGradient"]; });
  94812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["LoadFileError"]; });
  94813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["RetryStrategy"]; });
  94814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Tools"]; });
  94815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["PerfCounter"]; });
  94816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["className"]; });
  94817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["AsyncLoop"]; });
  94818. /* harmony import */ var _videoRecorder__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./videoRecorder */ "./Misc/videoRecorder.ts");
  94819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _videoRecorder__WEBPACK_IMPORTED_MODULE_20__["VideoRecorder"]; });
  94820. /* harmony import */ var _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./virtualJoystick */ "./Misc/virtualJoystick.ts");
  94821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["JoystickAxis"]; });
  94822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["VirtualJoystick"]; });
  94823. /* harmony import */ var _workerPool__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./workerPool */ "./Misc/workerPool.ts");
  94824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _workerPool__WEBPACK_IMPORTED_MODULE_22__["WorkerPool"]; });
  94825. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  94826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _logger__WEBPACK_IMPORTED_MODULE_23__["Logger"]; });
  94827. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  94828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _typeStore__WEBPACK_IMPORTED_MODULE_24__["_TypeStore"]; });
  94829. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  94830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _filesInputStore__WEBPACK_IMPORTED_MODULE_25__["FilesInputStore"]; });
  94831. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  94832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _deepCopier__WEBPACK_IMPORTED_MODULE_26__["DeepCopier"]; });
  94833. /* harmony import */ var _pivotTools__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./pivotTools */ "./Misc/pivotTools.ts");
  94834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _pivotTools__WEBPACK_IMPORTED_MODULE_27__["PivotTools"]; });
  94835. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  94836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _precisionDate__WEBPACK_IMPORTED_MODULE_28__["PrecisionDate"]; });
  94837. /* harmony import */ var _screenshotTools__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./screenshotTools */ "./Misc/screenshotTools.ts");
  94838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _screenshotTools__WEBPACK_IMPORTED_MODULE_29__["ScreenshotTools"]; });
  94839. /* empty/unused harmony star reexport */
  94840. /***/ }),
  94841. /***/ "./Misc/khronosTextureContainer.ts":
  94842. /*!*****************************************!*\
  94843. !*** ./Misc/khronosTextureContainer.ts ***!
  94844. \*****************************************/
  94845. /*! exports provided: KhronosTextureContainer */
  94846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94847. "use strict";
  94848. __webpack_require__.r(__webpack_exports__);
  94849. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return KhronosTextureContainer; });
  94850. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  94851. /**
  94852. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  94853. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  94854. */
  94855. var KhronosTextureContainer = /** @class */ (function () {
  94856. /**
  94857. * Creates a new KhronosTextureContainer
  94858. * @param arrayBuffer contents of the KTX container file
  94859. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  94860. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  94861. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  94862. */
  94863. function KhronosTextureContainer(
  94864. /** contents of the KTX container file */
  94865. arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) {
  94866. this.arrayBuffer = arrayBuffer;
  94867. /**
  94868. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  94869. */
  94870. this.isInvalid = false;
  94871. // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
  94872. // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n'
  94873. // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
  94874. var identifier = new Uint8Array(this.arrayBuffer, 0, 12);
  94875. if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
  94876. identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
  94877. this.isInvalid = true;
  94878. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture missing KTX identifier");
  94879. return;
  94880. }
  94881. // load the reset of the header in native 32 bit uint
  94882. var dataSize = Uint32Array.BYTES_PER_ELEMENT;
  94883. var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize);
  94884. var endianness = headerDataView.getUint32(0, true);
  94885. var littleEndian = endianness === 0x04030201;
  94886. this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
  94887. this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
  94888. this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
  94889. this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
  94890. this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
  94891. this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
  94892. this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
  94893. this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
  94894. this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
  94895. this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
  94896. this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
  94897. this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
  94898. // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.
  94899. if (this.glType !== 0) {
  94900. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only compressed formats currently supported");
  94901. return;
  94902. }
  94903. else {
  94904. // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
  94905. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  94906. }
  94907. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  94908. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only 2D textures currently supported");
  94909. return;
  94910. }
  94911. if (this.numberOfArrayElements !== 0) {
  94912. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture arrays not currently supported");
  94913. return;
  94914. }
  94915. if (this.numberOfFaces !== facesExpected) {
  94916. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
  94917. return;
  94918. }
  94919. // we now have a completely validated file, so could use existence of loadType as success
  94920. // would need to make this more elaborate & adjust checks above to support more than one load type
  94921. this.loadType = KhronosTextureContainer.COMPRESSED_2D;
  94922. }
  94923. /**
  94924. * Uploads KTX content to a Babylon Texture.
  94925. * It is assumed that the texture has already been created & is currently bound
  94926. * @hidden
  94927. */
  94928. KhronosTextureContainer.prototype.uploadLevels = function (texture, loadMipmaps) {
  94929. switch (this.loadType) {
  94930. case KhronosTextureContainer.COMPRESSED_2D:
  94931. this._upload2DCompressedLevels(texture, loadMipmaps);
  94932. break;
  94933. case KhronosTextureContainer.TEX_2D:
  94934. case KhronosTextureContainer.COMPRESSED_3D:
  94935. case KhronosTextureContainer.TEX_3D:
  94936. }
  94937. };
  94938. KhronosTextureContainer.prototype._upload2DCompressedLevels = function (texture, loadMipmaps) {
  94939. // initialize width & height for level 1
  94940. var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;
  94941. var width = this.pixelWidth;
  94942. var height = this.pixelHeight;
  94943. var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
  94944. for (var level = 0; level < mipmapCount; level++) {
  94945. var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
  94946. dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.
  94947. for (var face = 0; face < this.numberOfFaces; face++) {
  94948. var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize);
  94949. var engine = texture.getEngine();
  94950. engine._uploadCompressedDataToTextureDirectly(texture, this.glInternalFormat, width, height, byteArray, face, level);
  94951. dataOffset += imageSize; // add size of the image for the next face/mipmap
  94952. dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
  94953. }
  94954. width = Math.max(1.0, width * 0.5);
  94955. height = Math.max(1.0, height * 0.5);
  94956. }
  94957. };
  94958. KhronosTextureContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs)
  94959. // load types
  94960. KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
  94961. KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
  94962. KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D()
  94963. KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D()
  94964. return KhronosTextureContainer;
  94965. }());
  94966. /***/ }),
  94967. /***/ "./Misc/logger.ts":
  94968. /*!************************!*\
  94969. !*** ./Misc/logger.ts ***!
  94970. \************************/
  94971. /*! exports provided: Logger */
  94972. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94973. "use strict";
  94974. __webpack_require__.r(__webpack_exports__);
  94975. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return Logger; });
  94976. /**
  94977. * Logger used througouht the application to allow configuration of
  94978. * the log level required for the messages.
  94979. */
  94980. var Logger = /** @class */ (function () {
  94981. function Logger() {
  94982. }
  94983. Logger._AddLogEntry = function (entry) {
  94984. Logger._LogCache = entry + Logger._LogCache;
  94985. if (Logger.OnNewCacheEntry) {
  94986. Logger.OnNewCacheEntry(entry);
  94987. }
  94988. };
  94989. Logger._FormatMessage = function (message) {
  94990. var padStr = function (i) { return (i < 10) ? "0" + i : "" + i; };
  94991. var date = new Date();
  94992. return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
  94993. };
  94994. Logger._LogDisabled = function (message) {
  94995. // nothing to do
  94996. };
  94997. Logger._LogEnabled = function (message) {
  94998. var formattedMessage = Logger._FormatMessage(message);
  94999. console.log("BJS - " + formattedMessage);
  95000. var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
  95001. Logger._AddLogEntry(entry);
  95002. };
  95003. Logger._WarnDisabled = function (message) {
  95004. // nothing to do
  95005. };
  95006. Logger._WarnEnabled = function (message) {
  95007. var formattedMessage = Logger._FormatMessage(message);
  95008. console.warn("BJS - " + formattedMessage);
  95009. var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
  95010. Logger._AddLogEntry(entry);
  95011. };
  95012. Logger._ErrorDisabled = function (message) {
  95013. // nothing to do
  95014. };
  95015. Logger._ErrorEnabled = function (message) {
  95016. Logger.errorsCount++;
  95017. var formattedMessage = Logger._FormatMessage(message);
  95018. console.error("BJS - " + formattedMessage);
  95019. var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
  95020. Logger._AddLogEntry(entry);
  95021. };
  95022. Object.defineProperty(Logger, "LogCache", {
  95023. /**
  95024. * Gets current log cache (list of logs)
  95025. */
  95026. get: function () {
  95027. return Logger._LogCache;
  95028. },
  95029. enumerable: true,
  95030. configurable: true
  95031. });
  95032. /**
  95033. * Clears the log cache
  95034. */
  95035. Logger.ClearLogCache = function () {
  95036. Logger._LogCache = "";
  95037. Logger.errorsCount = 0;
  95038. };
  95039. Object.defineProperty(Logger, "LogLevels", {
  95040. /**
  95041. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  95042. */
  95043. set: function (level) {
  95044. if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
  95045. Logger.Log = Logger._LogEnabled;
  95046. }
  95047. else {
  95048. Logger.Log = Logger._LogDisabled;
  95049. }
  95050. if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
  95051. Logger.Warn = Logger._WarnEnabled;
  95052. }
  95053. else {
  95054. Logger.Warn = Logger._WarnDisabled;
  95055. }
  95056. if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
  95057. Logger.Error = Logger._ErrorEnabled;
  95058. }
  95059. else {
  95060. Logger.Error = Logger._ErrorDisabled;
  95061. }
  95062. },
  95063. enumerable: true,
  95064. configurable: true
  95065. });
  95066. /**
  95067. * No log
  95068. */
  95069. Logger.NoneLogLevel = 0;
  95070. /**
  95071. * Only message logs
  95072. */
  95073. Logger.MessageLogLevel = 1;
  95074. /**
  95075. * Only warning logs
  95076. */
  95077. Logger.WarningLogLevel = 2;
  95078. /**
  95079. * Only error logs
  95080. */
  95081. Logger.ErrorLogLevel = 4;
  95082. /**
  95083. * All logs
  95084. */
  95085. Logger.AllLogLevel = 7;
  95086. Logger._LogCache = "";
  95087. /**
  95088. * Gets a value indicating the number of loading errors
  95089. * @ignorenaming
  95090. */
  95091. Logger.errorsCount = 0;
  95092. /**
  95093. * Log a message to the console
  95094. */
  95095. Logger.Log = Logger._LogEnabled;
  95096. /**
  95097. * Write a warning message to the console
  95098. */
  95099. Logger.Warn = Logger._WarnEnabled;
  95100. /**
  95101. * Write an error message to the console
  95102. */
  95103. Logger.Error = Logger._ErrorEnabled;
  95104. return Logger;
  95105. }());
  95106. /***/ }),
  95107. /***/ "./Misc/observable.ts":
  95108. /*!****************************!*\
  95109. !*** ./Misc/observable.ts ***!
  95110. \****************************/
  95111. /*! exports provided: EventState, Observer, MultiObserver, Observable */
  95112. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95113. "use strict";
  95114. __webpack_require__.r(__webpack_exports__);
  95115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return EventState; });
  95116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return Observer; });
  95117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return MultiObserver; });
  95118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return Observable; });
  95119. /**
  95120. * A class serves as a medium between the observable and its observers
  95121. */
  95122. var EventState = /** @class */ (function () {
  95123. /**
  95124. * Create a new EventState
  95125. * @param mask defines the mask associated with this state
  95126. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  95127. * @param target defines the original target of the state
  95128. * @param currentTarget defines the current target of the state
  95129. */
  95130. function EventState(mask, skipNextObservers, target, currentTarget) {
  95131. if (skipNextObservers === void 0) { skipNextObservers = false; }
  95132. this.initalize(mask, skipNextObservers, target, currentTarget);
  95133. }
  95134. /**
  95135. * Initialize the current event state
  95136. * @param mask defines the mask associated with this state
  95137. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  95138. * @param target defines the original target of the state
  95139. * @param currentTarget defines the current target of the state
  95140. * @returns the current event state
  95141. */
  95142. EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {
  95143. if (skipNextObservers === void 0) { skipNextObservers = false; }
  95144. this.mask = mask;
  95145. this.skipNextObservers = skipNextObservers;
  95146. this.target = target;
  95147. this.currentTarget = currentTarget;
  95148. return this;
  95149. };
  95150. return EventState;
  95151. }());
  95152. /**
  95153. * Represent an Observer registered to a given Observable object.
  95154. */
  95155. var Observer = /** @class */ (function () {
  95156. /**
  95157. * Creates a new observer
  95158. * @param callback defines the callback to call when the observer is notified
  95159. * @param mask defines the mask of the observer (used to filter notifications)
  95160. * @param scope defines the current scope used to restore the JS context
  95161. */
  95162. function Observer(
  95163. /**
  95164. * Defines the callback to call when the observer is notified
  95165. */
  95166. callback,
  95167. /**
  95168. * Defines the mask of the observer (used to filter notifications)
  95169. */
  95170. mask,
  95171. /**
  95172. * Defines the current scope used to restore the JS context
  95173. */
  95174. scope) {
  95175. if (scope === void 0) { scope = null; }
  95176. this.callback = callback;
  95177. this.mask = mask;
  95178. this.scope = scope;
  95179. /** @hidden */
  95180. this._willBeUnregistered = false;
  95181. /**
  95182. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  95183. */
  95184. this.unregisterOnNextCall = false;
  95185. }
  95186. return Observer;
  95187. }());
  95188. /**
  95189. * Represent a list of observers registered to multiple Observables object.
  95190. */
  95191. var MultiObserver = /** @class */ (function () {
  95192. function MultiObserver() {
  95193. }
  95194. /**
  95195. * Release associated resources
  95196. */
  95197. MultiObserver.prototype.dispose = function () {
  95198. if (this._observers && this._observables) {
  95199. for (var index = 0; index < this._observers.length; index++) {
  95200. this._observables[index].remove(this._observers[index]);
  95201. }
  95202. }
  95203. this._observers = null;
  95204. this._observables = null;
  95205. };
  95206. /**
  95207. * Raise a callback when one of the observable will notify
  95208. * @param observables defines a list of observables to watch
  95209. * @param callback defines the callback to call on notification
  95210. * @param mask defines the mask used to filter notifications
  95211. * @param scope defines the current scope used to restore the JS context
  95212. * @returns the new MultiObserver
  95213. */
  95214. MultiObserver.Watch = function (observables, callback, mask, scope) {
  95215. if (mask === void 0) { mask = -1; }
  95216. if (scope === void 0) { scope = null; }
  95217. var result = new MultiObserver();
  95218. result._observers = new Array();
  95219. result._observables = observables;
  95220. for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {
  95221. var observable = observables_1[_i];
  95222. var observer = observable.add(callback, mask, false, scope);
  95223. if (observer) {
  95224. result._observers.push(observer);
  95225. }
  95226. }
  95227. return result;
  95228. };
  95229. return MultiObserver;
  95230. }());
  95231. /**
  95232. * The Observable class is a simple implementation of the Observable pattern.
  95233. *
  95234. * 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.
  95235. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  95236. * 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).
  95237. * 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.
  95238. */
  95239. var Observable = /** @class */ (function () {
  95240. /**
  95241. * Creates a new observable
  95242. * @param onObserverAdded defines a callback to call when a new observer is added
  95243. */
  95244. function Observable(onObserverAdded) {
  95245. this._observers = new Array();
  95246. this._eventState = new EventState(0);
  95247. if (onObserverAdded) {
  95248. this._onObserverAdded = onObserverAdded;
  95249. }
  95250. }
  95251. /**
  95252. * Create a new Observer with the specified callback
  95253. * @param callback the callback that will be executed for that Observer
  95254. * @param mask the mask used to filter observers
  95255. * @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.
  95256. * @param scope optional scope for the callback to be called from
  95257. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  95258. * @returns the new observer created for the callback
  95259. */
  95260. Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {
  95261. if (mask === void 0) { mask = -1; }
  95262. if (insertFirst === void 0) { insertFirst = false; }
  95263. if (scope === void 0) { scope = null; }
  95264. if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }
  95265. if (!callback) {
  95266. return null;
  95267. }
  95268. var observer = new Observer(callback, mask, scope);
  95269. observer.unregisterOnNextCall = unregisterOnFirstCall;
  95270. if (insertFirst) {
  95271. this._observers.unshift(observer);
  95272. }
  95273. else {
  95274. this._observers.push(observer);
  95275. }
  95276. if (this._onObserverAdded) {
  95277. this._onObserverAdded(observer);
  95278. }
  95279. return observer;
  95280. };
  95281. /**
  95282. * Create a new Observer with the specified callback and unregisters after the next notification
  95283. * @param callback the callback that will be executed for that Observer
  95284. * @returns the new observer created for the callback
  95285. */
  95286. Observable.prototype.addOnce = function (callback) {
  95287. return this.add(callback, undefined, undefined, undefined, true);
  95288. };
  95289. /**
  95290. * Remove an Observer from the Observable object
  95291. * @param observer the instance of the Observer to remove
  95292. * @returns false if it doesn't belong to this Observable
  95293. */
  95294. Observable.prototype.remove = function (observer) {
  95295. if (!observer) {
  95296. return false;
  95297. }
  95298. var index = this._observers.indexOf(observer);
  95299. if (index !== -1) {
  95300. this._deferUnregister(observer);
  95301. return true;
  95302. }
  95303. return false;
  95304. };
  95305. /**
  95306. * Remove a callback from the Observable object
  95307. * @param callback the callback to remove
  95308. * @param scope optional scope. If used only the callbacks with this scope will be removed
  95309. * @returns false if it doesn't belong to this Observable
  95310. */
  95311. Observable.prototype.removeCallback = function (callback, scope) {
  95312. for (var index = 0; index < this._observers.length; index++) {
  95313. if (this._observers[index].callback === callback && (!scope || scope === this._observers[index].scope)) {
  95314. this._deferUnregister(this._observers[index]);
  95315. return true;
  95316. }
  95317. }
  95318. return false;
  95319. };
  95320. Observable.prototype._deferUnregister = function (observer) {
  95321. var _this = this;
  95322. observer.unregisterOnNextCall = false;
  95323. observer._willBeUnregistered = true;
  95324. setTimeout(function () {
  95325. _this._remove(observer);
  95326. }, 0);
  95327. };
  95328. // This should only be called when not iterating over _observers to avoid callback skipping.
  95329. // Removes an observer from the _observer Array.
  95330. Observable.prototype._remove = function (observer) {
  95331. if (!observer) {
  95332. return false;
  95333. }
  95334. var index = this._observers.indexOf(observer);
  95335. if (index !== -1) {
  95336. this._observers.splice(index, 1);
  95337. return true;
  95338. }
  95339. return false;
  95340. };
  95341. /**
  95342. * Notify all Observers by calling their respective callback with the given data
  95343. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  95344. * @param eventData defines the data to send to all observers
  95345. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  95346. * @param target defines the original target of the state
  95347. * @param currentTarget defines the current target of the state
  95348. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  95349. */
  95350. Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {
  95351. if (mask === void 0) { mask = -1; }
  95352. if (!this._observers.length) {
  95353. return true;
  95354. }
  95355. var state = this._eventState;
  95356. state.mask = mask;
  95357. state.target = target;
  95358. state.currentTarget = currentTarget;
  95359. state.skipNextObservers = false;
  95360. state.lastReturnValue = eventData;
  95361. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  95362. var obs = _a[_i];
  95363. if (obs._willBeUnregistered) {
  95364. continue;
  95365. }
  95366. if (obs.mask & mask) {
  95367. if (obs.scope) {
  95368. state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);
  95369. }
  95370. else {
  95371. state.lastReturnValue = obs.callback(eventData, state);
  95372. }
  95373. if (obs.unregisterOnNextCall) {
  95374. this._deferUnregister(obs);
  95375. }
  95376. }
  95377. if (state.skipNextObservers) {
  95378. return false;
  95379. }
  95380. }
  95381. return true;
  95382. };
  95383. /**
  95384. * Calling this will execute each callback, expecting it to be a promise or return a value.
  95385. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  95386. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  95387. * and it is crucial that all callbacks will be executed.
  95388. * The order of the callbacks is kept, callbacks are not executed parallel.
  95389. *
  95390. * @param eventData The data to be sent to each callback
  95391. * @param mask is used to filter observers defaults to -1
  95392. * @param target defines the callback target (see EventState)
  95393. * @param currentTarget defines he current object in the bubbling phase
  95394. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  95395. */
  95396. Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {
  95397. var _this = this;
  95398. if (mask === void 0) { mask = -1; }
  95399. // create an empty promise
  95400. var p = Promise.resolve(eventData);
  95401. // no observers? return this promise.
  95402. if (!this._observers.length) {
  95403. return p;
  95404. }
  95405. var state = this._eventState;
  95406. state.mask = mask;
  95407. state.target = target;
  95408. state.currentTarget = currentTarget;
  95409. state.skipNextObservers = false;
  95410. // execute one callback after another (not using Promise.all, the order is important)
  95411. this._observers.forEach(function (obs) {
  95412. if (state.skipNextObservers) {
  95413. return;
  95414. }
  95415. if (obs._willBeUnregistered) {
  95416. return;
  95417. }
  95418. if (obs.mask & mask) {
  95419. if (obs.scope) {
  95420. p = p.then(function (lastReturnedValue) {
  95421. state.lastReturnValue = lastReturnedValue;
  95422. return obs.callback.apply(obs.scope, [eventData, state]);
  95423. });
  95424. }
  95425. else {
  95426. p = p.then(function (lastReturnedValue) {
  95427. state.lastReturnValue = lastReturnedValue;
  95428. return obs.callback(eventData, state);
  95429. });
  95430. }
  95431. if (obs.unregisterOnNextCall) {
  95432. _this._deferUnregister(obs);
  95433. }
  95434. }
  95435. });
  95436. // return the eventData
  95437. return p.then(function () { return eventData; });
  95438. };
  95439. /**
  95440. * Notify a specific observer
  95441. * @param observer defines the observer to notify
  95442. * @param eventData defines the data to be sent to each callback
  95443. * @param mask is used to filter observers defaults to -1
  95444. */
  95445. Observable.prototype.notifyObserver = function (observer, eventData, mask) {
  95446. if (mask === void 0) { mask = -1; }
  95447. var state = this._eventState;
  95448. state.mask = mask;
  95449. state.skipNextObservers = false;
  95450. observer.callback(eventData, state);
  95451. };
  95452. /**
  95453. * Gets a boolean indicating if the observable has at least one observer
  95454. * @returns true is the Observable has at least one Observer registered
  95455. */
  95456. Observable.prototype.hasObservers = function () {
  95457. return this._observers.length > 0;
  95458. };
  95459. /**
  95460. * Clear the list of observers
  95461. */
  95462. Observable.prototype.clear = function () {
  95463. this._observers = new Array();
  95464. this._onObserverAdded = null;
  95465. };
  95466. /**
  95467. * Clone the current observable
  95468. * @returns a new observable
  95469. */
  95470. Observable.prototype.clone = function () {
  95471. var result = new Observable();
  95472. result._observers = this._observers.slice(0);
  95473. return result;
  95474. };
  95475. /**
  95476. * Does this observable handles observer registered with a given mask
  95477. * @param mask defines the mask to be tested
  95478. * @return whether or not one observer registered with the given mask is handeled
  95479. **/
  95480. Observable.prototype.hasSpecificMask = function (mask) {
  95481. if (mask === void 0) { mask = -1; }
  95482. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  95483. var obs = _a[_i];
  95484. if (obs.mask & mask || obs.mask === mask) {
  95485. return true;
  95486. }
  95487. }
  95488. return false;
  95489. };
  95490. return Observable;
  95491. }());
  95492. /***/ }),
  95493. /***/ "./Misc/performanceMonitor.ts":
  95494. /*!************************************!*\
  95495. !*** ./Misc/performanceMonitor.ts ***!
  95496. \************************************/
  95497. /*! exports provided: PerformanceMonitor, RollingAverage */
  95498. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95499. "use strict";
  95500. __webpack_require__.r(__webpack_exports__);
  95501. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return PerformanceMonitor; });
  95502. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return RollingAverage; });
  95503. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  95504. /**
  95505. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  95506. */
  95507. var PerformanceMonitor = /** @class */ (function () {
  95508. /**
  95509. * constructor
  95510. * @param frameSampleSize The number of samples required to saturate the sliding window
  95511. */
  95512. function PerformanceMonitor(frameSampleSize) {
  95513. if (frameSampleSize === void 0) { frameSampleSize = 30; }
  95514. this._enabled = true;
  95515. this._rollingFrameTime = new RollingAverage(frameSampleSize);
  95516. }
  95517. /**
  95518. * Samples current frame
  95519. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  95520. */
  95521. PerformanceMonitor.prototype.sampleFrame = function (timeMs) {
  95522. if (timeMs === void 0) { timeMs = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now; }
  95523. if (!this._enabled) {
  95524. return;
  95525. }
  95526. if (this._lastFrameTimeMs != null) {
  95527. var dt = timeMs - this._lastFrameTimeMs;
  95528. this._rollingFrameTime.add(dt);
  95529. }
  95530. this._lastFrameTimeMs = timeMs;
  95531. };
  95532. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTime", {
  95533. /**
  95534. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  95535. */
  95536. get: function () {
  95537. return this._rollingFrameTime.average;
  95538. },
  95539. enumerable: true,
  95540. configurable: true
  95541. });
  95542. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTimeVariance", {
  95543. /**
  95544. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  95545. */
  95546. get: function () {
  95547. return this._rollingFrameTime.variance;
  95548. },
  95549. enumerable: true,
  95550. configurable: true
  95551. });
  95552. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFrameTime", {
  95553. /**
  95554. * Returns the frame time of the most recent frame
  95555. */
  95556. get: function () {
  95557. return this._rollingFrameTime.history(0);
  95558. },
  95559. enumerable: true,
  95560. configurable: true
  95561. });
  95562. Object.defineProperty(PerformanceMonitor.prototype, "averageFPS", {
  95563. /**
  95564. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  95565. */
  95566. get: function () {
  95567. return 1000.0 / this._rollingFrameTime.average;
  95568. },
  95569. enumerable: true,
  95570. configurable: true
  95571. });
  95572. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFPS", {
  95573. /**
  95574. * Returns the average framerate in frames per second using the most recent frame time
  95575. */
  95576. get: function () {
  95577. var history = this._rollingFrameTime.history(0);
  95578. if (history === 0) {
  95579. return 0;
  95580. }
  95581. return 1000.0 / history;
  95582. },
  95583. enumerable: true,
  95584. configurable: true
  95585. });
  95586. Object.defineProperty(PerformanceMonitor.prototype, "isSaturated", {
  95587. /**
  95588. * Returns true if enough samples have been taken to completely fill the sliding window
  95589. */
  95590. get: function () {
  95591. return this._rollingFrameTime.isSaturated();
  95592. },
  95593. enumerable: true,
  95594. configurable: true
  95595. });
  95596. /**
  95597. * Enables contributions to the sliding window sample set
  95598. */
  95599. PerformanceMonitor.prototype.enable = function () {
  95600. this._enabled = true;
  95601. };
  95602. /**
  95603. * Disables contributions to the sliding window sample set
  95604. * Samples will not be interpolated over the disabled period
  95605. */
  95606. PerformanceMonitor.prototype.disable = function () {
  95607. this._enabled = false;
  95608. //clear last sample to avoid interpolating over the disabled period when next enabled
  95609. this._lastFrameTimeMs = null;
  95610. };
  95611. Object.defineProperty(PerformanceMonitor.prototype, "isEnabled", {
  95612. /**
  95613. * Returns true if sampling is enabled
  95614. */
  95615. get: function () {
  95616. return this._enabled;
  95617. },
  95618. enumerable: true,
  95619. configurable: true
  95620. });
  95621. /**
  95622. * Resets performance monitor
  95623. */
  95624. PerformanceMonitor.prototype.reset = function () {
  95625. //clear last sample to avoid interpolating over the disabled period when next enabled
  95626. this._lastFrameTimeMs = null;
  95627. //wipe record
  95628. this._rollingFrameTime.reset();
  95629. };
  95630. return PerformanceMonitor;
  95631. }());
  95632. /**
  95633. * RollingAverage
  95634. *
  95635. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  95636. */
  95637. var RollingAverage = /** @class */ (function () {
  95638. /**
  95639. * constructor
  95640. * @param length The number of samples required to saturate the sliding window
  95641. */
  95642. function RollingAverage(length) {
  95643. this._samples = new Array(length);
  95644. this.reset();
  95645. }
  95646. /**
  95647. * Adds a sample to the sample set
  95648. * @param v The sample value
  95649. */
  95650. RollingAverage.prototype.add = function (v) {
  95651. //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  95652. var delta;
  95653. //we need to check if we've already wrapped round
  95654. if (this.isSaturated()) {
  95655. //remove bottom of stack from mean
  95656. var bottomValue = this._samples[this._pos];
  95657. delta = bottomValue - this.average;
  95658. this.average -= delta / (this._sampleCount - 1);
  95659. this._m2 -= delta * (bottomValue - this.average);
  95660. }
  95661. else {
  95662. this._sampleCount++;
  95663. }
  95664. //add new value to mean
  95665. delta = v - this.average;
  95666. this.average += delta / (this._sampleCount);
  95667. this._m2 += delta * (v - this.average);
  95668. //set the new variance
  95669. this.variance = this._m2 / (this._sampleCount - 1);
  95670. this._samples[this._pos] = v;
  95671. this._pos++;
  95672. this._pos %= this._samples.length; //positive wrap around
  95673. };
  95674. /**
  95675. * Returns previously added values or null if outside of history or outside the sliding window domain
  95676. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  95677. * @return Value previously recorded with add() or null if outside of range
  95678. */
  95679. RollingAverage.prototype.history = function (i) {
  95680. if ((i >= this._sampleCount) || (i >= this._samples.length)) {
  95681. return 0;
  95682. }
  95683. var i0 = this._wrapPosition(this._pos - 1.0);
  95684. return this._samples[this._wrapPosition(i0 - i)];
  95685. };
  95686. /**
  95687. * Returns true if enough samples have been taken to completely fill the sliding window
  95688. * @return true if sample-set saturated
  95689. */
  95690. RollingAverage.prototype.isSaturated = function () {
  95691. return this._sampleCount >= this._samples.length;
  95692. };
  95693. /**
  95694. * Resets the rolling average (equivalent to 0 samples taken so far)
  95695. */
  95696. RollingAverage.prototype.reset = function () {
  95697. this.average = 0;
  95698. this.variance = 0;
  95699. this._sampleCount = 0;
  95700. this._pos = 0;
  95701. this._m2 = 0;
  95702. };
  95703. /**
  95704. * Wraps a value around the sample range boundaries
  95705. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  95706. * @return Wrapped position in sample range
  95707. */
  95708. RollingAverage.prototype._wrapPosition = function (i) {
  95709. var max = this._samples.length;
  95710. return ((i % max) + max) % max;
  95711. };
  95712. return RollingAverage;
  95713. }());
  95714. /***/ }),
  95715. /***/ "./Misc/pivotTools.ts":
  95716. /*!****************************!*\
  95717. !*** ./Misc/pivotTools.ts ***!
  95718. \****************************/
  95719. /*! exports provided: PivotTools */
  95720. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95721. "use strict";
  95722. __webpack_require__.r(__webpack_exports__);
  95723. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return PivotTools; });
  95724. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  95725. /**
  95726. * Class containing a set of static utilities functions for managing Pivots
  95727. * @hidden
  95728. */
  95729. var PivotTools = /** @class */ (function () {
  95730. function PivotTools() {
  95731. }
  95732. /** @hidden */
  95733. PivotTools._RemoveAndStorePivotPoint = function (mesh) {
  95734. if (mesh && PivotTools._PivotCached === 0) {
  95735. // Save old pivot and set pivot to 0,0,0
  95736. mesh.getPivotPointToRef(PivotTools._OldPivotPoint);
  95737. if (!PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0)) {
  95738. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityReadOnly);
  95739. PivotTools._OldPivotPoint.subtractToRef(mesh.getPivotPoint(), PivotTools._PivotTranslation);
  95740. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  95741. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  95742. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  95743. mesh.position.addInPlace(PivotTools._PivotTmpVector);
  95744. }
  95745. }
  95746. PivotTools._PivotCached++;
  95747. };
  95748. /** @hidden */
  95749. PivotTools._RestorePivotPoint = function (mesh) {
  95750. if (mesh && !PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0) && PivotTools._PivotCached === 1) {
  95751. mesh.setPivotPoint(PivotTools._OldPivotPoint);
  95752. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  95753. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  95754. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  95755. mesh.position.subtractInPlace(PivotTools._PivotTmpVector);
  95756. }
  95757. this._PivotCached--;
  95758. };
  95759. // Stores the state of the pivot cache (_oldPivotPoint, _pivotTranslation)
  95760. // store/remove pivot point should only be applied during their outermost calls
  95761. PivotTools._PivotCached = 0;
  95762. PivotTools._OldPivotPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  95763. PivotTools._PivotTranslation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  95764. PivotTools._PivotTmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  95765. return PivotTools;
  95766. }());
  95767. /***/ }),
  95768. /***/ "./Misc/precisionDate.ts":
  95769. /*!*******************************!*\
  95770. !*** ./Misc/precisionDate.ts ***!
  95771. \*******************************/
  95772. /*! exports provided: PrecisionDate */
  95773. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95774. "use strict";
  95775. __webpack_require__.r(__webpack_exports__);
  95776. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return PrecisionDate; });
  95777. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  95778. /**
  95779. * Class containing a set of static utilities functions for precision date
  95780. */
  95781. var PrecisionDate = /** @class */ (function () {
  95782. function PrecisionDate() {
  95783. }
  95784. Object.defineProperty(PrecisionDate, "Now", {
  95785. /**
  95786. * Gets either window.performance.now() if supported or Date.now() else
  95787. */
  95788. get: function () {
  95789. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.performance && window.performance.now) {
  95790. return window.performance.now();
  95791. }
  95792. return Date.now();
  95793. },
  95794. enumerable: true,
  95795. configurable: true
  95796. });
  95797. return PrecisionDate;
  95798. }());
  95799. /***/ }),
  95800. /***/ "./Misc/promise.ts":
  95801. /*!*************************!*\
  95802. !*** ./Misc/promise.ts ***!
  95803. \*************************/
  95804. /*! exports provided: PromisePolyfill */
  95805. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95806. "use strict";
  95807. __webpack_require__.r(__webpack_exports__);
  95808. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return PromisePolyfill; });
  95809. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  95810. var PromiseStates;
  95811. (function (PromiseStates) {
  95812. PromiseStates[PromiseStates["Pending"] = 0] = "Pending";
  95813. PromiseStates[PromiseStates["Fulfilled"] = 1] = "Fulfilled";
  95814. PromiseStates[PromiseStates["Rejected"] = 2] = "Rejected";
  95815. })(PromiseStates || (PromiseStates = {}));
  95816. var FulFillmentAgregator = /** @class */ (function () {
  95817. function FulFillmentAgregator() {
  95818. this.count = 0;
  95819. this.target = 0;
  95820. this.results = [];
  95821. }
  95822. return FulFillmentAgregator;
  95823. }());
  95824. var InternalPromise = /** @class */ (function () {
  95825. function InternalPromise(resolver) {
  95826. var _this = this;
  95827. this._state = PromiseStates.Pending;
  95828. this._children = new Array();
  95829. this._rejectWasConsumed = false;
  95830. if (!resolver) {
  95831. return;
  95832. }
  95833. try {
  95834. resolver(function (value) {
  95835. _this._resolve(value);
  95836. }, function (reason) {
  95837. _this._reject(reason);
  95838. });
  95839. }
  95840. catch (e) {
  95841. this._reject(e);
  95842. }
  95843. }
  95844. Object.defineProperty(InternalPromise.prototype, "_result", {
  95845. get: function () {
  95846. return this._resultValue;
  95847. },
  95848. set: function (value) {
  95849. this._resultValue = value;
  95850. if (this._parent && this._parent._result === undefined) {
  95851. this._parent._result = value;
  95852. }
  95853. },
  95854. enumerable: true,
  95855. configurable: true
  95856. });
  95857. InternalPromise.prototype.catch = function (onRejected) {
  95858. return this.then(undefined, onRejected);
  95859. };
  95860. InternalPromise.prototype.then = function (onFulfilled, onRejected) {
  95861. var _this = this;
  95862. var newPromise = new InternalPromise();
  95863. newPromise._onFulfilled = onFulfilled;
  95864. newPromise._onRejected = onRejected;
  95865. // Composition
  95866. this._children.push(newPromise);
  95867. newPromise._parent = this;
  95868. if (this._state !== PromiseStates.Pending) {
  95869. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  95870. if (_this._state === PromiseStates.Fulfilled || _this._rejectWasConsumed) {
  95871. var returnedValue = newPromise._resolve(_this._result);
  95872. if (returnedValue !== undefined && returnedValue !== null) {
  95873. if (returnedValue._state !== undefined) {
  95874. var returnedPromise = returnedValue;
  95875. newPromise._children.push(returnedPromise);
  95876. returnedPromise._parent = newPromise;
  95877. newPromise = returnedPromise;
  95878. }
  95879. else {
  95880. newPromise._result = returnedValue;
  95881. }
  95882. }
  95883. }
  95884. else {
  95885. newPromise._reject(_this._reason);
  95886. }
  95887. });
  95888. }
  95889. return newPromise;
  95890. };
  95891. InternalPromise.prototype._moveChildren = function (children) {
  95892. var _this = this;
  95893. var _a;
  95894. (_a = this._children).push.apply(_a, children.splice(0, children.length));
  95895. this._children.forEach(function (child) {
  95896. child._parent = _this;
  95897. });
  95898. if (this._state === PromiseStates.Fulfilled) {
  95899. for (var _i = 0, _b = this._children; _i < _b.length; _i++) {
  95900. var child = _b[_i];
  95901. child._resolve(this._result);
  95902. }
  95903. }
  95904. else if (this._state === PromiseStates.Rejected) {
  95905. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  95906. var child = _d[_c];
  95907. child._reject(this._reason);
  95908. }
  95909. }
  95910. };
  95911. InternalPromise.prototype._resolve = function (value) {
  95912. try {
  95913. this._state = PromiseStates.Fulfilled;
  95914. var returnedValue = null;
  95915. if (this._onFulfilled) {
  95916. returnedValue = this._onFulfilled(value);
  95917. }
  95918. if (returnedValue !== undefined && returnedValue !== null) {
  95919. if (returnedValue._state !== undefined) {
  95920. // Transmit children
  95921. var returnedPromise = returnedValue;
  95922. returnedPromise._parent = this;
  95923. returnedPromise._moveChildren(this._children);
  95924. value = returnedPromise._result;
  95925. }
  95926. else {
  95927. value = returnedValue;
  95928. }
  95929. }
  95930. this._result = value;
  95931. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  95932. var child = _a[_i];
  95933. child._resolve(value);
  95934. }
  95935. this._children.length = 0;
  95936. delete this._onFulfilled;
  95937. delete this._onRejected;
  95938. }
  95939. catch (e) {
  95940. this._reject(e, true);
  95941. }
  95942. };
  95943. InternalPromise.prototype._reject = function (reason, onLocalThrow) {
  95944. if (onLocalThrow === void 0) { onLocalThrow = false; }
  95945. this._state = PromiseStates.Rejected;
  95946. this._reason = reason;
  95947. if (this._onRejected && !onLocalThrow) {
  95948. try {
  95949. this._onRejected(reason);
  95950. this._rejectWasConsumed = true;
  95951. }
  95952. catch (e) {
  95953. reason = e;
  95954. }
  95955. }
  95956. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  95957. var child = _a[_i];
  95958. if (this._rejectWasConsumed) {
  95959. child._resolve(null);
  95960. }
  95961. else {
  95962. child._reject(reason);
  95963. }
  95964. }
  95965. this._children.length = 0;
  95966. delete this._onFulfilled;
  95967. delete this._onRejected;
  95968. };
  95969. InternalPromise.resolve = function (value) {
  95970. var newPromise = new InternalPromise();
  95971. newPromise._resolve(value);
  95972. return newPromise;
  95973. };
  95974. InternalPromise._RegisterForFulfillment = function (promise, agregator, index) {
  95975. promise.then(function (value) {
  95976. agregator.results[index] = value;
  95977. agregator.count++;
  95978. if (agregator.count === agregator.target) {
  95979. agregator.rootPromise._resolve(agregator.results);
  95980. }
  95981. return null;
  95982. }, function (reason) {
  95983. if (agregator.rootPromise._state !== PromiseStates.Rejected) {
  95984. agregator.rootPromise._reject(reason);
  95985. }
  95986. });
  95987. };
  95988. InternalPromise.all = function (promises) {
  95989. var newPromise = new InternalPromise();
  95990. var agregator = new FulFillmentAgregator();
  95991. agregator.target = promises.length;
  95992. agregator.rootPromise = newPromise;
  95993. if (promises.length) {
  95994. for (var index = 0; index < promises.length; index++) {
  95995. InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
  95996. }
  95997. }
  95998. else {
  95999. newPromise._resolve([]);
  96000. }
  96001. return newPromise;
  96002. };
  96003. InternalPromise.race = function (promises) {
  96004. var newPromise = new InternalPromise();
  96005. if (promises.length) {
  96006. for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
  96007. var promise = promises_1[_i];
  96008. promise.then(function (value) {
  96009. if (newPromise) {
  96010. newPromise._resolve(value);
  96011. newPromise = null;
  96012. }
  96013. return null;
  96014. }, function (reason) {
  96015. if (newPromise) {
  96016. newPromise._reject(reason);
  96017. newPromise = null;
  96018. }
  96019. });
  96020. }
  96021. }
  96022. return newPromise;
  96023. };
  96024. return InternalPromise;
  96025. }());
  96026. /**
  96027. * Helper class that provides a small promise polyfill
  96028. */
  96029. var PromisePolyfill = /** @class */ (function () {
  96030. function PromisePolyfill() {
  96031. }
  96032. /**
  96033. * Static function used to check if the polyfill is required
  96034. * If this is the case then the function will inject the polyfill to window.Promise
  96035. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  96036. */
  96037. PromisePolyfill.Apply = function (force) {
  96038. if (force === void 0) { force = false; }
  96039. if (force || typeof Promise === 'undefined') {
  96040. var root = window;
  96041. root.Promise = InternalPromise;
  96042. }
  96043. };
  96044. return PromisePolyfill;
  96045. }());
  96046. /***/ }),
  96047. /***/ "./Misc/sceneOptimizer.ts":
  96048. /*!********************************!*\
  96049. !*** ./Misc/sceneOptimizer.ts ***!
  96050. \********************************/
  96051. /*! exports provided: SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer */
  96052. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96053. "use strict";
  96054. __webpack_require__.r(__webpack_exports__);
  96055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return SceneOptimization; });
  96056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return TextureOptimization; });
  96057. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return HardwareScalingOptimization; });
  96058. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return ShadowsOptimization; });
  96059. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return PostProcessesOptimization; });
  96060. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return LensFlaresOptimization; });
  96061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return CustomOptimization; });
  96062. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return ParticlesOptimization; });
  96063. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return RenderTargetsOptimization; });
  96064. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return MergeMeshesOptimization; });
  96065. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return SceneOptimizerOptions; });
  96066. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return SceneOptimizer; });
  96067. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  96068. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  96069. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  96070. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  96071. /**
  96072. * Defines the root class used to create scene optimization to use with SceneOptimizer
  96073. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96074. */
  96075. var SceneOptimization = /** @class */ (function () {
  96076. /**
  96077. * Creates the SceneOptimization object
  96078. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  96079. * @param desc defines the description associated with the optimization
  96080. */
  96081. function SceneOptimization(
  96082. /**
  96083. * Defines the priority of this optimization (0 by default which means first in the list)
  96084. */
  96085. priority) {
  96086. if (priority === void 0) { priority = 0; }
  96087. this.priority = priority;
  96088. }
  96089. /**
  96090. * Gets a string describing the action executed by the current optimization
  96091. * @returns description string
  96092. */
  96093. SceneOptimization.prototype.getDescription = function () {
  96094. return "";
  96095. };
  96096. /**
  96097. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96098. * @param scene defines the current scene where to apply this optimization
  96099. * @param optimizer defines the current optimizer
  96100. * @returns true if everything that can be done was applied
  96101. */
  96102. SceneOptimization.prototype.apply = function (scene, optimizer) {
  96103. return true;
  96104. };
  96105. return SceneOptimization;
  96106. }());
  96107. /**
  96108. * Defines an optimization used to reduce the size of render target textures
  96109. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96110. */
  96111. var TextureOptimization = /** @class */ (function (_super) {
  96112. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureOptimization, _super);
  96113. /**
  96114. * Creates the TextureOptimization object
  96115. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  96116. * @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
  96117. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  96118. */
  96119. function TextureOptimization(
  96120. /**
  96121. * Defines the priority of this optimization (0 by default which means first in the list)
  96122. */
  96123. priority,
  96124. /**
  96125. * 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
  96126. */
  96127. maximumSize,
  96128. /**
  96129. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  96130. */
  96131. step) {
  96132. if (priority === void 0) { priority = 0; }
  96133. if (maximumSize === void 0) { maximumSize = 1024; }
  96134. if (step === void 0) { step = 0.5; }
  96135. var _this = _super.call(this, priority) || this;
  96136. _this.priority = priority;
  96137. _this.maximumSize = maximumSize;
  96138. _this.step = step;
  96139. return _this;
  96140. }
  96141. /**
  96142. * Gets a string describing the action executed by the current optimization
  96143. * @returns description string
  96144. */
  96145. TextureOptimization.prototype.getDescription = function () {
  96146. return "Reducing render target texture size to " + this.maximumSize;
  96147. };
  96148. /**
  96149. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96150. * @param scene defines the current scene where to apply this optimization
  96151. * @param optimizer defines the current optimizer
  96152. * @returns true if everything that can be done was applied
  96153. */
  96154. TextureOptimization.prototype.apply = function (scene, optimizer) {
  96155. var allDone = true;
  96156. for (var index = 0; index < scene.textures.length; index++) {
  96157. var texture = scene.textures[index];
  96158. if (!texture.canRescale || texture.getContext) {
  96159. continue;
  96160. }
  96161. var currentSize = texture.getSize();
  96162. var maxDimension = Math.max(currentSize.width, currentSize.height);
  96163. if (maxDimension > this.maximumSize) {
  96164. texture.scale(this.step);
  96165. allDone = false;
  96166. }
  96167. }
  96168. return allDone;
  96169. };
  96170. return TextureOptimization;
  96171. }(SceneOptimization));
  96172. /**
  96173. * Defines an optimization used to increase or decrease the rendering resolution
  96174. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96175. */
  96176. var HardwareScalingOptimization = /** @class */ (function (_super) {
  96177. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HardwareScalingOptimization, _super);
  96178. /**
  96179. * Creates the HardwareScalingOptimization object
  96180. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  96181. * @param maximumScale defines the maximum scale to use (2 by default)
  96182. * @param step defines the step to use between two passes (0.5 by default)
  96183. */
  96184. function HardwareScalingOptimization(
  96185. /**
  96186. * Defines the priority of this optimization (0 by default which means first in the list)
  96187. */
  96188. priority,
  96189. /**
  96190. * Defines the maximum scale to use (2 by default)
  96191. */
  96192. maximumScale,
  96193. /**
  96194. * Defines the step to use between two passes (0.5 by default)
  96195. */
  96196. step) {
  96197. if (priority === void 0) { priority = 0; }
  96198. if (maximumScale === void 0) { maximumScale = 2; }
  96199. if (step === void 0) { step = 0.25; }
  96200. var _this = _super.call(this, priority) || this;
  96201. _this.priority = priority;
  96202. _this.maximumScale = maximumScale;
  96203. _this.step = step;
  96204. _this._currentScale = -1;
  96205. _this._directionOffset = 1;
  96206. return _this;
  96207. }
  96208. /**
  96209. * Gets a string describing the action executed by the current optimization
  96210. * @return description string
  96211. */
  96212. HardwareScalingOptimization.prototype.getDescription = function () {
  96213. return "Setting hardware scaling level to " + this._currentScale;
  96214. };
  96215. /**
  96216. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96217. * @param scene defines the current scene where to apply this optimization
  96218. * @param optimizer defines the current optimizer
  96219. * @returns true if everything that can be done was applied
  96220. */
  96221. HardwareScalingOptimization.prototype.apply = function (scene, optimizer) {
  96222. if (this._currentScale === -1) {
  96223. this._currentScale = scene.getEngine().getHardwareScalingLevel();
  96224. if (this._currentScale > this.maximumScale) {
  96225. this._directionOffset = -1;
  96226. }
  96227. }
  96228. this._currentScale += this._directionOffset * this.step;
  96229. scene.getEngine().setHardwareScalingLevel(this._currentScale);
  96230. return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
  96231. };
  96232. return HardwareScalingOptimization;
  96233. }(SceneOptimization));
  96234. /**
  96235. * Defines an optimization used to remove shadows
  96236. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96237. */
  96238. var ShadowsOptimization = /** @class */ (function (_super) {
  96239. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowsOptimization, _super);
  96240. function ShadowsOptimization() {
  96241. return _super !== null && _super.apply(this, arguments) || this;
  96242. }
  96243. /**
  96244. * Gets a string describing the action executed by the current optimization
  96245. * @return description string
  96246. */
  96247. ShadowsOptimization.prototype.getDescription = function () {
  96248. return "Turning shadows on/off";
  96249. };
  96250. /**
  96251. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96252. * @param scene defines the current scene where to apply this optimization
  96253. * @param optimizer defines the current optimizer
  96254. * @returns true if everything that can be done was applied
  96255. */
  96256. ShadowsOptimization.prototype.apply = function (scene, optimizer) {
  96257. scene.shadowsEnabled = optimizer.isInImprovementMode;
  96258. return true;
  96259. };
  96260. return ShadowsOptimization;
  96261. }(SceneOptimization));
  96262. /**
  96263. * Defines an optimization used to turn post-processes off
  96264. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96265. */
  96266. var PostProcessesOptimization = /** @class */ (function (_super) {
  96267. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PostProcessesOptimization, _super);
  96268. function PostProcessesOptimization() {
  96269. return _super !== null && _super.apply(this, arguments) || this;
  96270. }
  96271. /**
  96272. * Gets a string describing the action executed by the current optimization
  96273. * @return description string
  96274. */
  96275. PostProcessesOptimization.prototype.getDescription = function () {
  96276. return "Turning post-processes on/off";
  96277. };
  96278. /**
  96279. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96280. * @param scene defines the current scene where to apply this optimization
  96281. * @param optimizer defines the current optimizer
  96282. * @returns true if everything that can be done was applied
  96283. */
  96284. PostProcessesOptimization.prototype.apply = function (scene, optimizer) {
  96285. scene.postProcessesEnabled = optimizer.isInImprovementMode;
  96286. return true;
  96287. };
  96288. return PostProcessesOptimization;
  96289. }(SceneOptimization));
  96290. /**
  96291. * Defines an optimization used to turn lens flares off
  96292. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96293. */
  96294. var LensFlaresOptimization = /** @class */ (function (_super) {
  96295. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensFlaresOptimization, _super);
  96296. function LensFlaresOptimization() {
  96297. return _super !== null && _super.apply(this, arguments) || this;
  96298. }
  96299. /**
  96300. * Gets a string describing the action executed by the current optimization
  96301. * @return description string
  96302. */
  96303. LensFlaresOptimization.prototype.getDescription = function () {
  96304. return "Turning lens flares on/off";
  96305. };
  96306. /**
  96307. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96308. * @param scene defines the current scene where to apply this optimization
  96309. * @param optimizer defines the current optimizer
  96310. * @returns true if everything that can be done was applied
  96311. */
  96312. LensFlaresOptimization.prototype.apply = function (scene, optimizer) {
  96313. scene.lensFlaresEnabled = optimizer.isInImprovementMode;
  96314. return true;
  96315. };
  96316. return LensFlaresOptimization;
  96317. }(SceneOptimization));
  96318. /**
  96319. * Defines an optimization based on user defined callback.
  96320. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96321. */
  96322. var CustomOptimization = /** @class */ (function (_super) {
  96323. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomOptimization, _super);
  96324. function CustomOptimization() {
  96325. return _super !== null && _super.apply(this, arguments) || this;
  96326. }
  96327. /**
  96328. * Gets a string describing the action executed by the current optimization
  96329. * @returns description string
  96330. */
  96331. CustomOptimization.prototype.getDescription = function () {
  96332. if (this.onGetDescription) {
  96333. return this.onGetDescription();
  96334. }
  96335. return "Running user defined callback";
  96336. };
  96337. /**
  96338. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96339. * @param scene defines the current scene where to apply this optimization
  96340. * @param optimizer defines the current optimizer
  96341. * @returns true if everything that can be done was applied
  96342. */
  96343. CustomOptimization.prototype.apply = function (scene, optimizer) {
  96344. if (this.onApply) {
  96345. return this.onApply(scene, optimizer);
  96346. }
  96347. return true;
  96348. };
  96349. return CustomOptimization;
  96350. }(SceneOptimization));
  96351. /**
  96352. * Defines an optimization used to turn particles off
  96353. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96354. */
  96355. var ParticlesOptimization = /** @class */ (function (_super) {
  96356. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticlesOptimization, _super);
  96357. function ParticlesOptimization() {
  96358. return _super !== null && _super.apply(this, arguments) || this;
  96359. }
  96360. /**
  96361. * Gets a string describing the action executed by the current optimization
  96362. * @return description string
  96363. */
  96364. ParticlesOptimization.prototype.getDescription = function () {
  96365. return "Turning particles on/off";
  96366. };
  96367. /**
  96368. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96369. * @param scene defines the current scene where to apply this optimization
  96370. * @param optimizer defines the current optimizer
  96371. * @returns true if everything that can be done was applied
  96372. */
  96373. ParticlesOptimization.prototype.apply = function (scene, optimizer) {
  96374. scene.particlesEnabled = optimizer.isInImprovementMode;
  96375. return true;
  96376. };
  96377. return ParticlesOptimization;
  96378. }(SceneOptimization));
  96379. /**
  96380. * Defines an optimization used to turn render targets off
  96381. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96382. */
  96383. var RenderTargetsOptimization = /** @class */ (function (_super) {
  96384. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetsOptimization, _super);
  96385. function RenderTargetsOptimization() {
  96386. return _super !== null && _super.apply(this, arguments) || this;
  96387. }
  96388. /**
  96389. * Gets a string describing the action executed by the current optimization
  96390. * @return description string
  96391. */
  96392. RenderTargetsOptimization.prototype.getDescription = function () {
  96393. return "Turning render targets off";
  96394. };
  96395. /**
  96396. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96397. * @param scene defines the current scene where to apply this optimization
  96398. * @param optimizer defines the current optimizer
  96399. * @returns true if everything that can be done was applied
  96400. */
  96401. RenderTargetsOptimization.prototype.apply = function (scene, optimizer) {
  96402. scene.renderTargetsEnabled = optimizer.isInImprovementMode;
  96403. return true;
  96404. };
  96405. return RenderTargetsOptimization;
  96406. }(SceneOptimization));
  96407. /**
  96408. * Defines an optimization used to merge meshes with compatible materials
  96409. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96410. */
  96411. var MergeMeshesOptimization = /** @class */ (function (_super) {
  96412. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MergeMeshesOptimization, _super);
  96413. function MergeMeshesOptimization() {
  96414. var _this = _super !== null && _super.apply(this, arguments) || this;
  96415. _this._canBeMerged = function (abstractMesh) {
  96416. if (!(abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"])) {
  96417. return false;
  96418. }
  96419. var mesh = abstractMesh;
  96420. if (mesh.isDisposed()) {
  96421. return false;
  96422. }
  96423. if (!mesh.isVisible || !mesh.isEnabled()) {
  96424. return false;
  96425. }
  96426. if (mesh.instances.length > 0) {
  96427. return false;
  96428. }
  96429. if (mesh.skeleton || mesh.hasLODLevels) {
  96430. return false;
  96431. }
  96432. return true;
  96433. };
  96434. return _this;
  96435. }
  96436. Object.defineProperty(MergeMeshesOptimization, "UpdateSelectionTree", {
  96437. /**
  96438. * Gets or sets a boolean which defines if optimization octree has to be updated
  96439. */
  96440. get: function () {
  96441. return MergeMeshesOptimization._UpdateSelectionTree;
  96442. },
  96443. /**
  96444. * Gets or sets a boolean which defines if optimization octree has to be updated
  96445. */
  96446. set: function (value) {
  96447. MergeMeshesOptimization._UpdateSelectionTree = value;
  96448. },
  96449. enumerable: true,
  96450. configurable: true
  96451. });
  96452. /**
  96453. * Gets a string describing the action executed by the current optimization
  96454. * @return description string
  96455. */
  96456. MergeMeshesOptimization.prototype.getDescription = function () {
  96457. return "Merging similar meshes together";
  96458. };
  96459. /**
  96460. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96461. * @param scene defines the current scene where to apply this optimization
  96462. * @param optimizer defines the current optimizer
  96463. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  96464. * @returns true if everything that can be done was applied
  96465. */
  96466. MergeMeshesOptimization.prototype.apply = function (scene, optimizer, updateSelectionTree) {
  96467. var globalPool = scene.meshes.slice(0);
  96468. var globalLength = globalPool.length;
  96469. for (var index = 0; index < globalLength; index++) {
  96470. var currentPool = new Array();
  96471. var current = globalPool[index];
  96472. // Checks
  96473. if (!this._canBeMerged(current)) {
  96474. continue;
  96475. }
  96476. currentPool.push(current);
  96477. // Find compatible meshes
  96478. for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
  96479. var otherMesh = globalPool[subIndex];
  96480. if (!this._canBeMerged(otherMesh)) {
  96481. continue;
  96482. }
  96483. if (otherMesh.material !== current.material) {
  96484. continue;
  96485. }
  96486. if (otherMesh.checkCollisions !== current.checkCollisions) {
  96487. continue;
  96488. }
  96489. currentPool.push(otherMesh);
  96490. globalLength--;
  96491. globalPool.splice(subIndex, 1);
  96492. subIndex--;
  96493. }
  96494. if (currentPool.length < 2) {
  96495. continue;
  96496. }
  96497. // Merge meshes
  96498. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].MergeMeshes(currentPool, undefined, true);
  96499. }
  96500. // Call the octree system optimization if it is defined.
  96501. var sceneAsAny = scene;
  96502. if (sceneAsAny.createOrUpdateSelectionOctree) {
  96503. if (updateSelectionTree != undefined) {
  96504. if (updateSelectionTree) {
  96505. sceneAsAny.createOrUpdateSelectionOctree();
  96506. }
  96507. }
  96508. else if (MergeMeshesOptimization.UpdateSelectionTree) {
  96509. sceneAsAny.createOrUpdateSelectionOctree();
  96510. }
  96511. }
  96512. return true;
  96513. };
  96514. MergeMeshesOptimization._UpdateSelectionTree = false;
  96515. return MergeMeshesOptimization;
  96516. }(SceneOptimization));
  96517. /**
  96518. * Defines a list of options used by SceneOptimizer
  96519. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96520. */
  96521. var SceneOptimizerOptions = /** @class */ (function () {
  96522. /**
  96523. * Creates a new list of options used by SceneOptimizer
  96524. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  96525. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  96526. */
  96527. function SceneOptimizerOptions(
  96528. /**
  96529. * Defines the target frame rate to reach (60 by default)
  96530. */
  96531. targetFrameRate,
  96532. /**
  96533. * Defines the interval between two checkes (2000ms by default)
  96534. */
  96535. trackerDuration) {
  96536. if (targetFrameRate === void 0) { targetFrameRate = 60; }
  96537. if (trackerDuration === void 0) { trackerDuration = 2000; }
  96538. this.targetFrameRate = targetFrameRate;
  96539. this.trackerDuration = trackerDuration;
  96540. /**
  96541. * Gets the list of optimizations to apply
  96542. */
  96543. this.optimizations = new Array();
  96544. }
  96545. /**
  96546. * Add a new optimization
  96547. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  96548. * @returns the current SceneOptimizerOptions
  96549. */
  96550. SceneOptimizerOptions.prototype.addOptimization = function (optimization) {
  96551. this.optimizations.push(optimization);
  96552. return this;
  96553. };
  96554. /**
  96555. * Add a new custom optimization
  96556. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  96557. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  96558. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  96559. * @returns the current SceneOptimizerOptions
  96560. */
  96561. SceneOptimizerOptions.prototype.addCustomOptimization = function (onApply, onGetDescription, priority) {
  96562. if (priority === void 0) { priority = 0; }
  96563. var optimization = new CustomOptimization(priority);
  96564. optimization.onApply = onApply;
  96565. optimization.onGetDescription = onGetDescription;
  96566. this.optimizations.push(optimization);
  96567. return this;
  96568. };
  96569. /**
  96570. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  96571. * @param targetFrameRate defines the target frame rate (60 by default)
  96572. * @returns a SceneOptimizerOptions object
  96573. */
  96574. SceneOptimizerOptions.LowDegradationAllowed = function (targetFrameRate) {
  96575. var result = new SceneOptimizerOptions(targetFrameRate);
  96576. var priority = 0;
  96577. result.addOptimization(new MergeMeshesOptimization(priority));
  96578. result.addOptimization(new ShadowsOptimization(priority));
  96579. result.addOptimization(new LensFlaresOptimization(priority));
  96580. // Next priority
  96581. priority++;
  96582. result.addOptimization(new PostProcessesOptimization(priority));
  96583. result.addOptimization(new ParticlesOptimization(priority));
  96584. // Next priority
  96585. priority++;
  96586. result.addOptimization(new TextureOptimization(priority, 1024));
  96587. return result;
  96588. };
  96589. /**
  96590. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  96591. * @param targetFrameRate defines the target frame rate (60 by default)
  96592. * @returns a SceneOptimizerOptions object
  96593. */
  96594. SceneOptimizerOptions.ModerateDegradationAllowed = function (targetFrameRate) {
  96595. var result = new SceneOptimizerOptions(targetFrameRate);
  96596. var priority = 0;
  96597. result.addOptimization(new MergeMeshesOptimization(priority));
  96598. result.addOptimization(new ShadowsOptimization(priority));
  96599. result.addOptimization(new LensFlaresOptimization(priority));
  96600. // Next priority
  96601. priority++;
  96602. result.addOptimization(new PostProcessesOptimization(priority));
  96603. result.addOptimization(new ParticlesOptimization(priority));
  96604. // Next priority
  96605. priority++;
  96606. result.addOptimization(new TextureOptimization(priority, 512));
  96607. // Next priority
  96608. priority++;
  96609. result.addOptimization(new RenderTargetsOptimization(priority));
  96610. // Next priority
  96611. priority++;
  96612. result.addOptimization(new HardwareScalingOptimization(priority, 2));
  96613. return result;
  96614. };
  96615. /**
  96616. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  96617. * @param targetFrameRate defines the target frame rate (60 by default)
  96618. * @returns a SceneOptimizerOptions object
  96619. */
  96620. SceneOptimizerOptions.HighDegradationAllowed = function (targetFrameRate) {
  96621. var result = new SceneOptimizerOptions(targetFrameRate);
  96622. var priority = 0;
  96623. result.addOptimization(new MergeMeshesOptimization(priority));
  96624. result.addOptimization(new ShadowsOptimization(priority));
  96625. result.addOptimization(new LensFlaresOptimization(priority));
  96626. // Next priority
  96627. priority++;
  96628. result.addOptimization(new PostProcessesOptimization(priority));
  96629. result.addOptimization(new ParticlesOptimization(priority));
  96630. // Next priority
  96631. priority++;
  96632. result.addOptimization(new TextureOptimization(priority, 256));
  96633. // Next priority
  96634. priority++;
  96635. result.addOptimization(new RenderTargetsOptimization(priority));
  96636. // Next priority
  96637. priority++;
  96638. result.addOptimization(new HardwareScalingOptimization(priority, 4));
  96639. return result;
  96640. };
  96641. return SceneOptimizerOptions;
  96642. }());
  96643. /**
  96644. * Class used to run optimizations in order to reach a target frame rate
  96645. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96646. */
  96647. var SceneOptimizer = /** @class */ (function () {
  96648. /**
  96649. * Creates a new SceneOptimizer
  96650. * @param scene defines the scene to work on
  96651. * @param options defines the options to use with the SceneOptimizer
  96652. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  96653. * @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)
  96654. */
  96655. function SceneOptimizer(scene, options, autoGeneratePriorities, improvementMode) {
  96656. if (autoGeneratePriorities === void 0) { autoGeneratePriorities = true; }
  96657. if (improvementMode === void 0) { improvementMode = false; }
  96658. var _this = this;
  96659. this._isRunning = false;
  96660. this._currentPriorityLevel = 0;
  96661. this._targetFrameRate = 60;
  96662. this._trackerDuration = 2000;
  96663. this._currentFrameRate = 0;
  96664. this._improvementMode = false;
  96665. /**
  96666. * Defines an observable called when the optimizer reaches the target frame rate
  96667. */
  96668. this.onSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96669. /**
  96670. * Defines an observable called when the optimizer enables an optimization
  96671. */
  96672. this.onNewOptimizationAppliedObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96673. /**
  96674. * Defines an observable called when the optimizer is not able to reach the target frame rate
  96675. */
  96676. this.onFailureObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96677. if (!options) {
  96678. this._options = new SceneOptimizerOptions();
  96679. }
  96680. else {
  96681. this._options = options;
  96682. }
  96683. if (this._options.targetFrameRate) {
  96684. this._targetFrameRate = this._options.targetFrameRate;
  96685. }
  96686. if (this._options.trackerDuration) {
  96687. this._trackerDuration = this._options.trackerDuration;
  96688. }
  96689. if (autoGeneratePriorities) {
  96690. var priority = 0;
  96691. for (var _i = 0, _a = this._options.optimizations; _i < _a.length; _i++) {
  96692. var optim = _a[_i];
  96693. optim.priority = priority++;
  96694. }
  96695. }
  96696. this._improvementMode = improvementMode;
  96697. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene;
  96698. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  96699. _this._sceneDisposeObserver = null;
  96700. _this.dispose();
  96701. });
  96702. }
  96703. Object.defineProperty(SceneOptimizer.prototype, "isInImprovementMode", {
  96704. /**
  96705. * Gets a boolean indicating if the optimizer is in improvement mode
  96706. */
  96707. get: function () {
  96708. return this._improvementMode;
  96709. },
  96710. enumerable: true,
  96711. configurable: true
  96712. });
  96713. Object.defineProperty(SceneOptimizer.prototype, "currentPriorityLevel", {
  96714. /**
  96715. * Gets the current priority level (0 at start)
  96716. */
  96717. get: function () {
  96718. return this._currentPriorityLevel;
  96719. },
  96720. enumerable: true,
  96721. configurable: true
  96722. });
  96723. Object.defineProperty(SceneOptimizer.prototype, "currentFrameRate", {
  96724. /**
  96725. * Gets the current frame rate checked by the SceneOptimizer
  96726. */
  96727. get: function () {
  96728. return this._currentFrameRate;
  96729. },
  96730. enumerable: true,
  96731. configurable: true
  96732. });
  96733. Object.defineProperty(SceneOptimizer.prototype, "targetFrameRate", {
  96734. /**
  96735. * Gets or sets the current target frame rate (60 by default)
  96736. */
  96737. get: function () {
  96738. return this._targetFrameRate;
  96739. },
  96740. /**
  96741. * Gets or sets the current target frame rate (60 by default)
  96742. */
  96743. set: function (value) {
  96744. this._targetFrameRate = value;
  96745. },
  96746. enumerable: true,
  96747. configurable: true
  96748. });
  96749. Object.defineProperty(SceneOptimizer.prototype, "trackerDuration", {
  96750. /**
  96751. * Gets or sets the current interval between two checks (every 2000ms by default)
  96752. */
  96753. get: function () {
  96754. return this._trackerDuration;
  96755. },
  96756. /**
  96757. * Gets or sets the current interval between two checks (every 2000ms by default)
  96758. */
  96759. set: function (value) {
  96760. this._trackerDuration = value;
  96761. },
  96762. enumerable: true,
  96763. configurable: true
  96764. });
  96765. Object.defineProperty(SceneOptimizer.prototype, "optimizations", {
  96766. /**
  96767. * Gets the list of active optimizations
  96768. */
  96769. get: function () {
  96770. return this._options.optimizations;
  96771. },
  96772. enumerable: true,
  96773. configurable: true
  96774. });
  96775. /**
  96776. * Stops the current optimizer
  96777. */
  96778. SceneOptimizer.prototype.stop = function () {
  96779. this._isRunning = false;
  96780. };
  96781. /**
  96782. * Reset the optimizer to initial step (current priority level = 0)
  96783. */
  96784. SceneOptimizer.prototype.reset = function () {
  96785. this._currentPriorityLevel = 0;
  96786. };
  96787. /**
  96788. * Start the optimizer. By default it will try to reach a specific framerate
  96789. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  96790. */
  96791. SceneOptimizer.prototype.start = function () {
  96792. var _this = this;
  96793. if (this._isRunning) {
  96794. return;
  96795. }
  96796. this._isRunning = true;
  96797. // Let's wait for the scene to be ready before running our check
  96798. this._scene.executeWhenReady(function () {
  96799. setTimeout(function () {
  96800. _this._checkCurrentState();
  96801. }, _this._trackerDuration);
  96802. });
  96803. };
  96804. SceneOptimizer.prototype._checkCurrentState = function () {
  96805. var _this = this;
  96806. if (!this._isRunning) {
  96807. return;
  96808. }
  96809. var scene = this._scene;
  96810. var options = this._options;
  96811. this._currentFrameRate = Math.round(scene.getEngine().getFps());
  96812. if (this._improvementMode && this._currentFrameRate <= this._targetFrameRate ||
  96813. !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) {
  96814. this._isRunning = false;
  96815. this.onSuccessObservable.notifyObservers(this);
  96816. return;
  96817. }
  96818. // Apply current level of optimizations
  96819. var allDone = true;
  96820. var noOptimizationApplied = true;
  96821. for (var index = 0; index < options.optimizations.length; index++) {
  96822. var optimization = options.optimizations[index];
  96823. if (optimization.priority === this._currentPriorityLevel) {
  96824. noOptimizationApplied = false;
  96825. allDone = allDone && optimization.apply(scene, this);
  96826. this.onNewOptimizationAppliedObservable.notifyObservers(optimization);
  96827. }
  96828. }
  96829. // If no optimization was applied, this is a failure :(
  96830. if (noOptimizationApplied) {
  96831. this._isRunning = false;
  96832. this.onFailureObservable.notifyObservers(this);
  96833. return;
  96834. }
  96835. // If all optimizations were done, move to next level
  96836. if (allDone) {
  96837. this._currentPriorityLevel++;
  96838. }
  96839. // Let's the system running for a specific amount of time before checking FPS
  96840. scene.executeWhenReady(function () {
  96841. setTimeout(function () {
  96842. _this._checkCurrentState();
  96843. }, _this._trackerDuration);
  96844. });
  96845. };
  96846. /**
  96847. * Release all resources
  96848. */
  96849. SceneOptimizer.prototype.dispose = function () {
  96850. this.stop();
  96851. this.onSuccessObservable.clear();
  96852. this.onFailureObservable.clear();
  96853. this.onNewOptimizationAppliedObservable.clear();
  96854. if (this._sceneDisposeObserver) {
  96855. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  96856. }
  96857. };
  96858. /**
  96859. * Helper function to create a SceneOptimizer with one single line of code
  96860. * @param scene defines the scene to work on
  96861. * @param options defines the options to use with the SceneOptimizer
  96862. * @param onSuccess defines a callback to call on success
  96863. * @param onFailure defines a callback to call on failure
  96864. * @returns the new SceneOptimizer object
  96865. */
  96866. SceneOptimizer.OptimizeAsync = function (scene, options, onSuccess, onFailure) {
  96867. var optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);
  96868. if (onSuccess) {
  96869. optimizer.onSuccessObservable.add(function () {
  96870. onSuccess();
  96871. });
  96872. }
  96873. if (onFailure) {
  96874. optimizer.onFailureObservable.add(function () {
  96875. onFailure();
  96876. });
  96877. }
  96878. optimizer.start();
  96879. return optimizer;
  96880. };
  96881. return SceneOptimizer;
  96882. }());
  96883. /***/ }),
  96884. /***/ "./Misc/sceneSerializer.ts":
  96885. /*!*********************************!*\
  96886. !*** ./Misc/sceneSerializer.ts ***!
  96887. \*********************************/
  96888. /*! exports provided: SceneSerializer */
  96889. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96890. "use strict";
  96891. __webpack_require__.r(__webpack_exports__);
  96892. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return SceneSerializer; });
  96893. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  96894. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  96895. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  96896. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  96897. var serializedGeometries = [];
  96898. var serializeGeometry = function (geometry, serializationGeometries) {
  96899. if (serializedGeometries[geometry.id]) {
  96900. return;
  96901. }
  96902. if (geometry.doNotSerialize) {
  96903. return;
  96904. }
  96905. serializationGeometries.vertexData.push(geometry.serializeVerticeData());
  96906. serializedGeometries[geometry.id] = true;
  96907. };
  96908. var serializeMesh = function (mesh, serializationScene) {
  96909. var serializationObject = {};
  96910. // Geometry
  96911. var geometry = mesh._geometry;
  96912. if (geometry) {
  96913. if (!mesh.getScene().getGeometryByID(geometry.id)) {
  96914. // 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
  96915. serializeGeometry(geometry, serializationScene.geometries);
  96916. }
  96917. }
  96918. // Custom
  96919. if (mesh.serialize) {
  96920. mesh.serialize(serializationObject);
  96921. }
  96922. return serializationObject;
  96923. };
  96924. var finalizeSingleMesh = function (mesh, serializationObject) {
  96925. //only works if the mesh is already loaded
  96926. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  96927. //serialize material
  96928. if (mesh.material) {
  96929. if (mesh.material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__["MultiMaterial"]) {
  96930. serializationObject.multiMaterials = serializationObject.multiMaterials || [];
  96931. serializationObject.materials = serializationObject.materials || [];
  96932. if (!serializationObject.multiMaterials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  96933. serializationObject.multiMaterials.push(mesh.material.serialize());
  96934. var _loop_1 = function (submaterial) {
  96935. if (submaterial) {
  96936. if (!serializationObject.materials.some(function (mat) { return (mat.id === submaterial.id); })) {
  96937. serializationObject.materials.push(submaterial.serialize());
  96938. }
  96939. }
  96940. };
  96941. for (var _i = 0, _a = mesh.material.subMaterials; _i < _a.length; _i++) {
  96942. var submaterial = _a[_i];
  96943. _loop_1(submaterial);
  96944. }
  96945. }
  96946. }
  96947. else {
  96948. serializationObject.materials = serializationObject.materials || [];
  96949. if (!serializationObject.materials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  96950. serializationObject.materials.push(mesh.material.serialize());
  96951. }
  96952. }
  96953. }
  96954. //serialize geometry
  96955. var geometry = mesh._geometry;
  96956. if (geometry) {
  96957. if (!serializationObject.geometries) {
  96958. serializationObject.geometries = {};
  96959. serializationObject.geometries.boxes = [];
  96960. serializationObject.geometries.spheres = [];
  96961. serializationObject.geometries.cylinders = [];
  96962. serializationObject.geometries.toruses = [];
  96963. serializationObject.geometries.grounds = [];
  96964. serializationObject.geometries.planes = [];
  96965. serializationObject.geometries.torusKnots = [];
  96966. serializationObject.geometries.vertexData = [];
  96967. }
  96968. serializeGeometry(geometry, serializationObject.geometries);
  96969. }
  96970. // Skeletons
  96971. if (mesh.skeleton) {
  96972. serializationObject.skeletons = serializationObject.skeletons || [];
  96973. serializationObject.skeletons.push(mesh.skeleton.serialize());
  96974. }
  96975. //serialize the actual mesh
  96976. serializationObject.meshes = serializationObject.meshes || [];
  96977. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  96978. }
  96979. };
  96980. /**
  96981. * Class used to serialize a scene into a string
  96982. */
  96983. var SceneSerializer = /** @class */ (function () {
  96984. function SceneSerializer() {
  96985. }
  96986. /**
  96987. * Clear cache used by a previous serialization
  96988. */
  96989. SceneSerializer.ClearCache = function () {
  96990. serializedGeometries = [];
  96991. };
  96992. /**
  96993. * Serialize a scene into a JSON compatible object
  96994. * @param scene defines the scene to serialize
  96995. * @returns a JSON compatible object
  96996. */
  96997. SceneSerializer.Serialize = function (scene) {
  96998. var serializationObject = {};
  96999. SceneSerializer.ClearCache();
  97000. // Scene
  97001. serializationObject.useDelayedTextureLoading = scene.useDelayedTextureLoading;
  97002. serializationObject.autoClear = scene.autoClear;
  97003. serializationObject.clearColor = scene.clearColor.asArray();
  97004. serializationObject.ambientColor = scene.ambientColor.asArray();
  97005. serializationObject.gravity = scene.gravity.asArray();
  97006. serializationObject.collisionsEnabled = scene.collisionsEnabled;
  97007. // Fog
  97008. if (scene.fogMode && scene.fogMode !== 0) {
  97009. serializationObject.fogMode = scene.fogMode;
  97010. serializationObject.fogColor = scene.fogColor.asArray();
  97011. serializationObject.fogStart = scene.fogStart;
  97012. serializationObject.fogEnd = scene.fogEnd;
  97013. serializationObject.fogDensity = scene.fogDensity;
  97014. }
  97015. //Physics
  97016. if (scene.isPhysicsEnabled()) {
  97017. var physicEngine = scene.getPhysicsEngine();
  97018. if (physicEngine) {
  97019. serializationObject.physicsEnabled = true;
  97020. serializationObject.physicsGravity = physicEngine.gravity.asArray();
  97021. serializationObject.physicsEngine = physicEngine.getPhysicsPluginName();
  97022. }
  97023. }
  97024. // Metadata
  97025. if (scene.metadata) {
  97026. serializationObject.metadata = scene.metadata;
  97027. }
  97028. // Morph targets
  97029. serializationObject.morphTargetManagers = [];
  97030. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  97031. var abstractMesh = _a[_i];
  97032. var manager = abstractMesh.morphTargetManager;
  97033. if (manager) {
  97034. serializationObject.morphTargetManagers.push(manager.serialize());
  97035. }
  97036. }
  97037. // Lights
  97038. serializationObject.lights = [];
  97039. var index;
  97040. var light;
  97041. for (index = 0; index < scene.lights.length; index++) {
  97042. light = scene.lights[index];
  97043. if (!light.doNotSerialize) {
  97044. serializationObject.lights.push(light.serialize());
  97045. }
  97046. }
  97047. // Cameras
  97048. serializationObject.cameras = [];
  97049. for (index = 0; index < scene.cameras.length; index++) {
  97050. var camera = scene.cameras[index];
  97051. if (!camera.doNotSerialize) {
  97052. serializationObject.cameras.push(camera.serialize());
  97053. }
  97054. }
  97055. if (scene.activeCamera) {
  97056. serializationObject.activeCameraID = scene.activeCamera.id;
  97057. }
  97058. // Animations
  97059. _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"].AppendSerializedAnimations(scene, serializationObject);
  97060. // Reflection probes
  97061. if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
  97062. serializationObject.reflectionProbes = [];
  97063. for (index = 0; index < scene.reflectionProbes.length; index++) {
  97064. var reflectionProbe = scene.reflectionProbes[index];
  97065. serializationObject.reflectionProbes.push(reflectionProbe.serialize());
  97066. }
  97067. }
  97068. // Materials
  97069. serializationObject.materials = [];
  97070. serializationObject.multiMaterials = [];
  97071. var material;
  97072. for (index = 0; index < scene.materials.length; index++) {
  97073. material = scene.materials[index];
  97074. if (!material.doNotSerialize) {
  97075. serializationObject.materials.push(material.serialize());
  97076. }
  97077. }
  97078. // MultiMaterials
  97079. serializationObject.multiMaterials = [];
  97080. for (index = 0; index < scene.multiMaterials.length; index++) {
  97081. var multiMaterial = scene.multiMaterials[index];
  97082. serializationObject.multiMaterials.push(multiMaterial.serialize());
  97083. }
  97084. // Environment texture
  97085. if (scene.environmentTexture) {
  97086. serializationObject.environmentTexture = scene.environmentTexture.name;
  97087. }
  97088. // Skeletons
  97089. serializationObject.skeletons = [];
  97090. for (index = 0; index < scene.skeletons.length; index++) {
  97091. var skeleton = scene.skeletons[index];
  97092. if (!skeleton.doNotSerialize) {
  97093. serializationObject.skeletons.push(skeleton.serialize());
  97094. }
  97095. }
  97096. // Transform nodes
  97097. serializationObject.transformNodes = [];
  97098. for (index = 0; index < scene.transformNodes.length; index++) {
  97099. serializationObject.transformNodes.push(scene.transformNodes[index].serialize());
  97100. }
  97101. // Geometries
  97102. serializationObject.geometries = {};
  97103. serializationObject.geometries.boxes = [];
  97104. serializationObject.geometries.spheres = [];
  97105. serializationObject.geometries.cylinders = [];
  97106. serializationObject.geometries.toruses = [];
  97107. serializationObject.geometries.grounds = [];
  97108. serializationObject.geometries.planes = [];
  97109. serializationObject.geometries.torusKnots = [];
  97110. serializationObject.geometries.vertexData = [];
  97111. serializedGeometries = [];
  97112. var geometries = scene.getGeometries();
  97113. for (index = 0; index < geometries.length; index++) {
  97114. var geometry = geometries[index];
  97115. if (geometry.isReady()) {
  97116. serializeGeometry(geometry, serializationObject.geometries);
  97117. }
  97118. }
  97119. // Meshes
  97120. serializationObject.meshes = [];
  97121. for (index = 0; index < scene.meshes.length; index++) {
  97122. var abstractMesh = scene.meshes[index];
  97123. if (abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]) {
  97124. var mesh = abstractMesh;
  97125. if (!mesh.doNotSerialize) {
  97126. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  97127. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  97128. }
  97129. }
  97130. }
  97131. }
  97132. // Particles Systems
  97133. serializationObject.particleSystems = [];
  97134. for (index = 0; index < scene.particleSystems.length; index++) {
  97135. serializationObject.particleSystems.push(scene.particleSystems[index].serialize());
  97136. }
  97137. // Action Manager
  97138. if (scene.actionManager) {
  97139. serializationObject.actions = scene.actionManager.serialize("scene");
  97140. }
  97141. // Components
  97142. for (var _b = 0, _c = scene._serializableComponents; _b < _c.length; _b++) {
  97143. var component = _c[_b];
  97144. component.serialize(serializationObject);
  97145. }
  97146. return serializationObject;
  97147. };
  97148. /**
  97149. * Serialize a mesh into a JSON compatible object
  97150. * @param toSerialize defines the mesh to serialize
  97151. * @param withParents defines if parents must be serialized as well
  97152. * @param withChildren defines if children must be serialized as well
  97153. * @returns a JSON compatible object
  97154. */
  97155. SceneSerializer.SerializeMesh = function (toSerialize /* Mesh || Mesh[] */, withParents, withChildren) {
  97156. if (withParents === void 0) { withParents = false; }
  97157. if (withChildren === void 0) { withChildren = false; }
  97158. var serializationObject = {};
  97159. SceneSerializer.ClearCache();
  97160. toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
  97161. if (withParents || withChildren) {
  97162. //deliberate for loop! not for each, appended should be processed as well.
  97163. for (var i = 0; i < toSerialize.length; ++i) {
  97164. if (withChildren) {
  97165. toSerialize[i].getDescendants().forEach(function (node) {
  97166. if (node instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"] && (toSerialize.indexOf(node) < 0)) {
  97167. toSerialize.push(node);
  97168. }
  97169. });
  97170. }
  97171. //make sure the array doesn't contain the object already
  97172. if (withParents && toSerialize[i].parent && (toSerialize.indexOf(toSerialize[i].parent) < 0)) {
  97173. toSerialize.push(toSerialize[i].parent);
  97174. }
  97175. }
  97176. }
  97177. toSerialize.forEach(function (mesh) {
  97178. finalizeSingleMesh(mesh, serializationObject);
  97179. });
  97180. return serializationObject;
  97181. };
  97182. return SceneSerializer;
  97183. }());
  97184. /***/ }),
  97185. /***/ "./Misc/screenshotTools.ts":
  97186. /*!*********************************!*\
  97187. !*** ./Misc/screenshotTools.ts ***!
  97188. \*********************************/
  97189. /*! exports provided: ScreenshotTools */
  97190. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97191. "use strict";
  97192. __webpack_require__.r(__webpack_exports__);
  97193. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return ScreenshotTools; });
  97194. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  97195. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  97196. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  97197. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  97198. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  97199. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  97200. // Screenshots
  97201. var screenshotCanvas;
  97202. /**
  97203. * Class containing a set of static utilities functions for screenshots
  97204. */
  97205. var ScreenshotTools = /** @class */ (function () {
  97206. function ScreenshotTools() {
  97207. }
  97208. /**
  97209. * Captures a screenshot of the current rendering
  97210. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97211. * @param engine defines the rendering engine
  97212. * @param camera defines the source camera
  97213. * @param size This parameter can be set to a single number or to an object with the
  97214. * following (optional) properties: precision, width, height. If a single number is passed,
  97215. * it will be used for both width and height. If an object is passed, the screenshot size
  97216. * will be derived from the parameters. The precision property is a multiplier allowing
  97217. * rendering at a higher or lower resolution
  97218. * @param successCallback defines the callback receives a single parameter which contains the
  97219. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97220. * src parameter of an <img> to display it
  97221. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97222. * Check your browser for supported MIME types
  97223. */
  97224. ScreenshotTools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  97225. if (mimeType === void 0) { mimeType = "image/png"; }
  97226. var width;
  97227. var height;
  97228. // If a precision value is specified
  97229. if (size.precision) {
  97230. width = Math.round(engine.getRenderWidth() * size.precision);
  97231. height = Math.round(width / engine.getAspectRatio(camera));
  97232. }
  97233. else if (size.width && size.height) {
  97234. width = size.width;
  97235. height = size.height;
  97236. }
  97237. //If passing only width, computing height to keep display canvas ratio.
  97238. else if (size.width && !size.height) {
  97239. width = size.width;
  97240. height = Math.round(width / engine.getAspectRatio(camera));
  97241. }
  97242. //If passing only height, computing width to keep display canvas ratio.
  97243. else if (size.height && !size.width) {
  97244. height = size.height;
  97245. width = Math.round(height * engine.getAspectRatio(camera));
  97246. }
  97247. //Assuming here that "size" parameter is a number
  97248. else if (!isNaN(size)) {
  97249. height = size;
  97250. width = size;
  97251. }
  97252. else {
  97253. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  97254. return;
  97255. }
  97256. if (!screenshotCanvas) {
  97257. screenshotCanvas = document.createElement('canvas');
  97258. }
  97259. screenshotCanvas.width = width;
  97260. screenshotCanvas.height = height;
  97261. var renderContext = screenshotCanvas.getContext("2d");
  97262. var ratio = engine.getRenderWidth() / engine.getRenderHeight();
  97263. var newWidth = width;
  97264. var newHeight = newWidth / ratio;
  97265. if (newHeight > height) {
  97266. newHeight = height;
  97267. newWidth = newHeight * ratio;
  97268. }
  97269. var offsetX = Math.max(0, width - newWidth) / 2;
  97270. var offsetY = Math.max(0, height - newHeight) / 2;
  97271. var renderingCanvas = engine.getRenderingCanvas();
  97272. if (renderContext && renderingCanvas) {
  97273. renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
  97274. }
  97275. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].EncodeScreenshotCanvasData(successCallback, mimeType);
  97276. };
  97277. /**
  97278. * Generates an image screenshot from the specified camera.
  97279. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97280. * @param engine The engine to use for rendering
  97281. * @param camera The camera to use for rendering
  97282. * @param size This parameter can be set to a single number or to an object with the
  97283. * following (optional) properties: precision, width, height. If a single number is passed,
  97284. * it will be used for both width and height. If an object is passed, the screenshot size
  97285. * will be derived from the parameters. The precision property is a multiplier allowing
  97286. * rendering at a higher or lower resolution
  97287. * @param successCallback The callback receives a single parameter which contains the
  97288. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97289. * src parameter of an <img> to display it
  97290. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97291. * Check your browser for supported MIME types
  97292. * @param samples Texture samples (default: 1)
  97293. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97294. * @param fileName A name for for the downloaded file.
  97295. */
  97296. ScreenshotTools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  97297. if (mimeType === void 0) { mimeType = "image/png"; }
  97298. if (samples === void 0) { samples = 1; }
  97299. if (antialiasing === void 0) { antialiasing = false; }
  97300. var width;
  97301. var height;
  97302. //If a precision value is specified
  97303. if (size.precision) {
  97304. width = Math.round(engine.getRenderWidth() * size.precision);
  97305. height = Math.round(width / engine.getAspectRatio(camera));
  97306. size = { width: width, height: height };
  97307. }
  97308. else if (size.width && size.height) {
  97309. width = size.width;
  97310. height = size.height;
  97311. }
  97312. //If passing only width, computing height to keep display canvas ratio.
  97313. else if (size.width && !size.height) {
  97314. width = size.width;
  97315. height = Math.round(width / engine.getAspectRatio(camera));
  97316. size = { width: width, height: height };
  97317. }
  97318. //If passing only height, computing width to keep display canvas ratio.
  97319. else if (size.height && !size.width) {
  97320. height = size.height;
  97321. width = Math.round(height * engine.getAspectRatio(camera));
  97322. size = { width: width, height: height };
  97323. }
  97324. //Assuming here that "size" parameter is a number
  97325. else if (!isNaN(size)) {
  97326. height = size;
  97327. width = size;
  97328. }
  97329. else {
  97330. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  97331. return;
  97332. }
  97333. var scene = camera.getScene();
  97334. var previousCamera = null;
  97335. if (scene.activeCamera !== camera) {
  97336. previousCamera = scene.activeCamera;
  97337. scene.activeCamera = camera;
  97338. }
  97339. var renderCanvas = engine.getRenderingCanvas();
  97340. if (!renderCanvas) {
  97341. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("No rendering canvas found !");
  97342. return;
  97343. }
  97344. var originalSize = { width: renderCanvas.width, height: renderCanvas.height };
  97345. engine.setSize(width, height);
  97346. scene.render();
  97347. // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
  97348. 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);
  97349. texture.renderList = null;
  97350. texture.samples = samples;
  97351. if (antialiasing) {
  97352. texture.addPostProcess(new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__["FxaaPostProcess"]('antialiasing', 1.0, scene.activeCamera));
  97353. }
  97354. texture.onAfterRenderObservable.add(function () {
  97355. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);
  97356. });
  97357. scene.incrementRenderId();
  97358. scene.resetCachedMaterial();
  97359. texture.render(true);
  97360. texture.dispose();
  97361. if (previousCamera) {
  97362. scene.activeCamera = previousCamera;
  97363. }
  97364. engine.setSize(originalSize.width, originalSize.height);
  97365. camera.getProjectionMatrix(true); // Force cache refresh;
  97366. };
  97367. return ScreenshotTools;
  97368. }());
  97369. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshot = ScreenshotTools.CreateScreenshot;
  97370. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTarget = ScreenshotTools.CreateScreenshotUsingRenderTarget;
  97371. /***/ }),
  97372. /***/ "./Misc/smartArray.ts":
  97373. /*!****************************!*\
  97374. !*** ./Misc/smartArray.ts ***!
  97375. \****************************/
  97376. /*! exports provided: SmartArray, SmartArrayNoDuplicate */
  97377. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97378. "use strict";
  97379. __webpack_require__.r(__webpack_exports__);
  97380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return SmartArray; });
  97381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return SmartArrayNoDuplicate; });
  97382. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  97383. /**
  97384. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  97385. */
  97386. var SmartArray = /** @class */ (function () {
  97387. /**
  97388. * Instantiates a Smart Array.
  97389. * @param capacity defines the default capacity of the array.
  97390. */
  97391. function SmartArray(capacity) {
  97392. /**
  97393. * The active length of the array.
  97394. */
  97395. this.length = 0;
  97396. this.data = new Array(capacity);
  97397. this._id = SmartArray._GlobalId++;
  97398. }
  97399. /**
  97400. * Pushes a value at the end of the active data.
  97401. * @param value defines the object to push in the array.
  97402. */
  97403. SmartArray.prototype.push = function (value) {
  97404. this.data[this.length++] = value;
  97405. if (this.length > this.data.length) {
  97406. this.data.length *= 2;
  97407. }
  97408. };
  97409. /**
  97410. * Iterates over the active data and apply the lambda to them.
  97411. * @param func defines the action to apply on each value.
  97412. */
  97413. SmartArray.prototype.forEach = function (func) {
  97414. for (var index = 0; index < this.length; index++) {
  97415. func(this.data[index]);
  97416. }
  97417. };
  97418. /**
  97419. * Sorts the full sets of data.
  97420. * @param compareFn defines the comparison function to apply.
  97421. */
  97422. SmartArray.prototype.sort = function (compareFn) {
  97423. this.data.sort(compareFn);
  97424. };
  97425. /**
  97426. * Resets the active data to an empty array.
  97427. */
  97428. SmartArray.prototype.reset = function () {
  97429. this.length = 0;
  97430. };
  97431. /**
  97432. * Releases all the data from the array as well as the array.
  97433. */
  97434. SmartArray.prototype.dispose = function () {
  97435. this.reset();
  97436. if (this.data) {
  97437. this.data.length = 0;
  97438. this.data = [];
  97439. }
  97440. };
  97441. /**
  97442. * Concats the active data with a given array.
  97443. * @param array defines the data to concatenate with.
  97444. */
  97445. SmartArray.prototype.concat = function (array) {
  97446. if (array.length === 0) {
  97447. return;
  97448. }
  97449. if (this.length + array.length > this.data.length) {
  97450. this.data.length = (this.length + array.length) * 2;
  97451. }
  97452. for (var index = 0; index < array.length; index++) {
  97453. this.data[this.length++] = (array.data || array)[index];
  97454. }
  97455. };
  97456. /**
  97457. * Returns the position of a value in the active data.
  97458. * @param value defines the value to find the index for
  97459. * @returns the index if found in the active data otherwise -1
  97460. */
  97461. SmartArray.prototype.indexOf = function (value) {
  97462. var position = this.data.indexOf(value);
  97463. if (position >= this.length) {
  97464. return -1;
  97465. }
  97466. return position;
  97467. };
  97468. /**
  97469. * Returns whether an element is part of the active data.
  97470. * @param value defines the value to look for
  97471. * @returns true if found in the active data otherwise false
  97472. */
  97473. SmartArray.prototype.contains = function (value) {
  97474. return this.indexOf(value) !== -1;
  97475. };
  97476. // Statics
  97477. SmartArray._GlobalId = 0;
  97478. return SmartArray;
  97479. }());
  97480. /**
  97481. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  97482. * The data in this array can only be present once
  97483. */
  97484. var SmartArrayNoDuplicate = /** @class */ (function (_super) {
  97485. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SmartArrayNoDuplicate, _super);
  97486. function SmartArrayNoDuplicate() {
  97487. var _this = _super !== null && _super.apply(this, arguments) || this;
  97488. _this._duplicateId = 0;
  97489. return _this;
  97490. }
  97491. /**
  97492. * Pushes a value at the end of the active data.
  97493. * THIS DOES NOT PREVENT DUPPLICATE DATA
  97494. * @param value defines the object to push in the array.
  97495. */
  97496. SmartArrayNoDuplicate.prototype.push = function (value) {
  97497. _super.prototype.push.call(this, value);
  97498. if (!value.__smartArrayFlags) {
  97499. value.__smartArrayFlags = {};
  97500. }
  97501. value.__smartArrayFlags[this._id] = this._duplicateId;
  97502. };
  97503. /**
  97504. * Pushes a value at the end of the active data.
  97505. * If the data is already present, it won t be added again
  97506. * @param value defines the object to push in the array.
  97507. * @returns true if added false if it was already present
  97508. */
  97509. SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
  97510. if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
  97511. return false;
  97512. }
  97513. this.push(value);
  97514. return true;
  97515. };
  97516. /**
  97517. * Resets the active data to an empty array.
  97518. */
  97519. SmartArrayNoDuplicate.prototype.reset = function () {
  97520. _super.prototype.reset.call(this);
  97521. this._duplicateId++;
  97522. };
  97523. /**
  97524. * Concats the active data with a given array.
  97525. * This ensures no dupplicate will be present in the result.
  97526. * @param array defines the data to concatenate with.
  97527. */
  97528. SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
  97529. if (array.length === 0) {
  97530. return;
  97531. }
  97532. if (this.length + array.length > this.data.length) {
  97533. this.data.length = (this.length + array.length) * 2;
  97534. }
  97535. for (var index = 0; index < array.length; index++) {
  97536. var item = (array.data || array)[index];
  97537. this.pushNoDuplicate(item);
  97538. }
  97539. };
  97540. return SmartArrayNoDuplicate;
  97541. }(SmartArray));
  97542. /***/ }),
  97543. /***/ "./Misc/stringDictionary.ts":
  97544. /*!**********************************!*\
  97545. !*** ./Misc/stringDictionary.ts ***!
  97546. \**********************************/
  97547. /*! exports provided: StringDictionary */
  97548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97549. "use strict";
  97550. __webpack_require__.r(__webpack_exports__);
  97551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return StringDictionary; });
  97552. /**
  97553. * This class implement a typical dictionary using a string as key and the generic type T as value.
  97554. * The underlying implementation relies on an associative array to ensure the best performances.
  97555. * The value can be anything including 'null' but except 'undefined'
  97556. */
  97557. var StringDictionary = /** @class */ (function () {
  97558. function StringDictionary() {
  97559. this._count = 0;
  97560. this._data = {};
  97561. }
  97562. /**
  97563. * This will clear this dictionary and copy the content from the 'source' one.
  97564. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  97565. * @param source the dictionary to take the content from and copy to this dictionary
  97566. */
  97567. StringDictionary.prototype.copyFrom = function (source) {
  97568. var _this = this;
  97569. this.clear();
  97570. source.forEach(function (t, v) { return _this.add(t, v); });
  97571. };
  97572. /**
  97573. * Get a value based from its key
  97574. * @param key the given key to get the matching value from
  97575. * @return the value if found, otherwise undefined is returned
  97576. */
  97577. StringDictionary.prototype.get = function (key) {
  97578. var val = this._data[key];
  97579. if (val !== undefined) {
  97580. return val;
  97581. }
  97582. return undefined;
  97583. };
  97584. /**
  97585. * Get a value from its key or add it if it doesn't exist.
  97586. * This method will ensure you that a given key/data will be present in the dictionary.
  97587. * @param key the given key to get the matching value from
  97588. * @param factory the factory that will create the value if the key is not present in the dictionary.
  97589. * The factory will only be invoked if there's no data for the given key.
  97590. * @return the value corresponding to the key.
  97591. */
  97592. StringDictionary.prototype.getOrAddWithFactory = function (key, factory) {
  97593. var val = this.get(key);
  97594. if (val !== undefined) {
  97595. return val;
  97596. }
  97597. val = factory(key);
  97598. if (val) {
  97599. this.add(key, val);
  97600. }
  97601. return val;
  97602. };
  97603. /**
  97604. * Get a value from its key if present in the dictionary otherwise add it
  97605. * @param key the key to get the value from
  97606. * @param val if there's no such key/value pair in the dictionary add it with this value
  97607. * @return the value corresponding to the key
  97608. */
  97609. StringDictionary.prototype.getOrAdd = function (key, val) {
  97610. var curVal = this.get(key);
  97611. if (curVal !== undefined) {
  97612. return curVal;
  97613. }
  97614. this.add(key, val);
  97615. return val;
  97616. };
  97617. /**
  97618. * Check if there's a given key in the dictionary
  97619. * @param key the key to check for
  97620. * @return true if the key is present, false otherwise
  97621. */
  97622. StringDictionary.prototype.contains = function (key) {
  97623. return this._data[key] !== undefined;
  97624. };
  97625. /**
  97626. * Add a new key and its corresponding value
  97627. * @param key the key to add
  97628. * @param value the value corresponding to the key
  97629. * @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
  97630. */
  97631. StringDictionary.prototype.add = function (key, value) {
  97632. if (this._data[key] !== undefined) {
  97633. return false;
  97634. }
  97635. this._data[key] = value;
  97636. ++this._count;
  97637. return true;
  97638. };
  97639. /**
  97640. * Update a specific value associated to a key
  97641. * @param key defines the key to use
  97642. * @param value defines the value to store
  97643. * @returns true if the value was updated (or false if the key was not found)
  97644. */
  97645. StringDictionary.prototype.set = function (key, value) {
  97646. if (this._data[key] === undefined) {
  97647. return false;
  97648. }
  97649. this._data[key] = value;
  97650. return true;
  97651. };
  97652. /**
  97653. * Get the element of the given key and remove it from the dictionary
  97654. * @param key defines the key to search
  97655. * @returns the value associated with the key or null if not found
  97656. */
  97657. StringDictionary.prototype.getAndRemove = function (key) {
  97658. var val = this.get(key);
  97659. if (val !== undefined) {
  97660. delete this._data[key];
  97661. --this._count;
  97662. return val;
  97663. }
  97664. return null;
  97665. };
  97666. /**
  97667. * Remove a key/value from the dictionary.
  97668. * @param key the key to remove
  97669. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  97670. */
  97671. StringDictionary.prototype.remove = function (key) {
  97672. if (this.contains(key)) {
  97673. delete this._data[key];
  97674. --this._count;
  97675. return true;
  97676. }
  97677. return false;
  97678. };
  97679. /**
  97680. * Clear the whole content of the dictionary
  97681. */
  97682. StringDictionary.prototype.clear = function () {
  97683. this._data = {};
  97684. this._count = 0;
  97685. };
  97686. Object.defineProperty(StringDictionary.prototype, "count", {
  97687. /**
  97688. * Gets the current count
  97689. */
  97690. get: function () {
  97691. return this._count;
  97692. },
  97693. enumerable: true,
  97694. configurable: true
  97695. });
  97696. /**
  97697. * Execute a callback on each key/val of the dictionary.
  97698. * Note that you can remove any element in this dictionary in the callback implementation
  97699. * @param callback the callback to execute on a given key/value pair
  97700. */
  97701. StringDictionary.prototype.forEach = function (callback) {
  97702. for (var cur in this._data) {
  97703. var val = this._data[cur];
  97704. callback(cur, val);
  97705. }
  97706. };
  97707. /**
  97708. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  97709. * If the callback returns null or undefined the method will iterate to the next key/value pair
  97710. * Note that you can remove any element in this dictionary in the callback implementation
  97711. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  97712. * @returns the first item
  97713. */
  97714. StringDictionary.prototype.first = function (callback) {
  97715. for (var cur in this._data) {
  97716. var val = this._data[cur];
  97717. var res = callback(cur, val);
  97718. if (res) {
  97719. return res;
  97720. }
  97721. }
  97722. return null;
  97723. };
  97724. return StringDictionary;
  97725. }());
  97726. /***/ }),
  97727. /***/ "./Misc/tags.ts":
  97728. /*!**********************!*\
  97729. !*** ./Misc/tags.ts ***!
  97730. \**********************/
  97731. /*! exports provided: Tags */
  97732. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97733. "use strict";
  97734. __webpack_require__.r(__webpack_exports__);
  97735. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return Tags; });
  97736. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  97737. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  97738. /**
  97739. * Class used to store custom tags
  97740. */
  97741. var Tags = /** @class */ (function () {
  97742. function Tags() {
  97743. }
  97744. /**
  97745. * Adds support for tags on the given object
  97746. * @param obj defines the object to use
  97747. */
  97748. Tags.EnableFor = function (obj) {
  97749. obj._tags = obj._tags || {};
  97750. obj.hasTags = function () {
  97751. return Tags.HasTags(obj);
  97752. };
  97753. obj.addTags = function (tagsString) {
  97754. return Tags.AddTagsTo(obj, tagsString);
  97755. };
  97756. obj.removeTags = function (tagsString) {
  97757. return Tags.RemoveTagsFrom(obj, tagsString);
  97758. };
  97759. obj.matchesTagsQuery = function (tagsQuery) {
  97760. return Tags.MatchesQuery(obj, tagsQuery);
  97761. };
  97762. };
  97763. /**
  97764. * Removes tags support
  97765. * @param obj defines the object to use
  97766. */
  97767. Tags.DisableFor = function (obj) {
  97768. delete obj._tags;
  97769. delete obj.hasTags;
  97770. delete obj.addTags;
  97771. delete obj.removeTags;
  97772. delete obj.matchesTagsQuery;
  97773. };
  97774. /**
  97775. * Gets a boolean indicating if the given object has tags
  97776. * @param obj defines the object to use
  97777. * @returns a boolean
  97778. */
  97779. Tags.HasTags = function (obj) {
  97780. if (!obj._tags) {
  97781. return false;
  97782. }
  97783. return !_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsEmpty(obj._tags);
  97784. };
  97785. /**
  97786. * Gets the tags available on a given object
  97787. * @param obj defines the object to use
  97788. * @param asString defines if the tags must be returned as a string instead of an array of strings
  97789. * @returns the tags
  97790. */
  97791. Tags.GetTags = function (obj, asString) {
  97792. if (asString === void 0) { asString = true; }
  97793. if (!obj._tags) {
  97794. return null;
  97795. }
  97796. if (asString) {
  97797. var tagsArray = [];
  97798. for (var tag in obj._tags) {
  97799. if (obj._tags.hasOwnProperty(tag) && obj._tags[tag] === true) {
  97800. tagsArray.push(tag);
  97801. }
  97802. }
  97803. return tagsArray.join(" ");
  97804. }
  97805. else {
  97806. return obj._tags;
  97807. }
  97808. };
  97809. /**
  97810. * Adds tags to an object
  97811. * @param obj defines the object to use
  97812. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  97813. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  97814. */
  97815. Tags.AddTagsTo = function (obj, tagsString) {
  97816. if (!tagsString) {
  97817. return;
  97818. }
  97819. if (typeof tagsString !== "string") {
  97820. return;
  97821. }
  97822. var tags = tagsString.split(" ");
  97823. tags.forEach(function (tag, index, array) {
  97824. Tags._AddTagTo(obj, tag);
  97825. });
  97826. };
  97827. /**
  97828. * @hidden
  97829. */
  97830. Tags._AddTagTo = function (obj, tag) {
  97831. tag = tag.trim();
  97832. if (tag === "" || tag === "true" || tag === "false") {
  97833. return;
  97834. }
  97835. if (tag.match(/[\s]/) || tag.match(/^([!]|([|]|[&]){2})/)) {
  97836. return;
  97837. }
  97838. Tags.EnableFor(obj);
  97839. obj._tags[tag] = true;
  97840. };
  97841. /**
  97842. * Removes specific tags from a specific object
  97843. * @param obj defines the object to use
  97844. * @param tagsString defines the tags to remove
  97845. */
  97846. Tags.RemoveTagsFrom = function (obj, tagsString) {
  97847. if (!Tags.HasTags(obj)) {
  97848. return;
  97849. }
  97850. var tags = tagsString.split(" ");
  97851. for (var t in tags) {
  97852. Tags._RemoveTagFrom(obj, tags[t]);
  97853. }
  97854. };
  97855. /**
  97856. * @hidden
  97857. */
  97858. Tags._RemoveTagFrom = function (obj, tag) {
  97859. delete obj._tags[tag];
  97860. };
  97861. /**
  97862. * Defines if tags hosted on an object match a given query
  97863. * @param obj defines the object to use
  97864. * @param tagsQuery defines the tag query
  97865. * @returns a boolean
  97866. */
  97867. Tags.MatchesQuery = function (obj, tagsQuery) {
  97868. if (tagsQuery === undefined) {
  97869. return true;
  97870. }
  97871. if (tagsQuery === "") {
  97872. return Tags.HasTags(obj);
  97873. }
  97874. return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__["AndOrNotEvaluator"].Eval(tagsQuery, function (r) { return Tags.HasTags(obj) && obj._tags[r]; });
  97875. };
  97876. return Tags;
  97877. }());
  97878. /***/ }),
  97879. /***/ "./Misc/textureTools.ts":
  97880. /*!******************************!*\
  97881. !*** ./Misc/textureTools.ts ***!
  97882. \******************************/
  97883. /*! exports provided: TextureTools */
  97884. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97885. "use strict";
  97886. __webpack_require__.r(__webpack_exports__);
  97887. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return TextureTools; });
  97888. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  97889. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  97890. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  97891. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  97892. /**
  97893. * Class used to host texture specific utilities
  97894. */
  97895. var TextureTools = /** @class */ (function () {
  97896. function TextureTools() {
  97897. }
  97898. /**
  97899. * Uses the GPU to create a copy texture rescaled at a given size
  97900. * @param texture Texture to copy from
  97901. * @param width defines the desired width
  97902. * @param height defines the desired height
  97903. * @param useBilinearMode defines if bilinear mode has to be used
  97904. * @return the generated texture
  97905. */
  97906. TextureTools.CreateResizedCopy = function (texture, width, height, useBilinearMode) {
  97907. if (useBilinearMode === void 0) { useBilinearMode = true; }
  97908. var scene = texture.getScene();
  97909. var engine = scene.getEngine();
  97910. 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);
  97911. rtt.wrapU = texture.wrapU;
  97912. rtt.wrapV = texture.wrapV;
  97913. rtt.uOffset = texture.uOffset;
  97914. rtt.vOffset = texture.vOffset;
  97915. rtt.uScale = texture.uScale;
  97916. rtt.vScale = texture.vScale;
  97917. rtt.uAng = texture.uAng;
  97918. rtt.vAng = texture.vAng;
  97919. rtt.wAng = texture.wAng;
  97920. rtt.coordinatesIndex = texture.coordinatesIndex;
  97921. rtt.level = texture.level;
  97922. rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;
  97923. rtt._texture.isReady = false;
  97924. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97925. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97926. 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);
  97927. passPostProcess.getEffect().executeWhenCompiled(function () {
  97928. passPostProcess.onApply = function (effect) {
  97929. effect.setTexture("textureSampler", texture);
  97930. };
  97931. var internalTexture = rtt.getInternalTexture();
  97932. if (internalTexture) {
  97933. scene.postProcessManager.directRender([passPostProcess], internalTexture);
  97934. engine.unBindFramebuffer(internalTexture);
  97935. rtt.disposeFramebufferObjects();
  97936. passPostProcess.dispose();
  97937. internalTexture.isReady = true;
  97938. }
  97939. });
  97940. return rtt;
  97941. };
  97942. /**
  97943. * Gets an environment BRDF texture for a given scene
  97944. * @param scene defines the hosting scene
  97945. * @returns the environment BRDF texture
  97946. */
  97947. TextureTools.GetEnvironmentBRDFTexture = function (scene) {
  97948. if (!scene._environmentBRDFTexture) {
  97949. var texture = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CreateFromBase64String(this._environmentBRDFBase64Texture, "EnvironmentBRDFTexture", scene, true, false, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].BILINEAR_SAMPLINGMODE);
  97950. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97951. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97952. scene._environmentBRDFTexture = texture;
  97953. }
  97954. return scene._environmentBRDFTexture;
  97955. };
  97956. TextureTools._environmentBRDFBase64Texture = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR4Xu19Z7PtTHbW1g3jMMbGmGDAZAMm5xxMLDAU0WSKWOQcCoqccw6eGdtgk4yNbZxnvvAL+Af8Af6AsQl+06ako9X36dXPSi3pnPu+cz/cOntL3S1pq5+w1mrpLs/eud9fvn27rf9evPPwFz+v22S7fGZ/n7/70G79J5/Xv/qzbLP+Pnvvoc/6Tz7jX/15/c62LfeH7fofbpfP3l/ct36Wf+u4+D37+XYb++G26LPsr/zFttnPuh37bm1bt0f7MvtlnOx4uv0H4fty8UUsz77rfn/57u32cgXvDv72eQf0tl0+G38b0Nf9K4Dl704MEfA16KsE8Gw9JgD+DQE8EA0DT2b7GwK4GHnF4a8iguXZt9/vL5/dbisJbEq/uwD5vIK/fbbAv4N9U/8nJIDNCazKvBLBGwdwu62OhajxmQSAx6gqNp5HCg9wPan2nwSNjhLD8ux/3u8vP3y7vbwDAYjtR8AzFyDqLu1Q+YEINnew23rPCYiKb+q/K7o4AVT4tg0t/h4ydJZfkQASQ/d5b9fZ/Z1ENmuPn/cwYCYEELBguKC3nRkCnE0AFOwOKCOAR/sH/L4hgFMpbSWP5dn/uN9ffs7t9mJ5cAHoBLTyszBAFJ/F/xIKdASw5wgaEWDMLySxAk4svf6L+4QAGPiJCziNAPb4f3UZ2dh/m+z7BK4SAPYrxf5FB6ABPgCUAfANAZwKyscc7IEA/vv9/uLzbreXzx9cQCMACAl00m8jAlF7ov6SCMQ8gJsMFFBnCECSg5H6TxJAU3vPAbwhgFfz9AABeOEDBcIbB3AqPzwQwH+731/8sNvt5Ydut5e3B2C/fG9P+jESgGz/RgxG9r9VAwTUUh0goQDafUz+DYnAnSha5l99Z1l/yQVswAZSGIAugNd/9xBgCw9E8aECkHUB22QPHIAVDlQdQAMWAibhBgZAasAVHUAI8Cqg96Tm0bj3VBS9jwd7IIBvuN9ffMHt9vLTbreXy+32QlwAhgMIeuNzKwOqCoB2Aa00KHE+EsIeDuj4H2N+Hf/TfAC6A4nhgQCQDDwiaKDXiq9KgBEJNPArAtCk0AEd2mpAizW3/lYIoANpBPg3BPA+hjs/9eXZV+0E8Bm32wsJA9aEoBCAuAABPiEAC/yDC4gSgRgKRHkAlgsI6v7iEFqJEMgBwb4BGkEfEEDnDlReoAP/SQRgOYIB+IYDMEE/SQBbXoLNr0jhq4qOZc0PHBSf5oKW519xvz//kbfby8+83V68ABfwniIBgwgQ/HoRUMv8w5qAoQqgk4DWQiCw+63eD8k/XAPQgK5s/5a5xzAAqgR6wY9k+ZEMtCOoJABb230hEHMFWQdgAl0Ap/+uc6tKBrrP/n0AuwfiNwTwNKguHHV5/qX3+/M1B/Ddb7cXax7g2e324vaQB3hhkMAW92tHoFb96cVAbimwkgQ0Vv7R+D8iACfuxzKfLvnNlAAjAsBwwP2MwLQAD9sbYJME0AFcg5uBPSAA0x0AobhtcDKDA0j3KYDhk7Hp8uKj9/vzH3C7vfget9uLT9nDgDUZuOYCLBJA8MNKPyGGIftPrL+4gy3eh5p/lwRUYYAs9Fn7tM/E9lvJwCH2DxJ/mPTr4nyyLiDtBgTAGCrgNuPzNuETgN+suEEAFhng9lkCoICMLH7V0isCeEMCxylrefkl9/uzz90J4NNUGLDmAnYXINUBrf5dCCAuQCcCvYVAYPk3G++VAveVfkIAFRLolgbr2F9ifP33pAqAV/fHRF4HcAS7AKlAAEIYFNwITOszs/wMsB6II4BXFZ0QwBsSOEYCDwTw2TsBfPrt9uLlqzCgcwFABI0EVCiANl8Uvq0JWNsi2JPZ/0YKsOiHxftsW4v51ZqAaBWgZf91PsBL/jFHwEqBR1cCiuJ3gAfCmCEA3cf8rmz8AMZHIoA3JDBPAsuHVgL4jNvt+UoCH34ggK0asIYBGArsAB7AD+reQgCl+GwZ8LaNlP3MEEDaSg4ACMGr/+ulwV4JsAEfLH42/vdKgWElAJ4QpBl+LAlKErHwt+oGMgTA2ngE4IUIOH3dGr/hAKT/m/UBdSJYPuVL7vflU26352sScCWAD+0EsCcDVxewKjfmAzAsENVn4EfgdySgnYB81yEAgL4RA8T8mTUASAAYBgylQAkL8K/+zL6rsl8qF6ArAeS7WRGoAB8Sf7isN/VZqTs6jQ5wXlweWfyqpQ8I4I0TmCCAT/3I/b48u92ef9bt9nwNAdZE4FoOFALYXcAGegkDMByAzzQEgJh+cAIs/legH0IA5QTCPADE+7ISkD0TgA/8sBIgLQfOgF/F9kPcr+J8fIYguyCILQRKgV4DNviOzoKqeJS0u4AA3pBAjQSWT//I/b5OmC0MWB3ASgBrGLA+IryvDNxCgRXo+wKhjgwk8bcTwUACsJ09ANRVAALwCxmEoFcrAUsuAJ4M1E8BDuHABAHomJ8RgACrZfQLyT9dBWi2OOEG9NJd/TDQ8HAQuBE97ZhjGKy6o+imnU+4gDckkCeB5cMfud/v6zr9Dz84gOdCAM/3JwQhF9CAD25gBWWz/8wNgMpj3K9Lfy0foMMBVffXyT4r+cceC9bvCcDFP0311QrATPkvWgosYQFLAuoqQEcQuw3v2si25F+M1RkZXLUU+CgBmCBOEsCbvECOBJbP+Oj9fv+u2+3Zp91uz9cy4Kfebs/3ROD6iPD2b10YJCXB+0PyrgsHdtBuRACfBeTN+uM+suJPSEDbfh3/oxPoHgwiC3/06j8Eutj69sAQqj++I0CUfvIpwCEvYCT90O4Pn1XsT5Ve1/+dcp9FBh3woqXBSEJkvjHHEOUPqJPAjUUCeOMGfCJYPvOj9/t7//d2e7YmAlcS2B3A8xcPYcBm/7ULEDIQew+5gS0EIEA31R8Uf6gAoBsgKwBd9ddvBBJAs6XARgLQXQ2o7T8+IETe+9eRACg7rhCMVgCiE8D4O9wOCb2ubOht1/vYd2ubzLlgKbBHEDSnAMfL6durVm8qBPwXWz7rY/f7/X/fbsvL2+3Zqv4QAjzfw4COAMAJbEC3wC8koBJ9lAhgxZ+4hi3Oh/f8dU8EqtV/JhHgWn9cC4CJQZXZp6GAk/1nawMkrrcqAiwPIIA2FwOB2oaAF5UkcX+GADBs0I5gsNbBQqCorJcFJjqWKvhNMjky0Aek7/LZH7vf3/vO2215vruAD91uz/dSYCOAPQzYkoD7vw34sFIQw4LNymNSUKk8Wv0hCYhkoJ74Q6BboO9eDKoWAHXvBiCvAdPZf4nt3QqA924AbfXV8t8uN4Bt2We029WkoErWpSoCSm11TM8AOYA5uRS4RAITIQDDavaYHxCcm5exfM7H7vd3v2N9McDt9uxDD//WKsAG/ue32/M1DEACuO3g1jkBsf57fqCL/7UbIISAio85AAG0VQEYiIC9DJTYfy/+Dx8HlpeDRK8G90IBHQbgWgD2WT8LoOJ7NyeA5JEkAwwxmuqzur5X6y+sBEwDMggrqoBNH7c68Puk/fI9Vwfwvx4e6H724oEA1iSg5AAaAewlweeyLmAnAHQCTfU1CTAH4GyTMt+QDMRFQFEYQB71lXUAOjHYlvTqh4N2xe5yASoh2PpaJUGDBDrLr9cGIDlY1l+vDlQOAQHckYMiA68KMFsGtOy65RCGsMIDT+QqJoD3yUwCy/f+6P3+7koAt50AXrwigM0FrIuEoBrwHMMAUhmQUKAlAwHo7VmAPURo9h/r//ozLv1V7/5v6wGMV4B3rwYPXEBqIZAQwp4TYDE+LQlqtQfw6my/LgsyZaeLg7wVgmDnWQ5AA5ZWCDRx7ECzyn3udgFptFCIgTlyFRMEUCKgA+O/jl2Xz/3o/f7Otz88QvpszQOsLmAPARoBSDVgud02AthdwPZ5BSxUBVr8L3kAVHrvs076KSLQi3/M9QCJ7H/G/rf4n8X41XIgcwHecuBMDgAe+BHA6uQgqnvbF5DB5hwUQM3vQgIWkKOVftH+gAC6cz0RXZ9MjmD5fh/ZCWCd1CsB7CSwhgArAUgIIC5AQoDOCewJwab+CH79WR4C0mQAZT4hEQS9DgfEztNkoEECDfi6FAhZflb6Q1XXqwHDEECpvZX4a0qP1l7bfAS98cQfzQUo9a4mASMC0CsIm6JGK/2i/QkCuFK9PxmIYPm8nQDu795uy3K7LTvwVyJAB7ARwJoAVLkA7QIkJ9A5AQS95Ad2YmgvAJWwQFcBpB38pUuB9wVKbAWgCXwV86Mz2ICKTwUWFgOxMEBicr0eoBwCGBUADfxsDsAiA+zflNay31ZcfnAdAAXgDGkcdAcfZCJYfuCX3O9vf/vtthHAmgcQF7ATwOoAtn9IACsRSDkQ/wqIIUGoXYEQQ/sL5IDJP539776DwodVAGlr5QBgP8sDdApP3gSUXQa8/rZsRaBeHmy+HwDyCI1MUNlZzX9iJSBO9igJGJYCo4RdIqMfJQ4Ztq8C7FXjHuSnQ92XH/yvdwJ4Z68ErOXAlQRW0O9/JRG42v9GBHsuAImAqv+uzDo30C3yAfVHoHeg9xyAp/7wlp+WFCSWv1sOTBb+0EoAZP5DImBrApAUMFHolQG19c+EAkbpjyUEdQ6gm/QEsCzZFxKDlWNwprJVWfBm/1WAvWrcQ0ie7Lz80H91v7/9v263+9sPI2zrAZAEdvXvXMBKBJIIFDcgyUAEvHICg/o7wA/Bvyt35wCc2F9Cg03RvRyAA34N8hD0xsIfXP7bQgDMFSgyYO8GsF4N/hQ5ALak1yUGRQDZZJ5VWXgKEsie8yQuH63b8vn/8oEA3lsJYJ2EQgD73xX4z9bs/74gaHMBQgA7+DsXAJWBBniHCLTtNx2AUnkG/LYNiUCpvX7wp6sIOHF/lwgkNf8UGagwYMgLMBdgLQCyVgOyciCGCs5nz/Jr8EXOQOcQZEbrfjjTU8qaCBseMyx4vxPB8iP+RU8A24Kg9R8Qgaj/av8lDBgcwApQ+QdVgW0bKr3+jsk//AztzBKgtv4K+Kj08rl7JFgt9BnCAIsQcD2AsQAolQj0CAGAqhOFCK5u3cA+84dyIJLCPm6buAgoBa5qDoDF6wzUkZ13iSDKKwTamSKZSf29cuzJUwq7LV/wz18RwH2Nl9dKABLArv6bC5B/+9OBGxmsIIR1AQ3w2gk4RECTfwBulgC0rP96/FYJUOv9SzkAB/xuKTBY/qsTgZ0LILF/s/RW9v81ywEwhbeAwUIH6hRwGp+wEOhqoF49fojqQoPlR/+z+/3t77jd3n3rdru999CzEYAQAYJfXACEAqL8W5lQgA5uoJUK9zxBB3ii9ALiYT2AjvuN72wFILP+XdlP8gLKFeg6f5QM3AC+VlMMZ9ABGuN+VePHWL6tHVD23or3tQPo2iWfBRgShDp0ELcBjmIAbwTWqEzIJvLM6kEDEFcD9erxCzg3my4/9p/e7299x+323lu32+oAtjwAhgE7Cazqv7mAvRLQcgG7A9B5AAwHus87CWBYsIKFfe+eCSBgt2J+7QBQ+VsogOU/9fIPBvLhASEF8AHwlhPQ2wVYFhmo/Wby74QyYLcmQAEbbbue2FcnAb28QTmHQKBwNVCvHv8IESw//h/f7299pyIA7QIE/LsTeIbqL59hPUADvHIBG8jBIWgn0L4rsKMj2Noomz8QgZELsCoAAnh0Caj8lup7ib9tX+ZBoKgUmFkWTGJ8S/UHZa/kAHT+QGaeoeQmMUC/CoAzVYAjYDvSNwPCq8fPnINus/zEfwQE8O7tdt8dwGZjIQQQ9Y9cwAB+RQIC4I4MdvvdLL+O//E7LgLykn6q3Efjf6X8bOUfkoNYcQZ8z/KzBUBYCqT/YQgjBuOBHxPs7JHh7JoAy/IzWz+xEtBKBEYg8fIGw+SeQQQ+CzHZP+oWXWPU/8z9y0/+h/f729/5kAN4791X/6/cpl4SCsDfLRQwHEBLCmJFYH92vssNgBPo7D8qv4CekIHpAjKgx1iffGbKb5UAQwdguIAtz2KsEWj7vIQggNON91lYoIFN2mznYKj9UBmwQgXLLcDstRTdBchEFWAWcLP9MgC9cuzM8aXN8lP//v3+9v/uCUDyAM0FIBFADqAjAsgFiAvYwK3/MfAL8InSd/Yfy37Qpyv3OSTgxf8C5vZXPfF3aB2AA3hJGg5LghMOgCUBo8SgEAyC3Irvh5xAwhW0cT1iQBKYWds/QQLdeVUQcrEjeGoiWH7633sggHfWJOAaAkglYL/wLQyQf3tYsCp9CwmgFIgOgIJ/JwMdBuB3cQTDX4z9wR2whN+WE9idh67761p/F/8bpb8O/OotQCsJDhZfji0qT9p0LsCI83X9H8E9KH8iCSiTrQO29bwAAbvlCipPAw4T/oRKQAVElbaMJ472t7jnqnEjrlt+1t+539/6P4oAxLquawIkF7Bb/40M9hAAHcD2GVzABmBYKSgxfyMGAbROCipl1w6gs/8ZF0Cy/UIOOr7vHAIu9iHP/2v77yX9ROUt29+AHVUCnDJgtvSn8wXsnQGzIUAW3F27qFS4z2CrD07wCogqbR8LtGecUwR4vX/5OX/7FQFsOYC9FCiToBGAEAH83ZwA5AM06BspiPKrNQIt/kcg69iffBegNqVXb/wdQgIMC0DltUuQ+L+Bmz0OrNTdK/91+4JVf15SEPMCYRkwEfc3stBxurMS0AoTMKRocaV8cKw6jpcFsdUn2/8qRT8buGeP55HC8vP+5v3+1v99cADvvfNQBZB4dO24Kv5GAntSUOz/+n1wAis4wAnoMAC/N9svSUKsBABgmwPAbQTwWzsW/2vAI6j14h+1CEjnBYZFQWSxj+sEVFyPjgBBrhf+aOtPY39vRaBVJlQ2vyOGIATQsb6etBguDMSQyAF4IMhUAmZANNNnUNSqBDvtzzif6HSWL/wbuwN4eycA4gDEBQgRYPzfSGC3/BYBdOCHxKBHBAJoAbdWfIz1I9XXsf5g9y0yAJB7iUDPCaC6e2EA2ngMGyIHwAgBldncf4ID0EDXVp1NYmbnrclOtyfDhiPOoCO4CEXB/rOBfOZ4yy/8a7sDAALY1gKAfWMEgOovoNdk0IArKr+7gwH02gWQ2L4t/sEEoLL2IQnoFX96HYC4CIz/jcSgAJSVAtu2RPZ/SPRBHkC7AkYEqceC2fqBfdKaCcHAAeAkpKVBCANcElBVgBQRTC4HngHOTJ+rQo2jhEbP6xf/VU4AmBza7L+EAZgLgGSgxP8dGQDwmQOQbS2xp6oEWAnQn1seIEMCJO4fsv8Q2w/JQU0IJMvPiCCT/NPuQP/noJ0rAFBa23VSr1N/vQhIgxzzB9odMMIAkGvFZPF6JkyIlJeFFl6IcRYYX0ciOOOcll/6l+/3t/7fngPYy4BSCmyT0SGAlgvY4/+BAET10fZjUhAWCg2AV8nBEPQ6D6DJgSUAoQ/G+Dr+T9l/pfg0HxAs/e3WBUhbsihIgHKkHGiGCQHYO/UHomDgdd0BcRkZlYtyAFlgZNtlzqkSJcwc1xr/6FjLL/tLPQG8t+YA3tuXBKPiqISgAB//bjZdkoNE/Rs5EAIYXIAKCwYHYJADlvhalp8RgS4PogNwFN8jgo1A2LoALxRw1gA09TbCAjckQHBZlQEFwEoS0Iv1S3mAYFGPlwOIJn+0v+ocPohEsHzRX9gJYM0BvPvwTyoB2gGsP6iEAowANsBJWAAVgRYeAPCb/WdkAKEAttNJwRbzM+UPQI8K36k9Kf3RagBTe2vhj3o8uAFXLxUGxTdXBrK1AIltTZ2JzUe7Lp/Ralvxvrb5kcWP9nv2fwBzIRF4FRFkx/XcwRljHCGm5Vf++fv9re+63d4xCABVRhOAJoOtRCguQKoCmghwv7L/mBPQwB/KfMQhCEF0ym8RAUkIToUAxrP/gxOwSoDGmn9WCjTzASw3kHQA5poA7Q4g3n+MEMAChiadiopXwHZV26usvB43e/7Lr/pznADakmBdDcB8AFj+5ggcF4AhgAlwwyUM6m+pPgF8U3BS6jOdAAkJ3HUAO5C7ZKBT99/IVDsGhwyY3e8qNfhCERXDa5BrlW/ftaoqe265Ar0U+PIQQCUzqwqYBYfnSK4AcuW8sjmHaMzl1/zZnQDeud3eXRcCrfH/ngNYbyxzAKL8nQNAMiC5gI0gBNz42XIBAnAkBACwqDyWByPlp2BPWP7WD0Crs/5ewq+1JaBnWX8rEajbDiVAlbNpwHRyAJ4D6EqECQcQWfxo/0wI4E3wcPJnUbSLXqH5A26qHaD9kb7ssKaj+nV/ZiSALRG4rwhsJLBfUKt/k3yAJMGwEtCFBGD/PTIY4n6d8ANyaEk/Q/nPUv8h+WeRgXYCVgIwSwbK3osKi4PonEGUC2C2Pngc2LL73Xanlj9bBTg7BIgAFe2vuoxZS14B7wy/DCT8xX/qfn/rrYccwLtrElA7AJkgkrDSJUHJfO/Z/wZ4Kx8g4IXyYKfm0i9QfkoSJK5HghALr51Ce2Jwv0ad9BvAj1WCidKfZf1x3UDnvPQ90HYf7o1WfSQMGbOpU1D3H6oCynpjPE7VfSccpoalMEHNdAxFKkDLgDzTRo5ZaXukz1E34f1Gy2/8kzEB6MUlsjCoCwWMEAAdgOcGTECrnECn+JYTgPyABn0U82vwt7hfJft0rK9DAlHooTSolH94GxBUAnTSL/reAbz6UBADt344SDkIJBIT5E62HgnEAwgFmjq3ChFkAJUFd7Zd9fwsdZ89nnX85Tf/8Z0A1hwAOgDJAxBbuU1usboYCoiCKvWX+L/lAUDlNUG0bD8Bt7dviP9Vf0v9LbV3XQCz/3qbZf2d0h8D+JAPYDb/RAfArL1l92W7Z/OjEICpOZvkw7bES0EisET7M0RxRNkzx78qJGj37rf+MUUA+zoAnQjs1gTAhJNyFy4X7kBtkYHKB0ifDMgrLiADfJMESGa/Cwe0/a+CHsmA5QQ8N6ByAzJZh1IhEobOAegsvwaVDhEKDkCre0cielYbau4SQfIZggyIM0DMtMkc6ywnMHMsduzlt/+R+/2tt2+3d8QBiAtQSUBaEVDxPyYB22cEuiYDQgJtLUFk7539ke1vgAeAR05gC3ekbAclwuaEjEVA3XoAAnLpT6sBCuStrUrIpqsBHhkwcBOVTecFJAteCAFSyk/GzapwBOJofwV0mbEQkNX2p/X9HX9IEcB7eyLw3q8IlPgSbV/LBThEIMreQJkhAeYOIsDrsELV8VmIgHX9ITGo1L+BnxGB5wQY6IvKLzZZCKD7nsj8m+sADjoAVHk9ga19tF1CzSk5GO8T9MCUAdpZbSqEUW17lpNYfucfvN/fBgfwLlQBcEnwdkA9cdGiCjCgGrCpZhACDMSA6wL28dewgKl6GzuI963EXwtf1Nr/wQ0YMb+bCJwAPgKc5gPIPeiImeUC4B5J2zbZnGXBQjI4Mdk2HFNPYqv9MNlJCJByAzPPEezIiUAe7a8ANjPWGYpePc52Db/799/vb7/zKgQQAnhvDwH0cwFWLqBluwkRYJ7AqgoMTiHjApTqR9ZfbLxbCbCUX1wOKQGiO8ASn7XdKgMimL2SoG4nkxGVnqk+OoeBDHR4AN87EmCWnlULBGiBuiNJMFC5RJB8HsACRgYwZ7WpEEY2pNEuYOoYv/f37Q7g3dvtnT3+39YC6BBAv3IK1wVA9p8SAYC5gRDBqz53QDasvag/dQboGMCy0zBA7e/CgoTyszX/VeA35QeH1YGc2Hwr2YchGn5mJNGVd8FdoEOIHEBo9VkeQc3cqFJgEkPhxSBHwoIMCVTAlx1vlggq4y+/7/fe72+tDuDdV2XARgD7isDtd95BpZWjKRUov4Acwa6BT5OEsEjICg1aBUAl8DpwA2kgQeCYbHsjL0zygfKbll9XC5xk3zYGgM1yA0IKERGgI2PJQJ20M13CAQfgWv1kEjBj+Yc2zlqAGdWPgBPtrwI2O16FXMrn8Ad+z04AaxVgTwDiasAtBNgnrK4E6HBgSApichCBBHkBCnQNbmb1iTPoSEXlDXCfTv6x0EAA2OUDtCPA70bMT6sAXjVAlf4sIhieC8BYXy0CYk5gIPKCA8CJGzoAI5QYJqoRzx8NAZ6KCLLgzra7igSWP/i79hzA6gCAAMQFrBMNSUCrFypUm+x78k/cQRffY45AqatOGDJy0CDHkh5dDERielFhWvrTIYHO+icy/jK+qe6sCkCAH70erLsXylXMWv5GFowQrLyACISU6HZ0W+RALX0Qz2ug4NgYUWScRNQ+q6IZ8GbaVMCdHS99jX/4dwIBCAmsoNd5AHAB1sRDArByAV1YgLkBnfRDF6AtPbP4LNY32lkOgMX/tPynSKFzC466Y2JP+mT+mk8BOiVAVP2MA9COgH4nQGcgHxyCAe5uMicqARTcJ+QBIlB5+6O+V4E7c9wMCSx/9HfkCEDyAMPDJiQZ2AABqtZUVwG7s+ZWMlCDO/F9iPFZso9l/IkDaMRgxPqe4g8JQa30yg14pdaM7TddgWHxXcUPVgLqvnqyWw6AqrlT0jPV33AekYJb4IlAdfX+6LwR0BVi8Yhg+WO//X5/e68AyLMAawlwCAEwF2BkpTfgqwlu5QU6G45KrdYNsNi9qwAQMgjBnyEDI77XYGcxfjXut1wAhlfSptsGoNHJPab6XkLwTAeAk1MIidp+mJlRJYCqPxCABwizr0aUDl3I/ogEMsDMjJEZp0oYjECWP/HbSA4ACEDWAbA8gJ6MjADWbYP6i5LqvyRROBBABHgjXEAV14k963s7d0koOkm/s+J+FiaERADqbjkAHKNNrsRCoE7lmYsQ0HjlPm+dgMzKRLmQkkgyBJhR/SPWPwPyTJuriWD5U78FHMB7eyJQ5QDaYiBhXL0mgGWumRNQAO/KbieTASMOL8bvVgUSq2/lAvAaOvDiwiEjs6/BThdZ6bUBJNvfuQN0Z+pzVzI09nXqrT3UMRMAACAASURBVJcKg+J6xKAnLao7Tvruc6ZcyBS6EDpUXUIEvgyAz2oTnQuqe+aYzT386d98v69rALZ1AEIAazVgz/4zBzC8aorlAdS2rkIgC4e8v2TxkOsGMLeA45I6vgZ7ygFg4g8JQhOdl+FPZv+ZnRey0CQhE4PtH1TfCBmkXQd+S+1ZXkCTiQZq0gG4sb6qMHSAKFYQHpsIMoDMtKla/syYy5/9Tb0DWGP/7R8QgOUA2NtnzEw3LhRS6hjlA9CK6/gfS4XU5rOk427p9bg02cfATtS9CwGcSsB6/taTf9Zvx0ItvQ2JgH7WgEYyMMA+5AwmHMBMDsAjAhrPTz5M9H4mggy4M65g+XO/YSeAXf1lLYAsBca/24D7MwKdakBIYOUBxKYyJ0BDAeIOTOW2QI75AgVkXNVH7b+VBFTgDisAQda/gd5LrCrlZpa/WXJrEVBk+cGxNWAkqwDMQWiFNq2/zNKgDOi6A2NFICULRAV8rrSN7HgEzmh/NH4G2MZlDi8qXf78Fz8QgNj/thjIcADtvw9HNcgQwGxIwPIGLHTQVj8BfszWmzkAlZsQwFrlPbcCYOUCjBwKKwl6pUBRWyFhukxY7LmO7414X8f61BVY4YLY9iDBhy6BTX6LPJCoPHtcAXelbQRUD+gZEojGZyCvjrv8hV/fOwArBGBLgnFpcGdJYUJ0gNknxLDNCwm8xKEV6xtqPwt4DWpm92kIQICN7bSNF2Xv/pLfUgNd5wxoCEAA34GbqL0VAmhSuMIBuIqv8wGJRUQWmCzAfNIQwV/8tff7O+9BEhBKgEMiUIUAXjLQinMbAAAcCIruFWMVgBPFX28iLhW2Yvzu+JCo06A21wAQm69XRVJwk+RpaiEQCxeQKEDlaWhgtEWQWEqvt7vhwoQDKAFfjR+5hytdgjf20X1HLH/kIpa//GtUCLATgE4CogOQz628IwzslKx0gosuG1bWnuUGotJhyzUYYUIjBSsnoJKVXZnPCAeYo3EBH1UDDIA38CniiBR/CA1I1r5VEQBUg/1XVt8jjG7iWZUD5WEz5UIK8sRagIhYquQQgfqI/a/aeBYKZMOD5a/86r0MCGsApAqQcQDbgTQBMNuqJ70GE/nuOgMSGjDFj7ZZhNABnxBTIxon459Vfa9yYpUEEfRU5RXounEUkJEgGJlEYNb9O2IQ16hsO07y9nk2ETjzJKG4JIKUSlgQKqyDzgzQM22ic/AcxPLXflXSAew30no8eDsJvBGWyhmJsKojQOAOi3R0yRFtPcvuqxo/tf7qeryYv2T/mZqT0IARgfzmG9Eg6erP8Jvr+4Tk4Sk6IwnWfgA/IxsCPhmfKWuk3ugcqENIgLwC+hl1j4Ac7c+CPDNOd4/++q/ccwCRA1iFHkqAtBrA3ICh/J46Yp7AjM+DHIK27t1aA0YIbKGPIisrw59NAOqSH/0NEKyMCBS4qwnAtNpnk4JGnN8pfKYKoIgiA2R2DEYglW1XE8FZQI6AHu1vv8nf+BUPBNDKgFYOgDkAsHdmQhAnkhP74kNDg72OwgMP0CRuN90GW+CTdCwWoVluQKv3EAYQ1cZjuOpv9JXJNyT49KIgliMwlByVu7kJUFwvPBjcQuaxYSuUOBAGZMjGIxEP1BEQn3z/3/oi4gA0CQD4uxAACMBLCKLNjFSPJd3Q7rtJOWu1oZNcHMgmE+8H5T3P3Xj7OlCzCgEeN+sEVDs8Rpu4Ol9ggd1ScuYWkAQIsDv1lrYqB+BZ/2FfsBqQAe3sbZG6Xwn2aGzr3Ja//cuJA8CnAXfr314SajgBkwBwAs6EAwmwWWFChThY0s8iI297B3DDPYRtCLi3Psb2AdRAHrKvqb9BCEyNtaKXS4OkoqAnomXjKUEo9e/GSjqAs0HvAS8C5WzfaNwKES1/95cZDmAlAbIacPudIRcgi4H0oqBuUirgU6WDSVtJsHnJw8gtZNyGWeJLEJNn61vZzYjzo/3dQ0Ea1DgmUXMWAqTAbil9UOaLynttQj+iAzibCCLQRfstUM+ShJiqqP/y937p7gDuex5gBz5bByD23woDMA9ACeCAG8jkCLTis+8ZUhjCAisZOKvwySw/OoWONFWMrmv4ZsWAqX+wrXMGbLkwnMvgIowEIWuHTsV1CTKz978WeViA88IKDzRnA/Ts8TyCcUng7/+SngC2twFZJLBPljIB4IQ1wgA9waPM+rCfJApN9Tae1beOGZ1LO06CEKj7UbF9A7CVB7AShIa9R3Uf1gOwhF9V6S1iEEQFDqFN3my14IJEYNYRTANNERd+PZMMIsXXp7H8g198v68VgHf2uP9dBX5xAtvbgaUUqEqCg/1HKweAlx9vsLeGIlqxchWojCyqY1RCgXK5jxGHofIsD9B+V92nSAgIxCEkgLEGBU8mAaO4PgoVmEJbOQQG1CzIs+08Msg6kAwRzJBOlgiWf/SLRgewksCq8l0YAKBveQAgBGb/t4vDhJQmAwf4a9dQeZPWnJbiHMfgOYeNlAKlx3BFOxs3L6B+LySS8EUg6rzwuEgQ3luBGugDqx/lCzyCGPbtCBBi05M9Io2OFB4hEXgmGLMgzZDEjIvYruUf/0I7BGgkAJWAbY46SUArGThMyAIZVADH2ppEkiCBir2n5xmpu5ME1I5pUH+LYEnFICKEDpiFEADPSSu0JhQX/MphTBFBIYnI3MRjgLviLs48H9OR/JNf4IcAK9bxPwoV9TerAXgj4T0BOJk9MhAQDZOfACUCNgIy0zbTJpPZpyGAQwTiKug7AYkr0L+N991Vf00gpGyHINbK3yZVMQQwVT2xEMh1BEZ/Nvk1EKsKmgXyGeOeTQQdEf/TL3wggNX2b/H//jqwLRGo1gC0HMCeD9AlQPw+WDqZJEZIoCdaNY6OgOmFAVq5u7ae3Y9AHam7sd8kApUsZHaekclAvrv86eoBcwkZkFvrA1hf1wU4Cu4Btu1T/c8G/hWgrxDEmSFDc0D//OdDCEAqADoPIMnA7a8wrv6LpSEFfJlkoQtAdfKShEmAWlUDN7xgOYYE6DPuBY+Lv0W0HRXdK/cN2X6l0jqcsICubbx2AVeFAK7Sy+zV1YDiasAjgH6MvqZth+vXH6sksfyLn/eKAFaw6yoA5gEE9FYScDsZZfsR8CwhSJNb2Tq5UVLsQO0lE5Pk4bqRiBDU/oEcHFVn9X1T4dFZ6TKhYfWZcltqbm6HsZm6D07QKuGRcqQGgEUKSF5N2QySYPutbZkw4SmJwCIIJIXIYSz/8uf2BEDXAWAosN/w7gUhAHwhge7GY2wGBKFtf5oMGKgcl1Cx/wKwKKQY2hWB3oHbqver7ab6J8t/2L9VbaR6sM8auk4gArlRNbBchQnSaBw5RyV7lRCAgSYCerS/otRZwqiMmSECc7x/9XNUDkCvAyB5AAwDtrlBQgG8KegCOsvolQgrgPKcQKTQSReBhOCquBP3a8LTToXF/vpY8ls2J6AdBFH/rNJfov4YDoL6UzVP5gDc8MBJBFbBnwHrWW08EEcqrvhw+5oNBZZ//bMLBCDqb7kAcAJtUQeyOuQDcGIPnzFeJQClSbJqngBULW3xIzKpkBYe3wGxkISn/u5zASwccLbh5NHhht43ELsFcGeFXwfmA1UAdBsZ9YxU/ej+zDkwJ+RtO5Mkmhh9yc+637cKwJ79lxyAlP/kKcC1IqBzAJgL0K4AQwC0m7hgyAsBrAVEaL0HJU6SQKeiyT6dWictOwsTsqW+9ttosAax/pA3AKJBEqEhQLX+T+J2PG9GEIxEPPC6ag/SNzhOtm/fZo3JABYpfLT/KBFU+leUvxHNR37mSAAC/lYBUDkA76EgIYWOAHASKnXHm4/hwaB8pIxIV8oFFpxlziNws/0diSgF91bwuQQmE7QQ+2fUvwO+pf7KkXRA9db6W6QB1+KCHu1qMgTQE70DoTOG24/Y5qMuIEMOFYBXQ4FM++WjP2MnAFUClGTg5gCEAMhy4M4F7JNou/eZ0qBWELD7qO6D0uNkZXmEwKqb4HXI4wzAa8ejLTYSjb5mfXz8jgCvlP86YrhC/ZH4lfpSFU4SgAfMo88TZFxAlRgyY1aI4Iy2zQF87KfbBLCVAAP199YCaBJAV9AlnAxX0NqwnIBSrHSSziAPa/VeJt/ACMp0AY6l1+CNvofqb6h6NikoJMMUHN2apayZNt3YxRwAPa6Tb2iTXj4cVP2MwkdkUQFz5njsGt1tX/rTHghArwHY7P++DBhdwDanYCWgzgPIfh2TtfUB+6QcJhcBedfGUXoGwAaOyXhdKy4rC1rxPAtlymqfjP0x5h6ArVSdARJdiQa6BWC8t3h8RhQ616AnY+cEigRQdREWUZ1NDBnFz4I5Y+OroMf2y5f9VE4ACH50AS4B7OD28gDtxyEVgW6yOIQwWGlg/Uz8bQLXcBoa/AM56Dq8FcMbCTyx/o3ISF3fsvaMWPRv7JLEPht08nC4TyTDb5UNI1VnwO3coaHQFPBKxa0QwAO/G1LAucwA+2oHkDkny2Vs27/8pygCANUXF9D+h2CdC1CA334rcQf7Z7yxsp8qiFpBOKhPQAiW6jIlN9UdzllAKQBjdtxT9eF8HJLQ5xNae6Lska1nSu+pfyMjb3GOlxwEYrHANwA6sO/abdBxyRiPAf4ZoGf6WOA9y0Es/+YnAwHs4JfsP4v/JSEoTgD/is1veYFZEsB+xAp7gDEX0yRU2asQaHX2wD8QjEEsCDKt0pZqM2LpSqaiiNpteCW7mQSgukc4UTWxsH0Z8EaKT/erRGIW/E/pAo6AOdt35+Pxvwf/t0gA8BKQFfzZMiDmAYakoJ4oUB2gE4UtHDLiYQSa9bnsDEhJj4HfdBYHF/V4Vn8gvh3sh9Rfk60ot7c9Uf+Xc80AkDnCNGng+RrnzCa/RS6Z8zXBJDv0ORnf9bHY96Pbov7LV/ykMQfQrQMgVQABvP67//60BKgXA7UTU9Z/mDgk+TeAndjrBtpCBcEF9Wz23on7j1p9TW74mzaH4jgC/Vtri20uDdakzvIDbTL0y1I9Gx+V8CJHgNeTBfIMEXhjz5LDU5HB8pU/ccwByBOAXQ6AxP9sQVBL5EJGF8uByPYDCehJE1UGAuB7JKD3MadA22iFx9DCiPPpeZAFOZWyH46Jk2cDPiZFRX1IvI7XrMdg2fsOvCRsYGMM25QadgC8KAeQIg5BblAajOL26v5Z4DPrb6m95wKWf/cTxhwAPgJskQAu/aUhAIB5+22J9aelQa0uOuFFQoRBCY2Soc4PNBDBMQVAGJ50amqVI8kYOH4F3FTZsyU9EvuLMs4q/NBP3SNT1Y2FPQyQcs0RYYT7JxYTZQgiAmoE/Ki/8E80DgO+RQYe8Nvx/v2P3wng9updALgAyEoEYrY/ejS4katyBegG2OfOEqpSX7s4K0QohgVUpSft+5VgR7BFsb/nEkxScByD/s31pB2IIOMSIETRE9YLF0wiOGMtwcUu4EoyyIAe79uyEsDwIhAsBSrrT6sAuyJ0i4KU6p9CAkpl9boBNuHT7iCw9vThJBJfe8erKrt2IZZjoWSIcTkLCTwVt6oC6nojwLKYvuoWIsUf1DsZRljn7m3PAPcMBY/GqIK8YU/IHTYs/+HHKQLYAd+tBCQkMIQA7L0AQAxo8bbjI1MXPiOIqMJNOgIEly4HmvsUIaUA7oQ0tD/LuBsAzTqC7XosUnAy/MwBZADtKTl1fjhB2aT19j9RCHAGOWTGyII/Gyos//HHAgEo5c8kAbv4X6m+lRDEmy73EtViSEA5pcFOIVTSMHIEAgTLVuvVceXVeFWwO3F+ByIW5zuxv1ZRRqL6d2TK64E1Y/9dIiDWfVB3veqPEcEThAARcDNgPKtNdC6Dw/lPP+Z+fxcWAOHbgM2FQKDsQ/wP+7TSo+qzsiAqk1apLmGoVUor4kTpcCCDALzZen1EQpbNp+QEjgNdiZWxN8t4pCKQUXeLOChZOFacEoFxTmzsYRIjEZwQAnjjRwCL7Hu0PxofLnVc1IM7gzxGE96vWgkAHwUWF8AWAuGDQOyhIAQ/KwPu+9t5KmVvJwXtMHSgE9BQfU0g7oMy2g4byb9ZMFtkwUCMhNDtJ2VDDVoNLBoSEBLpQBYB18kPpElkv9HM1XRzwFB85gzw2BaArX4uoRRAFYG7up+RQYYgKm5i+aof/RACiPK39wAAEbB3ArSq3v4Bl//qpcAa8Nt3QhAM7N0FE7DTSWc4goEUAAwm8Ky1CNYCG69syWr/BJBWLkArvWflL1H/iDwE2I6dH0hKJkeyYtCRFYCThSdZYLuEwo6hCGwGlE9FBsNx//OP2gkAwwBJBBoVgK4SsE8KyQWwuJ8RAoIdCQJvpMXqVnlQA3z4TpRdjsHA1IEo6hss7JFzQQDQYwaE0AHAUmMrSWgAmJKomuRH7D8DmOVWGMAjgHb7T8oBeORR2XcFOcyMyfps2776C/ocwPr7df8rkEMC23xS/0uQLgVm3IBOAHYni1ldneHVcSMJKdbJEYYOQU7BDR+M8VMZeQZUY1tHVNYxlQJnQgJNKNbk9tzGAFovx0CWDXurDkPF1+MVcgBZhzDbbgaoVWdQsftNaIHcNwLQIYCQgCh9SwaC2jfgQ/lPg92qAnQnokIB6gCUcrlVAqNsZqqco+xMtTM2/FTwVxyBofAsvGGgNe25UxqskgxV+ETIkCaCAgFEzkLmqdXuqZ1ARBam6gMAl6/5kSoEUPYfwa/fBNSeBQBi2MZW7wRox8skBgnYTUfgKLeA11O4KDk3gJ0pWzI00BOYxuhOeU9fhwXWqdg/Io7MfuJKKNhBfRrAJisAFJgH1wF4oPYAF4HxyP6oLwN6xhls/f7Lj7jf5dHf9hdeBNoRgJH5L4UB+2TSpBDmBADsCG5U9izYq+Sg25uKqqsJhnJ64JdrcC13Mfan14tAdDL76MhM0qmOFdh2fRxGJBZQoycKI7BkQZ5tFx0v2h+BPw30BrhXH7bweCOA/eWf+kUgFvjxKcChGqAAbuYADCLQ4N5O14j9I/DjftcGe1UDpn7Ogh2LhCrHfyzw098Hwews/aVkkMzkD8qd7JciggNJQItUjoC0CuAjxMLOMzz3r/3h4ADgLcDM+ktOwKwC4HJg9ZmV/RoXWaGBUv1TiYABO8ofWLHwRDLPBd8JCn8quLMWPeMkiPozK5/dNpBCkAPIgnwWiLP9QqAqBc8of6rN1/3wh4VA8gRg9AxARwI7iFgJUCcAKwlBFg50lQIdDoCbMC1rpYKQrBygW+kUMcjkR+CsxvHus/sReCPQRvsR0A74rPCBnXtK6ZVTsdzgYwK+ovaVthE5zCi/8MnydZ+vQgC1AIiFARveINHnJQMbNlHlAbDbiTj7NBmUiYCoNqsiDBNUT+YjoHaSh3Lz3BDBcivedkaSjvqa8X2ypBe+QEQBVl9vBHrmCCi4H7EKcJban00GFcJYvv6H9UlA+i4AXAuAZT/1WWf/LdXv8G6VAQkxlMHPMsJFJ3CJylugstTaU2FPdT3wZpQ9UZ4LiYvU/TswJ1xDRsWZ88v0a0oIFjtDNt7YEQCPEEc0dnX/AwGQ2P9oDkDCAvld9XdP9dEV4I3tbpaenMZ3V2lIn0yCSlv0wyTh1Nkz9p6ppxVGoFU2VV/UOqn+6NKiMbtzdQgmcgRv1P/hJlXdw/C7/dcfajsAifeFDESU27MB+wa5jzoUaOB3LD4SA4v9NVF4LgAnd3ehgeozAHugHianEx6wCR+FG2YeA294whVQYtjvWQRUMw9BlDIkG7b6j4VmVrusOp9s/y0ncJX6R+POAD4kiI0A4L8BQ+Uf3gfg2H/2MBBTfdP+C7vAzdaPAFfIwLSERHVoIoqUBjNKm3EDGVIwx8kAOFLuaL86hkkkxcU/jDgrSh8CUhG9B6iMzc+0iUB7xO6H4EWszLqBb/ghJARgTwKytwI7OYAhBHBcQDYckOtlTmFYABIA3XILbCEJ3QaE1ampsRItHTbsF+mqqpUryCzZzYA/QzJJN+ICPLFqLwPCI/F/aXy5N4YjiRT6akB7BGmd2/INP/ghBGjJPwL+1QnIfGf2X8CuQ4GGEZXoO9UFEOdwhAxYDiCtXE79ngKh2t7LFWTAHwAbSTEKEby2kaqznEHUJ6XmCUJJjaPUdFbFK4CvtI2IprJ/+caVAHQSkD0ObL0MxCgJbnNNqb7+XlX+KATYLlwdky4NZVaRxY/ZcMGLZwNHkCaXCPwZ1bbOBZXNyS0wkJruSKmll1w9CsrHdACzZOBdYwWwYj7CcAhcijf+8o0/KHYAkgzs/u4Trqm+/g7gKYUDRNG7F4jKhTlAbz+SbgNjdz+g0S5yA0wFO5AQAnHVzwOoZ/vPAn8yMeclKSMlPwOspm1nhO2oeRZEM+0qgH8q9d/O8ZtWAig4AMGQuRDIWQ48JAUBkO3eRcDWuQSi+pETQOBSdpxQ/kjJI7IYljkrVXaBlajpZxbqeGrOQEDzGqA8OoywfvdqHP5+IICznEKFSDJOYhjvm35g0QEkFwIh2Bm4w3AgcAJ6MrV5R+y9BpcmCFQl+oOz8MByE0qNu/EK4UDkJBihWHF7Bvz4m5jAJct+I8Wn+6+I1a8YE0k4+OwBtaLwlbYZwIfjrQQwrP4jK/82+6+2y8q/IQmolR2SiNvvqFUc3x/A9jOwESfAgB6BnxGJFR6E9tWbhJ499ey9FUbIhDT6ejadAjwKMbSVtkgxY7kvAOuZjwFn1fvq0CACeAhucGPycejzzT9gdABYERheCLqDUQhh+0qeC2iYNcBvWf4wMWgQhE7+CdHoC04TAlFy0zkY6+41udAJkyANar8JKVIHEBFEspYfOZLIxofkmSEOr82B+H9WvWcIoALaStuILNj+bdtKAF4JUKu+uQpQx/5AFKj6NBwQeiLOYCCxKEegCELb++GHcCoCA2taYHXU0IrtXTJhjsd5kKcDpziDBEEgQZkkg+MBWVigiYjA/T3gZofjGI4kC+azwTszXgTaqwlgHX/5ls97tRRYVL2tADRCgUH1yYKgDofE4nc4VqDG/EGbE0ZiziMIF/yGYlCHYJEKKzviJLaOEWTbQ5CQpN9AAhcoP5JWGaBA8lmyKYHZI+FgldwMeLNhgncNlX0RWczufyAAWQqcjP2tCgACV+Z+t0RYAUmIpAOxEdtHTmDbTybBsHaAnIMmiuHmatcBk9m8iexcEgrqVgP2c6cxvFL+LMii2HkYJ5Er8H6TaeL4ANj/CKSPofiIowcH8P23COBGnwHQhOBVALxHg1l4kCED0mbIEVjqTIhk+4GT26dJIXAF0yGBQR4U6MR5ZNsNTkIRS0mVsa8ir+o4LnF4ZKvPYXKV3xWK/1o4gG/9/ioJKC8E9dyAAXaM75sDANDp+N8LA7p3CyjF1Y5B3xxKEsZ6AVo5SIDYZHMvGRUlqqLseLCSbzunpBVGMsy6hTA0icAWXf9sIjC45irZyPzKuJUjIH4KxR8cwLd+v50A1PMAmOzTnwXTYvkld7Bth5uM+9uBo3yAodKR8uP4HUEQ5dFtGYEM25QCDwQQqVAEzAgcQdx/JvipC4jICX50Cpxk/wzoorCkAsrM8WbHM0WCEGXU9qr9y0oAWwiglH8LCYz1/w3wqvznqr5BDhqsUwuEqg5BkUwHdgOI2yGsx02tHIHcaGd/pMQIbArMRF7hCGAwFMqAxWwTEdys+sO9zJzfjBuoKPVVba8lgGISsFsApElivyE45wdXADdNhwUdlkm8nnYCCeWXY+l439tecgvG5OxuZqSMjnPoJnwWYJETYUoenWOkaBP9M2C2yDML8my72fg/Am2FLKKxZvZvfb7t+77KAWxOwEj8NXUHp7DNb3QBCvwSAnSCq0MAQhiitugOcCzcbsX71qrAri9OXEY21nMGHUu9GnG4oQVncMg2Z8FPSDEFNMcVHemf6ssIidw3a6wsyM9oVwXhUQLwznkQMVIKbQRAV/45RKDJoAHcIQMhiwjUQwjQscer3hYh0BWBxhhCNCzej/ZZx9FuIsolHLbMFUWfAXIUviAY2ecKOUVjMTIoXH8EmAwhRSA/Cuoj/c255pHot33uQw6A5QFku5cLQGAjMSDmLCcw4BImixUaCDCZkntuwGtPCcABCx6nHBJkVDg7qSuvwEoAcQDIBPi9MTIAKyt59rcKyGWWHCr9IvJ4kv2NAII8gIC1Wwqs1wUAoi0yEABrx82UP+sGziCFDsgkHLDyBN1N80gjqCLg+CkQJOPqdn4BUOhEniENVJtE/2x8TduRa/IAmT1WBMSzxomO8yj7P/65r1YCotIPn0m8j28BFpVvwGdkoCRf2/gOd1k3MNgImIEEyBZZYEKJugVrHYEoi3EsTSzu5HEIZCCFyuQPnMIl4If7kgVMtt0hUkOCMj5XgVex7VM2XU3IlEAQxyPDdP0//n3GlYAh+FWs370OXBbbqWSfblNxAlbbsuUPyMLLBeA9YLafTZruB8+AO2vps+32650Flqem4b4T1d881oyreWICqJLL1e2XjQDkjUDkmX+d5WffEVeWE0CBNJU/qfq6f0eQBdVv/Qw1tdyCBWzGsDJGqBIZgiCAzjqK0kQ6A1hnjOGBNUEwIUmd5AAqxyndB0PFw7nkOAY9R5ePf+9XSUBGBAJudAVt234Ttn37xi4ESGyTE0rnAIBtBqwfAD/+Zl68r8nGdA3RykEsy2TtfJYkKsfWk+wM4GavJwnA2fj/CDCPgqzSPwoLov1HSOUVAeBKwGgtgJH80+AfbL8OC9A66Od0gFy0UiuCa+Sjt0cKboYQRGmHsR0w4vmGE0GRltk+AapuIlTbG9dcDh8mxpkCauL6wt/eUcojfY8AUiv0Wd+tc3ogAA/8xsKfDuykTVP2/YO1GlCLNnUCiii0Cpu7LUfgjUf2WTG/JgXLORwFtbkE2VLQRNKPTgiHjNKASBw7PZZ2J0Vnc+Q4ugsk6gAAG0BJREFUVVKKQH/muZxKCp/4Xv3DQGLn0fI3sEerAPVTghAaaFyllgcDi1Asq43t6yzwI2IIKgHiOFKWjZyjZ3XZBMuAOJqYbTJVwwuDfIb/l8FR2cy5VX6Ts0HmZdunz90i7eClJZnjZdoMv1EjAMcFbLiYAT+x8TpX0DCeAHPXxAA5XTug7YiW7on9NPYPwgLtEEKiSNjcTg2y4YSehCeBv+xUZid98ne5khCmwHaQDGeOGfVZVgKwqgAiiBH4U2XAfTCco1qxNcAZxiOAm+J/kSvwEoYU4Anl325ath0hr5BYNPDYq9Sr4LzY+reJfBZZVa/vhPYRGGf2Z/p4bZZPfM++CmCFAF4YIETR/upnApw3AqUJAQ4ShQPD/ovA3wjdANDwwxvKZbVjN45uSwI427eqnIywpsbIKOT7iAAy4Ix+p5kxMn2kzSsCCKoA+AiwJoOOAJTtF8vPSAK3NSFLhAJdPwLuTKiwHc8jhsx+1YaGBSRxJdeadQgWETBVTJNG0mVEE3TbXww9yg6lmPzL/gapawNSitpXgIdcF40783tlzmUd94EAEiVAuc8m+HWOoCH61fxAy19R/mplAElHicqrryeD3wM1fVkpm1gBkOgxHEV0gZA4VnpiFlQ5MzHNNoXjpM+9APBozKuI59BvpgAwJgE/B0KA6CWgrP7vZP4bWcBJZJYEI1FYQuzlAtw8gTFg2jXs12I+diz7gQA9tu/2GaRkOQvrfYapiZgNR6znyMn1zQCkpG7GOZfG0PenQAAZIM6cS2bcq9osnxAC0C6AgH14+Ie9EIQQwoY5FRo0HAbbKY5In3Yf2QtHEGVWiGEAVhHow1cHPHgeJnAZqAIll3GrSUdKBkdyBmQF41WTsxv3LMK6mAAe5bdwSKt6/AcCMEIAmevrbz88A7Dv1CofVQQ66w9ftAJrMdSuAHD46ucIiEGDeRDcKCwgB43KgZYa47l4biIav0QyybjfOufhWGcRiQHK7nivKQFUATcQ+Ylgnhl7+cT3sEOARgDO038dATjZ/w74AKTM9q05AScjBY8YEHRVy4/Kr4mEKZXbRnaSa/IAvR3HISk3CZkkr3AMOPeM3c2SiTtWAfyzgDyz3+xYZ/6e6XPoCMBZ9tuAboB8cALKIbT5x54H2CeVBrkGOHUFHjFQNlBJ6wnVZ+AWgogA3Fg6cVymuJ1zME/kYQdT0CwgXTUpEFdmUodtCgQQjrVf2NXtMuNn2lTu18x4rxyACgO8sp+n+ts+A+Rs+a+0Z1jFfXS/ASLLGQxjJEAYlgpn1FwdN0UazloDD6wR4aQVH4GTPP+ZCUkn/MmhxtWgsu7H7O9x5fkun/hsFQKw5B+AGsGfjfc9UrDIYjukmmjatlv4taoAFduvyccFWYJIvOSdFvIo7s8Avps0ScBaE606VoVUdFvL9byO4Inc2PvhnEcC2CfL+mf7p+P//ar1dgTsEA7AmJ1gFrZ36k36tXEjV8CshFwT3tEsqBPt2rDQNqX68GNl2kfEUQGmpcQR+VSOkQJIQf2vUMorxkxdd1R+hbl6aLzmAMhCnuEZAKPmrxW+EYAFcGtpsLM9dATgUrSiMvLQbSruYArQCaKIAJxyCjgxnGN6hGLuyy55npicFuEcJZSjAD7aPwvOK46TGfPBAej4nz3959T8B8VXYMR5aK4HIACOLD8DLZvzlp2nZiAB1G1+J9pVbD8jrdR6Awts5PymQL+Pf6j6EBCCNVHN/7iV/lgq6XkWCcn1k2NmwX2UxLLHyQBeLkPGXD7x3cccQGbdP1P9UPmt5CAAqiMLOVvD8re2XkjggHXASALUWfAzl4BzKLT0wblk+kdt0vuNc6lMbBPkhtU9tMpRgfUogGaApfmi8lsdPd9S/44ASLyPQEelZwlATQqIPU/56ctB1MtEGI61slP1NybvU4LfELBXmxMZfzZGxnGkQY8HgB9rxkVM9XkK0imqfYUYqgRYAnHBEelxXzkAJwcg4EOFz9p+5hSasBPlZuGCMgIPIkwmiN50RjWg+22zDsFxHRnwR21cEKtzjADvTUx0OzMgjsY2VbEI/iq4ps+L3JiKslfPszJ2pS2exwMBZHMA+8Re709HAGxxELTtnACgWZNIa5ew/APY9c0xngno+qlBXHxfDP7tBlaOwSZjsn+GFLZJciAMOUQYRQI4dKxHBvWVJDAz9vKJz4rXAYjidiHA/sPRtQDWE4LGOwIt1e+2KxvgEsD7DPyotNPqXwQNO84ApIkxI3IJwXryMcPjnUAAVeCd1f6MaxsJgNX9WXjgKbzlCIwyX7vn3jJhpZCUAGBjRBCKTzjukoraOlfbp04iooTk04mFic4I6QiwvQkvp+XlL44cewYkZwF0uDZ1D2Ztu76VR8ZZPv5ZDxpOwwDr+X9P4ZV9b66B2HodRmgXnHEGrc8Tgz98B4GF4wJp0Bud7B+BqDu9fcxMn6hNaT+5llL/IsnNkMNMn9eZUDYC0M/5I2jXzxqowzaw9l1bZzsCl1p9I1zQJCHkhffeVH+HJBgA9HwysZYE4TA/Z/sZziECi+clPAXOKg62y5xLFHJMjZFU2ciVnA30GRJ4jD7Lxz/zVQ5AwFVa/rt3osAv5gIQ3A+25OFuenbefV6AlBLZeBb4U/hMNSLQC8gonPyzx7Xq7gapyObwfKJx4SfIOJmzjveYQM78VlW7PktU2eseCSCI9wegW5Y/SQwakDpksPYLM1juofVTQHFxE71NKGkJQmyGDTyt9qsFGeCYo8N5ZcfJtnMnsvo9smNm2mWBUHU50bFnjvvYY67H6wiAvvLLyQPgk3xWqKCFRZSdAbdti5KBilws8YrcAd70cgxfJYtAYQPI97uPEog62DbxCmNGE7UKJjx2duwz2kVjXLl/hiAihzEz5isCCFYByhzRCj0A37H92xjE1neuwtmP/V1nQBYKWfMbQ40MCKvtD5EMO6ErgBqMGQGBnWa6z37sdPujoUYUipy4f9a+R0A/c9zl277bXgXYRQABjsDUIK0Anym7DiW0m2CCaS0ZHsggafuzYO6GSwCQNkn0CwnojDESYUwFjDjcTL9osVHZTTwigCMgvu77txCAEkCy7s9IAcHI3IIGNoJwIAV0ppmwYD+4xgn9HoCpAuIQl0aDsF9nH0J6KDWo2v5DKk86zxy/QjCZtq9Tm+hcrtq/EUCn9M4LQIYwYL+x5mpABUgK8H0jgmH47IC/U38Sl1fBnwV+GryzuYILwd+GTl5ENPmyzNONkzx2xg7PklP2ujLtHqtNdJxov3YljQBEibW1t7Y34CVW/Wngt3vv9MXxB4sPd5w5CBY+6PESTvihCUzU7JzF68uCwzrnSnKudCx1MZmJUxo/itWTP+bMeWX7PEW7s46ZGSdq00IA+uYfou4DkEG9vX2W7Weqz8gBccjcAQNPRfnNuUjcCQPB6a7BZIMqBI32SfBVjhZNtm6sxPFL48HglX5XtM2OeWa7zFhWm+VbP6NPAgrYXOX3VH8fwFT9qEqg+rvq76izRxQZfEVlQXcOJ4nDBdgZY6TZKoZ6ZpLFo4iq8JZHj1Htf1X7K8bNjDnTZiCAyPLPxvs4LnUEiaW/HaifCPyReEXEkSGfM22/nO82OaKTTyP4QMOLQo/M5NdnfXWf6viZ9pk263Vm2m0hwOoAUK3NxUCBsrvEkFH9YI1AN3+zFYHki0M6UBog8bCDYcth0SUHOgW3pwxyAPiJ9wvMjp6Z7Gzsx+pXPU62/RntGgFYyt/IQVnS9au3DwHL6vc6RIjWASDIBntvOMvsSkAPwBZuuu0HQBuNUwUFPd+LwZ+diFc4kPSxyQ/52H2rx6u0z7bV7ZZvkRyAEddr694BP3IFmXyAE/NHlt8iAv2fjXju1wJ/Cvhq4AzOzDZO58y4mXxClUxObX/4IvqzyU547xqOjnGkf7VvpX2p7bd8eCIJKIpLXAFTfq322jl0feCOee00qC2HYIHfUt408GFgb26n5v0JawVmiOVUgHuDpX6E+GwqEzseLRcnXz3OzDVV+3jtl5UAEKAIOhO40WO+mZifOA5KBEG7DuCJhUADIcDkZPPUJIQDil21/dP4KXYsNs9g46HNgYGrkz1/UucRwHrMo+c527/abwwBdgLoSIAou1bjSNU98jD/81Ct/t7/IyAuRPocAH9F9be2pEM0x+l+tTEag03u11H55Zy2yTZzURUUH2xbBVDmcEfGfOy+yzfrEMBaCrzfTAbsiBwyYcGg/oSEAOu9sKi2oe2fUP3WJQnacN4XbH84lp6VB9xJZoKn25RPPD3yaQ2PAC5zEkfHP9I/03cjAAbgAegHFv9YBMEsPyqsPgcNbNaWgb+bh4QsNLHgjWV9Q4IxZoZFIubxghmWcRWZSVrgj/xwb8Df/VYZMEY/7hVjPBAAgIIqvKHGkfJ3Y0UEsl99+L4AaQcoxLmm593Z4Gfz2pvrw76kg5giBXIiV+EwHDdsEE336/efAaiZszzzuEfHWr7508k7ARXIEMjMGZhKnnkpKGnDxhu2ESWfAX8K0Jn/ZwBmgjn3E7Y/i5uIWDITM3uszFgdYV01cPVEgvZHwXP0dK46fmXc5Zs+nZcBN8BFqn10v7H8V5NMZ7kTVYHBoicBTMkgqaqhC3AaRHiJ9m8TccJZeBM4dUw2wIHrjABVmdjkJ2nDV8eJzuus/VeelzX2RgCDwnuLghxV74CbedQ3Uy5MvBQkUn53P7odreIJUFnzvdueGKdq+b3xLwF2NqE/zRxnweiDNc6VpLD+Uo0AGnjBWg92f6dVur2yNFhA59h4nEfb5+T6fw2MCPxU9ZV8mG3UXKNzn1yjnqIRZtz9RXIpinaIplkiCgd+08D9Bc4ihuUbMQRQkzXrDBAv4UNBcllR+IDK/Ejgb5MZZnVEIJ7V9J4M9EAdEUI7ZqZhVrkzZJawFslTegPvR/gFMiSxEYBW2PX7oPIROWTe+JsIHzoygS/6fDTwjiq/Bv8s8BmJAOfR2x6BxnMW1dDBIyxrTkbnt/VzGqX6PwIgjhxCX0MGXEeO9xh912t4IIAo5nfAj2o0kAaqeDLb341hHNcDf/QEoAvsI8lCA4nW5D/iAE5558ABxR/O/SDCD3a/DCuZ83q/E8HyDZ/mVAF2pCEoKcizdj5DJEIaVfAnlgJXwT/lApxS3wzoM2DLTNSK8mfHE+UvtS/A9apxM6fwlMeW81vJ5WrnsREAA/W2LQHsVMyfGKez/gr8Q1ignEXm8V8PzFXXYIHJUmY2mWbIwPq/EvWEzkzeTJuQNMgg2XEzIJwJb6rjHgp7zjrYI43D3MryX8EBWHZ+VvUtEmGAbseAGUSPWwT/2apvglntOAv0bRwDWRnAXdYmM/BkEvKpgZm8tEeC7nWH6QhgRvVdkColt9rKcT1ioC4gsP0V8LttjUnMwFkBvjXJhu2EFGcBEk3saL8cN5uHmD3PaMpnzzMax9v/GMc4cn5n9N0IANXXBWnmPQCi0Enwb8AO2mbAXwFw1fJXiKQBxLg7FYJAR8aGiyboZfvVwNFxMhN1ZoyZPplzie5hZYzXve3y9RICEBAOZJAEdQnQxpiuG3DWBWA//RnJhu5TdyskFTIDKwBPtU2qfwQGb3/Ut/utEo0TTUxczPSd6ZMF5pVjZ88hanfkHDcCiAC7HSAqFQJthi4icAlU8YMyImPtAcAOmLBtCHzCHikwR6GEvtMnVxQY6ZFD2vMt8TDTjFN5yj5Xgisa29t/BNSV4y5f/6nj04ADABNZfI8kqJor5XcVPwF+D7RybimSgF/PHDNQ5YhAPCC2vkl3EYF6VvlpP7VxZpJW+lTasntbAYLVduYcKse9evzoXJav+9RX6wBkMnUKfgH4U+VFDcTkcmANCAR/SBIF8M+CPOUUCDnijZwB9UyfDlSJmZpo0s3HTPtMm7McRMkNRcgK9s9e18HDDt03AugArx7qMfftQ0XKP+MmvD4U4HguhDi8PpV9mfUGTJFToJdrMGaGNWHO2u46iYCQjgAwC4RsuyxRZoA0c8xo3CvGjI7p3dvla4kD2Dqom06JIOsOEs8A4A9jOZCzwV9yBKpxBtSZNt01JY5h3cwzicA7p84VZGZech1AFhjZdjPneYTIop+iet7ReGed60YAFuBc9T8R/IPiF2N+Rh6RWtM+xEmIw/EmlEckacA6KnsGuL0JaO5LJv2ykztqF+2fBXV23LNApcc5cnyPCM4Yd/kv6ACyoM62q7wSTD+BaDiQlAuYLBNSIBeAGRGBSQbkTlZAf0bb4dySbqQ62TOTNtPGDVkIarJjnkkCR45Z/V1nHMPa5xUBwEQ/TfnhF3DHJC8TYa7gKPhLqg8Hi4Bd3W9ZbDZhzgB3ZYx2bs7szUzsqM3R/Y/pBqJzPZM0HgP4eD0bAaTi/WxeoBDvD6SQIAzG/K1bslJgEUF3o48+XUhi32EiFev8WYKYAjzOPBCDSFkicHj7o75Zlc+MQy4vurS2vzp+9ryvtveZ81i+5lPGMiBT3zRJ7J3Tig9UHvVxHYC6SxmQm22csVwC2q8lcgTbGGRWHQF4tq83KbYxjNkegWAW6NG4mUk84wYyx50Zt3K+FgFUzu2o+9gIIALeVeBHuxmdQxb8VeAP48IAEZCn9zvHsCZQFuDZdvQ4CeWPJudTE0F0fjNOoDLmEQKoHmfmWjRhLF8dOQA1KVygFpKDrwP4B7IwgDkNdOYIDJBlgXt2O7wPenJEE3IG7DN9qhM9Ou8rx5slgMo5zzoT5hY2AjBBfTL48cfZhs6+OhzOvANtArBpR5AA5mEiIHc5GjPrCLLEcIXyW5O3uj07sTNgybTJgjU7Vna8KtEebe/1X/6z5QAmwT+AnL1g9CD4hTzcsMAiDba9mPCLQEv3G2RlTfoMoDNtvEnZ+quBZlR6Buwzx7lCvTMAz7SZIYDsuFlyZCrvnddGAIMDCMDfgbxCFIkKgUcg2q6m1X3/VWj7yTUD7Ec1iSHhLrJEcAT0dLIVKxHRRKwSQQSAq/dH15PdX2030z76LRj4oz7LV2kHQJRqIAgB1GOD31DRChF0bR3lM8GcKO91fYvuwmJr73y8yeQSRlL5zwL1rOJHk/jo/oxyR8e4GtDZ41fPoyeAQhKvVBk4Q/kD8FdIYLvhCTLxQozIAWzDBwCLQB3tj87BnQwTyl8hgkrbzKSNAHD1/gxJZNtkrhfVPLo2rfyV9hsBlMH8RMpfBjn8MpbyZ8asEEEbT/1GFZWOgB/tD13EBcpfBfwVbiCa+FfvrwA7OpfKWLNksZ7D8p8+lFwI9AS2H1U0A1Rp47YlwLTaTwF/7xSB9Oj+I+pfeX15SCYGyWYm5etGAhlQPmabqxwFjrsRgAaO+f0k5ccTcI+dBGuaHJLjReByCSNQ16PAj/qHgIUBKqrN2h7tH6ncFQQRgSoCeLQ/Gj+65gxxasufPSZrt/zHrAN4jcCfBjyG4RPPCZQdgAOuCLgeqUSEFIIeZt0VQD46pjeBryCBCMRX788CNjqPCplYx9wIIHQAB8GfVvwT3gNAgTQBflflme0l7qJCIDMgzwCvtQmcSZpECi82rTiECBTVsWbHi/pl9kdtzgT20bGW/xA5gNcc/K4bOAh8D8DdD3/kPygplhVLoL9Q+TPnESlUFdTV9rPOIgLw0f1HQRv9rjpE8I63EYDpAF5D8LuAP2j5o7GpSkMn/UNXvlfaZtxCa3Oh8lcAWWk7C9yzjpEFmAes2X3ZY2dIKNNm+feWA3hC8FeASNuS9QxZNbeOTfur38i6edkxI2BnVFc7kyPWPnO8yvhntI0m9WOSwBGQRy7g6P4skWwEMDiASfDjzTFdxX5m3f4CYCNyyCzwicZIkQUBv6fiFYWvtDVB9cjKnyWLqrqfBehZsM4CcbZfFrjR+BFRynGWf6cdwCT4GahSJBCAPwJrtx++6GOnQK3icVO5T3p+oAL0qG13fYScvImVAW/p+CoIzYxfPb8qkUSAuIIgZseMzjWzP9NmPb+NABpYXgPwlwAPE02vZjwT8BHJsMn7ZG6AzLoMAM9qU7H5Z6j7GWNkVLd6nCwAFVe2r5HCn7V/+crVAVSeAUALbyjhrPJ7LsIC9NaHKN4lDsBQVtMpOI7CIyg2ebxjzKr/DOgzfSok8NhtI2CeCfQjID3SN7pG3L985cvEOgAE/ZFXfSceCio7AMO1uIShriflFhySqQL2DMKgx0yofwbAnnupALYCpsx5PUaY8H4ILSoAjxzG8hUvi88C7Ee3VB5PjrZJuA02BgVp4EBSwM7E/cn1BBVV90A2tQ86RQCOCCuz/ygRZAF/lETOBLSnypXz9Igssy8igIp7WP7tTgAhcCfVuyOBE8DfLq4A/shVuERhAGsKpBeFBNH/gmRNqogoov2PRQJHj/MYJDBDDkeAPHs8fcxGAJaiVwHMwLZtS4Df7Kst+8HKgQX44fj7hizYz24XKbH8rmjzItAe3R+dU9WmZ53AB5UEZoE8228ggH+TdQAFADMgpQhGAZ0SAlHkSOGj/VZ4MRNCZPvMtuv6JQgqA9gqKWTBmAV3tl32uGcpvgWy6vZZpT8L5CgQlAA85a2qtwZ6RflDB5AEfwT4aL+21Fb7LIhn+kfAzfzHIhVgR22j8zmq/BVQZc61SgKV41fH9n6bWXI4q9/y5SoJiAMfBb9Xm7ccwXB8cQVE7QayIW8groI0s5KwOmYEHm9Cm/suUP+MEp/V5oiaV8B6VdsZEphR9Jk+FXLYCMAE0oTtb2OpCZoBq+kAjLFMsgDP4x33TOsfugohMnJuEUEM56lmRaSIV+/PnP8RwGfHrxzjyrZnksPlBPBlRhlwxrpnwW8CnWXJC0RymBCS5b4zwV5Wf+hwBNhH+lqW9rHdwVF1P9r/dQZ6ljiWlQC0SjIbPLRRilYFv0cC7Yc9WOrLAFWf94y9n+ljnZurdie8YnzquMS9PAUJHAVshqCs63oMsFeuzzvPaB8eZ/lS7QCU4jJVNckgUGurH1XuiVJfilSYFTdUtUIgR0nA67/tU7OjouBll2GEKVnQZ4EWXUPFps8es3KM15EEskoPt3T7KP02AojUO0UCk+CnoCWAzII7Au2w3yG8o6COzoUBioKCnKPrFBjJqRlQcQLVY2WJIjNuBaCvIwlUVX0G0NVjdATwMXEAAYBdEnhC8Ecgc/efGPNH5xFNdhOQRdt/ptpHCh3tj675CFE8JTFUjv2UriFz7GUlgOp/DNKRwUHwdxPfUeMjDoCCq5BfOOoEZvpr2x+BLavolXEyAM6obnTMzHEqoMuc09HxKv2rbTPAVYZO/ydUbXfkKP4/BnecprBuissAAAAASUVORK5CYII=";
  97957. return TextureTools;
  97958. }());
  97959. /***/ }),
  97960. /***/ "./Misc/tga.ts":
  97961. /*!*********************!*\
  97962. !*** ./Misc/tga.ts ***!
  97963. \*********************/
  97964. /*! exports provided: TGATools */
  97965. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97966. "use strict";
  97967. __webpack_require__.r(__webpack_exports__);
  97968. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return TGATools; });
  97969. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  97970. /**
  97971. * Based on jsTGALoader - Javascript loader for TGA file
  97972. * By Vincent Thibault
  97973. * @see http://blog.robrowser.com/javascript-tga-loader.html
  97974. */
  97975. var TGATools = /** @class */ (function () {
  97976. function TGATools() {
  97977. }
  97978. /**
  97979. * Gets the header of a TGA file
  97980. * @param data defines the TGA data
  97981. * @returns the header
  97982. */
  97983. TGATools.GetTGAHeader = function (data) {
  97984. var offset = 0;
  97985. var header = {
  97986. id_length: data[offset++],
  97987. colormap_type: data[offset++],
  97988. image_type: data[offset++],
  97989. colormap_index: data[offset++] | data[offset++] << 8,
  97990. colormap_length: data[offset++] | data[offset++] << 8,
  97991. colormap_size: data[offset++],
  97992. origin: [
  97993. data[offset++] | data[offset++] << 8,
  97994. data[offset++] | data[offset++] << 8
  97995. ],
  97996. width: data[offset++] | data[offset++] << 8,
  97997. height: data[offset++] | data[offset++] << 8,
  97998. pixel_size: data[offset++],
  97999. flags: data[offset++]
  98000. };
  98001. return header;
  98002. };
  98003. /**
  98004. * Uploads TGA content to a Babylon Texture
  98005. * @hidden
  98006. */
  98007. TGATools.UploadContent = function (texture, data) {
  98008. // Not enough data to contain header ?
  98009. if (data.length < 19) {
  98010. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data to contain header");
  98011. return;
  98012. }
  98013. // Read Header
  98014. var offset = 18;
  98015. var header = TGATools.GetTGAHeader(data);
  98016. // Assume it's a valid Targa file.
  98017. if (header.id_length + offset > data.length) {
  98018. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data");
  98019. return;
  98020. }
  98021. // Skip not needed data
  98022. offset += header.id_length;
  98023. var use_rle = false;
  98024. var use_pal = false;
  98025. var use_grey = false;
  98026. // Get some informations.
  98027. switch (header.image_type) {
  98028. case TGATools._TYPE_RLE_INDEXED:
  98029. use_rle = true;
  98030. case TGATools._TYPE_INDEXED:
  98031. use_pal = true;
  98032. break;
  98033. case TGATools._TYPE_RLE_RGB:
  98034. use_rle = true;
  98035. case TGATools._TYPE_RGB:
  98036. // use_rgb = true;
  98037. break;
  98038. case TGATools._TYPE_RLE_GREY:
  98039. use_rle = true;
  98040. case TGATools._TYPE_GREY:
  98041. use_grey = true;
  98042. break;
  98043. }
  98044. var pixel_data;
  98045. // var numAlphaBits = header.flags & 0xf;
  98046. var pixel_size = header.pixel_size >> 3;
  98047. var pixel_total = header.width * header.height * pixel_size;
  98048. // Read palettes
  98049. var palettes;
  98050. if (use_pal) {
  98051. palettes = data.subarray(offset, offset += header.colormap_length * (header.colormap_size >> 3));
  98052. }
  98053. // Read LRE
  98054. if (use_rle) {
  98055. pixel_data = new Uint8Array(pixel_total);
  98056. var c, count, i;
  98057. var localOffset = 0;
  98058. var pixels = new Uint8Array(pixel_size);
  98059. while (offset < pixel_total && localOffset < pixel_total) {
  98060. c = data[offset++];
  98061. count = (c & 0x7f) + 1;
  98062. // RLE pixels
  98063. if (c & 0x80) {
  98064. // Bind pixel tmp array
  98065. for (i = 0; i < pixel_size; ++i) {
  98066. pixels[i] = data[offset++];
  98067. }
  98068. // Copy pixel array
  98069. for (i = 0; i < count; ++i) {
  98070. pixel_data.set(pixels, localOffset + i * pixel_size);
  98071. }
  98072. localOffset += pixel_size * count;
  98073. }
  98074. // Raw pixels
  98075. else {
  98076. count *= pixel_size;
  98077. for (i = 0; i < count; ++i) {
  98078. pixel_data[localOffset + i] = data[offset++];
  98079. }
  98080. localOffset += count;
  98081. }
  98082. }
  98083. }
  98084. // RAW Pixels
  98085. else {
  98086. pixel_data = data.subarray(offset, offset += (use_pal ? header.width * header.height : pixel_total));
  98087. }
  98088. // Load to texture
  98089. var x_start, y_start, x_step, y_step, y_end, x_end;
  98090. switch ((header.flags & TGATools._ORIGIN_MASK) >> TGATools._ORIGIN_SHIFT) {
  98091. default:
  98092. case TGATools._ORIGIN_UL:
  98093. x_start = 0;
  98094. x_step = 1;
  98095. x_end = header.width;
  98096. y_start = 0;
  98097. y_step = 1;
  98098. y_end = header.height;
  98099. break;
  98100. case TGATools._ORIGIN_BL:
  98101. x_start = 0;
  98102. x_step = 1;
  98103. x_end = header.width;
  98104. y_start = header.height - 1;
  98105. y_step = -1;
  98106. y_end = -1;
  98107. break;
  98108. case TGATools._ORIGIN_UR:
  98109. x_start = header.width - 1;
  98110. x_step = -1;
  98111. x_end = -1;
  98112. y_start = 0;
  98113. y_step = 1;
  98114. y_end = header.height;
  98115. break;
  98116. case TGATools._ORIGIN_BR:
  98117. x_start = header.width - 1;
  98118. x_step = -1;
  98119. x_end = -1;
  98120. y_start = header.height - 1;
  98121. y_step = -1;
  98122. y_end = -1;
  98123. break;
  98124. }
  98125. // Load the specify method
  98126. var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
  98127. var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
  98128. var engine = texture.getEngine();
  98129. engine._uploadDataToTextureDirectly(texture, imageData);
  98130. };
  98131. /** @hidden */
  98132. TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98133. var image = pixel_data, colormap = palettes;
  98134. var width = header.width, height = header.height;
  98135. var color, i = 0, x, y;
  98136. var imageData = new Uint8Array(width * height * 4);
  98137. for (y = y_start; y !== y_end; y += y_step) {
  98138. for (x = x_start; x !== x_end; x += x_step, i++) {
  98139. color = image[i];
  98140. imageData[(x + width * y) * 4 + 3] = 255;
  98141. imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
  98142. imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
  98143. imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
  98144. }
  98145. }
  98146. return imageData;
  98147. };
  98148. /** @hidden */
  98149. TGATools._getImageData16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98150. var image = pixel_data;
  98151. var width = header.width, height = header.height;
  98152. var color, i = 0, x, y;
  98153. var imageData = new Uint8Array(width * height * 4);
  98154. for (y = y_start; y !== y_end; y += y_step) {
  98155. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  98156. color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
  98157. var r = (((color & 0x7C00) >> 10) * 255) / 0x1F | 0;
  98158. var g = (((color & 0x03E0) >> 5) * 255) / 0x1F | 0;
  98159. var b = ((color & 0x001F) * 255) / 0x1F | 0;
  98160. imageData[(x + width * y) * 4 + 0] = r;
  98161. imageData[(x + width * y) * 4 + 1] = g;
  98162. imageData[(x + width * y) * 4 + 2] = b;
  98163. imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
  98164. }
  98165. }
  98166. return imageData;
  98167. };
  98168. /** @hidden */
  98169. TGATools._getImageData24bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98170. var image = pixel_data;
  98171. var width = header.width, height = header.height;
  98172. var i = 0, x, y;
  98173. var imageData = new Uint8Array(width * height * 4);
  98174. for (y = y_start; y !== y_end; y += y_step) {
  98175. for (x = x_start; x !== x_end; x += x_step, i += 3) {
  98176. imageData[(x + width * y) * 4 + 3] = 255;
  98177. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  98178. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  98179. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  98180. }
  98181. }
  98182. return imageData;
  98183. };
  98184. /** @hidden */
  98185. TGATools._getImageData32bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98186. var image = pixel_data;
  98187. var width = header.width, height = header.height;
  98188. var i = 0, x, y;
  98189. var imageData = new Uint8Array(width * height * 4);
  98190. for (y = y_start; y !== y_end; y += y_step) {
  98191. for (x = x_start; x !== x_end; x += x_step, i += 4) {
  98192. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  98193. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  98194. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  98195. imageData[(x + width * y) * 4 + 3] = image[i + 3];
  98196. }
  98197. }
  98198. return imageData;
  98199. };
  98200. /** @hidden */
  98201. TGATools._getImageDataGrey8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98202. var image = pixel_data;
  98203. var width = header.width, height = header.height;
  98204. var color, i = 0, x, y;
  98205. var imageData = new Uint8Array(width * height * 4);
  98206. for (y = y_start; y !== y_end; y += y_step) {
  98207. for (x = x_start; x !== x_end; x += x_step, i++) {
  98208. color = image[i];
  98209. imageData[(x + width * y) * 4 + 0] = color;
  98210. imageData[(x + width * y) * 4 + 1] = color;
  98211. imageData[(x + width * y) * 4 + 2] = color;
  98212. imageData[(x + width * y) * 4 + 3] = 255;
  98213. }
  98214. }
  98215. return imageData;
  98216. };
  98217. /** @hidden */
  98218. TGATools._getImageDataGrey16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98219. var image = pixel_data;
  98220. var width = header.width, height = header.height;
  98221. var i = 0, x, y;
  98222. var imageData = new Uint8Array(width * height * 4);
  98223. for (y = y_start; y !== y_end; y += y_step) {
  98224. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  98225. imageData[(x + width * y) * 4 + 0] = image[i + 0];
  98226. imageData[(x + width * y) * 4 + 1] = image[i + 0];
  98227. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  98228. imageData[(x + width * y) * 4 + 3] = image[i + 1];
  98229. }
  98230. }
  98231. return imageData;
  98232. };
  98233. //private static _TYPE_NO_DATA = 0;
  98234. TGATools._TYPE_INDEXED = 1;
  98235. TGATools._TYPE_RGB = 2;
  98236. TGATools._TYPE_GREY = 3;
  98237. TGATools._TYPE_RLE_INDEXED = 9;
  98238. TGATools._TYPE_RLE_RGB = 10;
  98239. TGATools._TYPE_RLE_GREY = 11;
  98240. TGATools._ORIGIN_MASK = 0x30;
  98241. TGATools._ORIGIN_SHIFT = 0x04;
  98242. TGATools._ORIGIN_BL = 0x00;
  98243. TGATools._ORIGIN_BR = 0x01;
  98244. TGATools._ORIGIN_UL = 0x02;
  98245. TGATools._ORIGIN_UR = 0x03;
  98246. return TGATools;
  98247. }());
  98248. /***/ }),
  98249. /***/ "./Misc/tools.ts":
  98250. /*!***********************!*\
  98251. !*** ./Misc/tools.ts ***!
  98252. \***********************/
  98253. /*! exports provided: ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop */
  98254. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98255. "use strict";
  98256. __webpack_require__.r(__webpack_exports__);
  98257. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return ColorGradient; });
  98258. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return Color3Gradient; });
  98259. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return FactorGradient; });
  98260. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return LoadFileError; });
  98261. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return RetryStrategy; });
  98262. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return Tools; });
  98263. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return PerfCounter; });
  98264. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "className", function() { return className; });
  98265. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return AsyncLoop; });
  98266. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  98267. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  98268. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  98269. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  98270. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  98271. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  98272. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  98273. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  98274. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  98275. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  98276. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  98277. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  98278. /** Class used to store color4 gradient */
  98279. var ColorGradient = /** @class */ (function () {
  98280. function ColorGradient() {
  98281. }
  98282. /**
  98283. * Will get a color picked randomly between color1 and color2.
  98284. * If color2 is undefined then color1 will be used
  98285. * @param result defines the target Color4 to store the result in
  98286. */
  98287. ColorGradient.prototype.getColorToRef = function (result) {
  98288. if (!this.color2) {
  98289. result.copyFrom(this.color1);
  98290. return;
  98291. }
  98292. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].LerpToRef(this.color1, this.color2, Math.random(), result);
  98293. };
  98294. return ColorGradient;
  98295. }());
  98296. /** Class used to store color 3 gradient */
  98297. var Color3Gradient = /** @class */ (function () {
  98298. function Color3Gradient() {
  98299. }
  98300. return Color3Gradient;
  98301. }());
  98302. /** Class used to store factor gradient */
  98303. var FactorGradient = /** @class */ (function () {
  98304. function FactorGradient() {
  98305. }
  98306. /**
  98307. * Will get a number picked randomly between factor1 and factor2.
  98308. * If factor2 is undefined then factor1 will be used
  98309. * @returns the picked number
  98310. */
  98311. FactorGradient.prototype.getFactor = function () {
  98312. if (this.factor2 === undefined) {
  98313. return this.factor1;
  98314. }
  98315. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Lerp(this.factor1, this.factor2, Math.random());
  98316. };
  98317. return FactorGradient;
  98318. }());
  98319. /**
  98320. * @ignore
  98321. * Application error to support additional information when loading a file
  98322. */
  98323. var LoadFileError = /** @class */ (function (_super) {
  98324. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LoadFileError, _super);
  98325. /**
  98326. * Creates a new LoadFileError
  98327. * @param message defines the message of the error
  98328. * @param request defines the optional XHR request
  98329. */
  98330. function LoadFileError(message,
  98331. /** defines the optional XHR request */
  98332. request) {
  98333. var _this = _super.call(this, message) || this;
  98334. _this.request = request;
  98335. _this.name = "LoadFileError";
  98336. LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
  98337. return _this;
  98338. }
  98339. // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
  98340. // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  98341. // Polyfill for Object.setPrototypeOf if necessary.
  98342. LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
  98343. return LoadFileError;
  98344. }(Error));
  98345. /**
  98346. * Class used to define a retry strategy when error happens while loading assets
  98347. */
  98348. var RetryStrategy = /** @class */ (function () {
  98349. function RetryStrategy() {
  98350. }
  98351. /**
  98352. * Function used to defines an exponential back off strategy
  98353. * @param maxRetries defines the maximum number of retries (3 by default)
  98354. * @param baseInterval defines the interval between retries
  98355. * @returns the strategy function to use
  98356. */
  98357. RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
  98358. if (maxRetries === void 0) { maxRetries = 3; }
  98359. if (baseInterval === void 0) { baseInterval = 500; }
  98360. return function (url, request, retryIndex) {
  98361. if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
  98362. return -1;
  98363. }
  98364. return Math.pow(2, retryIndex) * baseInterval;
  98365. };
  98366. };
  98367. return RetryStrategy;
  98368. }());
  98369. // Screenshots
  98370. var screenshotCanvas;
  98371. /**
  98372. * Class containing a set of static utilities functions
  98373. */
  98374. var Tools = /** @class */ (function () {
  98375. function Tools() {
  98376. }
  98377. /**
  98378. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98379. * @param u defines the coordinate on X axis
  98380. * @param v defines the coordinate on Y axis
  98381. * @param width defines the width of the source data
  98382. * @param height defines the height of the source data
  98383. * @param pixels defines the source byte array
  98384. * @param color defines the output color
  98385. */
  98386. Tools.FetchToRef = function (u, v, width, height, pixels, color) {
  98387. var wrappedU = ((Math.abs(u) * width) % width) | 0;
  98388. var wrappedV = ((Math.abs(v) * height) % height) | 0;
  98389. var position = (wrappedU + wrappedV * width) * 4;
  98390. color.r = pixels[position] / 255;
  98391. color.g = pixels[position + 1] / 255;
  98392. color.b = pixels[position + 2] / 255;
  98393. color.a = pixels[position + 3] / 255;
  98394. };
  98395. /**
  98396. * Interpolates between a and b via alpha
  98397. * @param a The lower value (returned when alpha = 0)
  98398. * @param b The upper value (returned when alpha = 1)
  98399. * @param alpha The interpolation-factor
  98400. * @return The mixed value
  98401. */
  98402. Tools.Mix = function (a, b, alpha) {
  98403. return a * (1 - alpha) + b * alpha;
  98404. };
  98405. /**
  98406. * Tries to instantiate a new object from a given class name
  98407. * @param className defines the class name to instantiate
  98408. * @returns the new object or null if the system was not able to do the instantiation
  98409. */
  98410. Tools.Instantiate = function (className) {
  98411. if (Tools.RegisteredExternalClasses && Tools.RegisteredExternalClasses[className]) {
  98412. return Tools.RegisteredExternalClasses[className];
  98413. }
  98414. var internalClass = _typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass(className);
  98415. if (internalClass) {
  98416. return internalClass;
  98417. }
  98418. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(className + " not found, you may have missed an import.");
  98419. var arr = className.split(".");
  98420. var fn = (window || this);
  98421. for (var i = 0, len = arr.length; i < len; i++) {
  98422. fn = fn[arr[i]];
  98423. }
  98424. if (typeof fn !== "function") {
  98425. return null;
  98426. }
  98427. return fn;
  98428. };
  98429. /**
  98430. * Provides a slice function that will work even on IE
  98431. * @param data defines the array to slice
  98432. * @param start defines the start of the data (optional)
  98433. * @param end defines the end of the data (optional)
  98434. * @returns the new sliced array
  98435. */
  98436. Tools.Slice = function (data, start, end) {
  98437. if (data.slice) {
  98438. return data.slice(start, end);
  98439. }
  98440. return Array.prototype.slice.call(data, start, end);
  98441. };
  98442. /**
  98443. * Polyfill for setImmediate
  98444. * @param action defines the action to execute after the current execution block
  98445. */
  98446. Tools.SetImmediate = function (action) {
  98447. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && window.setImmediate) {
  98448. window.setImmediate(action);
  98449. }
  98450. else {
  98451. setTimeout(action, 1);
  98452. }
  98453. };
  98454. /**
  98455. * Function indicating if a number is an exponent of 2
  98456. * @param value defines the value to test
  98457. * @returns true if the value is an exponent of 2
  98458. */
  98459. Tools.IsExponentOfTwo = function (value) {
  98460. var count = 1;
  98461. do {
  98462. count *= 2;
  98463. } while (count < value);
  98464. return count === value;
  98465. };
  98466. /**
  98467. * Returns the nearest 32-bit single precision float representation of a Number
  98468. * @param value A Number. If the parameter is of a different type, it will get converted
  98469. * to a number or to NaN if it cannot be converted
  98470. * @returns number
  98471. */
  98472. Tools.FloatRound = function (value) {
  98473. if (Math.fround) {
  98474. return Math.fround(value);
  98475. }
  98476. return (Tools._tmpFloatArray[0] = value);
  98477. };
  98478. /**
  98479. * Find the next highest power of two.
  98480. * @param x Number to start search from.
  98481. * @return Next highest power of two.
  98482. */
  98483. Tools.CeilingPOT = function (x) {
  98484. x--;
  98485. x |= x >> 1;
  98486. x |= x >> 2;
  98487. x |= x >> 4;
  98488. x |= x >> 8;
  98489. x |= x >> 16;
  98490. x++;
  98491. return x;
  98492. };
  98493. /**
  98494. * Find the next lowest power of two.
  98495. * @param x Number to start search from.
  98496. * @return Next lowest power of two.
  98497. */
  98498. Tools.FloorPOT = function (x) {
  98499. x = x | (x >> 1);
  98500. x = x | (x >> 2);
  98501. x = x | (x >> 4);
  98502. x = x | (x >> 8);
  98503. x = x | (x >> 16);
  98504. return x - (x >> 1);
  98505. };
  98506. /**
  98507. * Find the nearest power of two.
  98508. * @param x Number to start search from.
  98509. * @return Next nearest power of two.
  98510. */
  98511. Tools.NearestPOT = function (x) {
  98512. var c = Tools.CeilingPOT(x);
  98513. var f = Tools.FloorPOT(x);
  98514. return (c - x) > (x - f) ? f : c;
  98515. };
  98516. /**
  98517. * Get the closest exponent of two
  98518. * @param value defines the value to approximate
  98519. * @param max defines the maximum value to return
  98520. * @param mode defines how to define the closest value
  98521. * @returns closest exponent of two of the given value
  98522. */
  98523. Tools.GetExponentOfTwo = function (value, max, mode) {
  98524. if (mode === void 0) { mode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST; }
  98525. var pot;
  98526. switch (mode) {
  98527. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_FLOOR:
  98528. pot = Tools.FloorPOT(value);
  98529. break;
  98530. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST:
  98531. pot = Tools.NearestPOT(value);
  98532. break;
  98533. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_CEILING:
  98534. default:
  98535. pot = Tools.CeilingPOT(value);
  98536. break;
  98537. }
  98538. return Math.min(pot, max);
  98539. };
  98540. /**
  98541. * Extracts the filename from a path
  98542. * @param path defines the path to use
  98543. * @returns the filename
  98544. */
  98545. Tools.GetFilename = function (path) {
  98546. var index = path.lastIndexOf("/");
  98547. if (index < 0) {
  98548. return path;
  98549. }
  98550. return path.substring(index + 1);
  98551. };
  98552. /**
  98553. * Extracts the "folder" part of a path (everything before the filename).
  98554. * @param uri The URI to extract the info from
  98555. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98556. * @returns The "folder" part of the path
  98557. */
  98558. Tools.GetFolderPath = function (uri, returnUnchangedIfNoSlash) {
  98559. if (returnUnchangedIfNoSlash === void 0) { returnUnchangedIfNoSlash = false; }
  98560. var index = uri.lastIndexOf("/");
  98561. if (index < 0) {
  98562. if (returnUnchangedIfNoSlash) {
  98563. return uri;
  98564. }
  98565. return "";
  98566. }
  98567. return uri.substring(0, index + 1);
  98568. };
  98569. /**
  98570. * Convert an angle in radians to degrees
  98571. * @param angle defines the angle to convert
  98572. * @returns the angle in degrees
  98573. */
  98574. Tools.ToDegrees = function (angle) {
  98575. return angle * 180 / Math.PI;
  98576. };
  98577. /**
  98578. * Convert an angle in degrees to radians
  98579. * @param angle defines the angle to convert
  98580. * @returns the angle in radians
  98581. */
  98582. Tools.ToRadians = function (angle) {
  98583. return angle * Math.PI / 180;
  98584. };
  98585. /**
  98586. * Encode a buffer to a base64 string
  98587. * @param buffer defines the buffer to encode
  98588. * @returns the encoded string
  98589. */
  98590. Tools.EncodeArrayBufferTobase64 = function (buffer) {
  98591. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  98592. var output = "";
  98593. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  98594. var i = 0;
  98595. var bytes = new Uint8Array(buffer);
  98596. while (i < bytes.length) {
  98597. chr1 = bytes[i++];
  98598. chr2 = i < bytes.length ? bytes[i++] : Number.NaN; // Not sure if the index
  98599. chr3 = i < bytes.length ? bytes[i++] : Number.NaN; // checks are needed here
  98600. enc1 = chr1 >> 2;
  98601. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  98602. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  98603. enc4 = chr3 & 63;
  98604. if (isNaN(chr2)) {
  98605. enc3 = enc4 = 64;
  98606. }
  98607. else if (isNaN(chr3)) {
  98608. enc4 = 64;
  98609. }
  98610. output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
  98611. keyStr.charAt(enc3) + keyStr.charAt(enc4);
  98612. }
  98613. return "data:image/png;base64," + output;
  98614. };
  98615. /**
  98616. * Extracts minimum and maximum values from a list of indexed positions
  98617. * @param positions defines the positions to use
  98618. * @param indices defines the indices to the positions
  98619. * @param indexStart defines the start index
  98620. * @param indexCount defines the end index
  98621. * @param bias defines bias value to add to the result
  98622. * @return minimum and maximum values
  98623. */
  98624. Tools.ExtractMinAndMaxIndexed = function (positions, indices, indexStart, indexCount, bias) {
  98625. if (bias === void 0) { bias = null; }
  98626. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  98627. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  98628. for (var index = indexStart; index < indexStart + indexCount; index++) {
  98629. var offset = indices[index] * 3;
  98630. var x = positions[offset];
  98631. var y = positions[offset + 1];
  98632. var z = positions[offset + 2];
  98633. minimum.minimizeInPlaceFromFloats(x, y, z);
  98634. maximum.maximizeInPlaceFromFloats(x, y, z);
  98635. }
  98636. if (bias) {
  98637. minimum.x -= minimum.x * bias.x + bias.y;
  98638. minimum.y -= minimum.y * bias.x + bias.y;
  98639. minimum.z -= minimum.z * bias.x + bias.y;
  98640. maximum.x += maximum.x * bias.x + bias.y;
  98641. maximum.y += maximum.y * bias.x + bias.y;
  98642. maximum.z += maximum.z * bias.x + bias.y;
  98643. }
  98644. return {
  98645. minimum: minimum,
  98646. maximum: maximum
  98647. };
  98648. };
  98649. /**
  98650. * Extracts minimum and maximum values from a list of positions
  98651. * @param positions defines the positions to use
  98652. * @param start defines the start index in the positions array
  98653. * @param count defines the number of positions to handle
  98654. * @param bias defines bias value to add to the result
  98655. * @param stride defines the stride size to use (distance between two positions in the positions array)
  98656. * @return minimum and maximum values
  98657. */
  98658. Tools.ExtractMinAndMax = function (positions, start, count, bias, stride) {
  98659. if (bias === void 0) { bias = null; }
  98660. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  98661. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  98662. if (!stride) {
  98663. stride = 3;
  98664. }
  98665. for (var index = start, offset = start * stride; index < start + count; index++, offset += stride) {
  98666. var x = positions[offset];
  98667. var y = positions[offset + 1];
  98668. var z = positions[offset + 2];
  98669. minimum.minimizeInPlaceFromFloats(x, y, z);
  98670. maximum.maximizeInPlaceFromFloats(x, y, z);
  98671. }
  98672. if (bias) {
  98673. minimum.x -= minimum.x * bias.x + bias.y;
  98674. minimum.y -= minimum.y * bias.x + bias.y;
  98675. minimum.z -= minimum.z * bias.x + bias.y;
  98676. maximum.x += maximum.x * bias.x + bias.y;
  98677. maximum.y += maximum.y * bias.x + bias.y;
  98678. maximum.z += maximum.z * bias.x + bias.y;
  98679. }
  98680. return {
  98681. minimum: minimum,
  98682. maximum: maximum
  98683. };
  98684. };
  98685. /**
  98686. * Returns an array if obj is not an array
  98687. * @param obj defines the object to evaluate as an array
  98688. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98689. * @returns either obj directly if obj is an array or a new array containing obj
  98690. */
  98691. Tools.MakeArray = function (obj, allowsNullUndefined) {
  98692. if (allowsNullUndefined !== true && (obj === undefined || obj == null)) {
  98693. return null;
  98694. }
  98695. return Array.isArray(obj) ? obj : [obj];
  98696. };
  98697. /**
  98698. * Gets the pointer prefix to use
  98699. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98700. */
  98701. Tools.GetPointerPrefix = function () {
  98702. var eventPrefix = "pointer";
  98703. // Check if pointer events are supported
  98704. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
  98705. eventPrefix = "mouse";
  98706. }
  98707. return eventPrefix;
  98708. };
  98709. /**
  98710. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  98711. * @param func - the function to be called
  98712. * @param requester - the object that will request the next frame. Falls back to window.
  98713. * @returns frame number
  98714. */
  98715. Tools.QueueNewFrame = function (func, requester) {
  98716. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  98717. return setTimeout(func, 16);
  98718. }
  98719. if (!requester) {
  98720. requester = window;
  98721. }
  98722. if (requester.requestAnimationFrame) {
  98723. return requester.requestAnimationFrame(func);
  98724. }
  98725. else if (requester.msRequestAnimationFrame) {
  98726. return requester.msRequestAnimationFrame(func);
  98727. }
  98728. else if (requester.webkitRequestAnimationFrame) {
  98729. return requester.webkitRequestAnimationFrame(func);
  98730. }
  98731. else if (requester.mozRequestAnimationFrame) {
  98732. return requester.mozRequestAnimationFrame(func);
  98733. }
  98734. else if (requester.oRequestAnimationFrame) {
  98735. return requester.oRequestAnimationFrame(func);
  98736. }
  98737. else {
  98738. return window.setTimeout(func, 16);
  98739. }
  98740. };
  98741. /**
  98742. * Ask the browser to promote the current element to fullscreen rendering mode
  98743. * @param element defines the DOM element to promote
  98744. */
  98745. Tools.RequestFullscreen = function (element) {
  98746. var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
  98747. if (!requestFunction) {
  98748. return;
  98749. }
  98750. requestFunction.call(element);
  98751. };
  98752. /**
  98753. * Asks the browser to exit fullscreen mode
  98754. */
  98755. Tools.ExitFullscreen = function () {
  98756. if (document.exitFullscreen) {
  98757. document.exitFullscreen();
  98758. }
  98759. else if (document.mozCancelFullScreen) {
  98760. document.mozCancelFullScreen();
  98761. }
  98762. else if (document.webkitCancelFullScreen) {
  98763. document.webkitCancelFullScreen();
  98764. }
  98765. else if (document.msCancelFullScreen) {
  98766. document.msCancelFullScreen();
  98767. }
  98768. };
  98769. /**
  98770. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98771. * @param url define the url we are trying
  98772. * @param element define the dom element where to configure the cors policy
  98773. */
  98774. Tools.SetCorsBehavior = function (url, element) {
  98775. if (url && url.indexOf("data:") === 0) {
  98776. return;
  98777. }
  98778. if (Tools.CorsBehavior) {
  98779. if (typeof (Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
  98780. element.crossOrigin = Tools.CorsBehavior;
  98781. }
  98782. else {
  98783. var result = Tools.CorsBehavior(url);
  98784. if (result) {
  98785. element.crossOrigin = result;
  98786. }
  98787. }
  98788. }
  98789. };
  98790. // External files
  98791. /**
  98792. * Removes unwanted characters from an url
  98793. * @param url defines the url to clean
  98794. * @returns the cleaned url
  98795. */
  98796. Tools.CleanUrl = function (url) {
  98797. url = url.replace(/#/mg, "%23");
  98798. return url;
  98799. };
  98800. /**
  98801. * Loads an image as an HTMLImageElement.
  98802. * @param input url string, ArrayBuffer, or Blob to load
  98803. * @param onLoad callback called when the image successfully loads
  98804. * @param onError callback called when the image fails to load
  98805. * @param offlineProvider offline provider for caching
  98806. * @returns the HTMLImageElement of the loaded image
  98807. */
  98808. Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  98809. var url;
  98810. var usingObjectURL = false;
  98811. if (input instanceof ArrayBuffer) {
  98812. url = URL.createObjectURL(new Blob([input]));
  98813. usingObjectURL = true;
  98814. }
  98815. else if (input instanceof Blob) {
  98816. url = URL.createObjectURL(input);
  98817. usingObjectURL = true;
  98818. }
  98819. else {
  98820. url = Tools.CleanUrl(input);
  98821. url = Tools.PreprocessUrl(input);
  98822. }
  98823. var img = new Image();
  98824. Tools.SetCorsBehavior(url, img);
  98825. var loadHandler = function () {
  98826. if (usingObjectURL && img.src) {
  98827. URL.revokeObjectURL(img.src);
  98828. }
  98829. img.removeEventListener("load", loadHandler);
  98830. img.removeEventListener("error", errorHandler);
  98831. onLoad(img);
  98832. };
  98833. var errorHandler = function (err) {
  98834. if (usingObjectURL && img.src) {
  98835. URL.revokeObjectURL(img.src);
  98836. }
  98837. img.removeEventListener("load", loadHandler);
  98838. img.removeEventListener("error", errorHandler);
  98839. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error while trying to load image: " + input);
  98840. if (onError) {
  98841. onError("Error while trying to load image: " + input, err);
  98842. }
  98843. };
  98844. img.addEventListener("load", loadHandler);
  98845. img.addEventListener("error", errorHandler);
  98846. var noOfflineSupport = function () {
  98847. img.src = url;
  98848. };
  98849. var loadFromOfflineSupport = function () {
  98850. if (offlineProvider) {
  98851. offlineProvider.loadImage(url, img);
  98852. }
  98853. };
  98854. if (url.substr(0, 5) !== "data:" && offlineProvider && offlineProvider.enableTexturesOffline) {
  98855. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);
  98856. }
  98857. else {
  98858. if (url.indexOf("file:") !== -1) {
  98859. var textureName = decodeURIComponent(url.substring(5).toLowerCase());
  98860. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]) {
  98861. try {
  98862. var blobURL;
  98863. try {
  98864. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  98865. }
  98866. catch (ex) {
  98867. // Chrome doesn't support oneTimeOnly parameter
  98868. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  98869. }
  98870. img.src = blobURL;
  98871. usingObjectURL = true;
  98872. }
  98873. catch (e) {
  98874. img.src = "";
  98875. }
  98876. return img;
  98877. }
  98878. }
  98879. noOfflineSupport();
  98880. }
  98881. return img;
  98882. };
  98883. /**
  98884. * Loads a file
  98885. * @param url url string, ArrayBuffer, or Blob to load
  98886. * @param onSuccess callback called when the file successfully loads
  98887. * @param onProgress callback called while file is loading (if the server supports this mode)
  98888. * @param offlineProvider defines the offline provider for caching
  98889. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98890. * @param onError callback called when the file fails to load
  98891. * @returns a file request object
  98892. */
  98893. Tools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  98894. url = Tools.CleanUrl(url);
  98895. url = Tools.PreprocessUrl(url);
  98896. // If file and file input are set
  98897. if (url.indexOf("file:") !== -1) {
  98898. var fileName = decodeURIComponent(url.substring(5).toLowerCase());
  98899. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName]) {
  98900. return Tools.ReadFile(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName], onSuccess, onProgress, useArrayBuffer);
  98901. }
  98902. }
  98903. var loadUrl = Tools.BaseUrl + url;
  98904. var aborted = false;
  98905. var fileRequest = {
  98906. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  98907. abort: function () { return aborted = true; },
  98908. };
  98909. var requestFile = function () {
  98910. var request = new XMLHttpRequest();
  98911. var retryHandle = null;
  98912. fileRequest.abort = function () {
  98913. aborted = true;
  98914. if (request.readyState !== (XMLHttpRequest.DONE || 4)) {
  98915. request.abort();
  98916. }
  98917. if (retryHandle !== null) {
  98918. clearTimeout(retryHandle);
  98919. retryHandle = null;
  98920. }
  98921. };
  98922. var retryLoop = function (retryIndex) {
  98923. request.open('GET', loadUrl, true);
  98924. if (useArrayBuffer) {
  98925. request.responseType = "arraybuffer";
  98926. }
  98927. if (onProgress) {
  98928. request.addEventListener("progress", onProgress);
  98929. }
  98930. var onLoadEnd = function () {
  98931. request.removeEventListener("loadend", onLoadEnd);
  98932. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  98933. fileRequest.onCompleteObservable.clear();
  98934. };
  98935. request.addEventListener("loadend", onLoadEnd);
  98936. var onReadyStateChange = function () {
  98937. if (aborted) {
  98938. return;
  98939. }
  98940. // In case of undefined state in some browsers.
  98941. if (request.readyState === (XMLHttpRequest.DONE || 4)) {
  98942. // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
  98943. request.removeEventListener("readystatechange", onReadyStateChange);
  98944. if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() || Tools.IsFileURL()))) {
  98945. onSuccess(!useArrayBuffer ? request.responseText : request.response, request.responseURL);
  98946. return;
  98947. }
  98948. var retryStrategy = Tools.DefaultRetryStrategy;
  98949. if (retryStrategy) {
  98950. var waitTime = retryStrategy(loadUrl, request, retryIndex);
  98951. if (waitTime !== -1) {
  98952. // Prevent the request from completing for retry.
  98953. request.removeEventListener("loadend", onLoadEnd);
  98954. request = new XMLHttpRequest();
  98955. retryHandle = setTimeout(function () { return retryLoop(retryIndex + 1); }, waitTime);
  98956. return;
  98957. }
  98958. }
  98959. var e = new LoadFileError("Error status: " + request.status + " " + request.statusText + " - Unable to load " + loadUrl, request);
  98960. if (onError) {
  98961. onError(request, e);
  98962. }
  98963. else {
  98964. throw e;
  98965. }
  98966. }
  98967. };
  98968. request.addEventListener("readystatechange", onReadyStateChange);
  98969. if (Tools.UseCustomRequestHeaders) {
  98970. Tools.InjectCustomRequestHeaders(request);
  98971. }
  98972. request.send();
  98973. };
  98974. retryLoop(0);
  98975. };
  98976. // Caching all files
  98977. if (offlineProvider && offlineProvider.enableSceneOffline) {
  98978. var noOfflineSupport_1 = function (request) {
  98979. if (request && request.status > 400) {
  98980. if (onError) {
  98981. onError(request);
  98982. }
  98983. }
  98984. else {
  98985. if (!aborted) {
  98986. requestFile();
  98987. }
  98988. }
  98989. };
  98990. var loadFromOfflineSupport = function () {
  98991. // TODO: database needs to support aborting and should return a IFileRequest
  98992. if (aborted) {
  98993. return;
  98994. }
  98995. if (offlineProvider) {
  98996. offlineProvider.loadFile(url, function (data) {
  98997. if (!aborted) {
  98998. onSuccess(data);
  98999. }
  99000. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  99001. }, onProgress ? function (event) {
  99002. if (!aborted) {
  99003. onProgress(event);
  99004. }
  99005. } : undefined, noOfflineSupport_1, useArrayBuffer);
  99006. }
  99007. };
  99008. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport_1);
  99009. }
  99010. else {
  99011. requestFile();
  99012. }
  99013. return fileRequest;
  99014. };
  99015. /**
  99016. * Load a script (identified by an url). When the url returns, the
  99017. * content of this file is added into a new script element, attached to the DOM (body element)
  99018. * @param scriptUrl defines the url of the script to laod
  99019. * @param onSuccess defines the callback called when the script is loaded
  99020. * @param onError defines the callback to call if an error occurs
  99021. */
  99022. Tools.LoadScript = function (scriptUrl, onSuccess, onError) {
  99023. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  99024. return;
  99025. }
  99026. var head = document.getElementsByTagName('head')[0];
  99027. var script = document.createElement('script');
  99028. script.type = 'text/javascript';
  99029. script.src = scriptUrl;
  99030. script.onload = function () {
  99031. if (onSuccess) {
  99032. onSuccess();
  99033. }
  99034. };
  99035. script.onerror = function (e) {
  99036. if (onError) {
  99037. onError("Unable to load script '" + scriptUrl + "'", e);
  99038. }
  99039. };
  99040. head.appendChild(script);
  99041. };
  99042. /**
  99043. * Loads a file from a blob
  99044. * @param fileToLoad defines the blob to use
  99045. * @param callback defines the callback to call when data is loaded
  99046. * @param progressCallback defines the callback to call during loading process
  99047. * @returns a file request object
  99048. */
  99049. Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
  99050. var reader = new FileReader();
  99051. var request = {
  99052. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  99053. abort: function () { return reader.abort(); },
  99054. };
  99055. reader.onloadend = function (e) {
  99056. request.onCompleteObservable.notifyObservers(request);
  99057. };
  99058. reader.onload = function (e) {
  99059. //target doesn't have result from ts 1.3
  99060. callback(e.target['result']);
  99061. };
  99062. reader.onprogress = progressCallback;
  99063. reader.readAsDataURL(fileToLoad);
  99064. return request;
  99065. };
  99066. /**
  99067. * Loads a file
  99068. * @param fileToLoad defines the file to load
  99069. * @param callback defines the callback to call when data is loaded
  99070. * @param progressCallBack defines the callback to call during loading process
  99071. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  99072. * @returns a file request object
  99073. */
  99074. Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  99075. var reader = new FileReader();
  99076. var request = {
  99077. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  99078. abort: function () { return reader.abort(); },
  99079. };
  99080. reader.onloadend = function (e) { return request.onCompleteObservable.notifyObservers(request); };
  99081. reader.onerror = function (e) {
  99082. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log("Error while reading file: " + fileToLoad.name);
  99083. callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
  99084. };
  99085. reader.onload = function (e) {
  99086. //target doesn't have result from ts 1.3
  99087. callback(e.target['result']);
  99088. };
  99089. if (progressCallBack) {
  99090. reader.onprogress = progressCallBack;
  99091. }
  99092. if (!useArrayBuffer) {
  99093. // Asynchronous read
  99094. reader.readAsText(fileToLoad);
  99095. }
  99096. else {
  99097. reader.readAsArrayBuffer(fileToLoad);
  99098. }
  99099. return request;
  99100. };
  99101. /**
  99102. * Creates a data url from a given string content
  99103. * @param content defines the content to convert
  99104. * @returns the new data url link
  99105. */
  99106. Tools.FileAsURL = function (content) {
  99107. var fileBlob = new Blob([content]);
  99108. var url = window.URL || window.webkitURL;
  99109. var link = url.createObjectURL(fileBlob);
  99110. return link;
  99111. };
  99112. /**
  99113. * Format the given number to a specific decimal format
  99114. * @param value defines the number to format
  99115. * @param decimals defines the number of decimals to use
  99116. * @returns the formatted string
  99117. */
  99118. Tools.Format = function (value, decimals) {
  99119. if (decimals === void 0) { decimals = 2; }
  99120. return value.toFixed(decimals);
  99121. };
  99122. /**
  99123. * Checks if a given vector is inside a specific range
  99124. * @param v defines the vector to test
  99125. * @param min defines the minimum range
  99126. * @param max defines the maximum range
  99127. */
  99128. Tools.CheckExtends = function (v, min, max) {
  99129. min.minimizeInPlace(v);
  99130. max.maximizeInPlace(v);
  99131. };
  99132. /**
  99133. * Tries to copy an object by duplicating every property
  99134. * @param source defines the source object
  99135. * @param destination defines the target object
  99136. * @param doNotCopyList defines a list of properties to avoid
  99137. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  99138. */
  99139. Tools.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  99140. _deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source, destination, doNotCopyList, mustCopyList);
  99141. };
  99142. /**
  99143. * Gets a boolean indicating if the given object has no own property
  99144. * @param obj defines the object to test
  99145. * @returns true if object has no own property
  99146. */
  99147. Tools.IsEmpty = function (obj) {
  99148. for (var i in obj) {
  99149. if (obj.hasOwnProperty(i)) {
  99150. return false;
  99151. }
  99152. }
  99153. return true;
  99154. };
  99155. /**
  99156. * Function used to register events at window level
  99157. * @param events defines the events to register
  99158. */
  99159. Tools.RegisterTopRootEvents = function (events) {
  99160. for (var index = 0; index < events.length; index++) {
  99161. var event = events[index];
  99162. window.addEventListener(event.name, event.handler, false);
  99163. try {
  99164. if (window.parent) {
  99165. window.parent.addEventListener(event.name, event.handler, false);
  99166. }
  99167. }
  99168. catch (e) {
  99169. // Silently fails...
  99170. }
  99171. }
  99172. };
  99173. /**
  99174. * Function used to unregister events from window level
  99175. * @param events defines the events to unregister
  99176. */
  99177. Tools.UnregisterTopRootEvents = function (events) {
  99178. for (var index = 0; index < events.length; index++) {
  99179. var event = events[index];
  99180. window.removeEventListener(event.name, event.handler);
  99181. try {
  99182. if (window.parent) {
  99183. window.parent.removeEventListener(event.name, event.handler);
  99184. }
  99185. }
  99186. catch (e) {
  99187. // Silently fails...
  99188. }
  99189. }
  99190. };
  99191. /**
  99192. * Dumps the current bound framebuffer
  99193. * @param width defines the rendering width
  99194. * @param height defines the rendering height
  99195. * @param engine defines the hosting engine
  99196. * @param successCallback defines the callback triggered once the data are available
  99197. * @param mimeType defines the mime type of the result
  99198. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  99199. */
  99200. Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType, fileName) {
  99201. if (mimeType === void 0) { mimeType = "image/png"; }
  99202. // Read the contents of the framebuffer
  99203. var numberOfChannelsByLine = width * 4;
  99204. var halfHeight = height / 2;
  99205. //Reading datas from WebGL
  99206. var data = engine.readPixels(0, 0, width, height);
  99207. //To flip image on Y axis.
  99208. for (var i = 0; i < halfHeight; i++) {
  99209. for (var j = 0; j < numberOfChannelsByLine; j++) {
  99210. var currentCell = j + i * numberOfChannelsByLine;
  99211. var targetLine = height - i - 1;
  99212. var targetCell = j + targetLine * numberOfChannelsByLine;
  99213. var temp = data[currentCell];
  99214. data[currentCell] = data[targetCell];
  99215. data[targetCell] = temp;
  99216. }
  99217. }
  99218. // Create a 2D canvas to store the result
  99219. if (!screenshotCanvas) {
  99220. screenshotCanvas = document.createElement('canvas');
  99221. }
  99222. screenshotCanvas.width = width;
  99223. screenshotCanvas.height = height;
  99224. var context = screenshotCanvas.getContext('2d');
  99225. if (context) {
  99226. // Copy the pixels to a 2D canvas
  99227. var imageData = context.createImageData(width, height);
  99228. var castData = (imageData.data);
  99229. castData.set(data);
  99230. context.putImageData(imageData, 0, 0);
  99231. Tools.EncodeScreenshotCanvasData(successCallback, mimeType, fileName);
  99232. }
  99233. };
  99234. /**
  99235. * Converts the canvas data to blob.
  99236. * This acts as a polyfill for browsers not supporting the to blob function.
  99237. * @param canvas Defines the canvas to extract the data from
  99238. * @param successCallback Defines the callback triggered once the data are available
  99239. * @param mimeType Defines the mime type of the result
  99240. */
  99241. Tools.ToBlob = function (canvas, successCallback, mimeType) {
  99242. if (mimeType === void 0) { mimeType = "image/png"; }
  99243. // We need HTMLCanvasElement.toBlob for HD screenshots
  99244. if (!canvas.toBlob) {
  99245. // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
  99246. canvas.toBlob = function (callback, type, quality) {
  99247. var _this = this;
  99248. setTimeout(function () {
  99249. var binStr = atob(_this.toDataURL(type, quality).split(',')[1]), len = binStr.length, arr = new Uint8Array(len);
  99250. for (var i = 0; i < len; i++) {
  99251. arr[i] = binStr.charCodeAt(i);
  99252. }
  99253. callback(new Blob([arr]));
  99254. });
  99255. };
  99256. }
  99257. canvas.toBlob(function (blob) {
  99258. successCallback(blob);
  99259. }, mimeType);
  99260. };
  99261. /**
  99262. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  99263. * @param successCallback defines the callback triggered once the data are available
  99264. * @param mimeType defines the mime type of the result
  99265. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  99266. */
  99267. Tools.EncodeScreenshotCanvasData = function (successCallback, mimeType, fileName) {
  99268. if (mimeType === void 0) { mimeType = "image/png"; }
  99269. if (successCallback) {
  99270. var base64Image = screenshotCanvas.toDataURL(mimeType);
  99271. successCallback(base64Image);
  99272. }
  99273. else {
  99274. this.ToBlob(screenshotCanvas, function (blob) {
  99275. //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
  99276. if (("download" in document.createElement("a"))) {
  99277. if (!fileName) {
  99278. var date = new Date();
  99279. var stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
  99280. fileName = "screenshot_" + stringDate + ".png";
  99281. }
  99282. Tools.Download(blob, fileName);
  99283. }
  99284. else {
  99285. var url = URL.createObjectURL(blob);
  99286. var newWindow = window.open("");
  99287. if (!newWindow) {
  99288. return;
  99289. }
  99290. var img = newWindow.document.createElement("img");
  99291. img.onload = function () {
  99292. // no longer need to read the blob so it's revoked
  99293. URL.revokeObjectURL(url);
  99294. };
  99295. img.src = url;
  99296. newWindow.document.body.appendChild(img);
  99297. }
  99298. }, mimeType);
  99299. }
  99300. };
  99301. /**
  99302. * Downloads a blob in the browser
  99303. * @param blob defines the blob to download
  99304. * @param fileName defines the name of the downloaded file
  99305. */
  99306. Tools.Download = function (blob, fileName) {
  99307. if (navigator && navigator.msSaveBlob) {
  99308. navigator.msSaveBlob(blob, fileName);
  99309. return;
  99310. }
  99311. var url = window.URL.createObjectURL(blob);
  99312. var a = document.createElement("a");
  99313. document.body.appendChild(a);
  99314. a.style.display = "none";
  99315. a.href = url;
  99316. a.download = fileName;
  99317. a.addEventListener("click", function () {
  99318. if (a.parentElement) {
  99319. a.parentElement.removeChild(a);
  99320. }
  99321. });
  99322. a.click();
  99323. window.URL.revokeObjectURL(url);
  99324. };
  99325. /**
  99326. * Captures a screenshot of the current rendering
  99327. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99328. * @param engine defines the rendering engine
  99329. * @param camera defines the source camera
  99330. * @param size This parameter can be set to a single number or to an object with the
  99331. * following (optional) properties: precision, width, height. If a single number is passed,
  99332. * it will be used for both width and height. If an object is passed, the screenshot size
  99333. * will be derived from the parameters. The precision property is a multiplier allowing
  99334. * rendering at a higher or lower resolution
  99335. * @param successCallback defines the callback receives a single parameter which contains the
  99336. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99337. * src parameter of an <img> to display it
  99338. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99339. * Check your browser for supported MIME types
  99340. */
  99341. Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  99342. if (mimeType === void 0) { mimeType = "image/png"; }
  99343. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  99344. };
  99345. /**
  99346. * Generates an image screenshot from the specified camera.
  99347. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99348. * @param engine The engine to use for rendering
  99349. * @param camera The camera to use for rendering
  99350. * @param size This parameter can be set to a single number or to an object with the
  99351. * following (optional) properties: precision, width, height. If a single number is passed,
  99352. * it will be used for both width and height. If an object is passed, the screenshot size
  99353. * will be derived from the parameters. The precision property is a multiplier allowing
  99354. * rendering at a higher or lower resolution
  99355. * @param successCallback The callback receives a single parameter which contains the
  99356. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99357. * src parameter of an <img> to display it
  99358. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99359. * Check your browser for supported MIME types
  99360. * @param samples Texture samples (default: 1)
  99361. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99362. * @param fileName A name for for the downloaded file.
  99363. */
  99364. Tools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  99365. if (mimeType === void 0) { mimeType = "image/png"; }
  99366. if (samples === void 0) { samples = 1; }
  99367. if (antialiasing === void 0) { antialiasing = false; }
  99368. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  99369. };
  99370. /**
  99371. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99372. * Be aware Math.random() could cause collisions, but:
  99373. * "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"
  99374. * @returns a pseudo random id
  99375. */
  99376. Tools.RandomId = function () {
  99377. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  99378. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  99379. return v.toString(16);
  99380. });
  99381. };
  99382. /**
  99383. * Test if the given uri is a base64 string
  99384. * @param uri The uri to test
  99385. * @return True if the uri is a base64 string or false otherwise
  99386. */
  99387. Tools.IsBase64 = function (uri) {
  99388. return uri.length < 5 ? false : uri.substr(0, 5) === "data:";
  99389. };
  99390. /**
  99391. * Decode the given base64 uri.
  99392. * @param uri The uri to decode
  99393. * @return The decoded base64 data.
  99394. */
  99395. Tools.DecodeBase64 = function (uri) {
  99396. var decodedString = atob(uri.split(",")[1]);
  99397. var bufferLength = decodedString.length;
  99398. var bufferView = new Uint8Array(new ArrayBuffer(bufferLength));
  99399. for (var i = 0; i < bufferLength; i++) {
  99400. bufferView[i] = decodedString.charCodeAt(i);
  99401. }
  99402. return bufferView.buffer;
  99403. };
  99404. Object.defineProperty(Tools, "errorsCount", {
  99405. /**
  99406. * Gets a value indicating the number of loading errors
  99407. * @ignorenaming
  99408. */
  99409. get: function () {
  99410. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].errorsCount;
  99411. },
  99412. enumerable: true,
  99413. configurable: true
  99414. });
  99415. /**
  99416. * Log a message to the console
  99417. * @param message defines the message to log
  99418. */
  99419. Tools.Log = function (message) {
  99420. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log(message);
  99421. };
  99422. /**
  99423. * Write a warning message to the console
  99424. * @param message defines the message to log
  99425. */
  99426. Tools.Warn = function (message) {
  99427. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(message);
  99428. };
  99429. /**
  99430. * Write an error message to the console
  99431. * @param message defines the message to log
  99432. */
  99433. Tools.Error = function (message) {
  99434. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error(message);
  99435. };
  99436. Object.defineProperty(Tools, "LogCache", {
  99437. /**
  99438. * Gets current log cache (list of logs)
  99439. */
  99440. get: function () {
  99441. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogCache;
  99442. },
  99443. enumerable: true,
  99444. configurable: true
  99445. });
  99446. /**
  99447. * Clears the log cache
  99448. */
  99449. Tools.ClearLogCache = function () {
  99450. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ClearLogCache();
  99451. };
  99452. Object.defineProperty(Tools, "LogLevels", {
  99453. /**
  99454. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99455. */
  99456. set: function (level) {
  99457. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogLevels = level;
  99458. },
  99459. enumerable: true,
  99460. configurable: true
  99461. });
  99462. /**
  99463. * Checks if the loaded document was accessed via `file:`-Protocol.
  99464. * @returns boolean
  99465. */
  99466. Tools.IsFileURL = function () {
  99467. return location.protocol === "file:";
  99468. };
  99469. Object.defineProperty(Tools, "PerformanceLogLevel", {
  99470. /**
  99471. * Sets the current performance log level
  99472. */
  99473. set: function (level) {
  99474. if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
  99475. Tools.StartPerformanceCounter = Tools._StartUserMark;
  99476. Tools.EndPerformanceCounter = Tools._EndUserMark;
  99477. return;
  99478. }
  99479. if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
  99480. Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
  99481. Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
  99482. return;
  99483. }
  99484. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  99485. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  99486. },
  99487. enumerable: true,
  99488. configurable: true
  99489. });
  99490. Tools._StartPerformanceCounterDisabled = function (counterName, condition) {
  99491. };
  99492. Tools._EndPerformanceCounterDisabled = function (counterName, condition) {
  99493. };
  99494. Tools._StartUserMark = function (counterName, condition) {
  99495. if (condition === void 0) { condition = true; }
  99496. if (!Tools._performance) {
  99497. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  99498. return;
  99499. }
  99500. Tools._performance = window.performance;
  99501. }
  99502. if (!condition || !Tools._performance.mark) {
  99503. return;
  99504. }
  99505. Tools._performance.mark(counterName + "-Begin");
  99506. };
  99507. Tools._EndUserMark = function (counterName, condition) {
  99508. if (condition === void 0) { condition = true; }
  99509. if (!condition || !Tools._performance.mark) {
  99510. return;
  99511. }
  99512. Tools._performance.mark(counterName + "-End");
  99513. Tools._performance.measure(counterName, counterName + "-Begin", counterName + "-End");
  99514. };
  99515. Tools._StartPerformanceConsole = function (counterName, condition) {
  99516. if (condition === void 0) { condition = true; }
  99517. if (!condition) {
  99518. return;
  99519. }
  99520. Tools._StartUserMark(counterName, condition);
  99521. if (console.time) {
  99522. console.time(counterName);
  99523. }
  99524. };
  99525. Tools._EndPerformanceConsole = function (counterName, condition) {
  99526. if (condition === void 0) { condition = true; }
  99527. if (!condition) {
  99528. return;
  99529. }
  99530. Tools._EndUserMark(counterName, condition);
  99531. if (console.time) {
  99532. console.timeEnd(counterName);
  99533. }
  99534. };
  99535. /**
  99536. * Injects the @see CustomRequestHeaders into the given request
  99537. * @param request the request that should be used for injection
  99538. */
  99539. Tools.InjectCustomRequestHeaders = function (request) {
  99540. for (var key in Tools.CustomRequestHeaders) {
  99541. var val = Tools.CustomRequestHeaders[key];
  99542. if (val) {
  99543. request.setRequestHeader(key, val);
  99544. }
  99545. }
  99546. };
  99547. Object.defineProperty(Tools, "Now", {
  99548. /**
  99549. * Gets either window.performance.now() if supported or Date.now() else
  99550. */
  99551. get: function () {
  99552. return _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99553. },
  99554. enumerable: true,
  99555. configurable: true
  99556. });
  99557. /**
  99558. * This method will return the name of the class used to create the instance of the given object.
  99559. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99560. * @param object the object to get the class name from
  99561. * @param isType defines if the object is actually a type
  99562. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99563. */
  99564. Tools.GetClassName = function (object, isType) {
  99565. if (isType === void 0) { isType = false; }
  99566. var name = null;
  99567. if (!isType && object.getClassName) {
  99568. name = object.getClassName();
  99569. }
  99570. else {
  99571. if (object instanceof Object) {
  99572. var classObj = isType ? object : Object.getPrototypeOf(object);
  99573. name = classObj.constructor["__bjsclassName__"];
  99574. }
  99575. if (!name) {
  99576. name = typeof object;
  99577. }
  99578. }
  99579. return name;
  99580. };
  99581. /**
  99582. * Gets the first element of an array satisfying a given predicate
  99583. * @param array defines the array to browse
  99584. * @param predicate defines the predicate to use
  99585. * @returns null if not found or the element
  99586. */
  99587. Tools.First = function (array, predicate) {
  99588. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  99589. var el = array_1[_i];
  99590. if (predicate(el)) {
  99591. return el;
  99592. }
  99593. }
  99594. return null;
  99595. };
  99596. /**
  99597. * This method will return the name of the full name of the class, including its owning module (if any).
  99598. * 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).
  99599. * @param object the object to get the class name from
  99600. * @param isType defines if the object is actually a type
  99601. * @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.
  99602. * @ignorenaming
  99603. */
  99604. Tools.getFullClassName = function (object, isType) {
  99605. if (isType === void 0) { isType = false; }
  99606. var className = null;
  99607. var moduleName = null;
  99608. if (!isType && object.getClassName) {
  99609. className = object.getClassName();
  99610. }
  99611. else {
  99612. if (object instanceof Object) {
  99613. var classObj = isType ? object : Object.getPrototypeOf(object);
  99614. className = classObj.constructor["__bjsclassName__"];
  99615. moduleName = classObj.constructor["__bjsmoduleName__"];
  99616. }
  99617. if (!className) {
  99618. className = typeof object;
  99619. }
  99620. }
  99621. if (!className) {
  99622. return null;
  99623. }
  99624. return ((moduleName != null) ? (moduleName + ".") : "") + className;
  99625. };
  99626. /**
  99627. * Returns a promise that resolves after the given amount of time.
  99628. * @param delay Number of milliseconds to delay
  99629. * @returns Promise that resolves after the given amount of time
  99630. */
  99631. Tools.DelayAsync = function (delay) {
  99632. return new Promise(function (resolve) {
  99633. setTimeout(function () {
  99634. resolve();
  99635. }, delay);
  99636. });
  99637. };
  99638. /**
  99639. * Gets the current gradient from an array of IValueGradient
  99640. * @param ratio defines the current ratio to get
  99641. * @param gradients defines the array of IValueGradient
  99642. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  99643. */
  99644. Tools.GetCurrentGradient = function (ratio, gradients, updateFunc) {
  99645. for (var gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {
  99646. var currentGradient = gradients[gradientIndex];
  99647. var nextGradient = gradients[gradientIndex + 1];
  99648. if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {
  99649. var scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);
  99650. updateFunc(currentGradient, nextGradient, scale);
  99651. return;
  99652. }
  99653. }
  99654. // Use last index if over
  99655. var lastIndex = gradients.length - 1;
  99656. updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);
  99657. };
  99658. /**
  99659. * Gets or sets the base URL to use to load assets
  99660. */
  99661. Tools.BaseUrl = "";
  99662. /**
  99663. * Enable/Disable Custom HTTP Request Headers globally.
  99664. * default = false
  99665. * @see CustomRequestHeaders
  99666. */
  99667. Tools.UseCustomRequestHeaders = false;
  99668. /**
  99669. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  99670. * i.e. when loading files, where the server/service expects an Authorization header.
  99671. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  99672. */
  99673. Tools.CustomRequestHeaders = {};
  99674. /**
  99675. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  99676. */
  99677. Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
  99678. /**
  99679. * Default behaviour for cors in the application.
  99680. * It can be a string if the expected behavior is identical in the entire app.
  99681. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  99682. */
  99683. Tools.CorsBehavior = "anonymous";
  99684. /**
  99685. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99686. * @ignorenaming
  99687. */
  99688. Tools.UseFallbackTexture = true;
  99689. /**
  99690. * Use this object to register external classes like custom textures or material
  99691. * to allow the laoders to instantiate them
  99692. */
  99693. Tools.RegisteredExternalClasses = {};
  99694. /**
  99695. * Texture content used if a texture cannot loaded
  99696. * @ignorenaming
  99697. */
  99698. 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";
  99699. Tools._tmpFloatArray = new Float32Array(1);
  99700. /**
  99701. * Extracts text content from a DOM element hierarchy
  99702. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  99703. */
  99704. Tools.GetDOMTextContent = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].GetDOMTextContent;
  99705. /**
  99706. * Gets or sets a function used to pre-process url before using them to load assets
  99707. */
  99708. Tools.PreprocessUrl = function (url) {
  99709. return url;
  99710. };
  99711. // Logs
  99712. /**
  99713. * No log
  99714. */
  99715. Tools.NoneLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].NoneLogLevel;
  99716. /**
  99717. * Only message logs
  99718. */
  99719. Tools.MessageLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].MessageLogLevel;
  99720. /**
  99721. * Only warning logs
  99722. */
  99723. Tools.WarningLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].WarningLogLevel;
  99724. /**
  99725. * Only error logs
  99726. */
  99727. Tools.ErrorLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ErrorLogLevel;
  99728. /**
  99729. * All logs
  99730. */
  99731. Tools.AllLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].AllLogLevel;
  99732. /**
  99733. * Checks if the window object exists
  99734. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99735. */
  99736. Tools.IsWindowObjectExist = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist;
  99737. // Performances
  99738. /**
  99739. * No performance log
  99740. */
  99741. Tools.PerformanceNoneLogLevel = 0;
  99742. /**
  99743. * Use user marks to log performance
  99744. */
  99745. Tools.PerformanceUserMarkLogLevel = 1;
  99746. /**
  99747. * Log performance to the console
  99748. */
  99749. Tools.PerformanceConsoleLogLevel = 2;
  99750. /**
  99751. * Starts a performance counter
  99752. */
  99753. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  99754. /**
  99755. * Ends a specific performance coutner
  99756. */
  99757. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  99758. return Tools;
  99759. }());
  99760. /**
  99761. * This class is used to track a performance counter which is number based.
  99762. * The user has access to many properties which give statistics of different nature.
  99763. *
  99764. * The implementer can track two kinds of Performance Counter: time and count.
  99765. * 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.
  99766. * 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.
  99767. */
  99768. var PerfCounter = /** @class */ (function () {
  99769. /**
  99770. * Creates a new counter
  99771. */
  99772. function PerfCounter() {
  99773. this._startMonitoringTime = 0;
  99774. this._min = 0;
  99775. this._max = 0;
  99776. this._average = 0;
  99777. this._lastSecAverage = 0;
  99778. this._current = 0;
  99779. this._totalValueCount = 0;
  99780. this._totalAccumulated = 0;
  99781. this._lastSecAccumulated = 0;
  99782. this._lastSecTime = 0;
  99783. this._lastSecValueCount = 0;
  99784. }
  99785. Object.defineProperty(PerfCounter.prototype, "min", {
  99786. /**
  99787. * Returns the smallest value ever
  99788. */
  99789. get: function () {
  99790. return this._min;
  99791. },
  99792. enumerable: true,
  99793. configurable: true
  99794. });
  99795. Object.defineProperty(PerfCounter.prototype, "max", {
  99796. /**
  99797. * Returns the biggest value ever
  99798. */
  99799. get: function () {
  99800. return this._max;
  99801. },
  99802. enumerable: true,
  99803. configurable: true
  99804. });
  99805. Object.defineProperty(PerfCounter.prototype, "average", {
  99806. /**
  99807. * Returns the average value since the performance counter is running
  99808. */
  99809. get: function () {
  99810. return this._average;
  99811. },
  99812. enumerable: true,
  99813. configurable: true
  99814. });
  99815. Object.defineProperty(PerfCounter.prototype, "lastSecAverage", {
  99816. /**
  99817. * Returns the average value of the last second the counter was monitored
  99818. */
  99819. get: function () {
  99820. return this._lastSecAverage;
  99821. },
  99822. enumerable: true,
  99823. configurable: true
  99824. });
  99825. Object.defineProperty(PerfCounter.prototype, "current", {
  99826. /**
  99827. * Returns the current value
  99828. */
  99829. get: function () {
  99830. return this._current;
  99831. },
  99832. enumerable: true,
  99833. configurable: true
  99834. });
  99835. Object.defineProperty(PerfCounter.prototype, "total", {
  99836. /**
  99837. * Gets the accumulated total
  99838. */
  99839. get: function () {
  99840. return this._totalAccumulated;
  99841. },
  99842. enumerable: true,
  99843. configurable: true
  99844. });
  99845. Object.defineProperty(PerfCounter.prototype, "count", {
  99846. /**
  99847. * Gets the total value count
  99848. */
  99849. get: function () {
  99850. return this._totalValueCount;
  99851. },
  99852. enumerable: true,
  99853. configurable: true
  99854. });
  99855. /**
  99856. * Call this method to start monitoring a new frame.
  99857. * 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.
  99858. */
  99859. PerfCounter.prototype.fetchNewFrame = function () {
  99860. this._totalValueCount++;
  99861. this._current = 0;
  99862. this._lastSecValueCount++;
  99863. };
  99864. /**
  99865. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  99866. * @param newCount the count value to add to the monitored count
  99867. * @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.
  99868. */
  99869. PerfCounter.prototype.addCount = function (newCount, fetchResult) {
  99870. if (!PerfCounter.Enabled) {
  99871. return;
  99872. }
  99873. this._current += newCount;
  99874. if (fetchResult) {
  99875. this._fetchResult();
  99876. }
  99877. };
  99878. /**
  99879. * Start monitoring this performance counter
  99880. */
  99881. PerfCounter.prototype.beginMonitoring = function () {
  99882. if (!PerfCounter.Enabled) {
  99883. return;
  99884. }
  99885. this._startMonitoringTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99886. };
  99887. /**
  99888. * Compute the time lapsed since the previous beginMonitoring() call.
  99889. * @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
  99890. */
  99891. PerfCounter.prototype.endMonitoring = function (newFrame) {
  99892. if (newFrame === void 0) { newFrame = true; }
  99893. if (!PerfCounter.Enabled) {
  99894. return;
  99895. }
  99896. if (newFrame) {
  99897. this.fetchNewFrame();
  99898. }
  99899. var currentTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99900. this._current = currentTime - this._startMonitoringTime;
  99901. if (newFrame) {
  99902. this._fetchResult();
  99903. }
  99904. };
  99905. PerfCounter.prototype._fetchResult = function () {
  99906. this._totalAccumulated += this._current;
  99907. this._lastSecAccumulated += this._current;
  99908. // Min/Max update
  99909. this._min = Math.min(this._min, this._current);
  99910. this._max = Math.max(this._max, this._current);
  99911. this._average = this._totalAccumulated / this._totalValueCount;
  99912. // Reset last sec?
  99913. var now = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  99914. if ((now - this._lastSecTime) > 1000) {
  99915. this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;
  99916. this._lastSecTime = now;
  99917. this._lastSecAccumulated = 0;
  99918. this._lastSecValueCount = 0;
  99919. }
  99920. };
  99921. /**
  99922. * Gets or sets a global boolean to turn on and off all the counters
  99923. */
  99924. PerfCounter.Enabled = true;
  99925. return PerfCounter;
  99926. }());
  99927. /**
  99928. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99929. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99930. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99931. * @param name The name of the class, case should be preserved
  99932. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99933. */
  99934. function className(name, module) {
  99935. return function (target) {
  99936. target["__bjsclassName__"] = name;
  99937. target["__bjsmoduleName__"] = (module != null) ? module : null;
  99938. };
  99939. }
  99940. /**
  99941. * An implementation of a loop for asynchronous functions.
  99942. */
  99943. var AsyncLoop = /** @class */ (function () {
  99944. /**
  99945. * Constructor.
  99946. * @param iterations the number of iterations.
  99947. * @param func the function to run each iteration
  99948. * @param successCallback the callback that will be called upon succesful execution
  99949. * @param offset starting offset.
  99950. */
  99951. function AsyncLoop(
  99952. /**
  99953. * Defines the number of iterations for the loop
  99954. */
  99955. iterations, func, successCallback, offset) {
  99956. if (offset === void 0) { offset = 0; }
  99957. this.iterations = iterations;
  99958. this.index = offset - 1;
  99959. this._done = false;
  99960. this._fn = func;
  99961. this._successCallback = successCallback;
  99962. }
  99963. /**
  99964. * Execute the next iteration. Must be called after the last iteration was finished.
  99965. */
  99966. AsyncLoop.prototype.executeNext = function () {
  99967. if (!this._done) {
  99968. if (this.index + 1 < this.iterations) {
  99969. ++this.index;
  99970. this._fn(this);
  99971. }
  99972. else {
  99973. this.breakLoop();
  99974. }
  99975. }
  99976. };
  99977. /**
  99978. * Break the loop and run the success callback.
  99979. */
  99980. AsyncLoop.prototype.breakLoop = function () {
  99981. this._done = true;
  99982. this._successCallback();
  99983. };
  99984. /**
  99985. * Create and run an async loop.
  99986. * @param iterations the number of iterations.
  99987. * @param fn the function to run each iteration
  99988. * @param successCallback the callback that will be called upon succesful execution
  99989. * @param offset starting offset.
  99990. * @returns the created async loop object
  99991. */
  99992. AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
  99993. if (offset === void 0) { offset = 0; }
  99994. var loop = new AsyncLoop(iterations, fn, successCallback, offset);
  99995. loop.executeNext();
  99996. return loop;
  99997. };
  99998. /**
  99999. * A for-loop that will run a given number of iterations synchronous and the rest async.
  100000. * @param iterations total number of iterations
  100001. * @param syncedIterations number of synchronous iterations in each async iteration.
  100002. * @param fn the function to call each iteration.
  100003. * @param callback a success call back that will be called when iterating stops.
  100004. * @param breakFunction a break condition (optional)
  100005. * @param timeout timeout settings for the setTimeout function. default - 0.
  100006. * @returns the created async loop object
  100007. */
  100008. AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
  100009. if (timeout === void 0) { timeout = 0; }
  100010. return AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
  100011. if (breakFunction && breakFunction()) {
  100012. loop.breakLoop();
  100013. }
  100014. else {
  100015. setTimeout(function () {
  100016. for (var i = 0; i < syncedIterations; ++i) {
  100017. var iteration = (loop.index * syncedIterations) + i;
  100018. if (iteration >= iterations) {
  100019. break;
  100020. }
  100021. fn(iteration);
  100022. if (breakFunction && breakFunction()) {
  100023. loop.breakLoop();
  100024. break;
  100025. }
  100026. }
  100027. loop.executeNext();
  100028. }, timeout);
  100029. }
  100030. }, callback);
  100031. };
  100032. return AsyncLoop;
  100033. }());
  100034. /***/ }),
  100035. /***/ "./Misc/typeStore.ts":
  100036. /*!***************************!*\
  100037. !*** ./Misc/typeStore.ts ***!
  100038. \***************************/
  100039. /*! exports provided: _TypeStore */
  100040. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100041. "use strict";
  100042. __webpack_require__.r(__webpack_exports__);
  100043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _TypeStore; });
  100044. /** @hidden */
  100045. var _TypeStore = /** @class */ (function () {
  100046. function _TypeStore() {
  100047. }
  100048. /** @hidden */
  100049. _TypeStore.GetClass = function (fqdn) {
  100050. if (this.RegisteredTypes && this.RegisteredTypes[fqdn]) {
  100051. return this.RegisteredTypes[fqdn];
  100052. }
  100053. return null;
  100054. };
  100055. /** @hidden */
  100056. _TypeStore.RegisteredTypes = {};
  100057. return _TypeStore;
  100058. }());
  100059. /***/ }),
  100060. /***/ "./Misc/videoRecorder.ts":
  100061. /*!*******************************!*\
  100062. !*** ./Misc/videoRecorder.ts ***!
  100063. \*******************************/
  100064. /*! exports provided: VideoRecorder */
  100065. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100066. "use strict";
  100067. __webpack_require__.r(__webpack_exports__);
  100068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return VideoRecorder; });
  100069. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  100070. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  100071. /**
  100072. * This can helps recording videos from BabylonJS.
  100073. * This is based on the available WebRTC functionalities of the browser.
  100074. *
  100075. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  100076. */
  100077. var VideoRecorder = /** @class */ (function () {
  100078. /**
  100079. * Create a new VideoCapture object which can help converting what you see in Babylon to
  100080. * a video file.
  100081. * @param engine Defines the BabylonJS Engine you wish to record
  100082. * @param options Defines options that can be used to customized the capture
  100083. */
  100084. function VideoRecorder(engine, options) {
  100085. if (options === void 0) { options = null; }
  100086. if (!VideoRecorder.IsSupported(engine)) {
  100087. throw "Your browser does not support recording so far.";
  100088. }
  100089. var canvas = engine.getRenderingCanvas();
  100090. if (!canvas) {
  100091. throw "The babylon engine must have a canvas to be recorded";
  100092. }
  100093. this._canvas = canvas;
  100094. this._canvas.isRecording = false;
  100095. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, VideoRecorder._defaultOptions, options);
  100096. var stream = this._canvas.captureStream(this._options.fps);
  100097. this._mediaRecorder = new MediaRecorder(stream, { mimeType: this._options.mimeType });
  100098. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this);
  100099. this._mediaRecorder.onerror = this._handleError.bind(this);
  100100. this._mediaRecorder.onstop = this._handleStop.bind(this);
  100101. }
  100102. /**
  100103. * Returns wehther or not the VideoRecorder is available in your browser.
  100104. * @param engine Defines the Babylon Engine to check the support for
  100105. * @returns true if supported otherwise false
  100106. */
  100107. VideoRecorder.IsSupported = function (engine) {
  100108. var canvas = engine.getRenderingCanvas();
  100109. return (!!canvas && typeof canvas.captureStream === "function");
  100110. };
  100111. Object.defineProperty(VideoRecorder.prototype, "isRecording", {
  100112. /**
  100113. * True wether a recording is already in progress.
  100114. */
  100115. get: function () {
  100116. return !!this._canvas && this._canvas.isRecording;
  100117. },
  100118. enumerable: true,
  100119. configurable: true
  100120. });
  100121. /**
  100122. * Stops the current recording before the default capture timeout passed in the startRecording
  100123. * functions.
  100124. */
  100125. VideoRecorder.prototype.stopRecording = function () {
  100126. if (!this._canvas || !this._mediaRecorder) {
  100127. return;
  100128. }
  100129. if (!this.isRecording) {
  100130. return;
  100131. }
  100132. this._canvas.isRecording = false;
  100133. this._mediaRecorder.stop();
  100134. };
  100135. /**
  100136. * Starts recording the canvas for a max duration specified in parameters.
  100137. * @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.
  100138. * @param maxDuration Defines the maximum recording time in seconds.
  100139. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  100140. * @return a promise callback at the end of the recording with the video data in Blob.
  100141. */
  100142. VideoRecorder.prototype.startRecording = function (fileName, maxDuration) {
  100143. var _this = this;
  100144. if (fileName === void 0) { fileName = "babylonjs.webm"; }
  100145. if (maxDuration === void 0) { maxDuration = 7; }
  100146. if (!this._canvas || !this._mediaRecorder) {
  100147. throw "Recorder has already been disposed";
  100148. }
  100149. if (this.isRecording) {
  100150. throw "Recording already in progress";
  100151. }
  100152. if (maxDuration > 0) {
  100153. setTimeout(function () {
  100154. _this.stopRecording();
  100155. }, maxDuration * 1000);
  100156. }
  100157. this._fileName = fileName;
  100158. this._recordedChunks = [];
  100159. this._resolve = null;
  100160. this._reject = null;
  100161. this._canvas.isRecording = true;
  100162. this._mediaRecorder.start(this._options.recordChunckSize);
  100163. return new Promise(function (resolve, reject) {
  100164. _this._resolve = resolve;
  100165. _this._reject = reject;
  100166. });
  100167. };
  100168. /**
  100169. * Releases internal resources used during the recording.
  100170. */
  100171. VideoRecorder.prototype.dispose = function () {
  100172. this._canvas = null;
  100173. this._mediaRecorder = null;
  100174. this._recordedChunks = [];
  100175. this._fileName = null;
  100176. this._resolve = null;
  100177. this._reject = null;
  100178. };
  100179. VideoRecorder.prototype._handleDataAvailable = function (event) {
  100180. if (event.data.size > 0) {
  100181. this._recordedChunks.push(event.data);
  100182. }
  100183. };
  100184. VideoRecorder.prototype._handleError = function (event) {
  100185. this.stopRecording();
  100186. if (this._reject) {
  100187. this._reject(event.error);
  100188. }
  100189. else {
  100190. throw new event.error();
  100191. }
  100192. };
  100193. VideoRecorder.prototype._handleStop = function () {
  100194. this.stopRecording();
  100195. var superBuffer = new Blob(this._recordedChunks);
  100196. if (this._resolve) {
  100197. this._resolve(superBuffer);
  100198. }
  100199. window.URL.createObjectURL(superBuffer);
  100200. if (this._fileName) {
  100201. _tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Download(superBuffer, this._fileName);
  100202. }
  100203. };
  100204. VideoRecorder._defaultOptions = {
  100205. mimeType: "video/webm",
  100206. fps: 25,
  100207. recordChunckSize: 3000
  100208. };
  100209. return VideoRecorder;
  100210. }());
  100211. /***/ }),
  100212. /***/ "./Misc/virtualJoystick.ts":
  100213. /*!*********************************!*\
  100214. !*** ./Misc/virtualJoystick.ts ***!
  100215. \*********************************/
  100216. /*! exports provided: JoystickAxis, VirtualJoystick */
  100217. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100218. "use strict";
  100219. __webpack_require__.r(__webpack_exports__);
  100220. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return JoystickAxis; });
  100221. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return VirtualJoystick; });
  100222. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  100223. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  100224. // Mainly based on these 2 articles :
  100225. // 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
  100226. // & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
  100227. /**
  100228. * Defines the potential axis of a Joystick
  100229. */
  100230. var JoystickAxis;
  100231. (function (JoystickAxis) {
  100232. /** X axis */
  100233. JoystickAxis[JoystickAxis["X"] = 0] = "X";
  100234. /** Y axis */
  100235. JoystickAxis[JoystickAxis["Y"] = 1] = "Y";
  100236. /** Z axis */
  100237. JoystickAxis[JoystickAxis["Z"] = 2] = "Z";
  100238. })(JoystickAxis || (JoystickAxis = {}));
  100239. /**
  100240. * Class used to define virtual joystick (used in touch mode)
  100241. */
  100242. var VirtualJoystick = /** @class */ (function () {
  100243. /**
  100244. * Creates a new virtual joystick
  100245. * @param leftJoystick defines that the joystick is for left hand (false by default)
  100246. */
  100247. function VirtualJoystick(leftJoystick) {
  100248. var _this = this;
  100249. if (leftJoystick) {
  100250. this._leftJoystick = true;
  100251. }
  100252. else {
  100253. this._leftJoystick = false;
  100254. }
  100255. VirtualJoystick._globalJoystickIndex++;
  100256. // By default left & right arrow keys are moving the X
  100257. // and up & down keys are moving the Y
  100258. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  100259. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  100260. this.reverseLeftRight = false;
  100261. this.reverseUpDown = false;
  100262. // collections of pointers
  100263. this._touches = new _stringDictionary__WEBPACK_IMPORTED_MODULE_1__["StringDictionary"]();
  100264. this.deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  100265. this._joystickSensibility = 25;
  100266. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  100267. this._onResize = function (evt) {
  100268. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  100269. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  100270. if (VirtualJoystick.Canvas) {
  100271. VirtualJoystick.Canvas.width = VirtualJoystick.vjCanvasWidth;
  100272. VirtualJoystick.Canvas.height = VirtualJoystick.vjCanvasHeight;
  100273. }
  100274. VirtualJoystick.halfWidth = VirtualJoystick.vjCanvasWidth / 2;
  100275. };
  100276. // injecting a canvas element on top of the canvas 3D game
  100277. if (!VirtualJoystick.Canvas) {
  100278. window.addEventListener("resize", this._onResize, false);
  100279. VirtualJoystick.Canvas = document.createElement("canvas");
  100280. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  100281. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  100282. VirtualJoystick.Canvas.width = window.innerWidth;
  100283. VirtualJoystick.Canvas.height = window.innerHeight;
  100284. VirtualJoystick.Canvas.style.width = "100%";
  100285. VirtualJoystick.Canvas.style.height = "100%";
  100286. VirtualJoystick.Canvas.style.position = "absolute";
  100287. VirtualJoystick.Canvas.style.backgroundColor = "transparent";
  100288. VirtualJoystick.Canvas.style.top = "0px";
  100289. VirtualJoystick.Canvas.style.left = "0px";
  100290. VirtualJoystick.Canvas.style.zIndex = "5";
  100291. VirtualJoystick.Canvas.style.msTouchAction = "none";
  100292. // Support for jQuery PEP polyfill
  100293. VirtualJoystick.Canvas.setAttribute("touch-action", "none");
  100294. var context = VirtualJoystick.Canvas.getContext('2d');
  100295. if (!context) {
  100296. throw new Error("Unable to create canvas for virtual joystick");
  100297. }
  100298. VirtualJoystick.vjCanvasContext = context;
  100299. VirtualJoystick.vjCanvasContext.strokeStyle = "#ffffff";
  100300. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  100301. document.body.appendChild(VirtualJoystick.Canvas);
  100302. }
  100303. VirtualJoystick.halfWidth = VirtualJoystick.Canvas.width / 2;
  100304. this.pressed = false;
  100305. // default joystick color
  100306. this._joystickColor = "cyan";
  100307. this._joystickPointerID = -1;
  100308. // current joystick position
  100309. this._joystickPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100310. this._joystickPreviousPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100311. // origin joystick position
  100312. this._joystickPointerStartPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100313. this._deltaJoystickVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100314. this._onPointerDownHandlerRef = function (evt) {
  100315. _this._onPointerDown(evt);
  100316. };
  100317. this._onPointerMoveHandlerRef = function (evt) {
  100318. _this._onPointerMove(evt);
  100319. };
  100320. this._onPointerUpHandlerRef = function (evt) {
  100321. _this._onPointerUp(evt);
  100322. };
  100323. VirtualJoystick.Canvas.addEventListener('pointerdown', this._onPointerDownHandlerRef, false);
  100324. VirtualJoystick.Canvas.addEventListener('pointermove', this._onPointerMoveHandlerRef, false);
  100325. VirtualJoystick.Canvas.addEventListener('pointerup', this._onPointerUpHandlerRef, false);
  100326. VirtualJoystick.Canvas.addEventListener('pointerout', this._onPointerUpHandlerRef, false);
  100327. VirtualJoystick.Canvas.addEventListener("contextmenu", function (evt) {
  100328. evt.preventDefault(); // Disables system menu
  100329. }, false);
  100330. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  100331. }
  100332. /**
  100333. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  100334. * @param newJoystickSensibility defines the new sensibility
  100335. */
  100336. VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
  100337. this._joystickSensibility = newJoystickSensibility;
  100338. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  100339. };
  100340. VirtualJoystick.prototype._onPointerDown = function (e) {
  100341. var positionOnScreenCondition;
  100342. e.preventDefault();
  100343. if (this._leftJoystick === true) {
  100344. positionOnScreenCondition = (e.clientX < VirtualJoystick.halfWidth);
  100345. }
  100346. else {
  100347. positionOnScreenCondition = (e.clientX > VirtualJoystick.halfWidth);
  100348. }
  100349. if (positionOnScreenCondition && this._joystickPointerID < 0) {
  100350. // First contact will be dedicated to the virtual joystick
  100351. this._joystickPointerID = e.pointerId;
  100352. this._joystickPointerStartPos.x = e.clientX;
  100353. this._joystickPointerStartPos.y = e.clientY;
  100354. this._joystickPointerPos = this._joystickPointerStartPos.clone();
  100355. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone();
  100356. this._deltaJoystickVector.x = 0;
  100357. this._deltaJoystickVector.y = 0;
  100358. this.pressed = true;
  100359. this._touches.add(e.pointerId.toString(), e);
  100360. }
  100361. else {
  100362. // You can only trigger the action buttons with a joystick declared
  100363. if (VirtualJoystick._globalJoystickIndex < 2 && this._action) {
  100364. this._action();
  100365. this._touches.add(e.pointerId.toString(), { x: e.clientX, y: e.clientY, prevX: e.clientX, prevY: e.clientY });
  100366. }
  100367. }
  100368. };
  100369. VirtualJoystick.prototype._onPointerMove = function (e) {
  100370. // If the current pointer is the one associated to the joystick (first touch contact)
  100371. if (this._joystickPointerID == e.pointerId) {
  100372. this._joystickPointerPos.x = e.clientX;
  100373. this._joystickPointerPos.y = e.clientY;
  100374. this._deltaJoystickVector = this._joystickPointerPos.clone();
  100375. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos);
  100376. var directionLeftRight = this.reverseLeftRight ? -1 : 1;
  100377. var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
  100378. switch (this._axisTargetedByLeftAndRight) {
  100379. case JoystickAxis.X:
  100380. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
  100381. break;
  100382. case JoystickAxis.Y:
  100383. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
  100384. break;
  100385. case JoystickAxis.Z:
  100386. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
  100387. break;
  100388. }
  100389. var directionUpDown = this.reverseUpDown ? 1 : -1;
  100390. var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
  100391. switch (this._axisTargetedByUpAndDown) {
  100392. case JoystickAxis.X:
  100393. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
  100394. break;
  100395. case JoystickAxis.Y:
  100396. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
  100397. break;
  100398. case JoystickAxis.Z:
  100399. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
  100400. break;
  100401. }
  100402. }
  100403. else {
  100404. var data = this._touches.get(e.pointerId.toString());
  100405. if (data) {
  100406. data.x = e.clientX;
  100407. data.y = e.clientY;
  100408. }
  100409. }
  100410. };
  100411. VirtualJoystick.prototype._onPointerUp = function (e) {
  100412. if (this._joystickPointerID == e.pointerId) {
  100413. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPointerStartPos.x - 64, this._joystickPointerStartPos.y - 64, 128, 128);
  100414. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - 42, this._joystickPreviousPointerPos.y - 42, 84, 84);
  100415. this._joystickPointerID = -1;
  100416. this.pressed = false;
  100417. }
  100418. else {
  100419. var touch = this._touches.get(e.pointerId.toString());
  100420. if (touch) {
  100421. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  100422. }
  100423. }
  100424. this._deltaJoystickVector.x = 0;
  100425. this._deltaJoystickVector.y = 0;
  100426. this._touches.remove(e.pointerId.toString());
  100427. };
  100428. /**
  100429. * Change the color of the virtual joystick
  100430. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  100431. */
  100432. VirtualJoystick.prototype.setJoystickColor = function (newColor) {
  100433. this._joystickColor = newColor;
  100434. };
  100435. /**
  100436. * Defines a callback to call when the joystick is touched
  100437. * @param action defines the callback
  100438. */
  100439. VirtualJoystick.prototype.setActionOnTouch = function (action) {
  100440. this._action = action;
  100441. };
  100442. /**
  100443. * Defines which axis you'd like to control for left & right
  100444. * @param axis defines the axis to use
  100445. */
  100446. VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
  100447. switch (axis) {
  100448. case JoystickAxis.X:
  100449. case JoystickAxis.Y:
  100450. case JoystickAxis.Z:
  100451. this._axisTargetedByLeftAndRight = axis;
  100452. break;
  100453. default:
  100454. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  100455. break;
  100456. }
  100457. };
  100458. /**
  100459. * Defines which axis you'd like to control for up & down
  100460. * @param axis defines the axis to use
  100461. */
  100462. VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
  100463. switch (axis) {
  100464. case JoystickAxis.X:
  100465. case JoystickAxis.Y:
  100466. case JoystickAxis.Z:
  100467. this._axisTargetedByUpAndDown = axis;
  100468. break;
  100469. default:
  100470. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  100471. break;
  100472. }
  100473. };
  100474. VirtualJoystick.prototype._drawVirtualJoystick = function () {
  100475. var _this = this;
  100476. if (this.pressed) {
  100477. this._touches.forEach(function (key, touch) {
  100478. if (touch.pointerId === _this._joystickPointerID) {
  100479. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPointerStartPos.x - 64, _this._joystickPointerStartPos.y - 64, 128, 128);
  100480. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPreviousPointerPos.x - 42, _this._joystickPreviousPointerPos.y - 42, 84, 84);
  100481. VirtualJoystick.vjCanvasContext.beginPath();
  100482. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  100483. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  100484. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 40, 0, Math.PI * 2, true);
  100485. VirtualJoystick.vjCanvasContext.stroke();
  100486. VirtualJoystick.vjCanvasContext.closePath();
  100487. VirtualJoystick.vjCanvasContext.beginPath();
  100488. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  100489. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  100490. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 60, 0, Math.PI * 2, true);
  100491. VirtualJoystick.vjCanvasContext.stroke();
  100492. VirtualJoystick.vjCanvasContext.closePath();
  100493. VirtualJoystick.vjCanvasContext.beginPath();
  100494. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  100495. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerPos.x, _this._joystickPointerPos.y, 40, 0, Math.PI * 2, true);
  100496. VirtualJoystick.vjCanvasContext.stroke();
  100497. VirtualJoystick.vjCanvasContext.closePath();
  100498. _this._joystickPreviousPointerPos = _this._joystickPointerPos.clone();
  100499. }
  100500. else {
  100501. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  100502. VirtualJoystick.vjCanvasContext.beginPath();
  100503. VirtualJoystick.vjCanvasContext.fillStyle = "white";
  100504. VirtualJoystick.vjCanvasContext.beginPath();
  100505. VirtualJoystick.vjCanvasContext.strokeStyle = "red";
  100506. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  100507. VirtualJoystick.vjCanvasContext.arc(touch.x, touch.y, 40, 0, Math.PI * 2, true);
  100508. VirtualJoystick.vjCanvasContext.stroke();
  100509. VirtualJoystick.vjCanvasContext.closePath();
  100510. touch.prevX = touch.x;
  100511. touch.prevY = touch.y;
  100512. }
  100513. });
  100514. }
  100515. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  100516. };
  100517. /**
  100518. * Release internal HTML canvas
  100519. */
  100520. VirtualJoystick.prototype.releaseCanvas = function () {
  100521. if (VirtualJoystick.Canvas) {
  100522. VirtualJoystick.Canvas.removeEventListener('pointerdown', this._onPointerDownHandlerRef);
  100523. VirtualJoystick.Canvas.removeEventListener('pointermove', this._onPointerMoveHandlerRef);
  100524. VirtualJoystick.Canvas.removeEventListener('pointerup', this._onPointerUpHandlerRef);
  100525. VirtualJoystick.Canvas.removeEventListener('pointerout', this._onPointerUpHandlerRef);
  100526. window.removeEventListener("resize", this._onResize);
  100527. document.body.removeChild(VirtualJoystick.Canvas);
  100528. VirtualJoystick.Canvas = null;
  100529. }
  100530. };
  100531. // Used to draw the virtual joystick inside a 2D canvas on top of the WebGL rendering canvas
  100532. VirtualJoystick._globalJoystickIndex = 0;
  100533. return VirtualJoystick;
  100534. }());
  100535. /***/ }),
  100536. /***/ "./Misc/workerPool.ts":
  100537. /*!****************************!*\
  100538. !*** ./Misc/workerPool.ts ***!
  100539. \****************************/
  100540. /*! exports provided: WorkerPool */
  100541. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100542. "use strict";
  100543. __webpack_require__.r(__webpack_exports__);
  100544. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return WorkerPool; });
  100545. /**
  100546. * Helper class to push actions to a pool of workers.
  100547. */
  100548. var WorkerPool = /** @class */ (function () {
  100549. /**
  100550. * Constructor
  100551. * @param workers Array of workers to use for actions
  100552. */
  100553. function WorkerPool(workers) {
  100554. this._pendingActions = new Array();
  100555. this._workerInfos = workers.map(function (worker) { return ({
  100556. worker: worker,
  100557. active: false
  100558. }); });
  100559. }
  100560. /**
  100561. * Terminates all workers and clears any pending actions.
  100562. */
  100563. WorkerPool.prototype.dispose = function () {
  100564. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  100565. var workerInfo = _a[_i];
  100566. workerInfo.worker.terminate();
  100567. }
  100568. delete this._workerInfos;
  100569. delete this._pendingActions;
  100570. };
  100571. /**
  100572. * Pushes an action to the worker pool. If all the workers are active, the action will be
  100573. * pended until a worker has completed its action.
  100574. * @param action The action to perform. Call onComplete when the action is complete.
  100575. */
  100576. WorkerPool.prototype.push = function (action) {
  100577. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  100578. var workerInfo = _a[_i];
  100579. if (!workerInfo.active) {
  100580. this._execute(workerInfo, action);
  100581. return;
  100582. }
  100583. }
  100584. this._pendingActions.push(action);
  100585. };
  100586. WorkerPool.prototype._execute = function (workerInfo, action) {
  100587. var _this = this;
  100588. workerInfo.active = true;
  100589. action(workerInfo.worker, function () {
  100590. workerInfo.active = false;
  100591. var nextAction = _this._pendingActions.shift();
  100592. if (nextAction) {
  100593. _this._execute(workerInfo, nextAction);
  100594. }
  100595. });
  100596. };
  100597. return WorkerPool;
  100598. }());
  100599. /***/ }),
  100600. /***/ "./Morph/index.ts":
  100601. /*!************************!*\
  100602. !*** ./Morph/index.ts ***!
  100603. \************************/
  100604. /*! exports provided: MorphTarget, MorphTargetManager */
  100605. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100606. "use strict";
  100607. __webpack_require__.r(__webpack_exports__);
  100608. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  100609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _morphTarget__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  100610. /* harmony import */ var _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./morphTargetManager */ "./Morph/morphTargetManager.ts");
  100611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__["MorphTargetManager"]; });
  100612. /***/ }),
  100613. /***/ "./Morph/morphTarget.ts":
  100614. /*!******************************!*\
  100615. !*** ./Morph/morphTarget.ts ***!
  100616. \******************************/
  100617. /*! exports provided: MorphTarget */
  100618. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100619. "use strict";
  100620. __webpack_require__.r(__webpack_exports__);
  100621. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return MorphTarget; });
  100622. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  100623. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  100624. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  100625. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  100626. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  100627. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  100628. /**
  100629. * Defines a target to use with MorphTargetManager
  100630. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  100631. */
  100632. var MorphTarget = /** @class */ (function () {
  100633. /**
  100634. * Creates a new MorphTarget
  100635. * @param name defines the name of the target
  100636. * @param influence defines the influence to use
  100637. * @param scene defines the scene the morphtarget belongs to
  100638. */
  100639. function MorphTarget(
  100640. /** defines the name of the target */
  100641. name, influence, scene) {
  100642. if (influence === void 0) { influence = 0; }
  100643. if (scene === void 0) { scene = null; }
  100644. this.name = name;
  100645. /**
  100646. * Gets or sets the list of animations
  100647. */
  100648. this.animations = new Array();
  100649. this._positions = null;
  100650. this._normals = null;
  100651. this._tangents = null;
  100652. /**
  100653. * Observable raised when the influence changes
  100654. */
  100655. this.onInfluenceChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  100656. /** @hidden */
  100657. this._onDataLayoutChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  100658. this._animationPropertiesOverride = null;
  100659. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  100660. this.influence = influence;
  100661. }
  100662. Object.defineProperty(MorphTarget.prototype, "influence", {
  100663. /**
  100664. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  100665. */
  100666. get: function () {
  100667. return this._influence;
  100668. },
  100669. set: function (influence) {
  100670. if (this._influence === influence) {
  100671. return;
  100672. }
  100673. var previous = this._influence;
  100674. this._influence = influence;
  100675. if (this.onInfluenceChanged.hasObservers) {
  100676. this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);
  100677. }
  100678. },
  100679. enumerable: true,
  100680. configurable: true
  100681. });
  100682. Object.defineProperty(MorphTarget.prototype, "animationPropertiesOverride", {
  100683. /**
  100684. * Gets or sets the animation properties override
  100685. */
  100686. get: function () {
  100687. if (!this._animationPropertiesOverride && this._scene) {
  100688. return this._scene.animationPropertiesOverride;
  100689. }
  100690. return this._animationPropertiesOverride;
  100691. },
  100692. set: function (value) {
  100693. this._animationPropertiesOverride = value;
  100694. },
  100695. enumerable: true,
  100696. configurable: true
  100697. });
  100698. Object.defineProperty(MorphTarget.prototype, "hasPositions", {
  100699. /**
  100700. * Gets a boolean defining if the target contains position data
  100701. */
  100702. get: function () {
  100703. return !!this._positions;
  100704. },
  100705. enumerable: true,
  100706. configurable: true
  100707. });
  100708. Object.defineProperty(MorphTarget.prototype, "hasNormals", {
  100709. /**
  100710. * Gets a boolean defining if the target contains normal data
  100711. */
  100712. get: function () {
  100713. return !!this._normals;
  100714. },
  100715. enumerable: true,
  100716. configurable: true
  100717. });
  100718. Object.defineProperty(MorphTarget.prototype, "hasTangents", {
  100719. /**
  100720. * Gets a boolean defining if the target contains tangent data
  100721. */
  100722. get: function () {
  100723. return !!this._tangents;
  100724. },
  100725. enumerable: true,
  100726. configurable: true
  100727. });
  100728. /**
  100729. * Affects position data to this target
  100730. * @param data defines the position data to use
  100731. */
  100732. MorphTarget.prototype.setPositions = function (data) {
  100733. var hadPositions = this.hasPositions;
  100734. this._positions = data;
  100735. if (hadPositions !== this.hasPositions) {
  100736. this._onDataLayoutChanged.notifyObservers(undefined);
  100737. }
  100738. };
  100739. /**
  100740. * Gets the position data stored in this target
  100741. * @returns a FloatArray containing the position data (or null if not present)
  100742. */
  100743. MorphTarget.prototype.getPositions = function () {
  100744. return this._positions;
  100745. };
  100746. /**
  100747. * Affects normal data to this target
  100748. * @param data defines the normal data to use
  100749. */
  100750. MorphTarget.prototype.setNormals = function (data) {
  100751. var hadNormals = this.hasNormals;
  100752. this._normals = data;
  100753. if (hadNormals !== this.hasNormals) {
  100754. this._onDataLayoutChanged.notifyObservers(undefined);
  100755. }
  100756. };
  100757. /**
  100758. * Gets the normal data stored in this target
  100759. * @returns a FloatArray containing the normal data (or null if not present)
  100760. */
  100761. MorphTarget.prototype.getNormals = function () {
  100762. return this._normals;
  100763. };
  100764. /**
  100765. * Affects tangent data to this target
  100766. * @param data defines the tangent data to use
  100767. */
  100768. MorphTarget.prototype.setTangents = function (data) {
  100769. var hadTangents = this.hasTangents;
  100770. this._tangents = data;
  100771. if (hadTangents !== this.hasTangents) {
  100772. this._onDataLayoutChanged.notifyObservers(undefined);
  100773. }
  100774. };
  100775. /**
  100776. * Gets the tangent data stored in this target
  100777. * @returns a FloatArray containing the tangent data (or null if not present)
  100778. */
  100779. MorphTarget.prototype.getTangents = function () {
  100780. return this._tangents;
  100781. };
  100782. /**
  100783. * Serializes the current target into a Serialization object
  100784. * @returns the serialized object
  100785. */
  100786. MorphTarget.prototype.serialize = function () {
  100787. var serializationObject = {};
  100788. serializationObject.name = this.name;
  100789. serializationObject.influence = this.influence;
  100790. serializationObject.positions = Array.prototype.slice.call(this.getPositions());
  100791. if (this.id != null) {
  100792. serializationObject.id = this.id;
  100793. }
  100794. if (this.hasNormals) {
  100795. serializationObject.normals = Array.prototype.slice.call(this.getNormals());
  100796. }
  100797. if (this.hasTangents) {
  100798. serializationObject.tangents = Array.prototype.slice.call(this.getTangents());
  100799. }
  100800. // Animations
  100801. _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  100802. return serializationObject;
  100803. };
  100804. /**
  100805. * Returns the string "MorphTarget"
  100806. * @returns "MorphTarget"
  100807. */
  100808. MorphTarget.prototype.getClassName = function () {
  100809. return "MorphTarget";
  100810. };
  100811. // Statics
  100812. /**
  100813. * Creates a new target from serialized data
  100814. * @param serializationObject defines the serialized data to use
  100815. * @returns a new MorphTarget
  100816. */
  100817. MorphTarget.Parse = function (serializationObject) {
  100818. var result = new MorphTarget(serializationObject.name, serializationObject.influence);
  100819. result.setPositions(serializationObject.positions);
  100820. if (serializationObject.id != null) {
  100821. result.id = serializationObject.id;
  100822. }
  100823. if (serializationObject.normals) {
  100824. result.setNormals(serializationObject.normals);
  100825. }
  100826. if (serializationObject.tangents) {
  100827. result.setTangents(serializationObject.tangents);
  100828. }
  100829. // Animations
  100830. if (serializationObject.animations) {
  100831. for (var animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
  100832. var parsedAnimation = serializationObject.animations[animationIndex];
  100833. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  100834. if (internalClass) {
  100835. result.animations.push(internalClass.Parse(parsedAnimation));
  100836. }
  100837. }
  100838. }
  100839. return result;
  100840. };
  100841. /**
  100842. * Creates a MorphTarget from mesh data
  100843. * @param mesh defines the source mesh
  100844. * @param name defines the name to use for the new target
  100845. * @param influence defines the influence to attach to the target
  100846. * @returns a new MorphTarget
  100847. */
  100848. MorphTarget.FromMesh = function (mesh, name, influence) {
  100849. if (!name) {
  100850. name = mesh.name;
  100851. }
  100852. var result = new MorphTarget(name, influence, mesh.getScene());
  100853. result.setPositions(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  100854. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  100855. result.setNormals(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  100856. }
  100857. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  100858. result.setTangents(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  100859. }
  100860. return result;
  100861. };
  100862. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  100863. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["serialize"])()
  100864. ], MorphTarget.prototype, "id", void 0);
  100865. return MorphTarget;
  100866. }());
  100867. /***/ }),
  100868. /***/ "./Morph/morphTargetManager.ts":
  100869. /*!*************************************!*\
  100870. !*** ./Morph/morphTargetManager.ts ***!
  100871. \*************************************/
  100872. /*! exports provided: MorphTargetManager */
  100873. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100874. "use strict";
  100875. __webpack_require__.r(__webpack_exports__);
  100876. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return MorphTargetManager; });
  100877. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  100878. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  100879. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  100880. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  100881. /**
  100882. * This class is used to deform meshes using morphing between different targets
  100883. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  100884. */
  100885. var MorphTargetManager = /** @class */ (function () {
  100886. /**
  100887. * Creates a new MorphTargetManager
  100888. * @param scene defines the current scene
  100889. */
  100890. function MorphTargetManager(scene) {
  100891. if (scene === void 0) { scene = null; }
  100892. this._targets = new Array();
  100893. this._targetInfluenceChangedObservers = new Array();
  100894. this._targetDataLayoutChangedObservers = new Array();
  100895. this._activeTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  100896. this._supportsNormals = false;
  100897. this._supportsTangents = false;
  100898. this._vertexCount = 0;
  100899. this._uniqueId = 0;
  100900. this._tempInfluences = new Array();
  100901. if (!scene) {
  100902. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  100903. }
  100904. this._scene = scene;
  100905. if (this._scene) {
  100906. this._scene.morphTargetManagers.push(this);
  100907. this._uniqueId = this._scene.getUniqueId();
  100908. }
  100909. }
  100910. Object.defineProperty(MorphTargetManager.prototype, "uniqueId", {
  100911. /**
  100912. * Gets the unique ID of this manager
  100913. */
  100914. get: function () {
  100915. return this._uniqueId;
  100916. },
  100917. enumerable: true,
  100918. configurable: true
  100919. });
  100920. Object.defineProperty(MorphTargetManager.prototype, "vertexCount", {
  100921. /**
  100922. * Gets the number of vertices handled by this manager
  100923. */
  100924. get: function () {
  100925. return this._vertexCount;
  100926. },
  100927. enumerable: true,
  100928. configurable: true
  100929. });
  100930. Object.defineProperty(MorphTargetManager.prototype, "supportsNormals", {
  100931. /**
  100932. * Gets a boolean indicating if this manager supports morphing of normals
  100933. */
  100934. get: function () {
  100935. return this._supportsNormals;
  100936. },
  100937. enumerable: true,
  100938. configurable: true
  100939. });
  100940. Object.defineProperty(MorphTargetManager.prototype, "supportsTangents", {
  100941. /**
  100942. * Gets a boolean indicating if this manager supports morphing of tangents
  100943. */
  100944. get: function () {
  100945. return this._supportsTangents;
  100946. },
  100947. enumerable: true,
  100948. configurable: true
  100949. });
  100950. Object.defineProperty(MorphTargetManager.prototype, "numTargets", {
  100951. /**
  100952. * Gets the number of targets stored in this manager
  100953. */
  100954. get: function () {
  100955. return this._targets.length;
  100956. },
  100957. enumerable: true,
  100958. configurable: true
  100959. });
  100960. Object.defineProperty(MorphTargetManager.prototype, "numInfluencers", {
  100961. /**
  100962. * Gets the number of influencers (ie. the number of targets with influences > 0)
  100963. */
  100964. get: function () {
  100965. return this._activeTargets.length;
  100966. },
  100967. enumerable: true,
  100968. configurable: true
  100969. });
  100970. Object.defineProperty(MorphTargetManager.prototype, "influences", {
  100971. /**
  100972. * Gets the list of influences (one per target)
  100973. */
  100974. get: function () {
  100975. return this._influences;
  100976. },
  100977. enumerable: true,
  100978. configurable: true
  100979. });
  100980. /**
  100981. * Gets the active target at specified index. An active target is a target with an influence > 0
  100982. * @param index defines the index to check
  100983. * @returns the requested target
  100984. */
  100985. MorphTargetManager.prototype.getActiveTarget = function (index) {
  100986. return this._activeTargets.data[index];
  100987. };
  100988. /**
  100989. * Gets the target at specified index
  100990. * @param index defines the index to check
  100991. * @returns the requested target
  100992. */
  100993. MorphTargetManager.prototype.getTarget = function (index) {
  100994. return this._targets[index];
  100995. };
  100996. /**
  100997. * Add a new target to this manager
  100998. * @param target defines the target to add
  100999. */
  101000. MorphTargetManager.prototype.addTarget = function (target) {
  101001. var _this = this;
  101002. this._targets.push(target);
  101003. this._targetInfluenceChangedObservers.push(target.onInfluenceChanged.add(function (needUpdate) {
  101004. _this._syncActiveTargets(needUpdate);
  101005. }));
  101006. this._targetDataLayoutChangedObservers.push(target._onDataLayoutChanged.add(function () {
  101007. _this._syncActiveTargets(true);
  101008. }));
  101009. this._syncActiveTargets(true);
  101010. };
  101011. /**
  101012. * Removes a target from the manager
  101013. * @param target defines the target to remove
  101014. */
  101015. MorphTargetManager.prototype.removeTarget = function (target) {
  101016. var index = this._targets.indexOf(target);
  101017. if (index >= 0) {
  101018. this._targets.splice(index, 1);
  101019. target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);
  101020. target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);
  101021. this._syncActiveTargets(true);
  101022. }
  101023. };
  101024. /**
  101025. * Serializes the current manager into a Serialization object
  101026. * @returns the serialized object
  101027. */
  101028. MorphTargetManager.prototype.serialize = function () {
  101029. var serializationObject = {};
  101030. serializationObject.id = this.uniqueId;
  101031. serializationObject.targets = [];
  101032. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  101033. var target = _a[_i];
  101034. serializationObject.targets.push(target.serialize());
  101035. }
  101036. return serializationObject;
  101037. };
  101038. MorphTargetManager.prototype._syncActiveTargets = function (needUpdate) {
  101039. var influenceCount = 0;
  101040. this._activeTargets.reset();
  101041. this._supportsNormals = true;
  101042. this._supportsTangents = true;
  101043. this._vertexCount = 0;
  101044. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  101045. var target = _a[_i];
  101046. if (target.influence === 0) {
  101047. continue;
  101048. }
  101049. this._activeTargets.push(target);
  101050. this._tempInfluences[influenceCount++] = target.influence;
  101051. this._supportsNormals = this._supportsNormals && target.hasNormals;
  101052. this._supportsTangents = this._supportsTangents && target.hasTangents;
  101053. var positions = target.getPositions();
  101054. if (positions) {
  101055. var vertexCount = positions.length / 3;
  101056. if (this._vertexCount === 0) {
  101057. this._vertexCount = vertexCount;
  101058. }
  101059. else if (this._vertexCount !== vertexCount) {
  101060. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Incompatible target. Targets must all have the same vertices count.");
  101061. return;
  101062. }
  101063. }
  101064. }
  101065. if (!this._influences || this._influences.length !== influenceCount) {
  101066. this._influences = new Float32Array(influenceCount);
  101067. }
  101068. for (var index = 0; index < influenceCount; index++) {
  101069. this._influences[index] = this._tempInfluences[index];
  101070. }
  101071. if (needUpdate) {
  101072. this.synchronize();
  101073. }
  101074. };
  101075. /**
  101076. * Syncrhonize the targets with all the meshes using this morph target manager
  101077. */
  101078. MorphTargetManager.prototype.synchronize = function () {
  101079. if (!this._scene) {
  101080. return;
  101081. }
  101082. // Flag meshes as dirty to resync with the active targets
  101083. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  101084. var mesh = _a[_i];
  101085. if (mesh.morphTargetManager === this) {
  101086. mesh._syncGeometryWithMorphTargetManager();
  101087. }
  101088. }
  101089. };
  101090. // Statics
  101091. /**
  101092. * Creates a new MorphTargetManager from serialized data
  101093. * @param serializationObject defines the serialized data
  101094. * @param scene defines the hosting scene
  101095. * @returns the new MorphTargetManager
  101096. */
  101097. MorphTargetManager.Parse = function (serializationObject, scene) {
  101098. var result = new MorphTargetManager(scene);
  101099. result._uniqueId = serializationObject.id;
  101100. for (var _i = 0, _a = serializationObject.targets; _i < _a.length; _i++) {
  101101. var targetData = _a[_i];
  101102. result.addTarget(_morphTarget__WEBPACK_IMPORTED_MODULE_3__["MorphTarget"].Parse(targetData));
  101103. }
  101104. return result;
  101105. };
  101106. return MorphTargetManager;
  101107. }());
  101108. /***/ }),
  101109. /***/ "./Offline/database.ts":
  101110. /*!*****************************!*\
  101111. !*** ./Offline/database.ts ***!
  101112. \*****************************/
  101113. /*! exports provided: Database */
  101114. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101115. "use strict";
  101116. __webpack_require__.r(__webpack_exports__);
  101117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
  101118. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  101119. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  101120. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tga */ "./Misc/tga.ts");
  101121. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  101122. // Sets the default offline provider to Babylon.js
  101123. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].OfflineProviderFactory = function (urlToScene, callbackManifestChecked, disableManifestCheck) {
  101124. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  101125. return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);
  101126. };
  101127. /**
  101128. * Class used to enable access to IndexedDB
  101129. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  101130. */
  101131. var Database = /** @class */ (function () {
  101132. /**
  101133. * Creates a new Database
  101134. * @param urlToScene defines the url to load the scene
  101135. * @param callbackManifestChecked defines the callback to use when manifest is checked
  101136. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  101137. */
  101138. function Database(urlToScene, callbackManifestChecked, disableManifestCheck) {
  101139. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  101140. var _this = this;
  101141. // Handling various flavors of prefixed version of IndexedDB
  101142. this._idbFactory = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
  101143. this._callbackManifestChecked = callbackManifestChecked;
  101144. this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);
  101145. this._db = null;
  101146. this._enableSceneOffline = false;
  101147. this._enableTexturesOffline = false;
  101148. this._manifestVersionFound = 0;
  101149. this._mustUpdateRessources = false;
  101150. this._hasReachedQuota = false;
  101151. if (!Database.IDBStorageEnabled) {
  101152. this._callbackManifestChecked(true);
  101153. }
  101154. else {
  101155. if (disableManifestCheck) {
  101156. this._enableSceneOffline = true;
  101157. this._enableTexturesOffline = true;
  101158. this._manifestVersionFound = 1;
  101159. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  101160. _this._callbackManifestChecked(true);
  101161. });
  101162. }
  101163. else {
  101164. this._checkManifestFile();
  101165. }
  101166. }
  101167. }
  101168. Object.defineProperty(Database.prototype, "enableSceneOffline", {
  101169. /**
  101170. * Gets a boolean indicating if scene must be saved in the database
  101171. */
  101172. get: function () {
  101173. return this._enableSceneOffline;
  101174. },
  101175. enumerable: true,
  101176. configurable: true
  101177. });
  101178. Object.defineProperty(Database.prototype, "enableTexturesOffline", {
  101179. /**
  101180. * Gets a boolean indicating if textures must be saved in the database
  101181. */
  101182. get: function () {
  101183. return this._enableTexturesOffline;
  101184. },
  101185. enumerable: true,
  101186. configurable: true
  101187. });
  101188. Database.prototype._checkManifestFile = function () {
  101189. var _this = this;
  101190. var noManifestFile = function () {
  101191. _this._enableSceneOffline = false;
  101192. _this._enableTexturesOffline = false;
  101193. _this._callbackManifestChecked(false);
  101194. };
  101195. var timeStampUsed = false;
  101196. var manifestURL = this._currentSceneUrl + ".manifest";
  101197. var xhr = new XMLHttpRequest();
  101198. if (navigator.onLine) {
  101199. // Adding a timestamp to by-pass browsers' cache
  101200. timeStampUsed = true;
  101201. manifestURL = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
  101202. }
  101203. xhr.open("GET", manifestURL, true);
  101204. xhr.addEventListener("load", function () {
  101205. if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {
  101206. try {
  101207. var manifestFile = JSON.parse(xhr.response);
  101208. _this._enableSceneOffline = manifestFile.enableSceneOffline;
  101209. _this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database.IsUASupportingBlobStorage;
  101210. if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
  101211. _this._manifestVersionFound = manifestFile.version;
  101212. }
  101213. if (_this._callbackManifestChecked) {
  101214. _this._callbackManifestChecked(true);
  101215. }
  101216. }
  101217. catch (ex) {
  101218. noManifestFile();
  101219. }
  101220. }
  101221. else {
  101222. noManifestFile();
  101223. }
  101224. }, false);
  101225. xhr.addEventListener("error", function () {
  101226. if (timeStampUsed) {
  101227. timeStampUsed = false;
  101228. // Let's retry without the timeStamp
  101229. // It could fail when coupled with HTML5 Offline API
  101230. var retryManifestURL = _this._currentSceneUrl + ".manifest";
  101231. xhr.open("GET", retryManifestURL, true);
  101232. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  101233. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101234. }
  101235. xhr.send();
  101236. }
  101237. else {
  101238. noManifestFile();
  101239. }
  101240. }, false);
  101241. try {
  101242. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  101243. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101244. }
  101245. xhr.send();
  101246. }
  101247. catch (ex) {
  101248. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error on XHR send request.");
  101249. this._callbackManifestChecked(false);
  101250. }
  101251. };
  101252. /**
  101253. * Open the database and make it available
  101254. * @param successCallback defines the callback to call on success
  101255. * @param errorCallback defines the callback to call on error
  101256. */
  101257. Database.prototype.open = function (successCallback, errorCallback) {
  101258. var _this = this;
  101259. var handleError = function () {
  101260. _this._isSupported = false;
  101261. if (errorCallback) {
  101262. errorCallback();
  101263. }
  101264. };
  101265. if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {
  101266. // Your browser doesn't support IndexedDB
  101267. this._isSupported = false;
  101268. if (errorCallback) {
  101269. errorCallback();
  101270. }
  101271. }
  101272. else {
  101273. // If the DB hasn't been opened or created yet
  101274. if (!this._db) {
  101275. this._hasReachedQuota = false;
  101276. this._isSupported = true;
  101277. var request = this._idbFactory.open("babylonjs", 1);
  101278. // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
  101279. request.onerror = function () {
  101280. handleError();
  101281. };
  101282. // executes when a version change transaction cannot complete due to other active transactions
  101283. request.onblocked = function () {
  101284. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("IDB request blocked. Please reload the page.");
  101285. handleError();
  101286. };
  101287. // DB has been opened successfully
  101288. request.onsuccess = function () {
  101289. _this._db = request.result;
  101290. successCallback();
  101291. };
  101292. // Initialization of the DB. Creating Scenes & Textures stores
  101293. request.onupgradeneeded = function (event) {
  101294. _this._db = (event.target).result;
  101295. if (_this._db) {
  101296. try {
  101297. _this._db.createObjectStore("scenes", { keyPath: "sceneUrl" });
  101298. _this._db.createObjectStore("versions", { keyPath: "sceneUrl" });
  101299. _this._db.createObjectStore("textures", { keyPath: "textureUrl" });
  101300. }
  101301. catch (ex) {
  101302. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while creating object stores. Exception: " + ex.message);
  101303. handleError();
  101304. }
  101305. }
  101306. };
  101307. }
  101308. // DB has already been created and opened
  101309. else {
  101310. if (successCallback) {
  101311. successCallback();
  101312. }
  101313. }
  101314. }
  101315. };
  101316. /**
  101317. * Loads an image from the database
  101318. * @param url defines the url to load from
  101319. * @param image defines the target DOM image
  101320. */
  101321. Database.prototype.loadImage = function (url, image) {
  101322. var _this = this;
  101323. var completeURL = Database._ReturnFullUrlLocation(url);
  101324. var saveAndLoadImage = function () {
  101325. if (!_this._hasReachedQuota && _this._db !== null) {
  101326. // the texture is not yet in the DB, let's try to save it
  101327. _this._saveImageIntoDBAsync(completeURL, image);
  101328. }
  101329. // If the texture is not in the DB and we've reached the DB quota limit
  101330. // let's load it directly from the web
  101331. else {
  101332. image.src = url;
  101333. }
  101334. };
  101335. if (!this._mustUpdateRessources) {
  101336. this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);
  101337. }
  101338. // First time we're download the images or update requested in the manifest file by a version change
  101339. else {
  101340. saveAndLoadImage();
  101341. }
  101342. };
  101343. Database.prototype._loadImageFromDBAsync = function (url, image, notInDBCallback) {
  101344. if (this._isSupported && this._db !== null) {
  101345. var texture;
  101346. var transaction = this._db.transaction(["textures"]);
  101347. transaction.onabort = function () {
  101348. image.src = url;
  101349. };
  101350. transaction.oncomplete = function () {
  101351. var blobTextureURL;
  101352. if (texture) {
  101353. var URL = window.URL || window.webkitURL;
  101354. blobTextureURL = URL.createObjectURL(texture.data);
  101355. image.onerror = function () {
  101356. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
  101357. image.src = url;
  101358. };
  101359. image.src = blobTextureURL;
  101360. }
  101361. else {
  101362. notInDBCallback();
  101363. }
  101364. };
  101365. var getRequest = transaction.objectStore("textures").get(url);
  101366. getRequest.onsuccess = function (event) {
  101367. texture = (event.target).result;
  101368. };
  101369. getRequest.onerror = function () {
  101370. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading texture " + url + " from DB.");
  101371. image.src = url;
  101372. };
  101373. }
  101374. else {
  101375. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101376. image.src = url;
  101377. }
  101378. };
  101379. Database.prototype._saveImageIntoDBAsync = function (url, image) {
  101380. var _this = this;
  101381. if (this._isSupported) {
  101382. // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on
  101383. var generateBlobUrl = function () {
  101384. var blobTextureURL;
  101385. if (blob) {
  101386. var URL = window.URL || window.webkitURL;
  101387. try {
  101388. blobTextureURL = URL.createObjectURL(blob);
  101389. }
  101390. // Chrome is raising a type error if we're setting the oneTimeOnly parameter
  101391. catch (ex) {
  101392. blobTextureURL = URL.createObjectURL(blob);
  101393. }
  101394. }
  101395. if (blobTextureURL) {
  101396. image.src = blobTextureURL;
  101397. }
  101398. };
  101399. if (Database.IsUASupportingBlobStorage) { // Create XHR
  101400. var xhr = new XMLHttpRequest(), blob;
  101401. xhr.open("GET", url, true);
  101402. xhr.responseType = "blob";
  101403. xhr.addEventListener("load", function () {
  101404. if (xhr.status === 200 && _this._db) {
  101405. // Blob as response (XHR2)
  101406. blob = xhr.response;
  101407. var transaction = _this._db.transaction(["textures"], "readwrite");
  101408. // the transaction could abort because of a QuotaExceededError error
  101409. transaction.onabort = function (event) {
  101410. try {
  101411. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  101412. var srcElement = (event.srcElement || event.target);
  101413. var error = srcElement.error;
  101414. if (error && error.name === "QuotaExceededError") {
  101415. _this._hasReachedQuota = true;
  101416. }
  101417. }
  101418. catch (ex) { }
  101419. generateBlobUrl();
  101420. };
  101421. transaction.oncomplete = function () {
  101422. generateBlobUrl();
  101423. };
  101424. var newTexture = { textureUrl: url, data: blob };
  101425. try {
  101426. // Put the blob into the dabase
  101427. var addRequest = transaction.objectStore("textures").put(newTexture);
  101428. addRequest.onsuccess = function () {
  101429. };
  101430. addRequest.onerror = function () {
  101431. generateBlobUrl();
  101432. };
  101433. }
  101434. catch (ex) {
  101435. // "DataCloneError" generated by Chrome when you try to inject blob into IndexedDB
  101436. if (ex.code === 25) {
  101437. Database.IsUASupportingBlobStorage = false;
  101438. _this._enableTexturesOffline = false;
  101439. }
  101440. image.src = url;
  101441. }
  101442. }
  101443. else {
  101444. image.src = url;
  101445. }
  101446. }, false);
  101447. xhr.addEventListener("error", function () {
  101448. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in XHR request in BABYLON.Database.");
  101449. image.src = url;
  101450. }, false);
  101451. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].CustomRequestHeaders) {
  101452. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101453. }
  101454. xhr.send();
  101455. }
  101456. else {
  101457. image.src = url;
  101458. }
  101459. }
  101460. else {
  101461. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101462. image.src = url;
  101463. }
  101464. };
  101465. Database.prototype._checkVersionFromDB = function (url, versionLoaded) {
  101466. var _this = this;
  101467. var updateVersion = function () {
  101468. // the version is not yet in the DB or we need to update it
  101469. _this._saveVersionIntoDBAsync(url, versionLoaded);
  101470. };
  101471. this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);
  101472. };
  101473. Database.prototype._loadVersionFromDBAsync = function (url, callback, updateInDBCallback) {
  101474. var _this = this;
  101475. if (this._isSupported && this._db) {
  101476. var version;
  101477. try {
  101478. var transaction = this._db.transaction(["versions"]);
  101479. transaction.oncomplete = function () {
  101480. if (version) {
  101481. // If the version in the JSON file is different from the version in DB
  101482. if (_this._manifestVersionFound !== version.data) {
  101483. _this._mustUpdateRessources = true;
  101484. updateInDBCallback();
  101485. }
  101486. else {
  101487. callback(version.data);
  101488. }
  101489. }
  101490. // version was not found in DB
  101491. else {
  101492. _this._mustUpdateRessources = true;
  101493. updateInDBCallback();
  101494. }
  101495. };
  101496. transaction.onabort = function () {
  101497. callback(-1);
  101498. };
  101499. var getRequest = transaction.objectStore("versions").get(url);
  101500. getRequest.onsuccess = function (event) {
  101501. version = (event.target).result;
  101502. };
  101503. getRequest.onerror = function () {
  101504. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading version for scene " + url + " from DB.");
  101505. callback(-1);
  101506. };
  101507. }
  101508. catch (ex) {
  101509. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
  101510. callback(-1);
  101511. }
  101512. }
  101513. else {
  101514. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101515. callback(-1);
  101516. }
  101517. };
  101518. Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
  101519. var _this = this;
  101520. if (this._isSupported && !this._hasReachedQuota && this._db) {
  101521. try {
  101522. // Open a transaction to the database
  101523. var transaction = this._db.transaction(["versions"], "readwrite");
  101524. // the transaction could abort because of a QuotaExceededError error
  101525. transaction.onabort = function (event) {
  101526. try { //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  101527. var error = event.srcElement['error'];
  101528. if (error && error.name === "QuotaExceededError") {
  101529. _this._hasReachedQuota = true;
  101530. }
  101531. }
  101532. catch (ex) { }
  101533. callback(-1);
  101534. };
  101535. transaction.oncomplete = function () {
  101536. callback(_this._manifestVersionFound);
  101537. };
  101538. var newVersion = { sceneUrl: url, data: this._manifestVersionFound };
  101539. // Put the scene into the database
  101540. var addRequest = transaction.objectStore("versions").put(newVersion);
  101541. addRequest.onsuccess = function () {
  101542. };
  101543. addRequest.onerror = function () {
  101544. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add version request in BABYLON.Database.");
  101545. };
  101546. }
  101547. catch (ex) {
  101548. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
  101549. callback(-1);
  101550. }
  101551. }
  101552. else {
  101553. callback(-1);
  101554. }
  101555. };
  101556. /**
  101557. * Loads a file from database
  101558. * @param url defines the URL to load from
  101559. * @param sceneLoaded defines a callback to call on success
  101560. * @param progressCallBack defines a callback to call when progress changed
  101561. * @param errorCallback defines a callback to call on error
  101562. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  101563. */
  101564. Database.prototype.loadFile = function (url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {
  101565. var _this = this;
  101566. var completeUrl = Database._ReturnFullUrlLocation(url);
  101567. var saveAndLoadFile = function () {
  101568. // the scene is not yet in the DB, let's try to save it
  101569. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  101570. };
  101571. this._checkVersionFromDB(completeUrl, function (version) {
  101572. if (version !== -1) {
  101573. if (!_this._mustUpdateRessources) {
  101574. _this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile);
  101575. }
  101576. else {
  101577. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  101578. }
  101579. }
  101580. else {
  101581. if (errorCallback) {
  101582. errorCallback();
  101583. }
  101584. }
  101585. });
  101586. };
  101587. Database.prototype._loadFileAsync = function (url, callback, notInDBCallback) {
  101588. if (this._isSupported && this._db) {
  101589. var targetStore;
  101590. if (url.indexOf(".babylon") !== -1) {
  101591. targetStore = "scenes";
  101592. }
  101593. else {
  101594. targetStore = "textures";
  101595. }
  101596. var file;
  101597. var transaction = this._db.transaction([targetStore]);
  101598. transaction.oncomplete = function () {
  101599. if (file) {
  101600. callback(file.data);
  101601. }
  101602. // file was not found in DB
  101603. else {
  101604. notInDBCallback();
  101605. }
  101606. };
  101607. transaction.onabort = function () {
  101608. notInDBCallback();
  101609. };
  101610. var getRequest = transaction.objectStore(targetStore).get(url);
  101611. getRequest.onsuccess = function (event) {
  101612. file = (event.target).result;
  101613. };
  101614. getRequest.onerror = function () {
  101615. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading file " + url + " from DB.");
  101616. notInDBCallback();
  101617. };
  101618. }
  101619. else {
  101620. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  101621. callback();
  101622. }
  101623. };
  101624. Database.prototype._saveFileAsync = function (url, callback, progressCallback, useArrayBuffer, errorCallback) {
  101625. var _this = this;
  101626. if (this._isSupported) {
  101627. var targetStore;
  101628. if (url.indexOf(".babylon") !== -1) {
  101629. targetStore = "scenes";
  101630. }
  101631. else {
  101632. targetStore = "textures";
  101633. }
  101634. // Create XHR
  101635. var xhr = new XMLHttpRequest();
  101636. var fileData;
  101637. xhr.open("GET", url + "?" + Date.now(), true);
  101638. if (useArrayBuffer) {
  101639. xhr.responseType = "arraybuffer";
  101640. }
  101641. if (progressCallback) {
  101642. xhr.onprogress = progressCallback;
  101643. }
  101644. xhr.addEventListener("load", function () {
  101645. if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {
  101646. // Blob as response (XHR2)
  101647. fileData = !useArrayBuffer ? xhr.responseText : xhr.response;
  101648. if (!_this._hasReachedQuota && _this._db) {
  101649. // Open a transaction to the database
  101650. var transaction = _this._db.transaction([targetStore], "readwrite");
  101651. // the transaction could abort because of a QuotaExceededError error
  101652. transaction.onabort = function (event) {
  101653. try {
  101654. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  101655. var error = event.srcElement['error'];
  101656. if (error && error.name === "QuotaExceededError") {
  101657. _this._hasReachedQuota = true;
  101658. }
  101659. }
  101660. catch (ex) { }
  101661. callback(fileData);
  101662. };
  101663. transaction.oncomplete = function () {
  101664. callback(fileData);
  101665. };
  101666. var newFile;
  101667. if (targetStore === "scenes") {
  101668. newFile = { sceneUrl: url, data: fileData, version: _this._manifestVersionFound };
  101669. }
  101670. else {
  101671. newFile = { textureUrl: url, data: fileData };
  101672. }
  101673. try {
  101674. // Put the scene into the database
  101675. var addRequest = transaction.objectStore(targetStore).put(newFile);
  101676. addRequest.onsuccess = function () {
  101677. };
  101678. addRequest.onerror = function () {
  101679. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add file request in BABYLON.Database.");
  101680. };
  101681. }
  101682. catch (ex) {
  101683. callback(fileData);
  101684. }
  101685. }
  101686. else {
  101687. callback(fileData);
  101688. }
  101689. }
  101690. else {
  101691. if (xhr.status >= 400 && errorCallback) {
  101692. errorCallback(xhr);
  101693. }
  101694. else {
  101695. callback();
  101696. }
  101697. }
  101698. }, false);
  101699. xhr.addEventListener("error", function () {
  101700. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("error on XHR request.");
  101701. callback();
  101702. }, false);
  101703. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  101704. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101705. }
  101706. xhr.send();
  101707. }
  101708. else {
  101709. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
  101710. callback();
  101711. }
  101712. };
  101713. /**
  101714. * Validates if xhr data is correct
  101715. * @param xhr defines the request to validate
  101716. * @param dataType defines the expected data type
  101717. * @returns true if data is correct
  101718. */
  101719. Database._ValidateXHRData = function (xhr, dataType) {
  101720. // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all
  101721. if (dataType === void 0) { dataType = 7; }
  101722. try {
  101723. if (dataType & 1) {
  101724. if (xhr.responseText && xhr.responseText.length > 0) {
  101725. return true;
  101726. }
  101727. else if (dataType === 1) {
  101728. return false;
  101729. }
  101730. }
  101731. if (dataType & 2) {
  101732. // Check header width and height since there is no "TGA" magic number
  101733. var tgaHeader = _Misc_tga__WEBPACK_IMPORTED_MODULE_2__["TGATools"].GetTGAHeader(xhr.response);
  101734. if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
  101735. return true;
  101736. }
  101737. else if (dataType === 2) {
  101738. return false;
  101739. }
  101740. }
  101741. if (dataType & 4) {
  101742. // Check for the "DDS" magic number
  101743. var ddsHeader = new Uint8Array(xhr.response, 0, 3);
  101744. if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
  101745. return true;
  101746. }
  101747. else {
  101748. return false;
  101749. }
  101750. }
  101751. }
  101752. catch (e) {
  101753. // Global protection
  101754. }
  101755. return false;
  101756. };
  101757. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  101758. Database.IsUASupportingBlobStorage = true;
  101759. /**
  101760. * Gets a boolean indicating if Database storate is enabled (off by default)
  101761. */
  101762. Database.IDBStorageEnabled = false;
  101763. Database._ParseURL = function (url) {
  101764. var a = document.createElement('a');
  101765. a.href = url;
  101766. var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
  101767. var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
  101768. var absLocation = url.substring(0, url.indexOf(fileName, 0));
  101769. return absLocation;
  101770. };
  101771. Database._ReturnFullUrlLocation = function (url) {
  101772. if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1) {
  101773. return (Database._ParseURL(window.location.href) + url);
  101774. }
  101775. else {
  101776. return url;
  101777. }
  101778. };
  101779. return Database;
  101780. }());
  101781. /***/ }),
  101782. /***/ "./Offline/index.ts":
  101783. /*!**************************!*\
  101784. !*** ./Offline/index.ts ***!
  101785. \**************************/
  101786. /*! exports provided: Database */
  101787. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101788. "use strict";
  101789. __webpack_require__.r(__webpack_exports__);
  101790. /* harmony import */ var _database__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database */ "./Offline/database.ts");
  101791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _database__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  101792. /***/ }),
  101793. /***/ "./Particles/EmitterTypes/boxParticleEmitter.ts":
  101794. /*!******************************************************!*\
  101795. !*** ./Particles/EmitterTypes/boxParticleEmitter.ts ***!
  101796. \******************************************************/
  101797. /*! exports provided: BoxParticleEmitter */
  101798. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101799. "use strict";
  101800. __webpack_require__.r(__webpack_exports__);
  101801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return BoxParticleEmitter; });
  101802. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101803. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101804. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101805. /**
  101806. * Particle emitter emitting particles from the inside of a box.
  101807. * It emits the particles randomly between 2 given directions.
  101808. */
  101809. var BoxParticleEmitter = /** @class */ (function () {
  101810. /**
  101811. * Creates a new instance BoxParticleEmitter
  101812. */
  101813. function BoxParticleEmitter() {
  101814. /**
  101815. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101816. */
  101817. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  101818. /**
  101819. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101820. */
  101821. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  101822. /**
  101823. * 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.
  101824. */
  101825. this.minEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-0.5, -0.5, -0.5);
  101826. /**
  101827. * 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.
  101828. */
  101829. this.maxEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.5, 0.5, 0.5);
  101830. }
  101831. /**
  101832. * Called by the particle System when the direction is computed for the created particle.
  101833. * @param worldMatrix is the world matrix of the particle system
  101834. * @param directionToUpdate is the direction vector to update with the result
  101835. * @param particle is the particle we are computed the direction for
  101836. */
  101837. BoxParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101838. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  101839. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  101840. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  101841. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  101842. };
  101843. /**
  101844. * Called by the particle System when the position is computed for the created particle.
  101845. * @param worldMatrix is the world matrix of the particle system
  101846. * @param positionToUpdate is the position vector to update with the result
  101847. * @param particle is the particle we are computed the position for
  101848. */
  101849. BoxParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101850. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.x, this.maxEmitBox.x);
  101851. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.y, this.maxEmitBox.y);
  101852. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  101853. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  101854. };
  101855. /**
  101856. * Clones the current emitter and returns a copy of it
  101857. * @returns the new emitter
  101858. */
  101859. BoxParticleEmitter.prototype.clone = function () {
  101860. var newOne = new BoxParticleEmitter();
  101861. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  101862. return newOne;
  101863. };
  101864. /**
  101865. * Called by the GPUParticleSystem to setup the update shader
  101866. * @param effect defines the update shader
  101867. */
  101868. BoxParticleEmitter.prototype.applyToShader = function (effect) {
  101869. effect.setVector3("direction1", this.direction1);
  101870. effect.setVector3("direction2", this.direction2);
  101871. effect.setVector3("minEmitBox", this.minEmitBox);
  101872. effect.setVector3("maxEmitBox", this.maxEmitBox);
  101873. };
  101874. /**
  101875. * Returns a string to use to update the GPU particles update shader
  101876. * @returns a string containng the defines string
  101877. */
  101878. BoxParticleEmitter.prototype.getEffectDefines = function () {
  101879. return "#define BOXEMITTER";
  101880. };
  101881. /**
  101882. * Returns the string "BoxParticleEmitter"
  101883. * @returns a string containing the class name
  101884. */
  101885. BoxParticleEmitter.prototype.getClassName = function () {
  101886. return "BoxParticleEmitter";
  101887. };
  101888. /**
  101889. * Serializes the particle system to a JSON object.
  101890. * @returns the JSON object
  101891. */
  101892. BoxParticleEmitter.prototype.serialize = function () {
  101893. var serializationObject = {};
  101894. serializationObject.type = this.getClassName();
  101895. serializationObject.direction1 = this.direction1.asArray();
  101896. serializationObject.direction2 = this.direction2.asArray();
  101897. serializationObject.minEmitBox = this.minEmitBox.asArray();
  101898. serializationObject.maxEmitBox = this.maxEmitBox.asArray();
  101899. return serializationObject;
  101900. };
  101901. /**
  101902. * Parse properties from a JSON object
  101903. * @param serializationObject defines the JSON object
  101904. */
  101905. BoxParticleEmitter.prototype.parse = function (serializationObject) {
  101906. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  101907. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  101908. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.minEmitBox, 0, this.minEmitBox);
  101909. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.maxEmitBox, 0, this.maxEmitBox);
  101910. };
  101911. return BoxParticleEmitter;
  101912. }());
  101913. /***/ }),
  101914. /***/ "./Particles/EmitterTypes/coneParticleEmitter.ts":
  101915. /*!*******************************************************!*\
  101916. !*** ./Particles/EmitterTypes/coneParticleEmitter.ts ***!
  101917. \*******************************************************/
  101918. /*! exports provided: ConeParticleEmitter */
  101919. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101920. "use strict";
  101921. __webpack_require__.r(__webpack_exports__);
  101922. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return ConeParticleEmitter; });
  101923. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101924. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101925. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101926. /**
  101927. * Particle emitter emitting particles from the inside of a cone.
  101928. * It emits the particles alongside the cone volume from the base to the particle.
  101929. * The emission direction might be randomized.
  101930. */
  101931. var ConeParticleEmitter = /** @class */ (function () {
  101932. /**
  101933. * Creates a new instance ConeParticleEmitter
  101934. * @param radius the radius of the emission cone (1 by default)
  101935. * @param angle the cone base angle (PI by default)
  101936. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  101937. */
  101938. function ConeParticleEmitter(radius, angle,
  101939. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  101940. directionRandomizer) {
  101941. if (radius === void 0) { radius = 1; }
  101942. if (angle === void 0) { angle = Math.PI; }
  101943. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  101944. this.directionRandomizer = directionRandomizer;
  101945. /**
  101946. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  101947. */
  101948. this.radiusRange = 1;
  101949. /**
  101950. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  101951. */
  101952. this.heightRange = 1;
  101953. /**
  101954. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  101955. */
  101956. this.emitFromSpawnPointOnly = false;
  101957. this.angle = angle;
  101958. this.radius = radius;
  101959. }
  101960. Object.defineProperty(ConeParticleEmitter.prototype, "radius", {
  101961. /**
  101962. * Gets or sets the radius of the emission cone
  101963. */
  101964. get: function () {
  101965. return this._radius;
  101966. },
  101967. set: function (value) {
  101968. this._radius = value;
  101969. this._buildHeight();
  101970. },
  101971. enumerable: true,
  101972. configurable: true
  101973. });
  101974. Object.defineProperty(ConeParticleEmitter.prototype, "angle", {
  101975. /**
  101976. * Gets or sets the angle of the emission cone
  101977. */
  101978. get: function () {
  101979. return this._angle;
  101980. },
  101981. set: function (value) {
  101982. this._angle = value;
  101983. this._buildHeight();
  101984. },
  101985. enumerable: true,
  101986. configurable: true
  101987. });
  101988. ConeParticleEmitter.prototype._buildHeight = function () {
  101989. if (this._angle !== 0) {
  101990. this._height = this._radius / Math.tan(this._angle / 2);
  101991. }
  101992. else {
  101993. this._height = 1;
  101994. }
  101995. };
  101996. /**
  101997. * Called by the particle System when the direction is computed for the created particle.
  101998. * @param worldMatrix is the world matrix of the particle system
  101999. * @param directionToUpdate is the direction vector to update with the result
  102000. * @param particle is the particle we are computed the direction for
  102001. */
  102002. ConeParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102003. if (Math.abs(Math.cos(this._angle)) === 1.0) {
  102004. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(0, 1.0, 0, worldMatrix, directionToUpdate);
  102005. }
  102006. else {
  102007. // measure the direction Vector from the emitter to the particle.
  102008. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  102009. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102010. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102011. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102012. direction.x += randX;
  102013. direction.y += randY;
  102014. direction.z += randZ;
  102015. direction.normalize();
  102016. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  102017. }
  102018. };
  102019. /**
  102020. * Called by the particle System when the position is computed for the created particle.
  102021. * @param worldMatrix is the world matrix of the particle system
  102022. * @param positionToUpdate is the position vector to update with the result
  102023. * @param particle is the particle we are computed the position for
  102024. */
  102025. ConeParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102026. var s = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, Math.PI * 2);
  102027. var h;
  102028. if (!this.emitFromSpawnPointOnly) {
  102029. h = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.heightRange);
  102030. // Better distribution in a cone at normal angles.
  102031. h = 1 - h * h;
  102032. }
  102033. else {
  102034. h = 0.0001;
  102035. }
  102036. var radius = this._radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this._radius * this.radiusRange);
  102037. radius = radius * h;
  102038. var randX = radius * Math.sin(s);
  102039. var randZ = radius * Math.cos(s);
  102040. var randY = h * this._height;
  102041. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  102042. };
  102043. /**
  102044. * Clones the current emitter and returns a copy of it
  102045. * @returns the new emitter
  102046. */
  102047. ConeParticleEmitter.prototype.clone = function () {
  102048. var newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);
  102049. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  102050. return newOne;
  102051. };
  102052. /**
  102053. * Called by the GPUParticleSystem to setup the update shader
  102054. * @param effect defines the update shader
  102055. */
  102056. ConeParticleEmitter.prototype.applyToShader = function (effect) {
  102057. effect.setFloat2("radius", this._radius, this.radiusRange);
  102058. effect.setFloat("coneAngle", this._angle);
  102059. effect.setFloat2("height", this._height, this.heightRange);
  102060. effect.setFloat("directionRandomizer", this.directionRandomizer);
  102061. };
  102062. /**
  102063. * Returns a string to use to update the GPU particles update shader
  102064. * @returns a string containng the defines string
  102065. */
  102066. ConeParticleEmitter.prototype.getEffectDefines = function () {
  102067. var defines = "#define CONEEMITTER";
  102068. if (this.emitFromSpawnPointOnly) {
  102069. defines += "\n#define CONEEMITTERSPAWNPOINT";
  102070. }
  102071. return defines;
  102072. };
  102073. /**
  102074. * Returns the string "ConeParticleEmitter"
  102075. * @returns a string containing the class name
  102076. */
  102077. ConeParticleEmitter.prototype.getClassName = function () {
  102078. return "ConeParticleEmitter";
  102079. };
  102080. /**
  102081. * Serializes the particle system to a JSON object.
  102082. * @returns the JSON object
  102083. */
  102084. ConeParticleEmitter.prototype.serialize = function () {
  102085. var serializationObject = {};
  102086. serializationObject.type = this.getClassName();
  102087. serializationObject.radius = this._radius;
  102088. serializationObject.angle = this._angle;
  102089. serializationObject.directionRandomizer = this.directionRandomizer;
  102090. return serializationObject;
  102091. };
  102092. /**
  102093. * Parse properties from a JSON object
  102094. * @param serializationObject defines the JSON object
  102095. */
  102096. ConeParticleEmitter.prototype.parse = function (serializationObject) {
  102097. this.radius = serializationObject.radius;
  102098. this.angle = serializationObject.angle;
  102099. this.directionRandomizer = serializationObject.directionRandomizer;
  102100. };
  102101. return ConeParticleEmitter;
  102102. }());
  102103. /***/ }),
  102104. /***/ "./Particles/EmitterTypes/cylinderParticleEmitter.ts":
  102105. /*!***********************************************************!*\
  102106. !*** ./Particles/EmitterTypes/cylinderParticleEmitter.ts ***!
  102107. \***********************************************************/
  102108. /*! exports provided: CylinderParticleEmitter, CylinderDirectedParticleEmitter */
  102109. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102110. "use strict";
  102111. __webpack_require__.r(__webpack_exports__);
  102112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return CylinderParticleEmitter; });
  102113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return CylinderDirectedParticleEmitter; });
  102114. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102115. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102116. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102117. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102118. /**
  102119. * Particle emitter emitting particles from the inside of a cylinder.
  102120. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  102121. */
  102122. var CylinderParticleEmitter = /** @class */ (function () {
  102123. /**
  102124. * Creates a new instance CylinderParticleEmitter
  102125. * @param radius the radius of the emission cylinder (1 by default)
  102126. * @param height the height of the emission cylinder (1 by default)
  102127. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102128. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  102129. */
  102130. function CylinderParticleEmitter(
  102131. /**
  102132. * The radius of the emission cylinder.
  102133. */
  102134. radius,
  102135. /**
  102136. * The height of the emission cylinder.
  102137. */
  102138. height,
  102139. /**
  102140. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  102141. */
  102142. radiusRange,
  102143. /**
  102144. * How much to randomize the particle direction [0-1].
  102145. */
  102146. directionRandomizer) {
  102147. if (radius === void 0) { radius = 1; }
  102148. if (height === void 0) { height = 1; }
  102149. if (radiusRange === void 0) { radiusRange = 1; }
  102150. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  102151. this.radius = radius;
  102152. this.height = height;
  102153. this.radiusRange = radiusRange;
  102154. this.directionRandomizer = directionRandomizer;
  102155. }
  102156. /**
  102157. * Called by the particle System when the direction is computed for the created particle.
  102158. * @param worldMatrix is the world matrix of the particle system
  102159. * @param directionToUpdate is the direction vector to update with the result
  102160. * @param particle is the particle we are computed the direction for
  102161. */
  102162. CylinderParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102163. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  102164. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);
  102165. var angle = Math.atan2(direction.x, direction.z);
  102166. angle += _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;
  102167. direction.y = randY; // set direction y to rand y to mirror normal of cylinder surface
  102168. direction.x = Math.sin(angle);
  102169. direction.z = Math.cos(angle);
  102170. direction.normalize();
  102171. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  102172. };
  102173. /**
  102174. * Called by the particle System when the position is computed for the created particle.
  102175. * @param worldMatrix is the world matrix of the particle system
  102176. * @param positionToUpdate is the position vector to update with the result
  102177. * @param particle is the particle we are computed the position for
  102178. */
  102179. CylinderParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102180. var yPos = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.height / 2, this.height / 2);
  102181. var angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  102182. // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
  102183. var radiusDistribution = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);
  102184. var positionRadius = Math.sqrt(radiusDistribution) * this.radius;
  102185. var xPos = positionRadius * Math.cos(angle);
  102186. var zPos = positionRadius * Math.sin(angle);
  102187. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);
  102188. };
  102189. /**
  102190. * Clones the current emitter and returns a copy of it
  102191. * @returns the new emitter
  102192. */
  102193. CylinderParticleEmitter.prototype.clone = function () {
  102194. var newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);
  102195. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102196. return newOne;
  102197. };
  102198. /**
  102199. * Called by the GPUParticleSystem to setup the update shader
  102200. * @param effect defines the update shader
  102201. */
  102202. CylinderParticleEmitter.prototype.applyToShader = function (effect) {
  102203. effect.setFloat("radius", this.radius);
  102204. effect.setFloat("height", this.height);
  102205. effect.setFloat("radiusRange", this.radiusRange);
  102206. effect.setFloat("directionRandomizer", this.directionRandomizer);
  102207. };
  102208. /**
  102209. * Returns a string to use to update the GPU particles update shader
  102210. * @returns a string containng the defines string
  102211. */
  102212. CylinderParticleEmitter.prototype.getEffectDefines = function () {
  102213. return "#define CYLINDEREMITTER";
  102214. };
  102215. /**
  102216. * Returns the string "CylinderParticleEmitter"
  102217. * @returns a string containing the class name
  102218. */
  102219. CylinderParticleEmitter.prototype.getClassName = function () {
  102220. return "CylinderParticleEmitter";
  102221. };
  102222. /**
  102223. * Serializes the particle system to a JSON object.
  102224. * @returns the JSON object
  102225. */
  102226. CylinderParticleEmitter.prototype.serialize = function () {
  102227. var serializationObject = {};
  102228. serializationObject.type = this.getClassName();
  102229. serializationObject.radius = this.radius;
  102230. serializationObject.height = this.height;
  102231. serializationObject.radiusRange = this.radiusRange;
  102232. serializationObject.directionRandomizer = this.directionRandomizer;
  102233. return serializationObject;
  102234. };
  102235. /**
  102236. * Parse properties from a JSON object
  102237. * @param serializationObject defines the JSON object
  102238. */
  102239. CylinderParticleEmitter.prototype.parse = function (serializationObject) {
  102240. this.radius = serializationObject.radius;
  102241. this.height = serializationObject.height;
  102242. this.radiusRange = serializationObject.radiusRange;
  102243. this.directionRandomizer = serializationObject.directionRandomizer;
  102244. };
  102245. return CylinderParticleEmitter;
  102246. }());
  102247. /**
  102248. * Particle emitter emitting particles from the inside of a cylinder.
  102249. * It emits the particles randomly between two vectors.
  102250. */
  102251. var CylinderDirectedParticleEmitter = /** @class */ (function (_super) {
  102252. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderDirectedParticleEmitter, _super);
  102253. /**
  102254. * Creates a new instance CylinderDirectedParticleEmitter
  102255. * @param radius the radius of the emission cylinder (1 by default)
  102256. * @param height the height of the emission cylinder (1 by default)
  102257. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102258. * @param direction1 the min limit of the emission direction (up vector by default)
  102259. * @param direction2 the max limit of the emission direction (up vector by default)
  102260. */
  102261. function CylinderDirectedParticleEmitter(radius, height, radiusRange,
  102262. /**
  102263. * The min limit of the emission direction.
  102264. */
  102265. direction1,
  102266. /**
  102267. * The max limit of the emission direction.
  102268. */
  102269. direction2) {
  102270. if (radius === void 0) { radius = 1; }
  102271. if (height === void 0) { height = 1; }
  102272. if (radiusRange === void 0) { radiusRange = 1; }
  102273. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102274. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102275. var _this = _super.call(this, radius, height, radiusRange) || this;
  102276. _this.direction1 = direction1;
  102277. _this.direction2 = direction2;
  102278. return _this;
  102279. }
  102280. /**
  102281. * Called by the particle System when the direction is computed for the created particle.
  102282. * @param worldMatrix is the world matrix of the particle system
  102283. * @param directionToUpdate is the direction vector to update with the result
  102284. * @param particle is the particle we are computed the direction for
  102285. */
  102286. CylinderDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102287. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  102288. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  102289. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  102290. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  102291. };
  102292. /**
  102293. * Clones the current emitter and returns a copy of it
  102294. * @returns the new emitter
  102295. */
  102296. CylinderDirectedParticleEmitter.prototype.clone = function () {
  102297. var newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
  102298. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102299. return newOne;
  102300. };
  102301. /**
  102302. * Called by the GPUParticleSystem to setup the update shader
  102303. * @param effect defines the update shader
  102304. */
  102305. CylinderDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  102306. effect.setFloat("radius", this.radius);
  102307. effect.setFloat("height", this.height);
  102308. effect.setFloat("radiusRange", this.radiusRange);
  102309. effect.setVector3("direction1", this.direction1);
  102310. effect.setVector3("direction2", this.direction2);
  102311. };
  102312. /**
  102313. * Returns a string to use to update the GPU particles update shader
  102314. * @returns a string containng the defines string
  102315. */
  102316. CylinderDirectedParticleEmitter.prototype.getEffectDefines = function () {
  102317. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER";
  102318. };
  102319. /**
  102320. * Returns the string "CylinderDirectedParticleEmitter"
  102321. * @returns a string containing the class name
  102322. */
  102323. CylinderDirectedParticleEmitter.prototype.getClassName = function () {
  102324. return "CylinderDirectedParticleEmitter";
  102325. };
  102326. /**
  102327. * Serializes the particle system to a JSON object.
  102328. * @returns the JSON object
  102329. */
  102330. CylinderDirectedParticleEmitter.prototype.serialize = function () {
  102331. var serializationObject = _super.prototype.serialize.call(this);
  102332. serializationObject.direction1 = this.direction1.asArray();
  102333. serializationObject.direction2 = this.direction2.asArray();
  102334. return serializationObject;
  102335. };
  102336. /**
  102337. * Parse properties from a JSON object
  102338. * @param serializationObject defines the JSON object
  102339. */
  102340. CylinderDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  102341. _super.prototype.parse.call(this, serializationObject);
  102342. this.direction1.copyFrom(serializationObject.direction1);
  102343. this.direction2.copyFrom(serializationObject.direction2);
  102344. };
  102345. return CylinderDirectedParticleEmitter;
  102346. }(CylinderParticleEmitter));
  102347. /***/ }),
  102348. /***/ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts":
  102349. /*!**************************************************************!*\
  102350. !*** ./Particles/EmitterTypes/hemisphericParticleEmitter.ts ***!
  102351. \**************************************************************/
  102352. /*! exports provided: HemisphericParticleEmitter */
  102353. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102354. "use strict";
  102355. __webpack_require__.r(__webpack_exports__);
  102356. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return HemisphericParticleEmitter; });
  102357. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102358. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102359. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102360. /**
  102361. * Particle emitter emitting particles from the inside of a hemisphere.
  102362. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  102363. */
  102364. var HemisphericParticleEmitter = /** @class */ (function () {
  102365. /**
  102366. * Creates a new instance HemisphericParticleEmitter
  102367. * @param radius the radius of the emission hemisphere (1 by default)
  102368. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102369. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  102370. */
  102371. function HemisphericParticleEmitter(
  102372. /**
  102373. * The radius of the emission hemisphere.
  102374. */
  102375. radius,
  102376. /**
  102377. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  102378. */
  102379. radiusRange,
  102380. /**
  102381. * How much to randomize the particle direction [0-1].
  102382. */
  102383. directionRandomizer) {
  102384. if (radius === void 0) { radius = 1; }
  102385. if (radiusRange === void 0) { radiusRange = 1; }
  102386. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  102387. this.radius = radius;
  102388. this.radiusRange = radiusRange;
  102389. this.directionRandomizer = directionRandomizer;
  102390. }
  102391. /**
  102392. * Called by the particle System when the direction is computed for the created particle.
  102393. * @param worldMatrix is the world matrix of the particle system
  102394. * @param directionToUpdate is the direction vector to update with the result
  102395. * @param particle is the particle we are computed the direction for
  102396. */
  102397. HemisphericParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102398. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  102399. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102400. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102401. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102402. direction.x += randX;
  102403. direction.y += randY;
  102404. direction.z += randZ;
  102405. direction.normalize();
  102406. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  102407. };
  102408. /**
  102409. * Called by the particle System when the position is computed for the created particle.
  102410. * @param worldMatrix is the world matrix of the particle system
  102411. * @param positionToUpdate is the position vector to update with the result
  102412. * @param particle is the particle we are computed the position for
  102413. */
  102414. HemisphericParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102415. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  102416. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  102417. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  102418. var theta = Math.acos(2 * v - 1);
  102419. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  102420. var randY = randRadius * Math.cos(theta);
  102421. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  102422. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);
  102423. };
  102424. /**
  102425. * Clones the current emitter and returns a copy of it
  102426. * @returns the new emitter
  102427. */
  102428. HemisphericParticleEmitter.prototype.clone = function () {
  102429. var newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);
  102430. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  102431. return newOne;
  102432. };
  102433. /**
  102434. * Called by the GPUParticleSystem to setup the update shader
  102435. * @param effect defines the update shader
  102436. */
  102437. HemisphericParticleEmitter.prototype.applyToShader = function (effect) {
  102438. effect.setFloat("radius", this.radius);
  102439. effect.setFloat("radiusRange", this.radiusRange);
  102440. effect.setFloat("directionRandomizer", this.directionRandomizer);
  102441. };
  102442. /**
  102443. * Returns a string to use to update the GPU particles update shader
  102444. * @returns a string containng the defines string
  102445. */
  102446. HemisphericParticleEmitter.prototype.getEffectDefines = function () {
  102447. return "#define HEMISPHERICEMITTER";
  102448. };
  102449. /**
  102450. * Returns the string "HemisphericParticleEmitter"
  102451. * @returns a string containing the class name
  102452. */
  102453. HemisphericParticleEmitter.prototype.getClassName = function () {
  102454. return "HemisphericParticleEmitter";
  102455. };
  102456. /**
  102457. * Serializes the particle system to a JSON object.
  102458. * @returns the JSON object
  102459. */
  102460. HemisphericParticleEmitter.prototype.serialize = function () {
  102461. var serializationObject = {};
  102462. serializationObject.type = this.getClassName();
  102463. serializationObject.radius = this.radius;
  102464. serializationObject.radiusRange = this.radiusRange;
  102465. serializationObject.directionRandomizer = this.directionRandomizer;
  102466. return serializationObject;
  102467. };
  102468. /**
  102469. * Parse properties from a JSON object
  102470. * @param serializationObject defines the JSON object
  102471. */
  102472. HemisphericParticleEmitter.prototype.parse = function (serializationObject) {
  102473. this.radius = serializationObject.radius;
  102474. this.radiusRange = serializationObject.radiusRange;
  102475. this.directionRandomizer = serializationObject.directionRandomizer;
  102476. };
  102477. return HemisphericParticleEmitter;
  102478. }());
  102479. /***/ }),
  102480. /***/ "./Particles/EmitterTypes/index.ts":
  102481. /*!*****************************************!*\
  102482. !*** ./Particles/EmitterTypes/index.ts ***!
  102483. \*****************************************/
  102484. /*! exports provided: BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  102485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102486. "use strict";
  102487. __webpack_require__.r(__webpack_exports__);
  102488. /* harmony import */ var _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  102489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  102490. /* harmony import */ var _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coneParticleEmitter */ "./Particles/EmitterTypes/coneParticleEmitter.ts");
  102491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  102492. /* harmony import */ var _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cylinderParticleEmitter */ "./Particles/EmitterTypes/cylinderParticleEmitter.ts");
  102493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"]; });
  102494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"]; });
  102495. /* harmony import */ var _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hemisphericParticleEmitter */ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts");
  102496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__["HemisphericParticleEmitter"]; });
  102497. /* harmony import */ var _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pointParticleEmitter */ "./Particles/EmitterTypes/pointParticleEmitter.ts");
  102498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__["PointParticleEmitter"]; });
  102499. /* harmony import */ var _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sphereParticleEmitter */ "./Particles/EmitterTypes/sphereParticleEmitter.ts");
  102500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereParticleEmitter"]; });
  102501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereDirectedParticleEmitter"]; });
  102502. /***/ }),
  102503. /***/ "./Particles/EmitterTypes/pointParticleEmitter.ts":
  102504. /*!********************************************************!*\
  102505. !*** ./Particles/EmitterTypes/pointParticleEmitter.ts ***!
  102506. \********************************************************/
  102507. /*! exports provided: PointParticleEmitter */
  102508. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102509. "use strict";
  102510. __webpack_require__.r(__webpack_exports__);
  102511. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return PointParticleEmitter; });
  102512. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102513. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102514. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102515. /**
  102516. * Particle emitter emitting particles from a point.
  102517. * It emits the particles randomly between 2 given directions.
  102518. */
  102519. var PointParticleEmitter = /** @class */ (function () {
  102520. /**
  102521. * Creates a new instance PointParticleEmitter
  102522. */
  102523. function PointParticleEmitter() {
  102524. /**
  102525. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102526. */
  102527. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  102528. /**
  102529. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102530. */
  102531. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  102532. }
  102533. /**
  102534. * Called by the particle System when the direction is computed for the created particle.
  102535. * @param worldMatrix is the world matrix of the particle system
  102536. * @param directionToUpdate is the direction vector to update with the result
  102537. * @param particle is the particle we are computed the direction for
  102538. */
  102539. PointParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102540. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  102541. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  102542. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  102543. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  102544. };
  102545. /**
  102546. * Called by the particle System when the position is computed for the created particle.
  102547. * @param worldMatrix is the world matrix of the particle system
  102548. * @param positionToUpdate is the position vector to update with the result
  102549. * @param particle is the particle we are computed the position for
  102550. */
  102551. PointParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102552. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);
  102553. };
  102554. /**
  102555. * Clones the current emitter and returns a copy of it
  102556. * @returns the new emitter
  102557. */
  102558. PointParticleEmitter.prototype.clone = function () {
  102559. var newOne = new PointParticleEmitter();
  102560. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  102561. return newOne;
  102562. };
  102563. /**
  102564. * Called by the GPUParticleSystem to setup the update shader
  102565. * @param effect defines the update shader
  102566. */
  102567. PointParticleEmitter.prototype.applyToShader = function (effect) {
  102568. effect.setVector3("direction1", this.direction1);
  102569. effect.setVector3("direction2", this.direction2);
  102570. };
  102571. /**
  102572. * Returns a string to use to update the GPU particles update shader
  102573. * @returns a string containng the defines string
  102574. */
  102575. PointParticleEmitter.prototype.getEffectDefines = function () {
  102576. return "#define POINTEMITTER";
  102577. };
  102578. /**
  102579. * Returns the string "PointParticleEmitter"
  102580. * @returns a string containing the class name
  102581. */
  102582. PointParticleEmitter.prototype.getClassName = function () {
  102583. return "PointParticleEmitter";
  102584. };
  102585. /**
  102586. * Serializes the particle system to a JSON object.
  102587. * @returns the JSON object
  102588. */
  102589. PointParticleEmitter.prototype.serialize = function () {
  102590. var serializationObject = {};
  102591. serializationObject.type = this.getClassName();
  102592. serializationObject.direction1 = this.direction1.asArray();
  102593. serializationObject.direction2 = this.direction2.asArray();
  102594. return serializationObject;
  102595. };
  102596. /**
  102597. * Parse properties from a JSON object
  102598. * @param serializationObject defines the JSON object
  102599. */
  102600. PointParticleEmitter.prototype.parse = function (serializationObject) {
  102601. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  102602. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  102603. };
  102604. return PointParticleEmitter;
  102605. }());
  102606. /***/ }),
  102607. /***/ "./Particles/EmitterTypes/sphereParticleEmitter.ts":
  102608. /*!*********************************************************!*\
  102609. !*** ./Particles/EmitterTypes/sphereParticleEmitter.ts ***!
  102610. \*********************************************************/
  102611. /*! exports provided: SphereParticleEmitter, SphereDirectedParticleEmitter */
  102612. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102613. "use strict";
  102614. __webpack_require__.r(__webpack_exports__);
  102615. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return SphereParticleEmitter; });
  102616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return SphereDirectedParticleEmitter; });
  102617. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102618. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102619. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102620. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102621. /**
  102622. * Particle emitter emitting particles from the inside of a sphere.
  102623. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  102624. */
  102625. var SphereParticleEmitter = /** @class */ (function () {
  102626. /**
  102627. * Creates a new instance SphereParticleEmitter
  102628. * @param radius the radius of the emission sphere (1 by default)
  102629. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102630. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  102631. */
  102632. function SphereParticleEmitter(
  102633. /**
  102634. * The radius of the emission sphere.
  102635. */
  102636. radius,
  102637. /**
  102638. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  102639. */
  102640. radiusRange,
  102641. /**
  102642. * How much to randomize the particle direction [0-1].
  102643. */
  102644. directionRandomizer) {
  102645. if (radius === void 0) { radius = 1; }
  102646. if (radiusRange === void 0) { radiusRange = 1; }
  102647. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  102648. this.radius = radius;
  102649. this.radiusRange = radiusRange;
  102650. this.directionRandomizer = directionRandomizer;
  102651. }
  102652. /**
  102653. * Called by the particle System when the direction is computed for the created particle.
  102654. * @param worldMatrix is the world matrix of the particle system
  102655. * @param directionToUpdate is the direction vector to update with the result
  102656. * @param particle is the particle we are computed the direction for
  102657. */
  102658. SphereParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102659. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  102660. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102661. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102662. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102663. direction.x += randX;
  102664. direction.y += randY;
  102665. direction.z += randZ;
  102666. direction.normalize();
  102667. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  102668. };
  102669. /**
  102670. * Called by the particle System when the position is computed for the created particle.
  102671. * @param worldMatrix is the world matrix of the particle system
  102672. * @param positionToUpdate is the position vector to update with the result
  102673. * @param particle is the particle we are computed the position for
  102674. */
  102675. SphereParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102676. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  102677. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  102678. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  102679. var theta = Math.acos(2 * v - 1);
  102680. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  102681. var randY = randRadius * Math.cos(theta);
  102682. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  102683. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  102684. };
  102685. /**
  102686. * Clones the current emitter and returns a copy of it
  102687. * @returns the new emitter
  102688. */
  102689. SphereParticleEmitter.prototype.clone = function () {
  102690. var newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);
  102691. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102692. return newOne;
  102693. };
  102694. /**
  102695. * Called by the GPUParticleSystem to setup the update shader
  102696. * @param effect defines the update shader
  102697. */
  102698. SphereParticleEmitter.prototype.applyToShader = function (effect) {
  102699. effect.setFloat("radius", this.radius);
  102700. effect.setFloat("radiusRange", this.radiusRange);
  102701. effect.setFloat("directionRandomizer", this.directionRandomizer);
  102702. };
  102703. /**
  102704. * Returns a string to use to update the GPU particles update shader
  102705. * @returns a string containng the defines string
  102706. */
  102707. SphereParticleEmitter.prototype.getEffectDefines = function () {
  102708. return "#define SPHEREEMITTER";
  102709. };
  102710. /**
  102711. * Returns the string "SphereParticleEmitter"
  102712. * @returns a string containing the class name
  102713. */
  102714. SphereParticleEmitter.prototype.getClassName = function () {
  102715. return "SphereParticleEmitter";
  102716. };
  102717. /**
  102718. * Serializes the particle system to a JSON object.
  102719. * @returns the JSON object
  102720. */
  102721. SphereParticleEmitter.prototype.serialize = function () {
  102722. var serializationObject = {};
  102723. serializationObject.type = this.getClassName();
  102724. serializationObject.radius = this.radius;
  102725. serializationObject.radiusRange = this.radiusRange;
  102726. serializationObject.directionRandomizer = this.directionRandomizer;
  102727. return serializationObject;
  102728. };
  102729. /**
  102730. * Parse properties from a JSON object
  102731. * @param serializationObject defines the JSON object
  102732. */
  102733. SphereParticleEmitter.prototype.parse = function (serializationObject) {
  102734. this.radius = serializationObject.radius;
  102735. this.radiusRange = serializationObject.radiusRange;
  102736. this.directionRandomizer = serializationObject.directionRandomizer;
  102737. };
  102738. return SphereParticleEmitter;
  102739. }());
  102740. /**
  102741. * Particle emitter emitting particles from the inside of a sphere.
  102742. * It emits the particles randomly between two vectors.
  102743. */
  102744. var SphereDirectedParticleEmitter = /** @class */ (function (_super) {
  102745. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereDirectedParticleEmitter, _super);
  102746. /**
  102747. * Creates a new instance SphereDirectedParticleEmitter
  102748. * @param radius the radius of the emission sphere (1 by default)
  102749. * @param direction1 the min limit of the emission direction (up vector by default)
  102750. * @param direction2 the max limit of the emission direction (up vector by default)
  102751. */
  102752. function SphereDirectedParticleEmitter(radius,
  102753. /**
  102754. * The min limit of the emission direction.
  102755. */
  102756. direction1,
  102757. /**
  102758. * The max limit of the emission direction.
  102759. */
  102760. direction2) {
  102761. if (radius === void 0) { radius = 1; }
  102762. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102763. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102764. var _this = _super.call(this, radius) || this;
  102765. _this.direction1 = direction1;
  102766. _this.direction2 = direction2;
  102767. return _this;
  102768. }
  102769. /**
  102770. * Called by the particle System when the direction is computed for the created particle.
  102771. * @param worldMatrix is the world matrix of the particle system
  102772. * @param directionToUpdate is the direction vector to update with the result
  102773. * @param particle is the particle we are computed the direction for
  102774. */
  102775. SphereDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102776. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  102777. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  102778. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  102779. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  102780. };
  102781. /**
  102782. * Clones the current emitter and returns a copy of it
  102783. * @returns the new emitter
  102784. */
  102785. SphereDirectedParticleEmitter.prototype.clone = function () {
  102786. var newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);
  102787. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102788. return newOne;
  102789. };
  102790. /**
  102791. * Called by the GPUParticleSystem to setup the update shader
  102792. * @param effect defines the update shader
  102793. */
  102794. SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  102795. effect.setFloat("radius", this.radius);
  102796. effect.setFloat("radiusRange", this.radiusRange);
  102797. effect.setVector3("direction1", this.direction1);
  102798. effect.setVector3("direction2", this.direction2);
  102799. };
  102800. /**
  102801. * Returns a string to use to update the GPU particles update shader
  102802. * @returns a string containng the defines string
  102803. */
  102804. SphereDirectedParticleEmitter.prototype.getEffectDefines = function () {
  102805. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER";
  102806. };
  102807. /**
  102808. * Returns the string "SphereDirectedParticleEmitter"
  102809. * @returns a string containing the class name
  102810. */
  102811. SphereDirectedParticleEmitter.prototype.getClassName = function () {
  102812. return "SphereDirectedParticleEmitter";
  102813. };
  102814. /**
  102815. * Serializes the particle system to a JSON object.
  102816. * @returns the JSON object
  102817. */
  102818. SphereDirectedParticleEmitter.prototype.serialize = function () {
  102819. var serializationObject = _super.prototype.serialize.call(this);
  102820. serializationObject.direction1 = this.direction1.asArray();
  102821. serializationObject.direction2 = this.direction2.asArray();
  102822. return serializationObject;
  102823. };
  102824. /**
  102825. * Parse properties from a JSON object
  102826. * @param serializationObject defines the JSON object
  102827. */
  102828. SphereDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  102829. _super.prototype.parse.call(this, serializationObject);
  102830. this.direction1.copyFrom(serializationObject.direction1);
  102831. this.direction2.copyFrom(serializationObject.direction2);
  102832. };
  102833. return SphereDirectedParticleEmitter;
  102834. }(SphereParticleEmitter));
  102835. /***/ }),
  102836. /***/ "./Particles/baseParticleSystem.ts":
  102837. /*!*****************************************!*\
  102838. !*** ./Particles/baseParticleSystem.ts ***!
  102839. \*****************************************/
  102840. /*! exports provided: BaseParticleSystem */
  102841. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102842. "use strict";
  102843. __webpack_require__.r(__webpack_exports__);
  102844. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return BaseParticleSystem; });
  102845. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  102846. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  102847. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  102848. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  102849. /**
  102850. * This represents the base class for particle system in Babylon.
  102851. * 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.
  102852. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  102853. * @example https://doc.babylonjs.com/babylon101/particles
  102854. */
  102855. var BaseParticleSystem = /** @class */ (function () {
  102856. /**
  102857. * Instantiates a particle system.
  102858. * 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.
  102859. * @param name The name of the particle system
  102860. */
  102861. function BaseParticleSystem(name) {
  102862. /**
  102863. * List of animations used by the particle system.
  102864. */
  102865. this.animations = [];
  102866. /**
  102867. * The rendering group used by the Particle system to chose when to render.
  102868. */
  102869. this.renderingGroupId = 0;
  102870. /**
  102871. * The emitter represents the Mesh or position we are attaching the particle system to.
  102872. */
  102873. this.emitter = null;
  102874. /**
  102875. * The maximum number of particles to emit per frame
  102876. */
  102877. this.emitRate = 10;
  102878. /**
  102879. * If you want to launch only a few particles at once, that can be done, as well.
  102880. */
  102881. this.manualEmitCount = -1;
  102882. /**
  102883. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  102884. */
  102885. this.updateSpeed = 0.01;
  102886. /**
  102887. * The amount of time the particle system is running (depends of the overall update speed).
  102888. */
  102889. this.targetStopDuration = 0;
  102890. /**
  102891. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  102892. */
  102893. this.disposeOnStop = false;
  102894. /**
  102895. * Minimum power of emitting particles.
  102896. */
  102897. this.minEmitPower = 1;
  102898. /**
  102899. * Maximum power of emitting particles.
  102900. */
  102901. this.maxEmitPower = 1;
  102902. /**
  102903. * Minimum life time of emitting particles.
  102904. */
  102905. this.minLifeTime = 1;
  102906. /**
  102907. * Maximum life time of emitting particles.
  102908. */
  102909. this.maxLifeTime = 1;
  102910. /**
  102911. * Minimum Size of emitting particles.
  102912. */
  102913. this.minSize = 1;
  102914. /**
  102915. * Maximum Size of emitting particles.
  102916. */
  102917. this.maxSize = 1;
  102918. /**
  102919. * Minimum scale of emitting particles on X axis.
  102920. */
  102921. this.minScaleX = 1;
  102922. /**
  102923. * Maximum scale of emitting particles on X axis.
  102924. */
  102925. this.maxScaleX = 1;
  102926. /**
  102927. * Minimum scale of emitting particles on Y axis.
  102928. */
  102929. this.minScaleY = 1;
  102930. /**
  102931. * Maximum scale of emitting particles on Y axis.
  102932. */
  102933. this.maxScaleY = 1;
  102934. /**
  102935. * Gets or sets the minimal initial rotation in radians.
  102936. */
  102937. this.minInitialRotation = 0;
  102938. /**
  102939. * Gets or sets the maximal initial rotation in radians.
  102940. */
  102941. this.maxInitialRotation = 0;
  102942. /**
  102943. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  102944. */
  102945. this.minAngularSpeed = 0;
  102946. /**
  102947. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  102948. */
  102949. this.maxAngularSpeed = 0;
  102950. /**
  102951. * The layer mask we are rendering the particles through.
  102952. */
  102953. this.layerMask = 0x0FFFFFFF;
  102954. /**
  102955. * This can help using your own shader to render the particle system.
  102956. * The according effect will be created
  102957. */
  102958. this.customShader = null;
  102959. /**
  102960. * By default particle system starts as soon as they are created. This prevents the
  102961. * automatic start to happen and let you decide when to start emitting particles.
  102962. */
  102963. this.preventAutoStart = false;
  102964. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  102965. this.noiseStrength = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](10, 10, 10);
  102966. /**
  102967. * Callback triggered when the particle animation is ending.
  102968. */
  102969. this.onAnimationEnd = null;
  102970. /**
  102971. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  102972. */
  102973. this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
  102974. /**
  102975. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  102976. * to override the particles.
  102977. */
  102978. this.forceDepthWrite = false;
  102979. /** 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 */
  102980. this.preWarmCycles = 0;
  102981. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  102982. this.preWarmStepOffset = 1;
  102983. /**
  102984. * 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)
  102985. */
  102986. this.spriteCellChangeSpeed = 1;
  102987. /**
  102988. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  102989. */
  102990. this.startSpriteCellID = 0;
  102991. /**
  102992. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  102993. */
  102994. this.endSpriteCellID = 0;
  102995. /**
  102996. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  102997. */
  102998. this.spriteCellWidth = 0;
  102999. /**
  103000. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  103001. */
  103002. this.spriteCellHeight = 0;
  103003. /**
  103004. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  103005. */
  103006. this.spriteRandomStartCell = false;
  103007. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  103008. this.translationPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  103009. /**
  103010. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  103011. */
  103012. this.beginAnimationOnStart = false;
  103013. /**
  103014. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  103015. */
  103016. this.beginAnimationFrom = 0;
  103017. /**
  103018. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  103019. */
  103020. this.beginAnimationTo = 60;
  103021. /**
  103022. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  103023. */
  103024. this.beginAnimationLoop = false;
  103025. /**
  103026. * You can use gravity if you want to give an orientation to your particles.
  103027. */
  103028. this.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103029. this._colorGradients = null;
  103030. this._sizeGradients = null;
  103031. this._lifeTimeGradients = null;
  103032. this._angularSpeedGradients = null;
  103033. this._velocityGradients = null;
  103034. this._limitVelocityGradients = null;
  103035. this._dragGradients = null;
  103036. this._emitRateGradients = null;
  103037. this._startSizeGradients = null;
  103038. this._rampGradients = null;
  103039. this._colorRemapGradients = null;
  103040. this._alphaRemapGradients = null;
  103041. /**
  103042. * Defines the delay in milliseconds before starting the system (0 by default)
  103043. */
  103044. this.startDelay = 0;
  103045. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  103046. this.limitVelocityDamping = 0.4;
  103047. /**
  103048. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  103049. */
  103050. this.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  103051. /**
  103052. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  103053. */
  103054. this.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  103055. /**
  103056. * Color the particle will have at the end of its lifetime
  103057. */
  103058. this.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 1.0);
  103059. /**
  103060. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  103061. */
  103062. this.textureMask = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  103063. /** @hidden */
  103064. this._isSubEmitter = false;
  103065. /**
  103066. * Gets or sets the billboard mode to use when isBillboardBased = true.
  103067. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  103068. */
  103069. this.billboardMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  103070. this._isBillboardBased = true;
  103071. /**
  103072. * Local cache of defines for image processing.
  103073. */
  103074. this._imageProcessingConfigurationDefines = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfigurationDefines"]();
  103075. this.id = name;
  103076. this.name = name;
  103077. }
  103078. Object.defineProperty(BaseParticleSystem.prototype, "noiseTexture", {
  103079. /**
  103080. * Gets or sets a texture used to add random noise to particle positions
  103081. */
  103082. get: function () {
  103083. return this._noiseTexture;
  103084. },
  103085. set: function (value) {
  103086. if (this._noiseTexture === value) {
  103087. return;
  103088. }
  103089. this._noiseTexture = value;
  103090. this._reset();
  103091. },
  103092. enumerable: true,
  103093. configurable: true
  103094. });
  103095. Object.defineProperty(BaseParticleSystem.prototype, "isAnimationSheetEnabled", {
  103096. /**
  103097. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  103098. */
  103099. get: function () {
  103100. return this._isAnimationSheetEnabled;
  103101. },
  103102. set: function (value) {
  103103. if (this._isAnimationSheetEnabled == value) {
  103104. return;
  103105. }
  103106. this._isAnimationSheetEnabled = value;
  103107. this._reset();
  103108. },
  103109. enumerable: true,
  103110. configurable: true
  103111. });
  103112. /**
  103113. * Get hosting scene
  103114. * @returns the scene
  103115. */
  103116. BaseParticleSystem.prototype.getScene = function () {
  103117. return this._scene;
  103118. };
  103119. BaseParticleSystem.prototype._hasTargetStopDurationDependantGradient = function () {
  103120. return (this._startSizeGradients && this._startSizeGradients.length > 0)
  103121. || (this._emitRateGradients && this._emitRateGradients.length > 0)
  103122. || (this._lifeTimeGradients && this._lifeTimeGradients.length > 0);
  103123. };
  103124. /**
  103125. * Gets the current list of drag gradients.
  103126. * You must use addDragGradient and removeDragGradient to udpate this list
  103127. * @returns the list of drag gradients
  103128. */
  103129. BaseParticleSystem.prototype.getDragGradients = function () {
  103130. return this._dragGradients;
  103131. };
  103132. /**
  103133. * Gets the current list of limit velocity gradients.
  103134. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  103135. * @returns the list of limit velocity gradients
  103136. */
  103137. BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
  103138. return this._limitVelocityGradients;
  103139. };
  103140. /**
  103141. * Gets the current list of color gradients.
  103142. * You must use addColorGradient and removeColorGradient to udpate this list
  103143. * @returns the list of color gradients
  103144. */
  103145. BaseParticleSystem.prototype.getColorGradients = function () {
  103146. return this._colorGradients;
  103147. };
  103148. /**
  103149. * Gets the current list of size gradients.
  103150. * You must use addSizeGradient and removeSizeGradient to udpate this list
  103151. * @returns the list of size gradients
  103152. */
  103153. BaseParticleSystem.prototype.getSizeGradients = function () {
  103154. return this._sizeGradients;
  103155. };
  103156. /**
  103157. * Gets the current list of color remap gradients.
  103158. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  103159. * @returns the list of color remap gradients
  103160. */
  103161. BaseParticleSystem.prototype.getColorRemapGradients = function () {
  103162. return this._colorRemapGradients;
  103163. };
  103164. /**
  103165. * Gets the current list of alpha remap gradients.
  103166. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  103167. * @returns the list of alpha remap gradients
  103168. */
  103169. BaseParticleSystem.prototype.getAlphaRemapGradients = function () {
  103170. return this._alphaRemapGradients;
  103171. };
  103172. /**
  103173. * Gets the current list of life time gradients.
  103174. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  103175. * @returns the list of life time gradients
  103176. */
  103177. BaseParticleSystem.prototype.getLifeTimeGradients = function () {
  103178. return this._lifeTimeGradients;
  103179. };
  103180. /**
  103181. * Gets the current list of angular speed gradients.
  103182. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  103183. * @returns the list of angular speed gradients
  103184. */
  103185. BaseParticleSystem.prototype.getAngularSpeedGradients = function () {
  103186. return this._angularSpeedGradients;
  103187. };
  103188. /**
  103189. * Gets the current list of velocity gradients.
  103190. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  103191. * @returns the list of velocity gradients
  103192. */
  103193. BaseParticleSystem.prototype.getVelocityGradients = function () {
  103194. return this._velocityGradients;
  103195. };
  103196. /**
  103197. * Gets the current list of start size gradients.
  103198. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  103199. * @returns the list of start size gradients
  103200. */
  103201. BaseParticleSystem.prototype.getStartSizeGradients = function () {
  103202. return this._startSizeGradients;
  103203. };
  103204. /**
  103205. * Gets the current list of emit rate gradients.
  103206. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  103207. * @returns the list of emit rate gradients
  103208. */
  103209. BaseParticleSystem.prototype.getEmitRateGradients = function () {
  103210. return this._emitRateGradients;
  103211. };
  103212. Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
  103213. /**
  103214. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  103215. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103216. */
  103217. get: function () {
  103218. if (this.particleEmitterType.direction1) {
  103219. return this.particleEmitterType.direction1;
  103220. }
  103221. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103222. },
  103223. set: function (value) {
  103224. if (this.particleEmitterType.direction1) {
  103225. this.particleEmitterType.direction1 = value;
  103226. }
  103227. },
  103228. enumerable: true,
  103229. configurable: true
  103230. });
  103231. Object.defineProperty(BaseParticleSystem.prototype, "direction2", {
  103232. /**
  103233. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  103234. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103235. */
  103236. get: function () {
  103237. if (this.particleEmitterType.direction2) {
  103238. return this.particleEmitterType.direction2;
  103239. }
  103240. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103241. },
  103242. set: function (value) {
  103243. if (this.particleEmitterType.direction2) {
  103244. this.particleEmitterType.direction2 = value;
  103245. }
  103246. },
  103247. enumerable: true,
  103248. configurable: true
  103249. });
  103250. Object.defineProperty(BaseParticleSystem.prototype, "minEmitBox", {
  103251. /**
  103252. * 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.
  103253. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103254. */
  103255. get: function () {
  103256. if (this.particleEmitterType.minEmitBox) {
  103257. return this.particleEmitterType.minEmitBox;
  103258. }
  103259. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103260. },
  103261. set: function (value) {
  103262. if (this.particleEmitterType.minEmitBox) {
  103263. this.particleEmitterType.minEmitBox = value;
  103264. }
  103265. },
  103266. enumerable: true,
  103267. configurable: true
  103268. });
  103269. Object.defineProperty(BaseParticleSystem.prototype, "maxEmitBox", {
  103270. /**
  103271. * 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.
  103272. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103273. */
  103274. get: function () {
  103275. if (this.particleEmitterType.maxEmitBox) {
  103276. return this.particleEmitterType.maxEmitBox;
  103277. }
  103278. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103279. },
  103280. set: function (value) {
  103281. if (this.particleEmitterType.maxEmitBox) {
  103282. this.particleEmitterType.maxEmitBox = value;
  103283. }
  103284. },
  103285. enumerable: true,
  103286. configurable: true
  103287. });
  103288. Object.defineProperty(BaseParticleSystem.prototype, "isBillboardBased", {
  103289. /**
  103290. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  103291. */
  103292. get: function () {
  103293. return this._isBillboardBased;
  103294. },
  103295. set: function (value) {
  103296. if (this._isBillboardBased === value) {
  103297. return;
  103298. }
  103299. this._isBillboardBased = value;
  103300. this._reset();
  103301. },
  103302. enumerable: true,
  103303. configurable: true
  103304. });
  103305. Object.defineProperty(BaseParticleSystem.prototype, "imageProcessingConfiguration", {
  103306. /**
  103307. * Gets the image processing configuration used either in this material.
  103308. */
  103309. get: function () {
  103310. return this._imageProcessingConfiguration;
  103311. },
  103312. /**
  103313. * Sets the Default image processing configuration used either in the this material.
  103314. *
  103315. * If sets to null, the scene one is in use.
  103316. */
  103317. set: function (value) {
  103318. this._attachImageProcessingConfiguration(value);
  103319. },
  103320. enumerable: true,
  103321. configurable: true
  103322. });
  103323. /**
  103324. * Attaches a new image processing configuration to the Standard Material.
  103325. * @param configuration
  103326. */
  103327. BaseParticleSystem.prototype._attachImageProcessingConfiguration = function (configuration) {
  103328. if (configuration === this._imageProcessingConfiguration) {
  103329. return;
  103330. }
  103331. // Pick the scene configuration if needed.
  103332. if (!configuration) {
  103333. this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
  103334. }
  103335. else {
  103336. this._imageProcessingConfiguration = configuration;
  103337. }
  103338. };
  103339. /** @hidden */
  103340. BaseParticleSystem.prototype._reset = function () {
  103341. };
  103342. /** @hidden */
  103343. BaseParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  103344. if (!gradients) {
  103345. return this;
  103346. }
  103347. var index = 0;
  103348. for (var _i = 0, gradients_1 = gradients; _i < gradients_1.length; _i++) {
  103349. var valueGradient = gradients_1[_i];
  103350. if (valueGradient.gradient === gradient) {
  103351. gradients.splice(index, 1);
  103352. break;
  103353. }
  103354. index++;
  103355. }
  103356. if (texture) {
  103357. texture.dispose();
  103358. }
  103359. return this;
  103360. };
  103361. /**
  103362. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  103363. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  103364. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  103365. * @returns the emitter
  103366. */
  103367. BaseParticleSystem.prototype.createPointEmitter = function (direction1, direction2) {
  103368. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["PointParticleEmitter"]();
  103369. particleEmitter.direction1 = direction1;
  103370. particleEmitter.direction2 = direction2;
  103371. this.particleEmitterType = particleEmitter;
  103372. return particleEmitter;
  103373. };
  103374. /**
  103375. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  103376. * @param radius The radius of the hemisphere to emit from
  103377. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  103378. * @returns the emitter
  103379. */
  103380. BaseParticleSystem.prototype.createHemisphericEmitter = function (radius, radiusRange) {
  103381. if (radius === void 0) { radius = 1; }
  103382. if (radiusRange === void 0) { radiusRange = 1; }
  103383. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["HemisphericParticleEmitter"](radius, radiusRange);
  103384. this.particleEmitterType = particleEmitter;
  103385. return particleEmitter;
  103386. };
  103387. /**
  103388. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  103389. * @param radius The radius of the sphere to emit from
  103390. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  103391. * @returns the emitter
  103392. */
  103393. BaseParticleSystem.prototype.createSphereEmitter = function (radius, radiusRange) {
  103394. if (radius === void 0) { radius = 1; }
  103395. if (radiusRange === void 0) { radiusRange = 1; }
  103396. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereParticleEmitter"](radius, radiusRange);
  103397. this.particleEmitterType = particleEmitter;
  103398. return particleEmitter;
  103399. };
  103400. /**
  103401. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  103402. * @param radius The radius of the sphere to emit from
  103403. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  103404. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  103405. * @returns the emitter
  103406. */
  103407. BaseParticleSystem.prototype.createDirectedSphereEmitter = function (radius, direction1, direction2) {
  103408. if (radius === void 0) { radius = 1; }
  103409. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103410. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103411. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereDirectedParticleEmitter"](radius, direction1, direction2);
  103412. this.particleEmitterType = particleEmitter;
  103413. return particleEmitter;
  103414. };
  103415. /**
  103416. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  103417. * @param radius The radius of the emission cylinder
  103418. * @param height The height of the emission cylinder
  103419. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  103420. * @param directionRandomizer How much to randomize the particle direction [0-1]
  103421. * @returns the emitter
  103422. */
  103423. BaseParticleSystem.prototype.createCylinderEmitter = function (radius, height, radiusRange, directionRandomizer) {
  103424. if (radius === void 0) { radius = 1; }
  103425. if (height === void 0) { height = 1; }
  103426. if (radiusRange === void 0) { radiusRange = 1; }
  103427. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  103428. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"](radius, height, radiusRange, directionRandomizer);
  103429. this.particleEmitterType = particleEmitter;
  103430. return particleEmitter;
  103431. };
  103432. /**
  103433. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  103434. * @param radius The radius of the cylinder to emit from
  103435. * @param height The height of the emission cylinder
  103436. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  103437. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  103438. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  103439. * @returns the emitter
  103440. */
  103441. BaseParticleSystem.prototype.createDirectedCylinderEmitter = function (radius, height, radiusRange, direction1, direction2) {
  103442. if (radius === void 0) { radius = 1; }
  103443. if (height === void 0) { height = 1; }
  103444. if (radiusRange === void 0) { radiusRange = 1; }
  103445. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103446. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  103447. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"](radius, height, radiusRange, direction1, direction2);
  103448. this.particleEmitterType = particleEmitter;
  103449. return particleEmitter;
  103450. };
  103451. /**
  103452. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  103453. * @param radius The radius of the cone to emit from
  103454. * @param angle The base angle of the cone
  103455. * @returns the emitter
  103456. */
  103457. BaseParticleSystem.prototype.createConeEmitter = function (radius, angle) {
  103458. if (radius === void 0) { radius = 1; }
  103459. if (angle === void 0) { angle = Math.PI / 4; }
  103460. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["ConeParticleEmitter"](radius, angle);
  103461. this.particleEmitterType = particleEmitter;
  103462. return particleEmitter;
  103463. };
  103464. /**
  103465. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  103466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  103467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  103468. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  103469. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  103470. * @returns the emitter
  103471. */
  103472. BaseParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
  103473. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["BoxParticleEmitter"]();
  103474. this.particleEmitterType = particleEmitter;
  103475. this.direction1 = direction1;
  103476. this.direction2 = direction2;
  103477. this.minEmitBox = minEmitBox;
  103478. this.maxEmitBox = maxEmitBox;
  103479. return particleEmitter;
  103480. };
  103481. /**
  103482. * Source color is added to the destination color without alpha affecting the result
  103483. */
  103484. BaseParticleSystem.BLENDMODE_ONEONE = 0;
  103485. /**
  103486. * Blend current color and particle color using particle’s alpha
  103487. */
  103488. BaseParticleSystem.BLENDMODE_STANDARD = 1;
  103489. /**
  103490. * Add current color and particle color multiplied by particle’s alpha
  103491. */
  103492. BaseParticleSystem.BLENDMODE_ADD = 2;
  103493. /**
  103494. * Multiply current color with particle color
  103495. */
  103496. BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
  103497. /**
  103498. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  103499. */
  103500. BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
  103501. return BaseParticleSystem;
  103502. }());
  103503. /***/ }),
  103504. /***/ "./Particles/gpuParticleSystem.ts":
  103505. /*!****************************************!*\
  103506. !*** ./Particles/gpuParticleSystem.ts ***!
  103507. \****************************************/
  103508. /*! exports provided: GPUParticleSystem */
  103509. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103510. "use strict";
  103511. __webpack_require__.r(__webpack_exports__);
  103512. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return GPUParticleSystem; });
  103513. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  103514. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  103515. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  103516. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  103517. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  103518. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  103519. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  103520. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  103521. /* harmony import */ var _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Particles/EmitterTypes/boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  103522. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  103523. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  103524. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  103525. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  103526. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  103527. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  103528. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  103529. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  103530. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  103531. /* harmony import */ var _Shaders_gpuUpdateParticles_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.fragment */ "./Shaders/gpuUpdateParticles.fragment.ts");
  103532. /* harmony import */ var _Shaders_gpuUpdateParticles_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.vertex */ "./Shaders/gpuUpdateParticles.vertex.ts");
  103533. /* harmony import */ var _Shaders_gpuRenderParticles_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.fragment */ "./Shaders/gpuRenderParticles.fragment.ts");
  103534. /* harmony import */ var _Shaders_gpuRenderParticles_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.vertex */ "./Shaders/gpuRenderParticles.vertex.ts");
  103535. /**
  103536. * This represents a GPU particle system in Babylon
  103537. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  103538. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  103539. */
  103540. var GPUParticleSystem = /** @class */ (function (_super) {
  103541. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GPUParticleSystem, _super);
  103542. /**
  103543. * Instantiates a GPU particle system.
  103544. * 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.
  103545. * @param name The name of the particle system
  103546. * @param options The options used to create the system
  103547. * @param scene The scene the particle system belongs to
  103548. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  103549. */
  103550. function GPUParticleSystem(name, options, scene, isAnimationSheetEnabled) {
  103551. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  103552. var _this = _super.call(this, name) || this;
  103553. /**
  103554. * The layer mask we are rendering the particles through.
  103555. */
  103556. _this.layerMask = 0x0FFFFFFF;
  103557. _this._accumulatedCount = 0;
  103558. _this._targetIndex = 0;
  103559. _this._currentRenderId = -1;
  103560. _this._started = false;
  103561. _this._stopped = false;
  103562. _this._timeDelta = 0;
  103563. _this._actualFrame = 0;
  103564. _this._rawTextureWidth = 256;
  103565. /**
  103566. * An event triggered when the system is disposed.
  103567. */
  103568. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  103569. /**
  103570. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  103571. * to override the particles.
  103572. */
  103573. _this.forceDepthWrite = false;
  103574. _this._preWarmDone = false;
  103575. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  103576. // Setup the default processing configuration to the scene.
  103577. _this._attachImageProcessingConfiguration(null);
  103578. _this._engine = _this._scene.getEngine();
  103579. if (!options.randomTextureSize) {
  103580. delete options.randomTextureSize;
  103581. }
  103582. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ capacity: 50000, randomTextureSize: _this._engine.getCaps().maxTextureSize }, options);
  103583. var optionsAsNumber = options;
  103584. if (isFinite(optionsAsNumber)) {
  103585. fullOptions.capacity = optionsAsNumber;
  103586. }
  103587. _this._capacity = fullOptions.capacity;
  103588. _this._activeCount = fullOptions.capacity;
  103589. _this._currentActiveCount = 0;
  103590. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  103591. _this._scene.particleSystems.push(_this);
  103592. _this._updateEffectOptions = {
  103593. attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  103594. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
  103595. "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
  103596. "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  103597. uniformBuffersNames: [],
  103598. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  103599. defines: "",
  103600. fallbacks: null,
  103601. onCompiled: null,
  103602. onError: null,
  103603. indexParameters: null,
  103604. maxSimultaneousLights: 0,
  103605. transformFeedbackVaryings: []
  103606. };
  103607. _this.particleEmitterType = new _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__["BoxParticleEmitter"]();
  103608. // Random data
  103609. var maxTextureSize = Math.min(_this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
  103610. var d = [];
  103611. for (var i = 0; i < maxTextureSize; ++i) {
  103612. d.push(Math.random());
  103613. d.push(Math.random());
  103614. d.push(Math.random());
  103615. d.push(Math.random());
  103616. }
  103617. _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);
  103618. _this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103619. _this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103620. d = [];
  103621. for (var i = 0; i < maxTextureSize; ++i) {
  103622. d.push(Math.random());
  103623. d.push(Math.random());
  103624. d.push(Math.random());
  103625. d.push(Math.random());
  103626. }
  103627. _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);
  103628. _this._randomTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103629. _this._randomTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  103630. _this._randomTextureSize = maxTextureSize;
  103631. return _this;
  103632. }
  103633. Object.defineProperty(GPUParticleSystem, "IsSupported", {
  103634. /**
  103635. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  103636. */
  103637. get: function () {
  103638. if (!_Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine) {
  103639. return false;
  103640. }
  103641. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine.webGLVersion > 1;
  103642. },
  103643. enumerable: true,
  103644. configurable: true
  103645. });
  103646. /**
  103647. * Gets the maximum number of particles active at the same time.
  103648. * @returns The max number of active particles.
  103649. */
  103650. GPUParticleSystem.prototype.getCapacity = function () {
  103651. return this._capacity;
  103652. };
  103653. Object.defineProperty(GPUParticleSystem.prototype, "activeParticleCount", {
  103654. /**
  103655. * Gets or set the number of active particles
  103656. */
  103657. get: function () {
  103658. return this._activeCount;
  103659. },
  103660. set: function (value) {
  103661. this._activeCount = Math.min(value, this._capacity);
  103662. },
  103663. enumerable: true,
  103664. configurable: true
  103665. });
  103666. /**
  103667. * Is this system ready to be used/rendered
  103668. * @return true if the system is ready
  103669. */
  103670. GPUParticleSystem.prototype.isReady = function () {
  103671. if (!this._updateEffect) {
  103672. this._recreateUpdateEffect();
  103673. this._recreateRenderEffect();
  103674. return false;
  103675. }
  103676. if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  103677. return false;
  103678. }
  103679. return true;
  103680. };
  103681. /**
  103682. * Gets if the system has been started. (Note: this will still be true after stop is called)
  103683. * @returns True if it has been started, otherwise false.
  103684. */
  103685. GPUParticleSystem.prototype.isStarted = function () {
  103686. return this._started;
  103687. };
  103688. /**
  103689. * Starts the particle system and begins to emit
  103690. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  103691. */
  103692. GPUParticleSystem.prototype.start = function (delay) {
  103693. var _this = this;
  103694. if (delay === void 0) { delay = this.startDelay; }
  103695. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  103696. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  103697. }
  103698. if (delay) {
  103699. setTimeout(function () {
  103700. _this.start(0);
  103701. }, delay);
  103702. return;
  103703. }
  103704. this._started = true;
  103705. this._stopped = false;
  103706. this._preWarmDone = false;
  103707. // Animations
  103708. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  103709. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  103710. }
  103711. };
  103712. /**
  103713. * Stops the particle system.
  103714. */
  103715. GPUParticleSystem.prototype.stop = function () {
  103716. this._stopped = true;
  103717. };
  103718. /**
  103719. * Remove all active particles
  103720. */
  103721. GPUParticleSystem.prototype.reset = function () {
  103722. this._releaseBuffers();
  103723. this._releaseVAOs();
  103724. this._currentActiveCount = 0;
  103725. this._targetIndex = 0;
  103726. };
  103727. /**
  103728. * Returns the string "GPUParticleSystem"
  103729. * @returns a string containing the class name
  103730. */
  103731. GPUParticleSystem.prototype.getClassName = function () {
  103732. return "GPUParticleSystem";
  103733. };
  103734. GPUParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  103735. _super.prototype._removeGradientAndTexture.call(this, gradient, gradients, texture);
  103736. this._releaseBuffers();
  103737. return this;
  103738. };
  103739. /**
  103740. * Adds a new color gradient
  103741. * @param gradient defines the gradient to use (between 0 and 1)
  103742. * @param color1 defines the color to affect to the specified gradient
  103743. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  103744. * @returns the current particle system
  103745. */
  103746. GPUParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  103747. if (!this._colorGradients) {
  103748. this._colorGradients = [];
  103749. }
  103750. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  103751. colorGradient.gradient = gradient;
  103752. colorGradient.color1 = color1;
  103753. this._colorGradients.push(colorGradient);
  103754. this._colorGradients.sort(function (a, b) {
  103755. if (a.gradient < b.gradient) {
  103756. return -1;
  103757. }
  103758. else if (a.gradient > b.gradient) {
  103759. return 1;
  103760. }
  103761. return 0;
  103762. });
  103763. if (this._colorGradientsTexture) {
  103764. this._colorGradientsTexture.dispose();
  103765. this._colorGradientsTexture = null;
  103766. }
  103767. this._releaseBuffers();
  103768. return this;
  103769. };
  103770. /**
  103771. * Remove a specific color gradient
  103772. * @param gradient defines the gradient to remove
  103773. * @returns the current particle system
  103774. */
  103775. GPUParticleSystem.prototype.removeColorGradient = function (gradient) {
  103776. this._removeGradientAndTexture(gradient, this._colorGradients, this._colorGradientsTexture);
  103777. this._colorGradientsTexture = null;
  103778. return this;
  103779. };
  103780. GPUParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor) {
  103781. var valueGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  103782. valueGradient.gradient = gradient;
  103783. valueGradient.factor1 = factor;
  103784. factorGradients.push(valueGradient);
  103785. factorGradients.sort(function (a, b) {
  103786. if (a.gradient < b.gradient) {
  103787. return -1;
  103788. }
  103789. else if (a.gradient > b.gradient) {
  103790. return 1;
  103791. }
  103792. return 0;
  103793. });
  103794. this._releaseBuffers();
  103795. };
  103796. /**
  103797. * Adds a new size gradient
  103798. * @param gradient defines the gradient to use (between 0 and 1)
  103799. * @param factor defines the size factor to affect to the specified gradient
  103800. * @returns the current particle system
  103801. */
  103802. GPUParticleSystem.prototype.addSizeGradient = function (gradient, factor) {
  103803. if (!this._sizeGradients) {
  103804. this._sizeGradients = [];
  103805. }
  103806. this._addFactorGradient(this._sizeGradients, gradient, factor);
  103807. if (this._sizeGradientsTexture) {
  103808. this._sizeGradientsTexture.dispose();
  103809. this._sizeGradientsTexture = null;
  103810. }
  103811. this._releaseBuffers();
  103812. return this;
  103813. };
  103814. /**
  103815. * Remove a specific size gradient
  103816. * @param gradient defines the gradient to remove
  103817. * @returns the current particle system
  103818. */
  103819. GPUParticleSystem.prototype.removeSizeGradient = function (gradient) {
  103820. this._removeGradientAndTexture(gradient, this._sizeGradients, this._sizeGradientsTexture);
  103821. this._sizeGradientsTexture = null;
  103822. return this;
  103823. };
  103824. /**
  103825. * Adds a new angular speed gradient
  103826. * @param gradient defines the gradient to use (between 0 and 1)
  103827. * @param factor defines the angular speed to affect to the specified gradient
  103828. * @returns the current particle system
  103829. */
  103830. GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
  103831. if (!this._angularSpeedGradients) {
  103832. this._angularSpeedGradients = [];
  103833. }
  103834. this._addFactorGradient(this._angularSpeedGradients, gradient, factor);
  103835. if (this._angularSpeedGradientsTexture) {
  103836. this._angularSpeedGradientsTexture.dispose();
  103837. this._angularSpeedGradientsTexture = null;
  103838. }
  103839. this._releaseBuffers();
  103840. return this;
  103841. };
  103842. /**
  103843. * Remove a specific angular speed gradient
  103844. * @param gradient defines the gradient to remove
  103845. * @returns the current particle system
  103846. */
  103847. GPUParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  103848. this._removeGradientAndTexture(gradient, this._angularSpeedGradients, this._angularSpeedGradientsTexture);
  103849. this._angularSpeedGradientsTexture = null;
  103850. return this;
  103851. };
  103852. /**
  103853. * Adds a new velocity gradient
  103854. * @param gradient defines the gradient to use (between 0 and 1)
  103855. * @param factor defines the velocity to affect to the specified gradient
  103856. * @returns the current particle system
  103857. */
  103858. GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
  103859. if (!this._velocityGradients) {
  103860. this._velocityGradients = [];
  103861. }
  103862. this._addFactorGradient(this._velocityGradients, gradient, factor);
  103863. if (this._velocityGradientsTexture) {
  103864. this._velocityGradientsTexture.dispose();
  103865. this._velocityGradientsTexture = null;
  103866. }
  103867. this._releaseBuffers();
  103868. return this;
  103869. };
  103870. /**
  103871. * Remove a specific velocity gradient
  103872. * @param gradient defines the gradient to remove
  103873. * @returns the current particle system
  103874. */
  103875. GPUParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  103876. this._removeGradientAndTexture(gradient, this._velocityGradients, this._velocityGradientsTexture);
  103877. this._velocityGradientsTexture = null;
  103878. return this;
  103879. };
  103880. /**
  103881. * Adds a new limit velocity gradient
  103882. * @param gradient defines the gradient to use (between 0 and 1)
  103883. * @param factor defines the limit velocity value to affect to the specified gradient
  103884. * @returns the current particle system
  103885. */
  103886. GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
  103887. if (!this._limitVelocityGradients) {
  103888. this._limitVelocityGradients = [];
  103889. }
  103890. this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
  103891. if (this._limitVelocityGradientsTexture) {
  103892. this._limitVelocityGradientsTexture.dispose();
  103893. this._limitVelocityGradientsTexture = null;
  103894. }
  103895. this._releaseBuffers();
  103896. return this;
  103897. };
  103898. /**
  103899. * Remove a specific limit velocity gradient
  103900. * @param gradient defines the gradient to remove
  103901. * @returns the current particle system
  103902. */
  103903. GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  103904. this._removeGradientAndTexture(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
  103905. this._limitVelocityGradientsTexture = null;
  103906. return this;
  103907. };
  103908. /**
  103909. * Adds a new drag gradient
  103910. * @param gradient defines the gradient to use (between 0 and 1)
  103911. * @param factor defines the drag value to affect to the specified gradient
  103912. * @returns the current particle system
  103913. */
  103914. GPUParticleSystem.prototype.addDragGradient = function (gradient, factor) {
  103915. if (!this._dragGradients) {
  103916. this._dragGradients = [];
  103917. }
  103918. this._addFactorGradient(this._dragGradients, gradient, factor);
  103919. if (this._dragGradientsTexture) {
  103920. this._dragGradientsTexture.dispose();
  103921. this._dragGradientsTexture = null;
  103922. }
  103923. this._releaseBuffers();
  103924. return this;
  103925. };
  103926. /**
  103927. * Remove a specific drag gradient
  103928. * @param gradient defines the gradient to remove
  103929. * @returns the current particle system
  103930. */
  103931. GPUParticleSystem.prototype.removeDragGradient = function (gradient) {
  103932. this._removeGradientAndTexture(gradient, this._dragGradients, this._dragGradientsTexture);
  103933. this._dragGradientsTexture = null;
  103934. return this;
  103935. };
  103936. /**
  103937. * Not supported by GPUParticleSystem
  103938. * @param gradient defines the gradient to use (between 0 and 1)
  103939. * @param factor defines the emit rate value to affect to the specified gradient
  103940. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  103941. * @returns the current particle system
  103942. */
  103943. GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  103944. // Do nothing as emit rate is not supported by GPUParticleSystem
  103945. return this;
  103946. };
  103947. /**
  103948. * Not supported by GPUParticleSystem
  103949. * @param gradient defines the gradient to remove
  103950. * @returns the current particle system
  103951. */
  103952. GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  103953. // Do nothing as emit rate is not supported by GPUParticleSystem
  103954. return this;
  103955. };
  103956. /**
  103957. * Not supported by GPUParticleSystem
  103958. * @param gradient defines the gradient to use (between 0 and 1)
  103959. * @param factor defines the start size value to affect to the specified gradient
  103960. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  103961. * @returns the current particle system
  103962. */
  103963. GPUParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  103964. // Do nothing as start size is not supported by GPUParticleSystem
  103965. return this;
  103966. };
  103967. /**
  103968. * Not supported by GPUParticleSystem
  103969. * @param gradient defines the gradient to remove
  103970. * @returns the current particle system
  103971. */
  103972. GPUParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  103973. // Do nothing as start size is not supported by GPUParticleSystem
  103974. return this;
  103975. };
  103976. /**
  103977. * Not supported by GPUParticleSystem
  103978. * @param gradient defines the gradient to use (between 0 and 1)
  103979. * @param min defines the color remap minimal range
  103980. * @param max defines the color remap maximal range
  103981. * @returns the current particle system
  103982. */
  103983. GPUParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  103984. // Do nothing as start size is not supported by GPUParticleSystem
  103985. return this;
  103986. };
  103987. /**
  103988. * Not supported by GPUParticleSystem
  103989. * @param gradient defines the gradient to remove
  103990. * @returns the current particle system
  103991. */
  103992. GPUParticleSystem.prototype.removeColorRemapGradient = function () {
  103993. // Do nothing as start size is not supported by GPUParticleSystem
  103994. return this;
  103995. };
  103996. /**
  103997. * Not supported by GPUParticleSystem
  103998. * @param gradient defines the gradient to use (between 0 and 1)
  103999. * @param min defines the alpha remap minimal range
  104000. * @param max defines the alpha remap maximal range
  104001. * @returns the current particle system
  104002. */
  104003. GPUParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  104004. // Do nothing as start size is not supported by GPUParticleSystem
  104005. return this;
  104006. };
  104007. /**
  104008. * Not supported by GPUParticleSystem
  104009. * @param gradient defines the gradient to remove
  104010. * @returns the current particle system
  104011. */
  104012. GPUParticleSystem.prototype.removeAlphaRemapGradient = function () {
  104013. // Do nothing as start size is not supported by GPUParticleSystem
  104014. return this;
  104015. };
  104016. /**
  104017. * Not supported by GPUParticleSystem
  104018. * @param gradient defines the gradient to use (between 0 and 1)
  104019. * @param color defines the color to affect to the specified gradient
  104020. * @returns the current particle system
  104021. */
  104022. GPUParticleSystem.prototype.addRampGradient = function (gradient, color) {
  104023. //Not supported by GPUParticleSystem
  104024. return this;
  104025. };
  104026. /**
  104027. * Not supported by GPUParticleSystem
  104028. * @param gradient defines the gradient to remove
  104029. * @returns the current particle system
  104030. */
  104031. GPUParticleSystem.prototype.removeRampGradient = function () {
  104032. //Not supported by GPUParticleSystem
  104033. return this;
  104034. };
  104035. /**
  104036. * Not supported by GPUParticleSystem
  104037. * @returns the list of ramp gradients
  104038. */
  104039. GPUParticleSystem.prototype.getRampGradients = function () {
  104040. return null;
  104041. };
  104042. Object.defineProperty(GPUParticleSystem.prototype, "useRampGradients", {
  104043. /**
  104044. * Not supported by GPUParticleSystem
  104045. * Gets or sets a boolean indicating that ramp gradients must be used
  104046. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  104047. */
  104048. get: function () {
  104049. //Not supported by GPUParticleSystem
  104050. return false;
  104051. },
  104052. set: function (value) {
  104053. //Not supported by GPUParticleSystem
  104054. },
  104055. enumerable: true,
  104056. configurable: true
  104057. });
  104058. /**
  104059. * Not supported by GPUParticleSystem
  104060. * @param gradient defines the gradient to use (between 0 and 1)
  104061. * @param factor defines the life time factor to affect to the specified gradient
  104062. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104063. * @returns the current particle system
  104064. */
  104065. GPUParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  104066. //Not supported by GPUParticleSystem
  104067. return this;
  104068. };
  104069. /**
  104070. * Not supported by GPUParticleSystem
  104071. * @param gradient defines the gradient to remove
  104072. * @returns the current particle system
  104073. */
  104074. GPUParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  104075. //Not supported by GPUParticleSystem
  104076. return this;
  104077. };
  104078. GPUParticleSystem.prototype._reset = function () {
  104079. this._releaseBuffers();
  104080. };
  104081. GPUParticleSystem.prototype._createUpdateVAO = function (source) {
  104082. var updateVertexBuffers = {};
  104083. updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
  104084. updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
  104085. updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
  104086. updateVertexBuffers["seed"] = source.createVertexBuffer("seed", 5, 4);
  104087. updateVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3);
  104088. var offset = 12;
  104089. if (!this._colorGradientsTexture) {
  104090. updateVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4);
  104091. offset += 4;
  104092. }
  104093. updateVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3);
  104094. offset += 3;
  104095. if (!this._isBillboardBased) {
  104096. updateVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3);
  104097. offset += 3;
  104098. }
  104099. if (this._angularSpeedGradientsTexture) {
  104100. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1);
  104101. offset += 1;
  104102. }
  104103. else {
  104104. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 2);
  104105. offset += 2;
  104106. }
  104107. if (this._isAnimationSheetEnabled) {
  104108. updateVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1);
  104109. offset += 1;
  104110. if (this.spriteRandomStartCell) {
  104111. updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
  104112. offset += 1;
  104113. }
  104114. }
  104115. if (this.noiseTexture) {
  104116. updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
  104117. offset += 3;
  104118. updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
  104119. offset += 3;
  104120. }
  104121. var vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
  104122. this._engine.bindArrayBuffer(null);
  104123. return vao;
  104124. };
  104125. GPUParticleSystem.prototype._createRenderVAO = function (source, spriteSource) {
  104126. var renderVertexBuffers = {};
  104127. renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
  104128. renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
  104129. renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
  104130. renderVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3, this._attributesStrideSize, true);
  104131. var offset = 12;
  104132. if (!this._colorGradientsTexture) {
  104133. renderVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
  104134. offset += 4;
  104135. }
  104136. if (this.billboardMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED) {
  104137. renderVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
  104138. }
  104139. offset += 3; // Direction
  104140. if (!this._isBillboardBased) {
  104141. renderVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
  104142. offset += 3;
  104143. }
  104144. renderVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1, this._attributesStrideSize, true);
  104145. if (this._angularSpeedGradientsTexture) {
  104146. offset++;
  104147. }
  104148. else {
  104149. offset += 2;
  104150. }
  104151. if (this._isAnimationSheetEnabled) {
  104152. renderVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1, this._attributesStrideSize, true);
  104153. offset += 1;
  104154. if (this.spriteRandomStartCell) {
  104155. renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
  104156. offset += 1;
  104157. }
  104158. }
  104159. if (this.noiseTexture) {
  104160. renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
  104161. offset += 3;
  104162. renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
  104163. offset += 3;
  104164. }
  104165. renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
  104166. renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
  104167. var vao = this._engine.recordVertexArrayObject(renderVertexBuffers, null, this._renderEffect);
  104168. this._engine.bindArrayBuffer(null);
  104169. return vao;
  104170. };
  104171. GPUParticleSystem.prototype._initialize = function (force) {
  104172. if (force === void 0) { force = false; }
  104173. if (this._buffer0 && !force) {
  104174. return;
  104175. }
  104176. var engine = this._scene.getEngine();
  104177. var data = new Array();
  104178. this._attributesStrideSize = 21;
  104179. this._targetIndex = 0;
  104180. if (!this.isBillboardBased) {
  104181. this._attributesStrideSize += 3;
  104182. }
  104183. if (this._colorGradientsTexture) {
  104184. this._attributesStrideSize -= 4;
  104185. }
  104186. if (this._angularSpeedGradientsTexture) {
  104187. this._attributesStrideSize -= 1;
  104188. }
  104189. if (this._isAnimationSheetEnabled) {
  104190. this._attributesStrideSize += 1;
  104191. if (this.spriteRandomStartCell) {
  104192. this._attributesStrideSize += 1;
  104193. }
  104194. }
  104195. if (this.noiseTexture) {
  104196. this._attributesStrideSize += 6;
  104197. }
  104198. for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
  104199. // position
  104200. data.push(0.0);
  104201. data.push(0.0);
  104202. data.push(0.0);
  104203. // Age and life
  104204. data.push(0.0); // create the particle as a dead one to create a new one at start
  104205. data.push(0.0);
  104206. // Seed
  104207. data.push(Math.random());
  104208. data.push(Math.random());
  104209. data.push(Math.random());
  104210. data.push(Math.random());
  104211. // Size
  104212. data.push(0.0);
  104213. data.push(0.0);
  104214. data.push(0.0);
  104215. if (!this._colorGradientsTexture) {
  104216. // color
  104217. data.push(0.0);
  104218. data.push(0.0);
  104219. data.push(0.0);
  104220. data.push(0.0);
  104221. }
  104222. // direction
  104223. data.push(0.0);
  104224. data.push(0.0);
  104225. data.push(0.0);
  104226. if (!this.isBillboardBased) {
  104227. // initialDirection
  104228. data.push(0.0);
  104229. data.push(0.0);
  104230. data.push(0.0);
  104231. }
  104232. // angle
  104233. data.push(0.0);
  104234. if (!this._angularSpeedGradientsTexture) {
  104235. data.push(0.0);
  104236. }
  104237. if (this._isAnimationSheetEnabled) {
  104238. data.push(0.0);
  104239. if (this.spriteRandomStartCell) {
  104240. data.push(0.0);
  104241. }
  104242. }
  104243. if (this.noiseTexture) { // Random coordinates for reading into noise texture
  104244. data.push(Math.random());
  104245. data.push(Math.random());
  104246. data.push(Math.random());
  104247. data.push(Math.random());
  104248. data.push(Math.random());
  104249. data.push(Math.random());
  104250. }
  104251. }
  104252. // Sprite data
  104253. var spriteData = new Float32Array([0.5, 0.5, 1, 1,
  104254. -0.5, 0.5, 0, 1,
  104255. -0.5, -0.5, 0, 0,
  104256. 0.5, -0.5, 1, 0]);
  104257. // Buffers
  104258. this._buffer0 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  104259. this._buffer1 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  104260. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 4);
  104261. // Update VAO
  104262. this._updateVAO = [];
  104263. this._updateVAO.push(this._createUpdateVAO(this._buffer0));
  104264. this._updateVAO.push(this._createUpdateVAO(this._buffer1));
  104265. // Render VAO
  104266. this._renderVAO = [];
  104267. this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer));
  104268. this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer));
  104269. // Links
  104270. this._sourceBuffer = this._buffer0;
  104271. this._targetBuffer = this._buffer1;
  104272. };
  104273. /** @hidden */
  104274. GPUParticleSystem.prototype._recreateUpdateEffect = function () {
  104275. var defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  104276. if (this._isBillboardBased) {
  104277. defines += "\n#define BILLBOARD";
  104278. }
  104279. if (this._colorGradientsTexture) {
  104280. defines += "\n#define COLORGRADIENTS";
  104281. }
  104282. if (this._sizeGradientsTexture) {
  104283. defines += "\n#define SIZEGRADIENTS";
  104284. }
  104285. if (this._angularSpeedGradientsTexture) {
  104286. defines += "\n#define ANGULARSPEEDGRADIENTS";
  104287. }
  104288. if (this._velocityGradientsTexture) {
  104289. defines += "\n#define VELOCITYGRADIENTS";
  104290. }
  104291. if (this._limitVelocityGradientsTexture) {
  104292. defines += "\n#define LIMITVELOCITYGRADIENTS";
  104293. }
  104294. if (this._dragGradientsTexture) {
  104295. defines += "\n#define DRAGGRADIENTS";
  104296. }
  104297. if (this.isAnimationSheetEnabled) {
  104298. defines += "\n#define ANIMATESHEET";
  104299. if (this.spriteRandomStartCell) {
  104300. defines += "\n#define ANIMATESHEETRANDOMSTART";
  104301. }
  104302. }
  104303. if (this.noiseTexture) {
  104304. defines += "\n#define NOISE";
  104305. }
  104306. if (this._updateEffect && this._updateEffectOptions.defines === defines) {
  104307. return;
  104308. }
  104309. this._updateEffectOptions.transformFeedbackVaryings = ["outPosition", "outAge", "outLife", "outSeed", "outSize"];
  104310. if (!this._colorGradientsTexture) {
  104311. this._updateEffectOptions.transformFeedbackVaryings.push("outColor");
  104312. }
  104313. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection");
  104314. if (!this._isBillboardBased) {
  104315. this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection");
  104316. }
  104317. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle");
  104318. if (this.isAnimationSheetEnabled) {
  104319. this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex");
  104320. if (this.spriteRandomStartCell) {
  104321. this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
  104322. }
  104323. }
  104324. if (this.noiseTexture) {
  104325. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
  104326. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
  104327. }
  104328. this._updateEffectOptions.defines = defines;
  104329. this._updateEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
  104330. };
  104331. /** @hidden */
  104332. GPUParticleSystem.prototype._recreateRenderEffect = function () {
  104333. var defines = "";
  104334. if (this._scene.clipPlane) {
  104335. defines = "\n#define CLIPPLANE";
  104336. }
  104337. if (this._scene.clipPlane2) {
  104338. defines = "\n#define CLIPPLANE2";
  104339. }
  104340. if (this._scene.clipPlane3) {
  104341. defines = "\n#define CLIPPLANE3";
  104342. }
  104343. if (this._scene.clipPlane4) {
  104344. defines = "\n#define CLIPPLANE4";
  104345. }
  104346. if (this.blendMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY) {
  104347. defines = "\n#define BLENDMULTIPLYMODE";
  104348. }
  104349. if (this._isBillboardBased) {
  104350. defines += "\n#define BILLBOARD";
  104351. switch (this.billboardMode) {
  104352. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_Y:
  104353. defines += "\n#define BILLBOARDY";
  104354. break;
  104355. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED:
  104356. defines += "\n#define BILLBOARDSTRETCHED";
  104357. break;
  104358. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_ALL:
  104359. default:
  104360. break;
  104361. }
  104362. }
  104363. if (this._colorGradientsTexture) {
  104364. defines += "\n#define COLORGRADIENTS";
  104365. }
  104366. if (this.isAnimationSheetEnabled) {
  104367. defines += "\n#define ANIMATESHEET";
  104368. }
  104369. if (this._imageProcessingConfiguration) {
  104370. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  104371. defines += "\n" + this._imageProcessingConfigurationDefines.toString();
  104372. }
  104373. if (this._renderEffect && this._renderEffect.defines === defines) {
  104374. return;
  104375. }
  104376. var uniforms = ["view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
  104377. var samplers = ["textureSampler", "colorGradientSampler"];
  104378. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  104379. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
  104380. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  104381. }
  104382. 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);
  104383. };
  104384. /**
  104385. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  104386. * @param preWarm defines if we are in the pre-warmimg phase
  104387. */
  104388. GPUParticleSystem.prototype.animate = function (preWarm) {
  104389. if (preWarm === void 0) { preWarm = false; }
  104390. this._timeDelta = this.updateSpeed * (preWarm ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  104391. this._actualFrame += this._timeDelta;
  104392. if (!this._stopped) {
  104393. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  104394. this.stop();
  104395. }
  104396. }
  104397. };
  104398. GPUParticleSystem.prototype._createFactorGradientTexture = function (factorGradients, textureName) {
  104399. var texture = this[textureName];
  104400. if (!factorGradients || !factorGradients.length || texture) {
  104401. return;
  104402. }
  104403. var data = new Float32Array(this._rawTextureWidth);
  104404. for (var x = 0; x < this._rawTextureWidth; x++) {
  104405. var ratio = x / this._rawTextureWidth;
  104406. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, factorGradients, function (currentGradient, nextGradient, scale) {
  104407. data[x] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  104408. });
  104409. }
  104410. 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);
  104411. };
  104412. GPUParticleSystem.prototype._createSizeGradientTexture = function () {
  104413. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
  104414. };
  104415. GPUParticleSystem.prototype._createAngularSpeedGradientTexture = function () {
  104416. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
  104417. };
  104418. GPUParticleSystem.prototype._createVelocityGradientTexture = function () {
  104419. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
  104420. };
  104421. GPUParticleSystem.prototype._createLimitVelocityGradientTexture = function () {
  104422. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
  104423. };
  104424. GPUParticleSystem.prototype._createDragGradientTexture = function () {
  104425. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
  104426. };
  104427. GPUParticleSystem.prototype._createColorGradientTexture = function () {
  104428. if (!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture) {
  104429. return;
  104430. }
  104431. var data = new Uint8Array(this._rawTextureWidth * 4);
  104432. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color4[0];
  104433. for (var x = 0; x < this._rawTextureWidth; x++) {
  104434. var ratio = x / this._rawTextureWidth;
  104435. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._colorGradients, function (currentGradient, nextGradient, scale) {
  104436. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(currentGradient.color1, nextGradient.color1, scale, tmpColor);
  104437. data[x * 4] = tmpColor.r * 255;
  104438. data[x * 4 + 1] = tmpColor.g * 255;
  104439. data[x * 4 + 2] = tmpColor.b * 255;
  104440. data[x * 4 + 3] = tmpColor.a * 255;
  104441. });
  104442. }
  104443. 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);
  104444. };
  104445. /**
  104446. * Renders the particle system in its current state
  104447. * @param preWarm defines if the system should only update the particles but not render them
  104448. * @returns the current number of particles
  104449. */
  104450. GPUParticleSystem.prototype.render = function (preWarm) {
  104451. if (preWarm === void 0) { preWarm = false; }
  104452. if (!this._started) {
  104453. return 0;
  104454. }
  104455. this._createColorGradientTexture();
  104456. this._createSizeGradientTexture();
  104457. this._createAngularSpeedGradientTexture();
  104458. this._createVelocityGradientTexture();
  104459. this._createLimitVelocityGradientTexture();
  104460. this._createDragGradientTexture();
  104461. this._recreateUpdateEffect();
  104462. this._recreateRenderEffect();
  104463. if (!this.isReady()) {
  104464. return 0;
  104465. }
  104466. if (!preWarm) {
  104467. if (!this._preWarmDone && this.preWarmCycles) {
  104468. for (var index = 0; index < this.preWarmCycles; index++) {
  104469. this.animate(true);
  104470. this.render(true);
  104471. }
  104472. this._preWarmDone = true;
  104473. }
  104474. if (this._currentRenderId === this._scene.getFrameId()) {
  104475. return 0;
  104476. }
  104477. this._currentRenderId = this._scene.getFrameId();
  104478. }
  104479. // Get everything ready to render
  104480. this._initialize();
  104481. this._accumulatedCount += this.emitRate * this._timeDelta;
  104482. if (this._accumulatedCount > 1) {
  104483. var intPart = this._accumulatedCount | 0;
  104484. this._accumulatedCount -= intPart;
  104485. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + intPart);
  104486. }
  104487. if (!this._currentActiveCount) {
  104488. return 0;
  104489. }
  104490. // Enable update effect
  104491. this._engine.enableEffect(this._updateEffect);
  104492. this._engine.setState(false);
  104493. this._updateEffect.setFloat("currentCount", this._currentActiveCount);
  104494. this._updateEffect.setFloat("timeDelta", this._timeDelta);
  104495. this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1);
  104496. this._updateEffect.setTexture("randomSampler", this._randomTexture);
  104497. this._updateEffect.setTexture("randomSampler2", this._randomTexture2);
  104498. this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
  104499. this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
  104500. if (!this._colorGradientsTexture) {
  104501. this._updateEffect.setDirectColor4("color1", this.color1);
  104502. this._updateEffect.setDirectColor4("color2", this.color2);
  104503. }
  104504. this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
  104505. this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
  104506. this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
  104507. this._updateEffect.setVector3("gravity", this.gravity);
  104508. if (this._sizeGradientsTexture) {
  104509. this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture);
  104510. }
  104511. if (this._angularSpeedGradientsTexture) {
  104512. this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture);
  104513. }
  104514. if (this._velocityGradientsTexture) {
  104515. this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture);
  104516. }
  104517. if (this._limitVelocityGradientsTexture) {
  104518. this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture);
  104519. this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping);
  104520. }
  104521. if (this._dragGradientsTexture) {
  104522. this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture);
  104523. }
  104524. if (this.particleEmitterType) {
  104525. this.particleEmitterType.applyToShader(this._updateEffect);
  104526. }
  104527. if (this._isAnimationSheetEnabled) {
  104528. this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed);
  104529. }
  104530. if (this.noiseTexture) {
  104531. this._updateEffect.setTexture("noiseSampler", this.noiseTexture);
  104532. this._updateEffect.setVector3("noiseStrength", this.noiseStrength);
  104533. }
  104534. var emitterWM;
  104535. if (this.emitter.position) {
  104536. var emitterMesh = this.emitter;
  104537. emitterWM = emitterMesh.getWorldMatrix();
  104538. }
  104539. else {
  104540. var emitterPosition = this.emitter;
  104541. emitterWM = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  104542. }
  104543. this._updateEffect.setMatrix("emitterWM", emitterWM);
  104544. // Bind source VAO
  104545. this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null);
  104546. // Update
  104547. this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer());
  104548. this._engine.setRasterizerState(false);
  104549. this._engine.beginTransformFeedback(true);
  104550. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].PointListDrawMode, 0, this._currentActiveCount);
  104551. this._engine.endTransformFeedback();
  104552. this._engine.setRasterizerState(true);
  104553. this._engine.bindTransformFeedbackBuffer(null);
  104554. if (!preWarm) {
  104555. // Enable render effect
  104556. this._engine.enableEffect(this._renderEffect);
  104557. var viewMatrix = this._scene.getViewMatrix();
  104558. this._renderEffect.setMatrix("view", viewMatrix);
  104559. this._renderEffect.setMatrix("projection", this._scene.getProjectionMatrix());
  104560. this._renderEffect.setTexture("textureSampler", this.particleTexture);
  104561. this._renderEffect.setVector2("translationPivot", this.translationPivot);
  104562. if (this._colorGradientsTexture) {
  104563. this._renderEffect.setTexture("colorGradientSampler", this._colorGradientsTexture);
  104564. }
  104565. else {
  104566. this._renderEffect.setDirectColor4("colorDead", this.colorDead);
  104567. }
  104568. if (this._isAnimationSheetEnabled && this.particleTexture) {
  104569. var baseSize = this.particleTexture.getBaseSize();
  104570. this._renderEffect.setFloat3("sheetInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  104571. }
  104572. if (this._isBillboardBased) {
  104573. var camera = this._scene.activeCamera;
  104574. this._renderEffect.setVector3("eyePosition", camera.globalPosition);
  104575. }
  104576. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  104577. var invView = viewMatrix.clone();
  104578. invView.invert();
  104579. this._renderEffect.setMatrix("invView", invView);
  104580. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindClipPlane(this._renderEffect, this._scene);
  104581. }
  104582. // image processing
  104583. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  104584. this._imageProcessingConfiguration.bind(this._renderEffect);
  104585. }
  104586. // Draw order
  104587. switch (this.blendMode) {
  104588. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ADD:
  104589. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ADD);
  104590. break;
  104591. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ONEONE:
  104592. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ONEONE);
  104593. break;
  104594. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_STANDARD:
  104595. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_COMBINE);
  104596. break;
  104597. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY:
  104598. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_MULTIPLY);
  104599. break;
  104600. }
  104601. if (this.forceDepthWrite) {
  104602. this._engine.setDepthWrite(true);
  104603. }
  104604. // Bind source VAO
  104605. this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null);
  104606. // Render
  104607. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].TriangleFanDrawMode, 0, 4, this._currentActiveCount);
  104608. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_DISABLE);
  104609. }
  104610. // Switch VAOs
  104611. this._targetIndex++;
  104612. if (this._targetIndex === 2) {
  104613. this._targetIndex = 0;
  104614. }
  104615. // Switch buffers
  104616. var tmpBuffer = this._sourceBuffer;
  104617. this._sourceBuffer = this._targetBuffer;
  104618. this._targetBuffer = tmpBuffer;
  104619. return this._currentActiveCount;
  104620. };
  104621. /**
  104622. * Rebuilds the particle system
  104623. */
  104624. GPUParticleSystem.prototype.rebuild = function () {
  104625. this._initialize(true);
  104626. };
  104627. GPUParticleSystem.prototype._releaseBuffers = function () {
  104628. if (this._buffer0) {
  104629. this._buffer0.dispose();
  104630. this._buffer0 = null;
  104631. }
  104632. if (this._buffer1) {
  104633. this._buffer1.dispose();
  104634. this._buffer1 = null;
  104635. }
  104636. if (this._spriteBuffer) {
  104637. this._spriteBuffer.dispose();
  104638. this._spriteBuffer = null;
  104639. }
  104640. };
  104641. GPUParticleSystem.prototype._releaseVAOs = function () {
  104642. if (!this._updateVAO) {
  104643. return;
  104644. }
  104645. for (var index = 0; index < this._updateVAO.length; index++) {
  104646. this._engine.releaseVertexArrayObject(this._updateVAO[index]);
  104647. }
  104648. this._updateVAO = [];
  104649. for (var index = 0; index < this._renderVAO.length; index++) {
  104650. this._engine.releaseVertexArrayObject(this._renderVAO[index]);
  104651. }
  104652. this._renderVAO = [];
  104653. };
  104654. /**
  104655. * Disposes the particle system and free the associated resources
  104656. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  104657. */
  104658. GPUParticleSystem.prototype.dispose = function (disposeTexture) {
  104659. if (disposeTexture === void 0) { disposeTexture = true; }
  104660. var index = this._scene.particleSystems.indexOf(this);
  104661. if (index > -1) {
  104662. this._scene.particleSystems.splice(index, 1);
  104663. }
  104664. this._releaseBuffers();
  104665. this._releaseVAOs();
  104666. if (this._colorGradientsTexture) {
  104667. this._colorGradientsTexture.dispose();
  104668. this._colorGradientsTexture = null;
  104669. }
  104670. if (this._sizeGradientsTexture) {
  104671. this._sizeGradientsTexture.dispose();
  104672. this._sizeGradientsTexture = null;
  104673. }
  104674. if (this._angularSpeedGradientsTexture) {
  104675. this._angularSpeedGradientsTexture.dispose();
  104676. this._angularSpeedGradientsTexture = null;
  104677. }
  104678. if (this._velocityGradientsTexture) {
  104679. this._velocityGradientsTexture.dispose();
  104680. this._velocityGradientsTexture = null;
  104681. }
  104682. if (this._limitVelocityGradientsTexture) {
  104683. this._limitVelocityGradientsTexture.dispose();
  104684. this._limitVelocityGradientsTexture = null;
  104685. }
  104686. if (this._dragGradientsTexture) {
  104687. this._dragGradientsTexture.dispose();
  104688. this._dragGradientsTexture = null;
  104689. }
  104690. if (this._randomTexture) {
  104691. this._randomTexture.dispose();
  104692. this._randomTexture = null;
  104693. }
  104694. if (this._randomTexture2) {
  104695. this._randomTexture2.dispose();
  104696. this._randomTexture2 = null;
  104697. }
  104698. if (disposeTexture && this.particleTexture) {
  104699. this.particleTexture.dispose();
  104700. this.particleTexture = null;
  104701. }
  104702. if (disposeTexture && this.noiseTexture) {
  104703. this.noiseTexture.dispose();
  104704. this.noiseTexture = null;
  104705. }
  104706. // Callback
  104707. this.onDisposeObservable.notifyObservers(this);
  104708. this.onDisposeObservable.clear();
  104709. };
  104710. /**
  104711. * Clones the particle system.
  104712. * @param name The name of the cloned object
  104713. * @param newEmitter The new emitter to use
  104714. * @returns the cloned particle system
  104715. */
  104716. GPUParticleSystem.prototype.clone = function (name, newEmitter) {
  104717. var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
  104718. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__["DeepCopier"].DeepCopy(this, result);
  104719. if (newEmitter === undefined) {
  104720. newEmitter = this.emitter;
  104721. }
  104722. result.emitter = newEmitter;
  104723. if (this.particleTexture) {
  104724. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"](this.particleTexture.url, this._scene);
  104725. }
  104726. return result;
  104727. };
  104728. /**
  104729. * Serializes the particle system to a JSON object.
  104730. * @returns the JSON object
  104731. */
  104732. GPUParticleSystem.prototype.serialize = function () {
  104733. var serializationObject = {};
  104734. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Serialize(serializationObject, this);
  104735. serializationObject.activeParticleCount = this.activeParticleCount;
  104736. return serializationObject;
  104737. };
  104738. /**
  104739. * Parses a JSON object to create a GPU particle system.
  104740. * @param parsedParticleSystem The JSON object to parse
  104741. * @param scene The scene to create the particle system in
  104742. * @param rootUrl The root url to use to load external dependencies like texture
  104743. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  104744. * @returns the parsed GPU particle system
  104745. */
  104746. GPUParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  104747. if (doNotStart === void 0) { doNotStart = false; }
  104748. var name = parsedParticleSystem.name;
  104749. var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
  104750. if (parsedParticleSystem.activeParticleCount) {
  104751. particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;
  104752. }
  104753. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  104754. // Auto start
  104755. if (parsedParticleSystem.preventAutoStart) {
  104756. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  104757. }
  104758. if (!doNotStart && !particleSystem.preventAutoStart) {
  104759. particleSystem.start();
  104760. }
  104761. return particleSystem;
  104762. };
  104763. return GPUParticleSystem;
  104764. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__["BaseParticleSystem"]));
  104765. /***/ }),
  104766. /***/ "./Particles/index.ts":
  104767. /*!****************************!*\
  104768. !*** ./Particles/index.ts ***!
  104769. \****************************/
  104770. /*! exports provided: BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  104771. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104772. "use strict";
  104773. __webpack_require__.r(__webpack_exports__);
  104774. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  104775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  104776. /* harmony import */ var _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  104777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["BoxParticleEmitter"]; });
  104778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  104779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderParticleEmitter"]; });
  104780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderDirectedParticleEmitter"]; });
  104781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["HemisphericParticleEmitter"]; });
  104782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["PointParticleEmitter"]; });
  104783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereParticleEmitter"]; });
  104784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereDirectedParticleEmitter"]; });
  104785. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  104786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"]; });
  104787. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  104788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _particle__WEBPACK_IMPORTED_MODULE_3__["Particle"]; });
  104789. /* harmony import */ var _particleHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleHelper */ "./Particles/particleHelper.ts");
  104790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _particleHelper__WEBPACK_IMPORTED_MODULE_4__["ParticleHelper"]; });
  104791. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  104792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _particleSystem__WEBPACK_IMPORTED_MODULE_5__["ParticleSystem"]; });
  104793. /* harmony import */ var _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystemComponent */ "./Particles/particleSystemComponent.ts");
  104794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__["_IDoNeedToBeInTheBuild"]; });
  104795. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  104796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__["ParticleSystemSet"]; });
  104797. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  104798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["SolidParticle"]; });
  104799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["ModelShape"]; });
  104800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["DepthSortedParticle"]; });
  104801. /* harmony import */ var _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./solidParticleSystem */ "./Particles/solidParticleSystem.ts");
  104802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__["SolidParticleSystem"]; });
  104803. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  104804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitterType"]; });
  104805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitter"]; });
  104806. /***/ }),
  104807. /***/ "./Particles/particle.ts":
  104808. /*!*******************************!*\
  104809. !*** ./Particles/particle.ts ***!
  104810. \*******************************/
  104811. /*! exports provided: Particle */
  104812. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104813. "use strict";
  104814. __webpack_require__.r(__webpack_exports__);
  104815. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return Particle; });
  104816. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  104817. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  104818. /**
  104819. * A particle represents one of the element emitted by a particle system.
  104820. * This is mainly define by its coordinates, direction, velocity and age.
  104821. */
  104822. var Particle = /** @class */ (function () {
  104823. /**
  104824. * Creates a new instance Particle
  104825. * @param particleSystem the particle system the particle belongs to
  104826. */
  104827. function Particle(
  104828. /**
  104829. * The particle system the particle belongs to.
  104830. */
  104831. particleSystem) {
  104832. this.particleSystem = particleSystem;
  104833. /**
  104834. * The world position of the particle in the scene.
  104835. */
  104836. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  104837. /**
  104838. * The world direction of the particle in the scene.
  104839. */
  104840. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  104841. /**
  104842. * The color of the particle.
  104843. */
  104844. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104845. /**
  104846. * The color change of the particle per step.
  104847. */
  104848. this.colorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104849. /**
  104850. * Defines how long will the life of the particle be.
  104851. */
  104852. this.lifeTime = 1.0;
  104853. /**
  104854. * The current age of the particle.
  104855. */
  104856. this.age = 0;
  104857. /**
  104858. * The current size of the particle.
  104859. */
  104860. this.size = 0;
  104861. /**
  104862. * The current scale of the particle.
  104863. */
  104864. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](1, 1);
  104865. /**
  104866. * The current angle of the particle.
  104867. */
  104868. this.angle = 0;
  104869. /**
  104870. * Defines how fast is the angle changing.
  104871. */
  104872. this.angularSpeed = 0;
  104873. /**
  104874. * Defines the cell index used by the particle to be rendered from a sprite.
  104875. */
  104876. this.cellIndex = 0;
  104877. /** @hidden */
  104878. this._attachedSubEmitters = null;
  104879. /** @hidden */
  104880. this._currentColor1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104881. /** @hidden */
  104882. this._currentColor2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  104883. /** @hidden */
  104884. this._currentSize1 = 0;
  104885. /** @hidden */
  104886. this._currentSize2 = 0;
  104887. /** @hidden */
  104888. this._currentAngularSpeed1 = 0;
  104889. /** @hidden */
  104890. this._currentAngularSpeed2 = 0;
  104891. /** @hidden */
  104892. this._currentVelocity1 = 0;
  104893. /** @hidden */
  104894. this._currentVelocity2 = 0;
  104895. /** @hidden */
  104896. this._currentLimitVelocity1 = 0;
  104897. /** @hidden */
  104898. this._currentLimitVelocity2 = 0;
  104899. /** @hidden */
  104900. this._currentDrag1 = 0;
  104901. /** @hidden */
  104902. this._currentDrag2 = 0;
  104903. this.id = Particle._Count++;
  104904. if (!this.particleSystem.isAnimationSheetEnabled) {
  104905. return;
  104906. }
  104907. this.updateCellInfoFromSystem();
  104908. }
  104909. Particle.prototype.updateCellInfoFromSystem = function () {
  104910. this.cellIndex = this.particleSystem.startSpriteCellID;
  104911. };
  104912. /**
  104913. * Defines how the sprite cell index is updated for the particle
  104914. */
  104915. Particle.prototype.updateCellIndex = function () {
  104916. var offsetAge = this.age;
  104917. var changeSpeed = this.particleSystem.spriteCellChangeSpeed;
  104918. if (this.particleSystem.spriteRandomStartCell) {
  104919. if (this._randomCellOffset === undefined) {
  104920. this._randomCellOffset = Math.random() * this.lifeTime;
  104921. }
  104922. if (changeSpeed === 0) { // Special case when speed = 0 meaning we want to stay on initial cell
  104923. changeSpeed = 1;
  104924. offsetAge = this._randomCellOffset;
  104925. }
  104926. else {
  104927. offsetAge += this._randomCellOffset;
  104928. }
  104929. }
  104930. var dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
  104931. var ratio = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);
  104932. this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
  104933. };
  104934. /** @hidden */
  104935. Particle.prototype._inheritParticleInfoToSubEmitter = function (subEmitter) {
  104936. if (subEmitter.particleSystem.emitter.position) {
  104937. var emitterMesh = subEmitter.particleSystem.emitter;
  104938. emitterMesh.position.copyFrom(this.position);
  104939. if (subEmitter.inheritDirection) {
  104940. emitterMesh.position.subtractToRef(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  104941. // Look at using Y as forward
  104942. emitterMesh.lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0], 0, Math.PI / 2);
  104943. }
  104944. }
  104945. else {
  104946. var emitterPosition = subEmitter.particleSystem.emitter;
  104947. emitterPosition.copyFrom(this.position);
  104948. }
  104949. // Set inheritedVelocityOffset to be used when new particles are created
  104950. this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  104951. subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  104952. };
  104953. /** @hidden */
  104954. Particle.prototype._inheritParticleInfoToSubEmitters = function () {
  104955. var _this = this;
  104956. if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {
  104957. this._attachedSubEmitters.forEach(function (subEmitter) {
  104958. _this._inheritParticleInfoToSubEmitter(subEmitter);
  104959. });
  104960. }
  104961. };
  104962. /** @hidden */
  104963. Particle.prototype._reset = function () {
  104964. this.age = 0;
  104965. this._currentColorGradient = null;
  104966. this._currentSizeGradient = null;
  104967. this._currentAngularSpeedGradient = null;
  104968. this._currentVelocityGradient = null;
  104969. this._currentLimitVelocityGradient = null;
  104970. this._currentDragGradient = null;
  104971. this.cellIndex = this.particleSystem.startSpriteCellID;
  104972. this._randomCellOffset = undefined;
  104973. };
  104974. /**
  104975. * Copy the properties of particle to another one.
  104976. * @param other the particle to copy the information to.
  104977. */
  104978. Particle.prototype.copyTo = function (other) {
  104979. other.position.copyFrom(this.position);
  104980. if (this._initialDirection) {
  104981. if (other._initialDirection) {
  104982. other._initialDirection.copyFrom(this._initialDirection);
  104983. }
  104984. else {
  104985. other._initialDirection = this._initialDirection.clone();
  104986. }
  104987. }
  104988. else {
  104989. other._initialDirection = null;
  104990. }
  104991. other.direction.copyFrom(this.direction);
  104992. other.color.copyFrom(this.color);
  104993. other.colorStep.copyFrom(this.colorStep);
  104994. other.lifeTime = this.lifeTime;
  104995. other.age = this.age;
  104996. other._randomCellOffset = this._randomCellOffset;
  104997. other.size = this.size;
  104998. other.scale.copyFrom(this.scale);
  104999. other.angle = this.angle;
  105000. other.angularSpeed = this.angularSpeed;
  105001. other.particleSystem = this.particleSystem;
  105002. other.cellIndex = this.cellIndex;
  105003. other.id = this.id;
  105004. other._attachedSubEmitters = this._attachedSubEmitters;
  105005. if (this._currentColorGradient) {
  105006. other._currentColorGradient = this._currentColorGradient;
  105007. other._currentColor1.copyFrom(this._currentColor1);
  105008. other._currentColor2.copyFrom(this._currentColor2);
  105009. }
  105010. if (this._currentSizeGradient) {
  105011. other._currentSizeGradient = this._currentSizeGradient;
  105012. other._currentSize1 = this._currentSize1;
  105013. other._currentSize2 = this._currentSize2;
  105014. }
  105015. if (this._currentAngularSpeedGradient) {
  105016. other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;
  105017. other._currentAngularSpeed1 = this._currentAngularSpeed1;
  105018. other._currentAngularSpeed2 = this._currentAngularSpeed2;
  105019. }
  105020. if (this._currentVelocityGradient) {
  105021. other._currentVelocityGradient = this._currentVelocityGradient;
  105022. other._currentVelocity1 = this._currentVelocity1;
  105023. other._currentVelocity2 = this._currentVelocity2;
  105024. }
  105025. if (this._currentLimitVelocityGradient) {
  105026. other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
  105027. other._currentLimitVelocity1 = this._currentLimitVelocity1;
  105028. other._currentLimitVelocity2 = this._currentLimitVelocity2;
  105029. }
  105030. if (this._currentDragGradient) {
  105031. other._currentDragGradient = this._currentDragGradient;
  105032. other._currentDrag1 = this._currentDrag1;
  105033. other._currentDrag2 = this._currentDrag2;
  105034. }
  105035. if (this.particleSystem.isAnimationSheetEnabled) {
  105036. other._initialStartSpriteCellID = this._initialStartSpriteCellID;
  105037. other._initialEndSpriteCellID = this._initialEndSpriteCellID;
  105038. }
  105039. if (this.particleSystem.useRampGradients) {
  105040. other.remapData.copyFrom(this.remapData);
  105041. }
  105042. if (this._randomNoiseCoordinates1) {
  105043. if (other._randomNoiseCoordinates1) {
  105044. other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);
  105045. other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);
  105046. }
  105047. else {
  105048. other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();
  105049. other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();
  105050. }
  105051. }
  105052. };
  105053. Particle._Count = 0;
  105054. return Particle;
  105055. }());
  105056. /***/ }),
  105057. /***/ "./Particles/particleHelper.ts":
  105058. /*!*************************************!*\
  105059. !*** ./Particles/particleHelper.ts ***!
  105060. \*************************************/
  105061. /*! exports provided: ParticleHelper */
  105062. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105063. "use strict";
  105064. __webpack_require__.r(__webpack_exports__);
  105065. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return ParticleHelper; });
  105066. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  105067. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  105068. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  105069. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  105070. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  105071. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  105072. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  105073. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  105074. /**
  105075. * This class is made for on one-liner static method to help creating particle system set.
  105076. */
  105077. var ParticleHelper = /** @class */ (function () {
  105078. function ParticleHelper() {
  105079. }
  105080. /**
  105081. * Create a default particle system that you can tweak
  105082. * @param emitter defines the emitter to use
  105083. * @param capacity defines the system capacity (default is 500 particles)
  105084. * @param scene defines the hosting scene
  105085. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  105086. * @returns the new Particle system
  105087. */
  105088. ParticleHelper.CreateDefault = function (emitter, capacity, scene, useGPU) {
  105089. if (capacity === void 0) { capacity = 500; }
  105090. if (useGPU === void 0) { useGPU = false; }
  105091. var system;
  105092. if (useGPU) {
  105093. system = new _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"]("default system", { capacity: capacity }, scene);
  105094. }
  105095. else {
  105096. system = new _particleSystem__WEBPACK_IMPORTED_MODULE_6__["ParticleSystem"]("default system", capacity, scene);
  105097. }
  105098. system.emitter = emitter;
  105099. system.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]("https://www.babylonjs.com/assets/Flare.png", system.getScene());
  105100. system.createConeEmitter(0.1, Math.PI / 4);
  105101. // Particle color
  105102. system.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  105103. system.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  105104. system.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 0.0);
  105105. // Particle Size
  105106. system.minSize = 0.1;
  105107. system.maxSize = 0.1;
  105108. // Emission speed
  105109. system.minEmitPower = 2;
  105110. system.maxEmitPower = 2;
  105111. // Update speed
  105112. system.updateSpeed = 1 / 60;
  105113. system.emitRate = 30;
  105114. return system;
  105115. };
  105116. /**
  105117. * This is the main static method (one-liner) of this helper to create different particle systems
  105118. * @param type This string represents the type to the particle system to create
  105119. * @param scene The scene where the particle system should live
  105120. * @param gpu If the system will use gpu
  105121. * @returns the ParticleSystemSet created
  105122. */
  105123. ParticleHelper.CreateAsync = function (type, scene, gpu) {
  105124. if (gpu === void 0) { gpu = false; }
  105125. if (!scene) {
  105126. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  105127. }
  105128. var token = {};
  105129. scene._addPendingData(token);
  105130. return new Promise(function (resolve, reject) {
  105131. if (gpu && !_gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"].IsSupported) {
  105132. scene._removePendingData(token);
  105133. return reject("Particle system with GPU is not supported.");
  105134. }
  105135. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(ParticleHelper.BaseAssetsUrl + "/systems/" + type + ".json", function (data) {
  105136. scene._removePendingData(token);
  105137. var newData = JSON.parse(data.toString());
  105138. return resolve(_particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].Parse(newData, scene, gpu));
  105139. }, undefined, undefined, undefined, function () {
  105140. scene._removePendingData(token);
  105141. return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
  105142. });
  105143. });
  105144. };
  105145. /**
  105146. * Static function used to export a particle system to a ParticleSystemSet variable.
  105147. * Please note that the emitter shape is not exported
  105148. * @param systems defines the particle systems to export
  105149. * @returns the created particle system set
  105150. */
  105151. ParticleHelper.ExportSet = function (systems) {
  105152. var set = new _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"]();
  105153. for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
  105154. var system = systems_1[_i];
  105155. set.systems.push(system);
  105156. }
  105157. return set;
  105158. };
  105159. /**
  105160. * Gets or sets base Assets URL
  105161. */
  105162. ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
  105163. return ParticleHelper;
  105164. }());
  105165. /***/ }),
  105166. /***/ "./Particles/particleSystem.ts":
  105167. /*!*************************************!*\
  105168. !*** ./Particles/particleSystem.ts ***!
  105169. \*************************************/
  105170. /*! exports provided: ParticleSystem */
  105171. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105172. "use strict";
  105173. __webpack_require__.r(__webpack_exports__);
  105174. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return ParticleSystem; });
  105175. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  105176. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  105177. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  105178. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  105179. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105180. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  105181. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  105182. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  105183. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  105184. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  105185. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  105186. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  105187. /* harmony import */ var _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Procedurals/proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  105188. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  105189. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  105190. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  105191. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  105192. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  105193. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  105194. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  105195. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105196. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  105197. /* harmony import */ var _Shaders_particles_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/particles.fragment */ "./Shaders/particles.fragment.ts");
  105198. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  105199. /**
  105200. * This represents a particle system in Babylon.
  105201. * 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.
  105202. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  105203. * @example https://doc.babylonjs.com/babylon101/particles
  105204. */
  105205. var ParticleSystem = /** @class */ (function (_super) {
  105206. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticleSystem, _super);
  105207. /**
  105208. * Instantiates a particle system.
  105209. * 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.
  105210. * @param name The name of the particle system
  105211. * @param capacity The max number of particles alive at the same time
  105212. * @param scene The scene the particle system belongs to
  105213. * @param customEffect a custom effect used to change the way particles are rendered by default
  105214. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  105215. * @param epsilon Offset used to render the particles
  105216. */
  105217. function ParticleSystem(name, capacity, scene, customEffect, isAnimationSheetEnabled, epsilon) {
  105218. if (customEffect === void 0) { customEffect = null; }
  105219. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  105220. if (epsilon === void 0) { epsilon = 0.01; }
  105221. var _this = _super.call(this, name) || this;
  105222. /**
  105223. * @hidden
  105224. */
  105225. _this._inheritedVelocityOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  105226. /**
  105227. * An event triggered when the system is disposed
  105228. */
  105229. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  105230. _this._particles = new Array();
  105231. _this._stockParticles = new Array();
  105232. _this._newPartsExcess = 0;
  105233. _this._vertexBuffers = {};
  105234. _this._scaledColorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  105235. _this._colorDiff = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  105236. _this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105237. _this._scaledGravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105238. _this._currentRenderId = -1;
  105239. _this._useInstancing = false;
  105240. _this._started = false;
  105241. _this._stopped = false;
  105242. _this._actualFrame = 0;
  105243. /** @hidden */
  105244. _this._currentEmitRate1 = 0;
  105245. /** @hidden */
  105246. _this._currentEmitRate2 = 0;
  105247. /** @hidden */
  105248. _this._currentStartSize1 = 0;
  105249. /** @hidden */
  105250. _this._currentStartSize2 = 0;
  105251. _this._rawTextureWidth = 256;
  105252. _this._useRampGradients = false;
  105253. /**
  105254. * @hidden
  105255. * If the particle systems emitter should be disposed when the particle system is disposed
  105256. */
  105257. _this._disposeEmitterOnDispose = false;
  105258. // start of sub system methods
  105259. /**
  105260. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  105261. * Its lifetime will start back at 0.
  105262. */
  105263. _this.recycleParticle = function (particle) {
  105264. // move particle from activeParticle list to stock particles
  105265. var lastParticle = _this._particles.pop();
  105266. if (lastParticle !== particle) {
  105267. lastParticle.copyTo(particle);
  105268. }
  105269. _this._stockParticles.push(lastParticle);
  105270. };
  105271. _this._createParticle = function () {
  105272. var particle;
  105273. if (_this._stockParticles.length !== 0) {
  105274. particle = _this._stockParticles.pop();
  105275. particle._reset();
  105276. }
  105277. else {
  105278. particle = new _particle__WEBPACK_IMPORTED_MODULE_16__["Particle"](_this);
  105279. }
  105280. // Attach emitters
  105281. if (_this._subEmitters && _this._subEmitters.length > 0) {
  105282. var subEmitters = _this._subEmitters[Math.floor(Math.random() * _this._subEmitters.length)];
  105283. particle._attachedSubEmitters = [];
  105284. subEmitters.forEach(function (subEmitter) {
  105285. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].ATTACHED) {
  105286. var newEmitter = subEmitter.clone();
  105287. particle._attachedSubEmitters.push(newEmitter);
  105288. newEmitter.particleSystem.start();
  105289. }
  105290. });
  105291. }
  105292. return particle;
  105293. };
  105294. _this._emitFromParticle = function (particle) {
  105295. if (!_this._subEmitters || _this._subEmitters.length === 0) {
  105296. return;
  105297. }
  105298. var templateIndex = Math.floor(Math.random() * _this._subEmitters.length);
  105299. _this._subEmitters[templateIndex].forEach(function (subEmitter) {
  105300. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].END) {
  105301. var subSystem = subEmitter.clone();
  105302. particle._inheritParticleInfoToSubEmitter(subSystem);
  105303. subSystem.particleSystem._rootParticleSystem = _this;
  105304. _this.activeSubSystems.push(subSystem.particleSystem);
  105305. subSystem.particleSystem.start();
  105306. }
  105307. });
  105308. };
  105309. _this._capacity = capacity;
  105310. _this._epsilon = epsilon;
  105311. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  105312. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__["EngineStore"].LastCreatedScene;
  105313. // Setup the default processing configuration to the scene.
  105314. _this._attachImageProcessingConfiguration(null);
  105315. _this._customEffect = customEffect;
  105316. _this._scene.particleSystems.push(_this);
  105317. _this._useInstancing = _this._scene.getEngine().getCaps().instancedArrays;
  105318. _this._createIndexBuffer();
  105319. _this._createVertexBuffers();
  105320. // Default emitter type
  105321. _this.particleEmitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  105322. // Update
  105323. _this.updateFunction = function (particles) {
  105324. var noiseTextureSize = null;
  105325. var noiseTextureData = null;
  105326. if (_this.noiseTexture) { // We need to get texture data back to CPU
  105327. noiseTextureSize = _this.noiseTexture.getSize();
  105328. noiseTextureData = (_this.noiseTexture.getContent());
  105329. }
  105330. var _loop_1 = function () {
  105331. particle = particles[index];
  105332. var scaledUpdateSpeed = _this._scaledUpdateSpeed;
  105333. var previousAge = particle.age;
  105334. particle.age += scaledUpdateSpeed;
  105335. // Evaluate step to death
  105336. if (particle.age > particle.lifeTime) {
  105337. var diff = particle.age - previousAge;
  105338. var oldDiff = particle.lifeTime - previousAge;
  105339. scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
  105340. particle.age = particle.lifeTime;
  105341. }
  105342. var ratio = particle.age / particle.lifeTime;
  105343. // Color
  105344. if (_this._colorGradients && _this._colorGradients.length > 0) {
  105345. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorGradients, function (currentGradient, nextGradient, scale) {
  105346. if (currentGradient !== particle._currentColorGradient) {
  105347. particle._currentColor1.copyFrom(particle._currentColor2);
  105348. nextGradient.getColorToRef(particle._currentColor2);
  105349. particle._currentColorGradient = currentGradient;
  105350. }
  105351. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
  105352. });
  105353. }
  105354. else {
  105355. particle.colorStep.scaleToRef(scaledUpdateSpeed, _this._scaledColorStep);
  105356. particle.color.addInPlace(_this._scaledColorStep);
  105357. if (particle.color.a < 0) {
  105358. particle.color.a = 0;
  105359. }
  105360. }
  105361. // Angular speed
  105362. if (_this._angularSpeedGradients && _this._angularSpeedGradients.length > 0) {
  105363. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._angularSpeedGradients, function (currentGradient, nextGradient, scale) {
  105364. if (currentGradient !== particle._currentAngularSpeedGradient) {
  105365. particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
  105366. particle._currentAngularSpeed2 = nextGradient.getFactor();
  105367. particle._currentAngularSpeedGradient = currentGradient;
  105368. }
  105369. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
  105370. });
  105371. }
  105372. particle.angle += particle.angularSpeed * scaledUpdateSpeed;
  105373. // Direction
  105374. var directionScale = scaledUpdateSpeed;
  105375. /// Velocity
  105376. if (_this._velocityGradients && _this._velocityGradients.length > 0) {
  105377. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
  105378. if (currentGradient !== particle._currentVelocityGradient) {
  105379. particle._currentVelocity1 = particle._currentVelocity2;
  105380. particle._currentVelocity2 = nextGradient.getFactor();
  105381. particle._currentVelocityGradient = currentGradient;
  105382. }
  105383. directionScale *= _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
  105384. });
  105385. }
  105386. particle.direction.scaleToRef(directionScale, _this._scaledDirection);
  105387. /// Limit velocity
  105388. if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
  105389. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
  105390. if (currentGradient !== particle._currentLimitVelocityGradient) {
  105391. particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
  105392. particle._currentLimitVelocity2 = nextGradient.getFactor();
  105393. particle._currentLimitVelocityGradient = currentGradient;
  105394. }
  105395. var limitVelocity = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
  105396. var currentVelocity = particle.direction.length();
  105397. if (currentVelocity > limitVelocity) {
  105398. particle.direction.scaleInPlace(_this.limitVelocityDamping);
  105399. }
  105400. });
  105401. }
  105402. /// Drag
  105403. if (_this._dragGradients && _this._dragGradients.length > 0) {
  105404. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._dragGradients, function (currentGradient, nextGradient, scale) {
  105405. if (currentGradient !== particle._currentDragGradient) {
  105406. particle._currentDrag1 = particle._currentDrag2;
  105407. particle._currentDrag2 = nextGradient.getFactor();
  105408. particle._currentDragGradient = currentGradient;
  105409. }
  105410. var drag = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentDrag1, particle._currentDrag2, scale);
  105411. _this._scaledDirection.scaleInPlace(1.0 - drag);
  105412. });
  105413. }
  105414. particle.position.addInPlace(_this._scaledDirection);
  105415. // Noise
  105416. if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
  105417. var fetchedColorR = _this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  105418. var fetchedColorG = _this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  105419. var fetchedColorB = _this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  105420. var force = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  105421. var scaledForce = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  105422. force.copyFromFloats((2 * fetchedColorR - 1) * _this.noiseStrength.x, (2 * fetchedColorG - 1) * _this.noiseStrength.y, (2 * fetchedColorB - 1) * _this.noiseStrength.z);
  105423. force.scaleToRef(scaledUpdateSpeed, scaledForce);
  105424. particle.direction.addInPlace(scaledForce);
  105425. }
  105426. // Gravity
  105427. _this.gravity.scaleToRef(scaledUpdateSpeed, _this._scaledGravity);
  105428. particle.direction.addInPlace(_this._scaledGravity);
  105429. // Size
  105430. if (_this._sizeGradients && _this._sizeGradients.length > 0) {
  105431. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._sizeGradients, function (currentGradient, nextGradient, scale) {
  105432. if (currentGradient !== particle._currentSizeGradient) {
  105433. particle._currentSize1 = particle._currentSize2;
  105434. particle._currentSize2 = nextGradient.getFactor();
  105435. particle._currentSizeGradient = currentGradient;
  105436. }
  105437. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentSize1, particle._currentSize2, scale);
  105438. });
  105439. }
  105440. // Remap data
  105441. if (_this._useRampGradients) {
  105442. if (_this._colorRemapGradients && _this._colorRemapGradients.length > 0) {
  105443. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorRemapGradients, function (currentGradient, nextGradient, scale) {
  105444. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  105445. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  105446. particle.remapData.x = min;
  105447. particle.remapData.y = max - min;
  105448. });
  105449. }
  105450. if (_this._alphaRemapGradients && _this._alphaRemapGradients.length > 0) {
  105451. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._alphaRemapGradients, function (currentGradient, nextGradient, scale) {
  105452. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  105453. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  105454. particle.remapData.z = min;
  105455. particle.remapData.w = max - min;
  105456. });
  105457. }
  105458. }
  105459. if (_this._isAnimationSheetEnabled) {
  105460. particle.updateCellIndex();
  105461. }
  105462. // Update the position of the attached sub-emitters to match their attached particle
  105463. particle._inheritParticleInfoToSubEmitters();
  105464. if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
  105465. _this._emitFromParticle(particle);
  105466. if (particle._attachedSubEmitters) {
  105467. particle._attachedSubEmitters.forEach(function (subEmitter) {
  105468. subEmitter.particleSystem.disposeOnStop = true;
  105469. subEmitter.particleSystem.stop();
  105470. });
  105471. particle._attachedSubEmitters = null;
  105472. }
  105473. _this.recycleParticle(particle);
  105474. index--;
  105475. return "continue";
  105476. }
  105477. };
  105478. var particle;
  105479. for (var index = 0; index < particles.length; index++) {
  105480. _loop_1();
  105481. }
  105482. };
  105483. return _this;
  105484. }
  105485. Object.defineProperty(ParticleSystem.prototype, "onDispose", {
  105486. /**
  105487. * Sets a callback that will be triggered when the system is disposed
  105488. */
  105489. set: function (callback) {
  105490. if (this._onDisposeObserver) {
  105491. this.onDisposeObservable.remove(this._onDisposeObserver);
  105492. }
  105493. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  105494. },
  105495. enumerable: true,
  105496. configurable: true
  105497. });
  105498. Object.defineProperty(ParticleSystem.prototype, "useRampGradients", {
  105499. /** Gets or sets a boolean indicating that ramp gradients must be used
  105500. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  105501. */
  105502. get: function () {
  105503. return this._useRampGradients;
  105504. },
  105505. set: function (value) {
  105506. if (this._useRampGradients === value) {
  105507. return;
  105508. }
  105509. this._useRampGradients = value;
  105510. this._resetEffect();
  105511. },
  105512. enumerable: true,
  105513. configurable: true
  105514. });
  105515. Object.defineProperty(ParticleSystem.prototype, "particles", {
  105516. //end of Sub-emitter
  105517. /**
  105518. * Gets the current list of active particles
  105519. */
  105520. get: function () {
  105521. return this._particles;
  105522. },
  105523. enumerable: true,
  105524. configurable: true
  105525. });
  105526. /**
  105527. * Returns the string "ParticleSystem"
  105528. * @returns a string containing the class name
  105529. */
  105530. ParticleSystem.prototype.getClassName = function () {
  105531. return "ParticleSystem";
  105532. };
  105533. ParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor, factor2) {
  105534. var newGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  105535. newGradient.gradient = gradient;
  105536. newGradient.factor1 = factor;
  105537. newGradient.factor2 = factor2;
  105538. factorGradients.push(newGradient);
  105539. factorGradients.sort(function (a, b) {
  105540. if (a.gradient < b.gradient) {
  105541. return -1;
  105542. }
  105543. else if (a.gradient > b.gradient) {
  105544. return 1;
  105545. }
  105546. return 0;
  105547. });
  105548. };
  105549. ParticleSystem.prototype._removeFactorGradient = function (factorGradients, gradient) {
  105550. if (!factorGradients) {
  105551. return;
  105552. }
  105553. var index = 0;
  105554. for (var _i = 0, factorGradients_1 = factorGradients; _i < factorGradients_1.length; _i++) {
  105555. var factorGradient = factorGradients_1[_i];
  105556. if (factorGradient.gradient === gradient) {
  105557. factorGradients.splice(index, 1);
  105558. break;
  105559. }
  105560. index++;
  105561. }
  105562. };
  105563. /**
  105564. * Adds a new life time gradient
  105565. * @param gradient defines the gradient to use (between 0 and 1)
  105566. * @param factor defines the life time factor to affect to the specified gradient
  105567. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105568. * @returns the current particle system
  105569. */
  105570. ParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  105571. if (!this._lifeTimeGradients) {
  105572. this._lifeTimeGradients = [];
  105573. }
  105574. this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
  105575. return this;
  105576. };
  105577. /**
  105578. * Remove a specific life time gradient
  105579. * @param gradient defines the gradient to remove
  105580. * @returns the current particle system
  105581. */
  105582. ParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  105583. this._removeFactorGradient(this._lifeTimeGradients, gradient);
  105584. return this;
  105585. };
  105586. /**
  105587. * Adds a new size gradient
  105588. * @param gradient defines the gradient to use (between 0 and 1)
  105589. * @param factor defines the size factor to affect to the specified gradient
  105590. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105591. * @returns the current particle system
  105592. */
  105593. ParticleSystem.prototype.addSizeGradient = function (gradient, factor, factor2) {
  105594. if (!this._sizeGradients) {
  105595. this._sizeGradients = [];
  105596. }
  105597. this._addFactorGradient(this._sizeGradients, gradient, factor, factor2);
  105598. return this;
  105599. };
  105600. /**
  105601. * Remove a specific size gradient
  105602. * @param gradient defines the gradient to remove
  105603. * @returns the current particle system
  105604. */
  105605. ParticleSystem.prototype.removeSizeGradient = function (gradient) {
  105606. this._removeFactorGradient(this._sizeGradients, gradient);
  105607. return this;
  105608. };
  105609. /**
  105610. * Adds a new color remap gradient
  105611. * @param gradient defines the gradient to use (between 0 and 1)
  105612. * @param min defines the color remap minimal range
  105613. * @param max defines the color remap maximal range
  105614. * @returns the current particle system
  105615. */
  105616. ParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  105617. if (!this._colorRemapGradients) {
  105618. this._colorRemapGradients = [];
  105619. }
  105620. this._addFactorGradient(this._colorRemapGradients, gradient, min, max);
  105621. return this;
  105622. };
  105623. /**
  105624. * Remove a specific color remap gradient
  105625. * @param gradient defines the gradient to remove
  105626. * @returns the current particle system
  105627. */
  105628. ParticleSystem.prototype.removeColorRemapGradient = function (gradient) {
  105629. this._removeFactorGradient(this._colorRemapGradients, gradient);
  105630. return this;
  105631. };
  105632. /**
  105633. * Adds a new alpha remap gradient
  105634. * @param gradient defines the gradient to use (between 0 and 1)
  105635. * @param min defines the alpha remap minimal range
  105636. * @param max defines the alpha remap maximal range
  105637. * @returns the current particle system
  105638. */
  105639. ParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  105640. if (!this._alphaRemapGradients) {
  105641. this._alphaRemapGradients = [];
  105642. }
  105643. this._addFactorGradient(this._alphaRemapGradients, gradient, min, max);
  105644. return this;
  105645. };
  105646. /**
  105647. * Remove a specific alpha remap gradient
  105648. * @param gradient defines the gradient to remove
  105649. * @returns the current particle system
  105650. */
  105651. ParticleSystem.prototype.removeAlphaRemapGradient = function (gradient) {
  105652. this._removeFactorGradient(this._alphaRemapGradients, gradient);
  105653. return this;
  105654. };
  105655. /**
  105656. * Adds a new angular speed gradient
  105657. * @param gradient defines the gradient to use (between 0 and 1)
  105658. * @param factor defines the angular speed to affect to the specified gradient
  105659. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105660. * @returns the current particle system
  105661. */
  105662. ParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor, factor2) {
  105663. if (!this._angularSpeedGradients) {
  105664. this._angularSpeedGradients = [];
  105665. }
  105666. this._addFactorGradient(this._angularSpeedGradients, gradient, factor, factor2);
  105667. return this;
  105668. };
  105669. /**
  105670. * Remove a specific angular speed gradient
  105671. * @param gradient defines the gradient to remove
  105672. * @returns the current particle system
  105673. */
  105674. ParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  105675. this._removeFactorGradient(this._angularSpeedGradients, gradient);
  105676. return this;
  105677. };
  105678. /**
  105679. * Adds a new velocity gradient
  105680. * @param gradient defines the gradient to use (between 0 and 1)
  105681. * @param factor defines the velocity to affect to the specified gradient
  105682. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105683. * @returns the current particle system
  105684. */
  105685. ParticleSystem.prototype.addVelocityGradient = function (gradient, factor, factor2) {
  105686. if (!this._velocityGradients) {
  105687. this._velocityGradients = [];
  105688. }
  105689. this._addFactorGradient(this._velocityGradients, gradient, factor, factor2);
  105690. return this;
  105691. };
  105692. /**
  105693. * Remove a specific velocity gradient
  105694. * @param gradient defines the gradient to remove
  105695. * @returns the current particle system
  105696. */
  105697. ParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  105698. this._removeFactorGradient(this._velocityGradients, gradient);
  105699. return this;
  105700. };
  105701. /**
  105702. * Adds a new limit velocity gradient
  105703. * @param gradient defines the gradient to use (between 0 and 1)
  105704. * @param factor defines the limit velocity value to affect to the specified gradient
  105705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105706. * @returns the current particle system
  105707. */
  105708. ParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor, factor2) {
  105709. if (!this._limitVelocityGradients) {
  105710. this._limitVelocityGradients = [];
  105711. }
  105712. this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
  105713. return this;
  105714. };
  105715. /**
  105716. * Remove a specific limit velocity gradient
  105717. * @param gradient defines the gradient to remove
  105718. * @returns the current particle system
  105719. */
  105720. ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  105721. this._removeFactorGradient(this._limitVelocityGradients, gradient);
  105722. return this;
  105723. };
  105724. /**
  105725. * Adds a new drag gradient
  105726. * @param gradient defines the gradient to use (between 0 and 1)
  105727. * @param factor defines the drag value to affect to the specified gradient
  105728. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105729. * @returns the current particle system
  105730. */
  105731. ParticleSystem.prototype.addDragGradient = function (gradient, factor, factor2) {
  105732. if (!this._dragGradients) {
  105733. this._dragGradients = [];
  105734. }
  105735. this._addFactorGradient(this._dragGradients, gradient, factor, factor2);
  105736. return this;
  105737. };
  105738. /**
  105739. * Remove a specific drag gradient
  105740. * @param gradient defines the gradient to remove
  105741. * @returns the current particle system
  105742. */
  105743. ParticleSystem.prototype.removeDragGradient = function (gradient) {
  105744. this._removeFactorGradient(this._dragGradients, gradient);
  105745. return this;
  105746. };
  105747. /**
  105748. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  105749. * @param gradient defines the gradient to use (between 0 and 1)
  105750. * @param factor defines the emit rate value to affect to the specified gradient
  105751. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105752. * @returns the current particle system
  105753. */
  105754. ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  105755. if (!this._emitRateGradients) {
  105756. this._emitRateGradients = [];
  105757. }
  105758. this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
  105759. return this;
  105760. };
  105761. /**
  105762. * Remove a specific emit rate gradient
  105763. * @param gradient defines the gradient to remove
  105764. * @returns the current particle system
  105765. */
  105766. ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  105767. this._removeFactorGradient(this._emitRateGradients, gradient);
  105768. return this;
  105769. };
  105770. /**
  105771. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  105772. * @param gradient defines the gradient to use (between 0 and 1)
  105773. * @param factor defines the start size value to affect to the specified gradient
  105774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105775. * @returns the current particle system
  105776. */
  105777. ParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  105778. if (!this._startSizeGradients) {
  105779. this._startSizeGradients = [];
  105780. }
  105781. this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
  105782. return this;
  105783. };
  105784. /**
  105785. * Remove a specific start size gradient
  105786. * @param gradient defines the gradient to remove
  105787. * @returns the current particle system
  105788. */
  105789. ParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  105790. this._removeFactorGradient(this._emitRateGradients, gradient);
  105791. return this;
  105792. };
  105793. ParticleSystem.prototype._createRampGradientTexture = function () {
  105794. if (!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture) {
  105795. return;
  105796. }
  105797. var data = new Uint8Array(this._rawTextureWidth * 4);
  105798. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color3[0];
  105799. for (var x = 0; x < this._rawTextureWidth; x++) {
  105800. var ratio = x / this._rawTextureWidth;
  105801. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._rampGradients, function (currentGradient, nextGradient, scale) {
  105802. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].LerpToRef(currentGradient.color, nextGradient.color, scale, tmpColor);
  105803. data[x * 4] = tmpColor.r * 255;
  105804. data[x * 4 + 1] = tmpColor.g * 255;
  105805. data[x * 4 + 2] = tmpColor.b * 255;
  105806. data[x * 4 + 3] = 255;
  105807. });
  105808. }
  105809. 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);
  105810. };
  105811. /**
  105812. * Gets the current list of ramp gradients.
  105813. * You must use addRampGradient and removeRampGradient to udpate this list
  105814. * @returns the list of ramp gradients
  105815. */
  105816. ParticleSystem.prototype.getRampGradients = function () {
  105817. return this._rampGradients;
  105818. };
  105819. /**
  105820. * Adds a new ramp gradient used to remap particle colors
  105821. * @param gradient defines the gradient to use (between 0 and 1)
  105822. * @param color defines the color to affect to the specified gradient
  105823. * @returns the current particle system
  105824. */
  105825. ParticleSystem.prototype.addRampGradient = function (gradient, color) {
  105826. if (!this._rampGradients) {
  105827. this._rampGradients = [];
  105828. }
  105829. var rampGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Color3Gradient"]();
  105830. rampGradient.gradient = gradient;
  105831. rampGradient.color = color;
  105832. this._rampGradients.push(rampGradient);
  105833. this._rampGradients.sort(function (a, b) {
  105834. if (a.gradient < b.gradient) {
  105835. return -1;
  105836. }
  105837. else if (a.gradient > b.gradient) {
  105838. return 1;
  105839. }
  105840. return 0;
  105841. });
  105842. if (this._rampGradientsTexture) {
  105843. this._rampGradientsTexture.dispose();
  105844. this._rampGradientsTexture = null;
  105845. }
  105846. this._createRampGradientTexture();
  105847. return this;
  105848. };
  105849. /**
  105850. * Remove a specific ramp gradient
  105851. * @param gradient defines the gradient to remove
  105852. * @returns the current particle system
  105853. */
  105854. ParticleSystem.prototype.removeRampGradient = function (gradient) {
  105855. this._removeGradientAndTexture(gradient, this._rampGradients, this._rampGradientsTexture);
  105856. this._rampGradientsTexture = null;
  105857. if (this._rampGradients && this._rampGradients.length > 0) {
  105858. this._createRampGradientTexture();
  105859. }
  105860. return this;
  105861. };
  105862. /**
  105863. * Adds a new color gradient
  105864. * @param gradient defines the gradient to use (between 0 and 1)
  105865. * @param color1 defines the color to affect to the specified gradient
  105866. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  105867. * @returns this particle system
  105868. */
  105869. ParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  105870. if (!this._colorGradients) {
  105871. this._colorGradients = [];
  105872. }
  105873. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  105874. colorGradient.gradient = gradient;
  105875. colorGradient.color1 = color1;
  105876. colorGradient.color2 = color2;
  105877. this._colorGradients.push(colorGradient);
  105878. this._colorGradients.sort(function (a, b) {
  105879. if (a.gradient < b.gradient) {
  105880. return -1;
  105881. }
  105882. else if (a.gradient > b.gradient) {
  105883. return 1;
  105884. }
  105885. return 0;
  105886. });
  105887. return this;
  105888. };
  105889. /**
  105890. * Remove a specific color gradient
  105891. * @param gradient defines the gradient to remove
  105892. * @returns this particle system
  105893. */
  105894. ParticleSystem.prototype.removeColorGradient = function (gradient) {
  105895. if (!this._colorGradients) {
  105896. return this;
  105897. }
  105898. var index = 0;
  105899. for (var _i = 0, _a = this._colorGradients; _i < _a.length; _i++) {
  105900. var colorGradient = _a[_i];
  105901. if (colorGradient.gradient === gradient) {
  105902. this._colorGradients.splice(index, 1);
  105903. break;
  105904. }
  105905. index++;
  105906. }
  105907. return this;
  105908. };
  105909. ParticleSystem.prototype._fetchR = function (u, v, width, height, pixels) {
  105910. u = Math.abs(u) * 0.5 + 0.5;
  105911. v = Math.abs(v) * 0.5 + 0.5;
  105912. var wrappedU = ((u * width) % width) | 0;
  105913. var wrappedV = ((v * height) % height) | 0;
  105914. var position = (wrappedU + wrappedV * width) * 4;
  105915. return pixels[position] / 255;
  105916. };
  105917. ParticleSystem.prototype._reset = function () {
  105918. this._resetEffect();
  105919. };
  105920. ParticleSystem.prototype._resetEffect = function () {
  105921. if (this._vertexBuffer) {
  105922. this._vertexBuffer.dispose();
  105923. this._vertexBuffer = null;
  105924. }
  105925. if (this._spriteBuffer) {
  105926. this._spriteBuffer.dispose();
  105927. this._spriteBuffer = null;
  105928. }
  105929. this._createVertexBuffers();
  105930. };
  105931. ParticleSystem.prototype._createVertexBuffers = function () {
  105932. this._vertexBufferSize = this._useInstancing ? 10 : 12;
  105933. if (this._isAnimationSheetEnabled) {
  105934. this._vertexBufferSize += 1;
  105935. }
  105936. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  105937. this._vertexBufferSize += 3;
  105938. }
  105939. if (this._useRampGradients) {
  105940. this._vertexBufferSize += 4;
  105941. }
  105942. var engine = this._scene.getEngine();
  105943. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
  105944. this._vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, this._vertexData, true, this._vertexBufferSize);
  105945. var dataOffset = 0;
  105946. var positions = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  105947. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind] = positions;
  105948. dataOffset += 3;
  105949. var colors = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  105950. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind] = colors;
  105951. dataOffset += 4;
  105952. var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  105953. this._vertexBuffers["angle"] = options;
  105954. dataOffset += 1;
  105955. var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  105956. this._vertexBuffers["size"] = size;
  105957. dataOffset += 2;
  105958. if (this._isAnimationSheetEnabled) {
  105959. var cellIndexBuffer = this._vertexBuffer.createVertexBuffer("cellIndex", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  105960. this._vertexBuffers["cellIndex"] = cellIndexBuffer;
  105961. dataOffset += 1;
  105962. }
  105963. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  105964. var directionBuffer = this._vertexBuffer.createVertexBuffer("direction", dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  105965. this._vertexBuffers["direction"] = directionBuffer;
  105966. dataOffset += 3;
  105967. }
  105968. if (this._useRampGradients) {
  105969. var rampDataBuffer = this._vertexBuffer.createVertexBuffer("remapData", dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  105970. this._vertexBuffers["remapData"] = rampDataBuffer;
  105971. dataOffset += 4;
  105972. }
  105973. var offsets;
  105974. if (this._useInstancing) {
  105975. var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
  105976. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 2);
  105977. offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
  105978. }
  105979. else {
  105980. offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  105981. dataOffset += 2;
  105982. }
  105983. this._vertexBuffers["offset"] = offsets;
  105984. };
  105985. ParticleSystem.prototype._createIndexBuffer = function () {
  105986. if (this._useInstancing) {
  105987. return;
  105988. }
  105989. var indices = [];
  105990. var index = 0;
  105991. for (var count = 0; count < this._capacity; count++) {
  105992. indices.push(index);
  105993. indices.push(index + 1);
  105994. indices.push(index + 2);
  105995. indices.push(index);
  105996. indices.push(index + 2);
  105997. indices.push(index + 3);
  105998. index += 4;
  105999. }
  106000. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  106001. };
  106002. /**
  106003. * Gets the maximum number of particles active at the same time.
  106004. * @returns The max number of active particles.
  106005. */
  106006. ParticleSystem.prototype.getCapacity = function () {
  106007. return this._capacity;
  106008. };
  106009. /**
  106010. * Gets whether there are still active particles in the system.
  106011. * @returns True if it is alive, otherwise false.
  106012. */
  106013. ParticleSystem.prototype.isAlive = function () {
  106014. return this._alive;
  106015. };
  106016. /**
  106017. * Gets if the system has been started. (Note: this will still be true after stop is called)
  106018. * @returns True if it has been started, otherwise false.
  106019. */
  106020. ParticleSystem.prototype.isStarted = function () {
  106021. return this._started;
  106022. };
  106023. ParticleSystem.prototype._prepareSubEmitterInternalArray = function () {
  106024. var _this = this;
  106025. this._subEmitters = new Array();
  106026. if (this.subEmitters) {
  106027. this.subEmitters.forEach(function (subEmitter) {
  106028. if (subEmitter instanceof ParticleSystem) {
  106029. _this._subEmitters.push([new _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"](subEmitter)]);
  106030. }
  106031. else if (subEmitter instanceof _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]) {
  106032. _this._subEmitters.push([subEmitter]);
  106033. }
  106034. else if (subEmitter instanceof Array) {
  106035. _this._subEmitters.push(subEmitter);
  106036. }
  106037. });
  106038. }
  106039. };
  106040. /**
  106041. * Starts the particle system and begins to emit
  106042. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  106043. */
  106044. ParticleSystem.prototype.start = function (delay) {
  106045. var _this = this;
  106046. if (delay === void 0) { delay = this.startDelay; }
  106047. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  106048. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  106049. }
  106050. if (delay) {
  106051. setTimeout(function () {
  106052. _this.start(0);
  106053. }, delay);
  106054. return;
  106055. }
  106056. // Convert the subEmitters field to the constant type field _subEmitters
  106057. this._prepareSubEmitterInternalArray();
  106058. this._started = true;
  106059. this._stopped = false;
  106060. this._actualFrame = 0;
  106061. if (this._subEmitters && this._subEmitters.length != 0) {
  106062. this.activeSubSystems = new Array();
  106063. }
  106064. // Reset emit gradient so it acts the same on every start
  106065. if (this._emitRateGradients) {
  106066. if (this._emitRateGradients.length > 0) {
  106067. this._currentEmitRateGradient = this._emitRateGradients[0];
  106068. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
  106069. this._currentEmitRate2 = this._currentEmitRate1;
  106070. }
  106071. if (this._emitRateGradients.length > 1) {
  106072. this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
  106073. }
  106074. }
  106075. // Reset start size gradient so it acts the same on every start
  106076. if (this._startSizeGradients) {
  106077. if (this._startSizeGradients.length > 0) {
  106078. this._currentStartSizeGradient = this._startSizeGradients[0];
  106079. this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
  106080. this._currentStartSize2 = this._currentStartSize1;
  106081. }
  106082. if (this._startSizeGradients.length > 1) {
  106083. this._currentStartSize2 = this._startSizeGradients[1].getFactor();
  106084. }
  106085. }
  106086. if (this.preWarmCycles) {
  106087. if (this.emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__["AbstractMesh"]) {
  106088. this.emitter.computeWorldMatrix(true);
  106089. }
  106090. var noiseTextureAsProcedural_1 = this.noiseTexture;
  106091. if (noiseTextureAsProcedural_1 && noiseTextureAsProcedural_1.onGeneratedObservable) {
  106092. noiseTextureAsProcedural_1.onGeneratedObservable.addOnce(function () {
  106093. setTimeout(function () {
  106094. for (var index = 0; index < _this.preWarmCycles; index++) {
  106095. _this.animate(true);
  106096. noiseTextureAsProcedural_1.render();
  106097. }
  106098. });
  106099. });
  106100. }
  106101. else {
  106102. for (var index = 0; index < this.preWarmCycles; index++) {
  106103. this.animate(true);
  106104. }
  106105. }
  106106. }
  106107. // Animations
  106108. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  106109. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  106110. }
  106111. };
  106112. /**
  106113. * Stops the particle system.
  106114. * @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.
  106115. */
  106116. ParticleSystem.prototype.stop = function (stopSubEmitters) {
  106117. if (stopSubEmitters === void 0) { stopSubEmitters = true; }
  106118. this._stopped = true;
  106119. if (stopSubEmitters) {
  106120. this._stopSubEmitters();
  106121. }
  106122. };
  106123. // animation sheet
  106124. /**
  106125. * Remove all active particles
  106126. */
  106127. ParticleSystem.prototype.reset = function () {
  106128. this._stockParticles = [];
  106129. this._particles = [];
  106130. };
  106131. /**
  106132. * @hidden (for internal use only)
  106133. */
  106134. ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
  106135. var offset = index * this._vertexBufferSize;
  106136. this._vertexData[offset++] = particle.position.x;
  106137. this._vertexData[offset++] = particle.position.y;
  106138. this._vertexData[offset++] = particle.position.z;
  106139. this._vertexData[offset++] = particle.color.r;
  106140. this._vertexData[offset++] = particle.color.g;
  106141. this._vertexData[offset++] = particle.color.b;
  106142. this._vertexData[offset++] = particle.color.a;
  106143. this._vertexData[offset++] = particle.angle;
  106144. this._vertexData[offset++] = particle.scale.x * particle.size;
  106145. this._vertexData[offset++] = particle.scale.y * particle.size;
  106146. if (this._isAnimationSheetEnabled) {
  106147. this._vertexData[offset++] = particle.cellIndex;
  106148. }
  106149. if (!this._isBillboardBased) {
  106150. if (particle._initialDirection) {
  106151. this._vertexData[offset++] = particle._initialDirection.x;
  106152. this._vertexData[offset++] = particle._initialDirection.y;
  106153. this._vertexData[offset++] = particle._initialDirection.z;
  106154. }
  106155. else {
  106156. this._vertexData[offset++] = particle.direction.x;
  106157. this._vertexData[offset++] = particle.direction.y;
  106158. this._vertexData[offset++] = particle.direction.z;
  106159. }
  106160. }
  106161. else if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  106162. this._vertexData[offset++] = particle.direction.x;
  106163. this._vertexData[offset++] = particle.direction.y;
  106164. this._vertexData[offset++] = particle.direction.z;
  106165. }
  106166. if (this._useRampGradients) {
  106167. this._vertexData[offset++] = particle.remapData.x;
  106168. this._vertexData[offset++] = particle.remapData.y;
  106169. this._vertexData[offset++] = particle.remapData.z;
  106170. this._vertexData[offset++] = particle.remapData.w;
  106171. }
  106172. if (!this._useInstancing) {
  106173. if (this._isAnimationSheetEnabled) {
  106174. if (offsetX === 0) {
  106175. offsetX = this._epsilon;
  106176. }
  106177. else if (offsetX === 1) {
  106178. offsetX = 1 - this._epsilon;
  106179. }
  106180. if (offsetY === 0) {
  106181. offsetY = this._epsilon;
  106182. }
  106183. else if (offsetY === 1) {
  106184. offsetY = 1 - this._epsilon;
  106185. }
  106186. }
  106187. this._vertexData[offset++] = offsetX;
  106188. this._vertexData[offset++] = offsetY;
  106189. }
  106190. };
  106191. ParticleSystem.prototype._stopSubEmitters = function () {
  106192. if (!this.activeSubSystems) {
  106193. return;
  106194. }
  106195. this.activeSubSystems.forEach(function (subSystem) {
  106196. subSystem.stop(true);
  106197. });
  106198. this.activeSubSystems = new Array();
  106199. };
  106200. ParticleSystem.prototype._removeFromRoot = function () {
  106201. if (!this._rootParticleSystem) {
  106202. return;
  106203. }
  106204. var index = this._rootParticleSystem.activeSubSystems.indexOf(this);
  106205. if (index !== -1) {
  106206. this._rootParticleSystem.activeSubSystems.splice(index, 1);
  106207. }
  106208. this._rootParticleSystem = null;
  106209. };
  106210. // End of sub system methods
  106211. ParticleSystem.prototype._update = function (newParticles) {
  106212. var _this = this;
  106213. // Update current
  106214. this._alive = this._particles.length > 0;
  106215. if (this.emitter.position) {
  106216. var emitterMesh = this.emitter;
  106217. this._emitterWorldMatrix = emitterMesh.getWorldMatrix();
  106218. }
  106219. else {
  106220. var emitterPosition = this.emitter;
  106221. this._emitterWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  106222. }
  106223. this.updateFunction(this._particles);
  106224. // Add new ones
  106225. var particle;
  106226. var _loop_2 = function () {
  106227. if (this_1._particles.length === this_1._capacity) {
  106228. return "break";
  106229. }
  106230. particle = this_1._createParticle();
  106231. this_1._particles.push(particle);
  106232. // Emitter
  106233. var emitPower = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minEmitPower, this_1.maxEmitPower);
  106234. if (this_1.startPositionFunction) {
  106235. this_1.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  106236. }
  106237. else {
  106238. this_1.particleEmitterType.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  106239. }
  106240. if (this_1.startDirectionFunction) {
  106241. this_1.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  106242. }
  106243. else {
  106244. this_1.particleEmitterType.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  106245. }
  106246. if (emitPower === 0) {
  106247. if (!particle._initialDirection) {
  106248. particle._initialDirection = particle.direction.clone();
  106249. }
  106250. else {
  106251. particle._initialDirection.copyFrom(particle.direction);
  106252. }
  106253. }
  106254. else {
  106255. particle._initialDirection = null;
  106256. }
  106257. particle.direction.scaleInPlace(emitPower);
  106258. // Life time
  106259. if (this_1.targetStopDuration && this_1._lifeTimeGradients && this_1._lifeTimeGradients.length > 0) {
  106260. var ratio_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(this_1._actualFrame / this_1.targetStopDuration);
  106261. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio_1, this_1._lifeTimeGradients, function (currentGradient, nextGradient) {
  106262. var factorGradient1 = currentGradient;
  106263. var factorGradient2 = nextGradient;
  106264. var lifeTime1 = factorGradient1.getFactor();
  106265. var lifeTime2 = factorGradient2.getFactor();
  106266. var gradient = (ratio_1 - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
  106267. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(lifeTime1, lifeTime2, gradient);
  106268. });
  106269. }
  106270. else {
  106271. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minLifeTime, this_1.maxLifeTime);
  106272. }
  106273. // Size
  106274. if (!this_1._sizeGradients || this_1._sizeGradients.length === 0) {
  106275. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minSize, this_1.maxSize);
  106276. }
  106277. else {
  106278. particle._currentSizeGradient = this_1._sizeGradients[0];
  106279. particle._currentSize1 = particle._currentSizeGradient.getFactor();
  106280. particle.size = particle._currentSize1;
  106281. if (this_1._sizeGradients.length > 1) {
  106282. particle._currentSize2 = this_1._sizeGradients[1].getFactor();
  106283. }
  106284. else {
  106285. particle._currentSize2 = particle._currentSize1;
  106286. }
  106287. }
  106288. // Size and scale
  106289. 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));
  106290. // Adjust scale by start size
  106291. if (this_1._startSizeGradients && this_1._startSizeGradients[0] && this_1.targetStopDuration) {
  106292. var ratio = this_1._actualFrame / this_1.targetStopDuration;
  106293. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this_1._startSizeGradients, function (currentGradient, nextGradient, scale) {
  106294. if (currentGradient !== _this._currentStartSizeGradient) {
  106295. _this._currentStartSize1 = _this._currentStartSize2;
  106296. _this._currentStartSize2 = nextGradient.getFactor();
  106297. _this._currentStartSizeGradient = currentGradient;
  106298. }
  106299. var value = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentStartSize1, _this._currentStartSize2, scale);
  106300. particle.scale.scaleInPlace(value);
  106301. });
  106302. }
  106303. // Angle
  106304. if (!this_1._angularSpeedGradients || this_1._angularSpeedGradients.length === 0) {
  106305. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minAngularSpeed, this_1.maxAngularSpeed);
  106306. }
  106307. else {
  106308. particle._currentAngularSpeedGradient = this_1._angularSpeedGradients[0];
  106309. particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
  106310. particle._currentAngularSpeed1 = particle.angularSpeed;
  106311. if (this_1._angularSpeedGradients.length > 1) {
  106312. particle._currentAngularSpeed2 = this_1._angularSpeedGradients[1].getFactor();
  106313. }
  106314. else {
  106315. particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
  106316. }
  106317. }
  106318. particle.angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minInitialRotation, this_1.maxInitialRotation);
  106319. // Velocity
  106320. if (this_1._velocityGradients && this_1._velocityGradients.length > 0) {
  106321. particle._currentVelocityGradient = this_1._velocityGradients[0];
  106322. particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
  106323. if (this_1._velocityGradients.length > 1) {
  106324. particle._currentVelocity2 = this_1._velocityGradients[1].getFactor();
  106325. }
  106326. else {
  106327. particle._currentVelocity2 = particle._currentVelocity1;
  106328. }
  106329. }
  106330. // Limit velocity
  106331. if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
  106332. particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
  106333. particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
  106334. if (this_1._limitVelocityGradients.length > 1) {
  106335. particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
  106336. }
  106337. else {
  106338. particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
  106339. }
  106340. }
  106341. // Drag
  106342. if (this_1._dragGradients && this_1._dragGradients.length > 0) {
  106343. particle._currentDragGradient = this_1._dragGradients[0];
  106344. particle._currentDrag1 = particle._currentDragGradient.getFactor();
  106345. if (this_1._dragGradients.length > 1) {
  106346. particle._currentDrag2 = this_1._dragGradients[1].getFactor();
  106347. }
  106348. else {
  106349. particle._currentDrag2 = particle._currentDrag1;
  106350. }
  106351. }
  106352. // Color
  106353. if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
  106354. step = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(0, 1.0);
  106355. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(this_1.color1, this_1.color2, step, particle.color);
  106356. this_1.colorDead.subtractToRef(particle.color, this_1._colorDiff);
  106357. this_1._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
  106358. }
  106359. else {
  106360. particle._currentColorGradient = this_1._colorGradients[0];
  106361. particle._currentColorGradient.getColorToRef(particle.color);
  106362. particle._currentColor1.copyFrom(particle.color);
  106363. if (this_1._colorGradients.length > 1) {
  106364. this_1._colorGradients[1].getColorToRef(particle._currentColor2);
  106365. }
  106366. else {
  106367. particle._currentColor2.copyFrom(particle.color);
  106368. }
  106369. }
  106370. // Sheet
  106371. if (this_1._isAnimationSheetEnabled) {
  106372. particle._initialStartSpriteCellID = this_1.startSpriteCellID;
  106373. particle._initialEndSpriteCellID = this_1.endSpriteCellID;
  106374. }
  106375. // Inherited Velocity
  106376. particle.direction.addInPlace(this_1._inheritedVelocityOffset);
  106377. // Ramp
  106378. if (this_1._useRampGradients) {
  106379. particle.remapData = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](0, 1, 0, 1);
  106380. }
  106381. // Noise texture coordinates
  106382. if (this_1.noiseTexture) {
  106383. if (particle._randomNoiseCoordinates1) {
  106384. particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
  106385. particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
  106386. }
  106387. else {
  106388. particle._randomNoiseCoordinates1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  106389. particle._randomNoiseCoordinates2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  106390. }
  106391. }
  106392. // Update the position of the attached sub-emitters to match their attached particle
  106393. particle._inheritParticleInfoToSubEmitters();
  106394. };
  106395. var this_1 = this, step;
  106396. for (var index = 0; index < newParticles; index++) {
  106397. var state_1 = _loop_2();
  106398. if (state_1 === "break")
  106399. break;
  106400. }
  106401. };
  106402. /** @hidden */
  106403. ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased, useRampGradients) {
  106404. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  106405. if (isBillboardBased === void 0) { isBillboardBased = false; }
  106406. if (useRampGradients === void 0) { useRampGradients = false; }
  106407. var attributeNamesOrOptions = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, "angle", "offset", "size"];
  106408. if (isAnimationSheetEnabled) {
  106409. attributeNamesOrOptions.push("cellIndex");
  106410. }
  106411. if (!isBillboardBased) {
  106412. attributeNamesOrOptions.push("direction");
  106413. }
  106414. if (useRampGradients) {
  106415. attributeNamesOrOptions.push("remapData");
  106416. }
  106417. return attributeNamesOrOptions;
  106418. };
  106419. /** @hidden */
  106420. ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
  106421. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  106422. var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
  106423. if (isAnimationSheetEnabled) {
  106424. effectCreationOption.push("particlesInfos");
  106425. }
  106426. return effectCreationOption;
  106427. };
  106428. /** @hidden */
  106429. ParticleSystem.prototype._getEffect = function (blendMode) {
  106430. if (this._customEffect) {
  106431. return this._customEffect;
  106432. }
  106433. var defines = [];
  106434. if (this._scene.clipPlane) {
  106435. defines.push("#define CLIPPLANE");
  106436. }
  106437. if (this._scene.clipPlane2) {
  106438. defines.push("#define CLIPPLANE2");
  106439. }
  106440. if (this._scene.clipPlane3) {
  106441. defines.push("#define CLIPPLANE3");
  106442. }
  106443. if (this._scene.clipPlane4) {
  106444. defines.push("#define CLIPPLANE4");
  106445. }
  106446. if (this._isAnimationSheetEnabled) {
  106447. defines.push("#define ANIMATESHEET");
  106448. }
  106449. if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
  106450. defines.push("#define BLENDMULTIPLYMODE");
  106451. }
  106452. if (this._useRampGradients) {
  106453. defines.push("#define RAMPGRADIENT");
  106454. }
  106455. if (this._isBillboardBased) {
  106456. defines.push("#define BILLBOARD");
  106457. switch (this.billboardMode) {
  106458. case ParticleSystem.BILLBOARDMODE_Y:
  106459. defines.push("#define BILLBOARDY");
  106460. break;
  106461. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  106462. defines.push("#define BILLBOARDSTRETCHED");
  106463. break;
  106464. case ParticleSystem.BILLBOARDMODE_ALL:
  106465. default:
  106466. break;
  106467. }
  106468. }
  106469. if (this._imageProcessingConfiguration) {
  106470. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  106471. defines.push(this._imageProcessingConfigurationDefines.toString());
  106472. }
  106473. // Effect
  106474. var join = defines.join("\n");
  106475. if (this._cachedDefines !== join) {
  106476. this._cachedDefines = join;
  106477. var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED, this._useRampGradients);
  106478. var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
  106479. var samplers = ["diffuseSampler", "rampSampler"];
  106480. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"]) {
  106481. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareUniforms(effectCreationOption, this._imageProcessingConfigurationDefines);
  106482. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  106483. }
  106484. this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, samplers, join);
  106485. }
  106486. return this._effect;
  106487. };
  106488. /**
  106489. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  106490. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  106491. */
  106492. ParticleSystem.prototype.animate = function (preWarmOnly) {
  106493. var _this = this;
  106494. if (preWarmOnly === void 0) { preWarmOnly = false; }
  106495. if (!this._started) {
  106496. return;
  106497. }
  106498. if (!preWarmOnly) {
  106499. // Check
  106500. if (!this.isReady()) {
  106501. return;
  106502. }
  106503. if (this._currentRenderId === this._scene.getFrameId()) {
  106504. return;
  106505. }
  106506. this._currentRenderId = this._scene.getFrameId();
  106507. }
  106508. this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  106509. // Determine the number of particles we need to create
  106510. var newParticles;
  106511. if (this.manualEmitCount > -1) {
  106512. newParticles = this.manualEmitCount;
  106513. this._newPartsExcess = 0;
  106514. this.manualEmitCount = 0;
  106515. }
  106516. else {
  106517. var rate_1 = this.emitRate;
  106518. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  106519. var ratio = this._actualFrame / this.targetStopDuration;
  106520. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
  106521. if (currentGradient !== _this._currentEmitRateGradient) {
  106522. _this._currentEmitRate1 = _this._currentEmitRate2;
  106523. _this._currentEmitRate2 = nextGradient.getFactor();
  106524. _this._currentEmitRateGradient = currentGradient;
  106525. }
  106526. rate_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
  106527. });
  106528. }
  106529. newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
  106530. this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
  106531. }
  106532. if (this._newPartsExcess > 1.0) {
  106533. newParticles += this._newPartsExcess >> 0;
  106534. this._newPartsExcess -= this._newPartsExcess >> 0;
  106535. }
  106536. this._alive = false;
  106537. if (!this._stopped) {
  106538. this._actualFrame += this._scaledUpdateSpeed;
  106539. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  106540. this.stop();
  106541. }
  106542. }
  106543. else {
  106544. newParticles = 0;
  106545. }
  106546. this._update(newParticles);
  106547. // Stopped?
  106548. if (this._stopped) {
  106549. if (!this._alive) {
  106550. this._started = false;
  106551. if (this.onAnimationEnd) {
  106552. this.onAnimationEnd();
  106553. }
  106554. if (this.disposeOnStop) {
  106555. this._scene._toBeDisposed.push(this);
  106556. }
  106557. }
  106558. }
  106559. if (!preWarmOnly) {
  106560. // Update VBO
  106561. var offset = 0;
  106562. for (var index = 0; index < this._particles.length; index++) {
  106563. var particle = this._particles[index];
  106564. this._appendParticleVertices(offset, particle);
  106565. offset += this._useInstancing ? 1 : 4;
  106566. }
  106567. if (this._vertexBuffer) {
  106568. this._vertexBuffer.update(this._vertexData);
  106569. }
  106570. }
  106571. if (this.manualEmitCount === 0 && this.disposeOnStop) {
  106572. this.stop();
  106573. }
  106574. };
  106575. ParticleSystem.prototype._appendParticleVertices = function (offset, particle) {
  106576. this._appendParticleVertex(offset++, particle, 0, 0);
  106577. if (!this._useInstancing) {
  106578. this._appendParticleVertex(offset++, particle, 1, 0);
  106579. this._appendParticleVertex(offset++, particle, 1, 1);
  106580. this._appendParticleVertex(offset++, particle, 0, 1);
  106581. }
  106582. };
  106583. /**
  106584. * Rebuilds the particle system.
  106585. */
  106586. ParticleSystem.prototype.rebuild = function () {
  106587. this._createIndexBuffer();
  106588. if (this._vertexBuffer) {
  106589. this._vertexBuffer._rebuild();
  106590. }
  106591. };
  106592. /**
  106593. * Is this system ready to be used/rendered
  106594. * @return true if the system is ready
  106595. */
  106596. ParticleSystem.prototype.isReady = function () {
  106597. if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  106598. return false;
  106599. }
  106600. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  106601. if (!this._getEffect(this.blendMode).isReady()) {
  106602. return false;
  106603. }
  106604. }
  106605. else {
  106606. if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
  106607. return false;
  106608. }
  106609. if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
  106610. return false;
  106611. }
  106612. }
  106613. return true;
  106614. };
  106615. ParticleSystem.prototype._render = function (blendMode) {
  106616. var effect = this._getEffect(blendMode);
  106617. var engine = this._scene.getEngine();
  106618. // Render
  106619. engine.enableEffect(effect);
  106620. var viewMatrix = this._scene.getViewMatrix();
  106621. effect.setTexture("diffuseSampler", this.particleTexture);
  106622. effect.setMatrix("view", viewMatrix);
  106623. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  106624. if (this._isAnimationSheetEnabled && this.particleTexture) {
  106625. var baseSize = this.particleTexture.getBaseSize();
  106626. effect.setFloat3("particlesInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  106627. }
  106628. effect.setVector2("translationPivot", this.translationPivot);
  106629. effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
  106630. if (this._isBillboardBased) {
  106631. var camera = this._scene.activeCamera;
  106632. effect.setVector3("eyePosition", camera.globalPosition);
  106633. }
  106634. if (this._rampGradientsTexture) {
  106635. effect.setTexture("rampSampler", this._rampGradientsTexture);
  106636. }
  106637. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  106638. var invView = viewMatrix.clone();
  106639. invView.invert();
  106640. effect.setMatrix("invView", invView);
  106641. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].BindClipPlane(effect, this._scene);
  106642. }
  106643. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  106644. // image processing
  106645. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  106646. this._imageProcessingConfiguration.bind(effect);
  106647. }
  106648. // Draw order
  106649. switch (blendMode) {
  106650. case ParticleSystem.BLENDMODE_ADD:
  106651. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ADD);
  106652. break;
  106653. case ParticleSystem.BLENDMODE_ONEONE:
  106654. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ONEONE);
  106655. break;
  106656. case ParticleSystem.BLENDMODE_STANDARD:
  106657. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_COMBINE);
  106658. break;
  106659. case ParticleSystem.BLENDMODE_MULTIPLY:
  106660. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_MULTIPLY);
  106661. break;
  106662. }
  106663. if (this._useInstancing) {
  106664. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFanDrawMode, 0, 4, this._particles.length);
  106665. }
  106666. else {
  106667. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, this._particles.length * 6);
  106668. }
  106669. return this._particles.length;
  106670. };
  106671. /**
  106672. * Renders the particle system in its current state.
  106673. * @returns the current number of particles
  106674. */
  106675. ParticleSystem.prototype.render = function () {
  106676. // Check
  106677. if (!this.isReady() || !this._particles.length) {
  106678. return 0;
  106679. }
  106680. var engine = this._scene.getEngine();
  106681. engine.setState(false);
  106682. if (this.forceDepthWrite) {
  106683. engine.setDepthWrite(true);
  106684. }
  106685. var outparticles = 0;
  106686. if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
  106687. outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
  106688. }
  106689. outparticles = this._render(this.blendMode);
  106690. engine.unbindInstanceAttributes();
  106691. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_DISABLE);
  106692. return outparticles;
  106693. };
  106694. /**
  106695. * Disposes the particle system and free the associated resources
  106696. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  106697. */
  106698. ParticleSystem.prototype.dispose = function (disposeTexture) {
  106699. if (disposeTexture === void 0) { disposeTexture = true; }
  106700. if (this._vertexBuffer) {
  106701. this._vertexBuffer.dispose();
  106702. this._vertexBuffer = null;
  106703. }
  106704. if (this._spriteBuffer) {
  106705. this._spriteBuffer.dispose();
  106706. this._spriteBuffer = null;
  106707. }
  106708. if (this._indexBuffer) {
  106709. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  106710. this._indexBuffer = null;
  106711. }
  106712. if (disposeTexture && this.particleTexture) {
  106713. this.particleTexture.dispose();
  106714. this.particleTexture = null;
  106715. }
  106716. if (disposeTexture && this.noiseTexture) {
  106717. this.noiseTexture.dispose();
  106718. this.noiseTexture = null;
  106719. }
  106720. if (this._rampGradientsTexture) {
  106721. this._rampGradientsTexture.dispose();
  106722. this._rampGradientsTexture = null;
  106723. }
  106724. this._removeFromRoot();
  106725. if (this._subEmitters && this._subEmitters.length) {
  106726. for (var index = 0; index < this._subEmitters.length; index++) {
  106727. for (var _i = 0, _a = this._subEmitters[index]; _i < _a.length; _i++) {
  106728. var subEmitter = _a[_i];
  106729. subEmitter.dispose();
  106730. }
  106731. }
  106732. this._subEmitters = [];
  106733. this.subEmitters = [];
  106734. }
  106735. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
  106736. this.emitter.dispose(true);
  106737. }
  106738. // Remove from scene
  106739. var index = this._scene.particleSystems.indexOf(this);
  106740. if (index > -1) {
  106741. this._scene.particleSystems.splice(index, 1);
  106742. }
  106743. this._scene._activeParticleSystems.dispose();
  106744. // Callback
  106745. this.onDisposeObservable.notifyObservers(this);
  106746. this.onDisposeObservable.clear();
  106747. this.reset();
  106748. };
  106749. // Clone
  106750. /**
  106751. * Clones the particle system.
  106752. * @param name The name of the cloned object
  106753. * @param newEmitter The new emitter to use
  106754. * @returns the cloned particle system
  106755. */
  106756. ParticleSystem.prototype.clone = function (name, newEmitter) {
  106757. var custom = null;
  106758. var program = null;
  106759. if (this.customShader != null) {
  106760. program = this.customShader;
  106761. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  106762. custom = this._scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  106763. }
  106764. else if (this._customEffect) {
  106765. custom = this._customEffect;
  106766. }
  106767. var result = new ParticleSystem(name, this._capacity, this._scene, custom);
  106768. result.customShader = program;
  106769. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture"]);
  106770. if (newEmitter === undefined) {
  106771. newEmitter = this.emitter;
  106772. }
  106773. result.noiseTexture = this.noiseTexture;
  106774. result.emitter = newEmitter;
  106775. if (this.particleTexture) {
  106776. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](this.particleTexture.url, this._scene);
  106777. }
  106778. // Clone gradients
  106779. if (this._colorGradients) {
  106780. this._colorGradients.forEach(function (v) {
  106781. result.addColorGradient(v.gradient, v.color1, v.color2);
  106782. });
  106783. }
  106784. if (this._dragGradients) {
  106785. this._dragGradients.forEach(function (v) {
  106786. result.addDragGradient(v.gradient, v.factor1, v.factor2);
  106787. });
  106788. }
  106789. if (this._angularSpeedGradients) {
  106790. this._angularSpeedGradients.forEach(function (v) {
  106791. result.addAngularSpeedGradient(v.gradient, v.factor1, v.factor2);
  106792. });
  106793. }
  106794. if (this._emitRateGradients) {
  106795. this._emitRateGradients.forEach(function (v) {
  106796. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  106797. });
  106798. }
  106799. if (this._lifeTimeGradients) {
  106800. this._lifeTimeGradients.forEach(function (v) {
  106801. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  106802. });
  106803. }
  106804. if (this._limitVelocityGradients) {
  106805. this._limitVelocityGradients.forEach(function (v) {
  106806. result.addLimitVelocityGradient(v.gradient, v.factor1, v.factor2);
  106807. });
  106808. }
  106809. if (this._sizeGradients) {
  106810. this._sizeGradients.forEach(function (v) {
  106811. result.addSizeGradient(v.gradient, v.factor1, v.factor2);
  106812. });
  106813. }
  106814. if (this._startSizeGradients) {
  106815. this._startSizeGradients.forEach(function (v) {
  106816. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  106817. });
  106818. }
  106819. if (this._velocityGradients) {
  106820. this._velocityGradients.forEach(function (v) {
  106821. result.addVelocityGradient(v.gradient, v.factor1, v.factor2);
  106822. });
  106823. }
  106824. if (this._rampGradients) {
  106825. this._rampGradients.forEach(function (v) {
  106826. result.addRampGradient(v.gradient, v.color);
  106827. });
  106828. }
  106829. if (this._colorRemapGradients) {
  106830. this._colorRemapGradients.forEach(function (v) {
  106831. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  106832. });
  106833. }
  106834. if (this._alphaRemapGradients) {
  106835. this._alphaRemapGradients.forEach(function (v) {
  106836. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  106837. });
  106838. }
  106839. if (!this.preventAutoStart) {
  106840. result.start();
  106841. }
  106842. return result;
  106843. };
  106844. /**
  106845. * Serializes the particle system to a JSON object.
  106846. * @returns the JSON object
  106847. */
  106848. ParticleSystem.prototype.serialize = function () {
  106849. var serializationObject = {};
  106850. ParticleSystem._Serialize(serializationObject, this);
  106851. serializationObject.textureMask = this.textureMask.asArray();
  106852. serializationObject.customShader = this.customShader;
  106853. serializationObject.preventAutoStart = this.preventAutoStart;
  106854. // SubEmitters
  106855. if (this.subEmitters) {
  106856. serializationObject.subEmitters = [];
  106857. if (!this._subEmitters) {
  106858. this._prepareSubEmitterInternalArray();
  106859. }
  106860. for (var _i = 0, _a = this._subEmitters; _i < _a.length; _i++) {
  106861. var subs = _a[_i];
  106862. var cell = [];
  106863. for (var _b = 0, subs_1 = subs; _b < subs_1.length; _b++) {
  106864. var sub = subs_1[_b];
  106865. cell.push(sub.serialize());
  106866. }
  106867. serializationObject.subEmitters.push(cell);
  106868. }
  106869. }
  106870. return serializationObject;
  106871. };
  106872. /** @hidden */
  106873. ParticleSystem._Serialize = function (serializationObject, particleSystem) {
  106874. serializationObject.name = particleSystem.name;
  106875. serializationObject.id = particleSystem.id;
  106876. serializationObject.capacity = particleSystem.getCapacity();
  106877. // Emitter
  106878. if (particleSystem.emitter.position) {
  106879. var emitterMesh = particleSystem.emitter;
  106880. serializationObject.emitterId = emitterMesh.id;
  106881. }
  106882. else {
  106883. var emitterPosition = particleSystem.emitter;
  106884. serializationObject.emitter = emitterPosition.asArray();
  106885. }
  106886. // Emitter
  106887. if (particleSystem.particleEmitterType) {
  106888. serializationObject.particleEmitterType = particleSystem.particleEmitterType.serialize();
  106889. }
  106890. if (particleSystem.particleTexture) {
  106891. serializationObject.textureName = particleSystem.particleTexture.name;
  106892. serializationObject.invertY = particleSystem.particleTexture._invertY;
  106893. }
  106894. // Animations
  106895. _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__["SerializationHelper"].AppendSerializedAnimations(particleSystem, serializationObject);
  106896. serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
  106897. serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
  106898. serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
  106899. serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
  106900. // Particle system
  106901. serializationObject.startDelay = particleSystem.startDelay;
  106902. serializationObject.renderingGroupId = particleSystem.renderingGroupId;
  106903. serializationObject.isBillboardBased = particleSystem.isBillboardBased;
  106904. serializationObject.billboardMode = particleSystem.billboardMode;
  106905. serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
  106906. serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
  106907. serializationObject.minSize = particleSystem.minSize;
  106908. serializationObject.maxSize = particleSystem.maxSize;
  106909. serializationObject.minScaleX = particleSystem.minScaleX;
  106910. serializationObject.maxScaleX = particleSystem.maxScaleX;
  106911. serializationObject.minScaleY = particleSystem.minScaleY;
  106912. serializationObject.maxScaleY = particleSystem.maxScaleY;
  106913. serializationObject.minEmitPower = particleSystem.minEmitPower;
  106914. serializationObject.maxEmitPower = particleSystem.maxEmitPower;
  106915. serializationObject.minLifeTime = particleSystem.minLifeTime;
  106916. serializationObject.maxLifeTime = particleSystem.maxLifeTime;
  106917. serializationObject.emitRate = particleSystem.emitRate;
  106918. serializationObject.gravity = particleSystem.gravity.asArray();
  106919. serializationObject.noiseStrength = particleSystem.noiseStrength.asArray();
  106920. serializationObject.color1 = particleSystem.color1.asArray();
  106921. serializationObject.color2 = particleSystem.color2.asArray();
  106922. serializationObject.colorDead = particleSystem.colorDead.asArray();
  106923. serializationObject.updateSpeed = particleSystem.updateSpeed;
  106924. serializationObject.targetStopDuration = particleSystem.targetStopDuration;
  106925. serializationObject.blendMode = particleSystem.blendMode;
  106926. serializationObject.preWarmCycles = particleSystem.preWarmCycles;
  106927. serializationObject.preWarmStepOffset = particleSystem.preWarmStepOffset;
  106928. serializationObject.minInitialRotation = particleSystem.minInitialRotation;
  106929. serializationObject.maxInitialRotation = particleSystem.maxInitialRotation;
  106930. serializationObject.startSpriteCellID = particleSystem.startSpriteCellID;
  106931. serializationObject.endSpriteCellID = particleSystem.endSpriteCellID;
  106932. serializationObject.spriteCellChangeSpeed = particleSystem.spriteCellChangeSpeed;
  106933. serializationObject.spriteCellWidth = particleSystem.spriteCellWidth;
  106934. serializationObject.spriteCellHeight = particleSystem.spriteCellHeight;
  106935. serializationObject.spriteRandomStartCell = particleSystem.spriteRandomStartCell;
  106936. serializationObject.isAnimationSheetEnabled = particleSystem.isAnimationSheetEnabled;
  106937. var colorGradients = particleSystem.getColorGradients();
  106938. if (colorGradients) {
  106939. serializationObject.colorGradients = [];
  106940. for (var _i = 0, colorGradients_1 = colorGradients; _i < colorGradients_1.length; _i++) {
  106941. var colorGradient = colorGradients_1[_i];
  106942. var serializedGradient = {
  106943. gradient: colorGradient.gradient,
  106944. color1: colorGradient.color1.asArray()
  106945. };
  106946. if (colorGradient.color2) {
  106947. serializedGradient.color2 = colorGradient.color2.asArray();
  106948. }
  106949. serializationObject.colorGradients.push(serializedGradient);
  106950. }
  106951. }
  106952. var rampGradients = particleSystem.getRampGradients();
  106953. if (rampGradients) {
  106954. serializationObject.rampGradients = [];
  106955. for (var _a = 0, rampGradients_1 = rampGradients; _a < rampGradients_1.length; _a++) {
  106956. var rampGradient = rampGradients_1[_a];
  106957. var serializedGradient = {
  106958. gradient: rampGradient.gradient,
  106959. color: rampGradient.color.asArray()
  106960. };
  106961. serializationObject.rampGradients.push(serializedGradient);
  106962. }
  106963. serializationObject.useRampGradients = particleSystem.useRampGradients;
  106964. }
  106965. var colorRemapGradients = particleSystem.getColorRemapGradients();
  106966. if (colorRemapGradients) {
  106967. serializationObject.colorRemapGradients = [];
  106968. for (var _b = 0, colorRemapGradients_1 = colorRemapGradients; _b < colorRemapGradients_1.length; _b++) {
  106969. var colorRemapGradient = colorRemapGradients_1[_b];
  106970. var serializedGradient = {
  106971. gradient: colorRemapGradient.gradient,
  106972. factor1: colorRemapGradient.factor1
  106973. };
  106974. if (colorRemapGradient.factor2 !== undefined) {
  106975. serializedGradient.factor2 = colorRemapGradient.factor2;
  106976. }
  106977. serializationObject.colorRemapGradients.push(serializedGradient);
  106978. }
  106979. }
  106980. var alphaRemapGradients = particleSystem.getAlphaRemapGradients();
  106981. if (alphaRemapGradients) {
  106982. serializationObject.alphaRemapGradients = [];
  106983. for (var _c = 0, alphaRemapGradients_1 = alphaRemapGradients; _c < alphaRemapGradients_1.length; _c++) {
  106984. var alphaRemapGradient = alphaRemapGradients_1[_c];
  106985. var serializedGradient = {
  106986. gradient: alphaRemapGradient.gradient,
  106987. factor1: alphaRemapGradient.factor1
  106988. };
  106989. if (alphaRemapGradient.factor2 !== undefined) {
  106990. serializedGradient.factor2 = alphaRemapGradient.factor2;
  106991. }
  106992. serializationObject.alphaRemapGradients.push(serializedGradient);
  106993. }
  106994. }
  106995. var sizeGradients = particleSystem.getSizeGradients();
  106996. if (sizeGradients) {
  106997. serializationObject.sizeGradients = [];
  106998. for (var _d = 0, sizeGradients_1 = sizeGradients; _d < sizeGradients_1.length; _d++) {
  106999. var sizeGradient = sizeGradients_1[_d];
  107000. var serializedGradient = {
  107001. gradient: sizeGradient.gradient,
  107002. factor1: sizeGradient.factor1
  107003. };
  107004. if (sizeGradient.factor2 !== undefined) {
  107005. serializedGradient.factor2 = sizeGradient.factor2;
  107006. }
  107007. serializationObject.sizeGradients.push(serializedGradient);
  107008. }
  107009. }
  107010. var angularSpeedGradients = particleSystem.getAngularSpeedGradients();
  107011. if (angularSpeedGradients) {
  107012. serializationObject.angularSpeedGradients = [];
  107013. for (var _e = 0, angularSpeedGradients_1 = angularSpeedGradients; _e < angularSpeedGradients_1.length; _e++) {
  107014. var angularSpeedGradient = angularSpeedGradients_1[_e];
  107015. var serializedGradient = {
  107016. gradient: angularSpeedGradient.gradient,
  107017. factor1: angularSpeedGradient.factor1
  107018. };
  107019. if (angularSpeedGradient.factor2 !== undefined) {
  107020. serializedGradient.factor2 = angularSpeedGradient.factor2;
  107021. }
  107022. serializationObject.angularSpeedGradients.push(serializedGradient);
  107023. }
  107024. }
  107025. var velocityGradients = particleSystem.getVelocityGradients();
  107026. if (velocityGradients) {
  107027. serializationObject.velocityGradients = [];
  107028. for (var _f = 0, velocityGradients_1 = velocityGradients; _f < velocityGradients_1.length; _f++) {
  107029. var velocityGradient = velocityGradients_1[_f];
  107030. var serializedGradient = {
  107031. gradient: velocityGradient.gradient,
  107032. factor1: velocityGradient.factor1
  107033. };
  107034. if (velocityGradient.factor2 !== undefined) {
  107035. serializedGradient.factor2 = velocityGradient.factor2;
  107036. }
  107037. serializationObject.velocityGradients.push(serializedGradient);
  107038. }
  107039. }
  107040. var dragGradients = particleSystem.getDragGradients();
  107041. if (dragGradients) {
  107042. serializationObject.dragyGradients = [];
  107043. for (var _g = 0, dragGradients_1 = dragGradients; _g < dragGradients_1.length; _g++) {
  107044. var dragGradient = dragGradients_1[_g];
  107045. var serializedGradient = {
  107046. gradient: dragGradient.gradient,
  107047. factor1: dragGradient.factor1
  107048. };
  107049. if (dragGradient.factor2 !== undefined) {
  107050. serializedGradient.factor2 = dragGradient.factor2;
  107051. }
  107052. serializationObject.dragGradients.push(serializedGradient);
  107053. }
  107054. }
  107055. var emitRateGradients = particleSystem.getEmitRateGradients();
  107056. if (emitRateGradients) {
  107057. serializationObject.emitRateGradients = [];
  107058. for (var _h = 0, emitRateGradients_1 = emitRateGradients; _h < emitRateGradients_1.length; _h++) {
  107059. var emitRateGradient = emitRateGradients_1[_h];
  107060. var serializedGradient = {
  107061. gradient: emitRateGradient.gradient,
  107062. factor1: emitRateGradient.factor1
  107063. };
  107064. if (emitRateGradient.factor2 !== undefined) {
  107065. serializedGradient.factor2 = emitRateGradient.factor2;
  107066. }
  107067. serializationObject.emitRateGradients.push(serializedGradient);
  107068. }
  107069. }
  107070. var startSizeGradients = particleSystem.getStartSizeGradients();
  107071. if (startSizeGradients) {
  107072. serializationObject.startSizeGradients = [];
  107073. for (var _j = 0, startSizeGradients_1 = startSizeGradients; _j < startSizeGradients_1.length; _j++) {
  107074. var startSizeGradient = startSizeGradients_1[_j];
  107075. var serializedGradient = {
  107076. gradient: startSizeGradient.gradient,
  107077. factor1: startSizeGradient.factor1
  107078. };
  107079. if (startSizeGradient.factor2 !== undefined) {
  107080. serializedGradient.factor2 = startSizeGradient.factor2;
  107081. }
  107082. serializationObject.startSizeGradients.push(serializedGradient);
  107083. }
  107084. }
  107085. var lifeTimeGradients = particleSystem.getLifeTimeGradients();
  107086. if (lifeTimeGradients) {
  107087. serializationObject.lifeTimeGradients = [];
  107088. for (var _k = 0, lifeTimeGradients_1 = lifeTimeGradients; _k < lifeTimeGradients_1.length; _k++) {
  107089. var lifeTimeGradient = lifeTimeGradients_1[_k];
  107090. var serializedGradient = {
  107091. gradient: lifeTimeGradient.gradient,
  107092. factor1: lifeTimeGradient.factor1
  107093. };
  107094. if (lifeTimeGradient.factor2 !== undefined) {
  107095. serializedGradient.factor2 = lifeTimeGradient.factor2;
  107096. }
  107097. serializationObject.lifeTimeGradients.push(serializedGradient);
  107098. }
  107099. }
  107100. var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
  107101. if (limitVelocityGradients) {
  107102. serializationObject.limitVelocityGradients = [];
  107103. for (var _l = 0, limitVelocityGradients_1 = limitVelocityGradients; _l < limitVelocityGradients_1.length; _l++) {
  107104. var limitVelocityGradient = limitVelocityGradients_1[_l];
  107105. var serializedGradient = {
  107106. gradient: limitVelocityGradient.gradient,
  107107. factor1: limitVelocityGradient.factor1
  107108. };
  107109. if (limitVelocityGradient.factor2 !== undefined) {
  107110. serializedGradient.factor2 = limitVelocityGradient.factor2;
  107111. }
  107112. serializationObject.limitVelocityGradients.push(serializedGradient);
  107113. }
  107114. serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
  107115. }
  107116. if (particleSystem.noiseTexture) {
  107117. serializationObject.noiseTexture = particleSystem.noiseTexture.serialize();
  107118. }
  107119. };
  107120. /** @hidden */
  107121. ParticleSystem._Parse = function (parsedParticleSystem, particleSystem, scene, rootUrl) {
  107122. // Texture
  107123. if (parsedParticleSystem.textureName) {
  107124. particleSystem.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](rootUrl + parsedParticleSystem.textureName, scene, false, parsedParticleSystem.invertY !== undefined ? parsedParticleSystem.invertY : true);
  107125. particleSystem.particleTexture.name = parsedParticleSystem.textureName;
  107126. }
  107127. // Emitter
  107128. if (!parsedParticleSystem.emitterId && parsedParticleSystem.emitterId !== 0 && parsedParticleSystem.emitter === undefined) {
  107129. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  107130. }
  107131. else if (parsedParticleSystem.emitterId) {
  107132. particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
  107133. }
  107134. else {
  107135. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.emitter);
  107136. }
  107137. // Misc.
  107138. if (parsedParticleSystem.renderingGroupId !== undefined) {
  107139. particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
  107140. }
  107141. if (parsedParticleSystem.isBillboardBased !== undefined) {
  107142. particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
  107143. }
  107144. if (parsedParticleSystem.billboardMode !== undefined) {
  107145. particleSystem.billboardMode = parsedParticleSystem.billboardMode;
  107146. }
  107147. // Animations
  107148. if (parsedParticleSystem.animations) {
  107149. for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
  107150. var parsedAnimation = parsedParticleSystem.animations[animationIndex];
  107151. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__["_TypeStore"].GetClass("BABYLON.Animation");
  107152. if (internalClass) {
  107153. particleSystem.animations.push(internalClass.Parse(parsedAnimation));
  107154. }
  107155. }
  107156. particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
  107157. particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
  107158. particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
  107159. particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
  107160. }
  107161. if (parsedParticleSystem.autoAnimate) {
  107162. scene.beginAnimation(particleSystem, parsedParticleSystem.autoAnimateFrom, parsedParticleSystem.autoAnimateTo, parsedParticleSystem.autoAnimateLoop, parsedParticleSystem.autoAnimateSpeed || 1.0);
  107163. }
  107164. // Particle system
  107165. particleSystem.startDelay = parsedParticleSystem.startDelay | 0;
  107166. particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
  107167. particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
  107168. particleSystem.minSize = parsedParticleSystem.minSize;
  107169. particleSystem.maxSize = parsedParticleSystem.maxSize;
  107170. if (parsedParticleSystem.minScaleX) {
  107171. particleSystem.minScaleX = parsedParticleSystem.minScaleX;
  107172. particleSystem.maxScaleX = parsedParticleSystem.maxScaleX;
  107173. particleSystem.minScaleY = parsedParticleSystem.minScaleY;
  107174. particleSystem.maxScaleY = parsedParticleSystem.maxScaleY;
  107175. }
  107176. if (parsedParticleSystem.preWarmCycles !== undefined) {
  107177. particleSystem.preWarmCycles = parsedParticleSystem.preWarmCycles;
  107178. particleSystem.preWarmStepOffset = parsedParticleSystem.preWarmStepOffset;
  107179. }
  107180. if (parsedParticleSystem.minInitialRotation !== undefined) {
  107181. particleSystem.minInitialRotation = parsedParticleSystem.minInitialRotation;
  107182. particleSystem.maxInitialRotation = parsedParticleSystem.maxInitialRotation;
  107183. }
  107184. particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
  107185. particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
  107186. particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
  107187. particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
  107188. particleSystem.emitRate = parsedParticleSystem.emitRate;
  107189. particleSystem.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.gravity);
  107190. if (parsedParticleSystem.noiseStrength) {
  107191. particleSystem.noiseStrength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.noiseStrength);
  107192. }
  107193. particleSystem.color1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color1);
  107194. particleSystem.color2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color2);
  107195. particleSystem.colorDead = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.colorDead);
  107196. particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
  107197. particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
  107198. particleSystem.blendMode = parsedParticleSystem.blendMode;
  107199. if (parsedParticleSystem.colorGradients) {
  107200. for (var _i = 0, _a = parsedParticleSystem.colorGradients; _i < _a.length; _i++) {
  107201. var colorGradient = _a[_i];
  107202. 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);
  107203. }
  107204. }
  107205. if (parsedParticleSystem.rampGradients) {
  107206. for (var _b = 0, _c = parsedParticleSystem.rampGradients; _b < _c.length; _b++) {
  107207. var rampGradient = _c[_b];
  107208. particleSystem.addRampGradient(rampGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(rampGradient.color));
  107209. }
  107210. particleSystem.useRampGradients = parsedParticleSystem.useRampGradients;
  107211. }
  107212. if (parsedParticleSystem.colorRemapGradients) {
  107213. for (var _d = 0, _e = parsedParticleSystem.colorRemapGradients; _d < _e.length; _d++) {
  107214. var colorRemapGradient = _e[_d];
  107215. particleSystem.addColorRemapGradient(colorRemapGradient.gradient, colorRemapGradient.factor1 !== undefined ? colorRemapGradient.factor1 : colorRemapGradient.factor, colorRemapGradient.factor2);
  107216. }
  107217. }
  107218. if (parsedParticleSystem.alphaRemapGradients) {
  107219. for (var _f = 0, _g = parsedParticleSystem.alphaRemapGradients; _f < _g.length; _f++) {
  107220. var alphaRemapGradient = _g[_f];
  107221. particleSystem.addAlphaRemapGradient(alphaRemapGradient.gradient, alphaRemapGradient.factor1 !== undefined ? alphaRemapGradient.factor1 : alphaRemapGradient.factor, alphaRemapGradient.factor2);
  107222. }
  107223. }
  107224. if (parsedParticleSystem.sizeGradients) {
  107225. for (var _h = 0, _j = parsedParticleSystem.sizeGradients; _h < _j.length; _h++) {
  107226. var sizeGradient = _j[_h];
  107227. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  107228. }
  107229. }
  107230. if (parsedParticleSystem.sizeGradients) {
  107231. for (var _k = 0, _l = parsedParticleSystem.sizeGradients; _k < _l.length; _k++) {
  107232. var sizeGradient = _l[_k];
  107233. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  107234. }
  107235. }
  107236. if (parsedParticleSystem.angularSpeedGradients) {
  107237. for (var _m = 0, _o = parsedParticleSystem.angularSpeedGradients; _m < _o.length; _m++) {
  107238. var angularSpeedGradient = _o[_m];
  107239. particleSystem.addAngularSpeedGradient(angularSpeedGradient.gradient, angularSpeedGradient.factor1 !== undefined ? angularSpeedGradient.factor1 : angularSpeedGradient.factor, angularSpeedGradient.factor2);
  107240. }
  107241. }
  107242. if (parsedParticleSystem.velocityGradients) {
  107243. for (var _p = 0, _q = parsedParticleSystem.velocityGradients; _p < _q.length; _p++) {
  107244. var velocityGradient = _q[_p];
  107245. particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
  107246. }
  107247. }
  107248. if (parsedParticleSystem.dragGradients) {
  107249. for (var _r = 0, _s = parsedParticleSystem.dragGradients; _r < _s.length; _r++) {
  107250. var dragGradient = _s[_r];
  107251. particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
  107252. }
  107253. }
  107254. if (parsedParticleSystem.emitRateGradients) {
  107255. for (var _t = 0, _u = parsedParticleSystem.emitRateGradients; _t < _u.length; _t++) {
  107256. var emitRateGradient = _u[_t];
  107257. particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
  107258. }
  107259. }
  107260. if (parsedParticleSystem.startSizeGradients) {
  107261. for (var _v = 0, _w = parsedParticleSystem.startSizeGradients; _v < _w.length; _v++) {
  107262. var startSizeGradient = _w[_v];
  107263. particleSystem.addStartSizeGradient(startSizeGradient.gradient, startSizeGradient.factor1 !== undefined ? startSizeGradient.factor1 : startSizeGradient.factor, startSizeGradient.factor2);
  107264. }
  107265. }
  107266. if (parsedParticleSystem.lifeTimeGradients) {
  107267. for (var _x = 0, _y = parsedParticleSystem.lifeTimeGradients; _x < _y.length; _x++) {
  107268. var lifeTimeGradient = _y[_x];
  107269. particleSystem.addLifeTimeGradient(lifeTimeGradient.gradient, lifeTimeGradient.factor1 !== undefined ? lifeTimeGradient.factor1 : lifeTimeGradient.factor, lifeTimeGradient.factor2);
  107270. }
  107271. }
  107272. if (parsedParticleSystem.limitVelocityGradients) {
  107273. for (var _z = 0, _0 = parsedParticleSystem.limitVelocityGradients; _z < _0.length; _z++) {
  107274. var limitVelocityGradient = _0[_z];
  107275. particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
  107276. }
  107277. particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
  107278. }
  107279. if (parsedParticleSystem.noiseTexture) {
  107280. particleSystem.noiseTexture = _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__["ProceduralTexture"].Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
  107281. }
  107282. // Emitter
  107283. var emitterType;
  107284. if (parsedParticleSystem.particleEmitterType) {
  107285. switch (parsedParticleSystem.particleEmitterType.type) {
  107286. case "SphereParticleEmitter":
  107287. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereParticleEmitter"]();
  107288. break;
  107289. case "SphereDirectedParticleEmitter":
  107290. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereDirectedParticleEmitter"]();
  107291. break;
  107292. case "ConeEmitter":
  107293. case "ConeParticleEmitter":
  107294. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["ConeParticleEmitter"]();
  107295. break;
  107296. case "CylinderParticleEmitter":
  107297. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["CylinderParticleEmitter"]();
  107298. break;
  107299. case "HemisphericParticleEmitter":
  107300. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["HemisphericParticleEmitter"]();
  107301. break;
  107302. case "BoxEmitter":
  107303. case "BoxParticleEmitter":
  107304. default:
  107305. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  107306. break;
  107307. }
  107308. emitterType.parse(parsedParticleSystem.particleEmitterType);
  107309. }
  107310. else {
  107311. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  107312. emitterType.parse(parsedParticleSystem);
  107313. }
  107314. particleSystem.particleEmitterType = emitterType;
  107315. // Animation sheet
  107316. particleSystem.startSpriteCellID = parsedParticleSystem.startSpriteCellID;
  107317. particleSystem.endSpriteCellID = parsedParticleSystem.endSpriteCellID;
  107318. particleSystem.spriteCellWidth = parsedParticleSystem.spriteCellWidth;
  107319. particleSystem.spriteCellHeight = parsedParticleSystem.spriteCellHeight;
  107320. particleSystem.spriteCellChangeSpeed = parsedParticleSystem.spriteCellChangeSpeed;
  107321. particleSystem.spriteRandomStartCell = parsedParticleSystem.spriteRandomStartCell;
  107322. };
  107323. /**
  107324. * Parses a JSON object to create a particle system.
  107325. * @param parsedParticleSystem The JSON object to parse
  107326. * @param scene The scene to create the particle system in
  107327. * @param rootUrl The root url to use to load external dependencies like texture
  107328. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  107329. * @returns the Parsed particle system
  107330. */
  107331. ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  107332. if (doNotStart === void 0) { doNotStart = false; }
  107333. var name = parsedParticleSystem.name;
  107334. var custom = null;
  107335. var program = null;
  107336. if (parsedParticleSystem.customShader) {
  107337. program = parsedParticleSystem.customShader;
  107338. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  107339. custom = scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  107340. }
  107341. var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene, custom, parsedParticleSystem.isAnimationSheetEnabled);
  107342. particleSystem.customShader = program;
  107343. if (parsedParticleSystem.id) {
  107344. particleSystem.id = parsedParticleSystem.id;
  107345. }
  107346. // SubEmitters
  107347. if (parsedParticleSystem.subEmitters) {
  107348. particleSystem.subEmitters = [];
  107349. for (var _i = 0, _a = parsedParticleSystem.subEmitters; _i < _a.length; _i++) {
  107350. var cell = _a[_i];
  107351. var cellArray = [];
  107352. for (var _b = 0, cell_1 = cell; _b < cell_1.length; _b++) {
  107353. var sub = cell_1[_b];
  107354. cellArray.push(_subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"].Parse(sub, scene, rootUrl));
  107355. }
  107356. particleSystem.subEmitters.push(cellArray);
  107357. }
  107358. }
  107359. ParticleSystem._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  107360. particleSystem.textureMask = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.textureMask);
  107361. // Auto start
  107362. if (parsedParticleSystem.preventAutoStart) {
  107363. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  107364. }
  107365. if (!doNotStart && !particleSystem.preventAutoStart) {
  107366. particleSystem.start();
  107367. }
  107368. return particleSystem;
  107369. };
  107370. /**
  107371. * Billboard mode will only apply to Y axis
  107372. */
  107373. ParticleSystem.BILLBOARDMODE_Y = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_Y;
  107374. /**
  107375. * Billboard mode will apply to all axes
  107376. */
  107377. ParticleSystem.BILLBOARDMODE_ALL = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  107378. /**
  107379. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  107380. */
  107381. ParticleSystem.BILLBOARDMODE_STRETCHED = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_STRETCHED;
  107382. return ParticleSystem;
  107383. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__["BaseParticleSystem"]));
  107384. _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]._ParseParticleSystem = ParticleSystem.Parse;
  107385. /***/ }),
  107386. /***/ "./Particles/particleSystemComponent.ts":
  107387. /*!**********************************************!*\
  107388. !*** ./Particles/particleSystemComponent.ts ***!
  107389. \**********************************************/
  107390. /*! exports provided: _IDoNeedToBeInTheBuild */
  107391. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107392. "use strict";
  107393. __webpack_require__.r(__webpack_exports__);
  107394. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _IDoNeedToBeInTheBuild; });
  107395. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  107396. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  107397. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  107398. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  107399. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  107400. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  107401. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  107402. // Adds the parsers to the scene parsers.
  107403. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedData, scene, container, rootUrl) {
  107404. var individualParser = _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  107405. if (!individualParser) {
  107406. return;
  107407. }
  107408. // Particles Systems
  107409. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  107410. for (var index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  107411. var parsedParticleSystem = parsedData.particleSystems[index];
  107412. container.particleSystems.push(individualParser(parsedParticleSystem, scene, rootUrl));
  107413. }
  107414. }
  107415. });
  107416. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedParticleSystem, scene, rootUrl) {
  107417. if (parsedParticleSystem.activeParticleCount) {
  107418. var ps = _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__["GPUParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  107419. return ps;
  107420. }
  107421. else {
  107422. var ps = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  107423. return ps;
  107424. }
  107425. });
  107426. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createEffectForParticles = function (fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) {
  107427. if (uniformsNames === void 0) { uniformsNames = []; }
  107428. if (samplers === void 0) { samplers = []; }
  107429. if (defines === void 0) { defines = ""; }
  107430. var attributesNamesOrOptions = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetAttributeNamesOrOptions();
  107431. var effectCreationOption = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetEffectCreationOptions();
  107432. if (defines.indexOf(" BILLBOARD") === -1) {
  107433. defines += "\n#define BILLBOARD\n";
  107434. }
  107435. if (samplers.indexOf("diffuseSampler") === -1) {
  107436. samplers.push("diffuseSampler");
  107437. }
  107438. return this.createEffect({
  107439. vertex: "particles",
  107440. fragmentElement: fragmentName
  107441. }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), samplers, defines, fallbacks, onCompiled, onError);
  107442. };
  107443. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getEmittedParticleSystems = function () {
  107444. var results = new Array();
  107445. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  107446. var particleSystem = this.getScene().particleSystems[index];
  107447. if (particleSystem.emitter === this) {
  107448. results.push(particleSystem);
  107449. }
  107450. }
  107451. return results;
  107452. };
  107453. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getHierarchyEmittedParticleSystems = function () {
  107454. var results = new Array();
  107455. var descendants = this.getDescendants();
  107456. descendants.push(this);
  107457. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  107458. var particleSystem = this.getScene().particleSystems[index];
  107459. var emitter = particleSystem.emitter;
  107460. if (emitter.position && descendants.indexOf(emitter) !== -1) {
  107461. results.push(particleSystem);
  107462. }
  107463. }
  107464. return results;
  107465. };
  107466. /**
  107467. * @hidden
  107468. */
  107469. var _IDoNeedToBeInTheBuild = 42;
  107470. /***/ }),
  107471. /***/ "./Particles/particleSystemSet.ts":
  107472. /*!****************************************!*\
  107473. !*** ./Particles/particleSystemSet.ts ***!
  107474. \****************************************/
  107475. /*! exports provided: ParticleSystemSet */
  107476. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107477. "use strict";
  107478. __webpack_require__.r(__webpack_exports__);
  107479. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return ParticleSystemSet; });
  107480. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107481. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  107482. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  107483. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  107484. /* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
  107485. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  107486. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  107487. /** Internal class used to store shapes for emitters */
  107488. var ParticleSystemSetEmitterCreationOptions = /** @class */ (function () {
  107489. function ParticleSystemSetEmitterCreationOptions() {
  107490. }
  107491. return ParticleSystemSetEmitterCreationOptions;
  107492. }());
  107493. /**
  107494. * Represents a set of particle systems working together to create a specific effect
  107495. */
  107496. var ParticleSystemSet = /** @class */ (function () {
  107497. function ParticleSystemSet() {
  107498. /**
  107499. * Gets the particle system list
  107500. */
  107501. this.systems = new Array();
  107502. }
  107503. Object.defineProperty(ParticleSystemSet.prototype, "emitterNode", {
  107504. /**
  107505. * Gets the emitter node used with this set
  107506. */
  107507. get: function () {
  107508. return this._emitterNode;
  107509. },
  107510. enumerable: true,
  107511. configurable: true
  107512. });
  107513. /**
  107514. * Creates a new emitter mesh as a sphere
  107515. * @param options defines the options used to create the sphere
  107516. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  107517. * @param scene defines the hosting scene
  107518. */
  107519. ParticleSystemSet.prototype.setEmitterAsSphere = function (options, renderingGroupId, scene) {
  107520. if (this._emitterNode) {
  107521. this._emitterNode.dispose();
  107522. }
  107523. this._emitterCreationOptions = {
  107524. kind: "Sphere",
  107525. options: options,
  107526. renderingGroupId: renderingGroupId
  107527. };
  107528. var emitterMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("emitterSphere", { diameter: options.diameter, segments: options.segments }, scene);
  107529. emitterMesh.renderingGroupId = renderingGroupId;
  107530. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("emitterSphereMaterial", scene);
  107531. material.emissiveColor = options.color;
  107532. emitterMesh.material = material;
  107533. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107534. var system = _a[_i];
  107535. system.emitter = emitterMesh;
  107536. }
  107537. this._emitterNode = emitterMesh;
  107538. };
  107539. /**
  107540. * Starts all particle systems of the set
  107541. * @param emitter defines an optional mesh to use as emitter for the particle systems
  107542. */
  107543. ParticleSystemSet.prototype.start = function (emitter) {
  107544. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107545. var system = _a[_i];
  107546. if (emitter) {
  107547. system.emitter = emitter;
  107548. }
  107549. system.start();
  107550. }
  107551. };
  107552. /**
  107553. * Release all associated resources
  107554. */
  107555. ParticleSystemSet.prototype.dispose = function () {
  107556. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107557. var system = _a[_i];
  107558. system.dispose();
  107559. }
  107560. this.systems = [];
  107561. if (this._emitterNode) {
  107562. this._emitterNode.dispose();
  107563. this._emitterNode = null;
  107564. }
  107565. };
  107566. /**
  107567. * Serialize the set into a JSON compatible object
  107568. * @returns a JSON compatible representation of the set
  107569. */
  107570. ParticleSystemSet.prototype.serialize = function () {
  107571. var result = {};
  107572. result.systems = [];
  107573. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  107574. var system = _a[_i];
  107575. result.systems.push(system.serialize());
  107576. }
  107577. if (this._emitterNode) {
  107578. result.emitter = this._emitterCreationOptions;
  107579. }
  107580. return result;
  107581. };
  107582. /**
  107583. * Parse a new ParticleSystemSet from a serialized source
  107584. * @param data defines a JSON compatible representation of the set
  107585. * @param scene defines the hosting scene
  107586. * @param gpu defines if we want GPU particles or CPU particles
  107587. * @returns a new ParticleSystemSet
  107588. */
  107589. ParticleSystemSet.Parse = function (data, scene, gpu) {
  107590. if (gpu === void 0) { gpu = false; }
  107591. var result = new ParticleSystemSet();
  107592. var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
  107593. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  107594. for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
  107595. var system = _a[_i];
  107596. 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));
  107597. }
  107598. if (data.emitter) {
  107599. var options = data.emitter.options;
  107600. switch (data.emitter.kind) {
  107601. case "Sphere":
  107602. result.setEmitterAsSphere({
  107603. diameter: options.diameter,
  107604. segments: options.segments,
  107605. color: _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(options.color)
  107606. }, data.emitter.renderingGroupId, scene);
  107607. break;
  107608. }
  107609. }
  107610. return result;
  107611. };
  107612. return ParticleSystemSet;
  107613. }());
  107614. /***/ }),
  107615. /***/ "./Particles/solidParticle.ts":
  107616. /*!************************************!*\
  107617. !*** ./Particles/solidParticle.ts ***!
  107618. \************************************/
  107619. /*! exports provided: SolidParticle, ModelShape, DepthSortedParticle */
  107620. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107621. "use strict";
  107622. __webpack_require__.r(__webpack_exports__);
  107623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return SolidParticle; });
  107624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return ModelShape; });
  107625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return DepthSortedParticle; });
  107626. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107627. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  107628. /* harmony import */ var _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/boundingSphere */ "./Culling/boundingSphere.ts");
  107629. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  107630. /**
  107631. * Represents one particle of a solid particle system.
  107632. */
  107633. var SolidParticle = /** @class */ (function () {
  107634. /**
  107635. * Creates a Solid Particle object.
  107636. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  107637. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  107638. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  107639. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  107640. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  107641. * @param shapeId (integer) is the model shape identifier in the SPS.
  107642. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  107643. * @param sps defines the sps it is associated to
  107644. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  107645. */
  107646. function SolidParticle(particleIndex, positionIndex, indiceIndex, model, shapeId, idxInShape, sps, modelBoundingInfo) {
  107647. if (modelBoundingInfo === void 0) { modelBoundingInfo = null; }
  107648. /**
  107649. * particle global index
  107650. */
  107651. this.idx = 0;
  107652. /**
  107653. * The color of the particle
  107654. */
  107655. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  107656. /**
  107657. * The world space position of the particle.
  107658. */
  107659. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107660. /**
  107661. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  107662. */
  107663. this.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107664. /**
  107665. * The scaling of the particle.
  107666. */
  107667. this.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  107668. /**
  107669. * The uvs of the particle.
  107670. */
  107671. this.uvs = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  107672. /**
  107673. * The current speed of the particle.
  107674. */
  107675. this.velocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107676. /**
  107677. * The pivot point in the particle local space.
  107678. */
  107679. this.pivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107680. /**
  107681. * Must the particle be translated from its pivot point in its local space ?
  107682. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  107683. * Default : false
  107684. */
  107685. this.translateFromPivot = false;
  107686. /**
  107687. * Is the particle active or not ?
  107688. */
  107689. this.alive = true;
  107690. /**
  107691. * Is the particle visible or not ?
  107692. */
  107693. this.isVisible = true;
  107694. /**
  107695. * Index of this particle in the global "positions" array (Internal use)
  107696. * @hidden
  107697. */
  107698. this._pos = 0;
  107699. /**
  107700. * @hidden Index of this particle in the global "indices" array (Internal use)
  107701. */
  107702. this._ind = 0;
  107703. /**
  107704. * ModelShape id of this particle
  107705. */
  107706. this.shapeId = 0;
  107707. /**
  107708. * Index of the particle in its shape id (Internal use)
  107709. */
  107710. this.idxInShape = 0;
  107711. /**
  107712. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  107713. */
  107714. this._stillInvisible = false;
  107715. /**
  107716. * @hidden Last computed particle rotation matrix
  107717. */
  107718. this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
  107719. /**
  107720. * Parent particle Id, if any.
  107721. * Default null.
  107722. */
  107723. this.parentId = null;
  107724. /**
  107725. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  107726. * The possible values are :
  107727. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  107728. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107729. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  107730. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  107731. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107732. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  107733. * */
  107734. this.cullingStrategy = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"].CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  107735. /**
  107736. * @hidden Internal global position in the SPS.
  107737. */
  107738. this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107739. this.idx = particleIndex;
  107740. this._pos = positionIndex;
  107741. this._ind = indiceIndex;
  107742. this._model = model;
  107743. this.shapeId = shapeId;
  107744. this.idxInShape = idxInShape;
  107745. this._sps = sps;
  107746. if (modelBoundingInfo) {
  107747. this._modelBoundingInfo = modelBoundingInfo;
  107748. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"](modelBoundingInfo.minimum, modelBoundingInfo.maximum);
  107749. }
  107750. }
  107751. Object.defineProperty(SolidParticle.prototype, "scale", {
  107752. /**
  107753. * Legacy support, changed scale to scaling
  107754. */
  107755. get: function () {
  107756. return this.scaling;
  107757. },
  107758. /**
  107759. * Legacy support, changed scale to scaling
  107760. */
  107761. set: function (scale) {
  107762. this.scaling = scale;
  107763. },
  107764. enumerable: true,
  107765. configurable: true
  107766. });
  107767. Object.defineProperty(SolidParticle.prototype, "quaternion", {
  107768. /**
  107769. * Legacy support, changed quaternion to rotationQuaternion
  107770. */
  107771. get: function () {
  107772. return this.rotationQuaternion;
  107773. },
  107774. /**
  107775. * Legacy support, changed quaternion to rotationQuaternion
  107776. */
  107777. set: function (q) {
  107778. this.rotationQuaternion = q;
  107779. },
  107780. enumerable: true,
  107781. configurable: true
  107782. });
  107783. /**
  107784. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  107785. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  107786. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  107787. * @returns true if it intersects
  107788. */
  107789. SolidParticle.prototype.intersectsMesh = function (target) {
  107790. if (!this._boundingInfo || !target._boundingInfo) {
  107791. return false;
  107792. }
  107793. if (this._sps._bSphereOnly) {
  107794. return _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"].Intersects(this._boundingInfo.boundingSphere, target._boundingInfo.boundingSphere);
  107795. }
  107796. return this._boundingInfo.intersects(target._boundingInfo, false);
  107797. };
  107798. /**
  107799. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  107800. * A particle is in the frustum if its bounding box intersects the frustum
  107801. * @param frustumPlanes defines the frustum to test
  107802. * @returns true if the particle is in the frustum planes
  107803. */
  107804. SolidParticle.prototype.isInFrustum = function (frustumPlanes) {
  107805. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  107806. };
  107807. /**
  107808. * get the rotation matrix of the particle
  107809. * @hidden
  107810. */
  107811. SolidParticle.prototype.getRotationMatrix = function (m) {
  107812. var quaternion;
  107813. if (this.rotationQuaternion) {
  107814. quaternion = this.rotationQuaternion;
  107815. }
  107816. else {
  107817. quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  107818. var rotation = this.rotation;
  107819. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  107820. }
  107821. quaternion.toRotationMatrix(m);
  107822. };
  107823. return SolidParticle;
  107824. }());
  107825. /**
  107826. * Represents the shape of the model used by one particle of a solid particle system.
  107827. * SPS internal tool, don't use it manually.
  107828. */
  107829. var ModelShape = /** @class */ (function () {
  107830. /**
  107831. * 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.
  107832. * SPS internal tool, don't use it manually.
  107833. * @hidden
  107834. */
  107835. function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
  107836. /**
  107837. * length of the shape in the model indices array (internal use)
  107838. * @hidden
  107839. */
  107840. this._indicesLength = 0;
  107841. this.shapeID = id;
  107842. this._shape = shape;
  107843. this._indicesLength = indicesLength;
  107844. this._shapeUV = shapeUV;
  107845. this._positionFunction = posFunction;
  107846. this._vertexFunction = vtxFunction;
  107847. }
  107848. return ModelShape;
  107849. }());
  107850. /**
  107851. * Represents a Depth Sorted Particle in the solid particle system.
  107852. */
  107853. var DepthSortedParticle = /** @class */ (function () {
  107854. function DepthSortedParticle() {
  107855. /**
  107856. * Index of the particle in the "indices" array
  107857. */
  107858. this.ind = 0;
  107859. /**
  107860. * Length of the particle shape in the "indices" array
  107861. */
  107862. this.indicesLength = 0;
  107863. /**
  107864. * Squared distance from the particle to the camera
  107865. */
  107866. this.sqDistance = 0.0;
  107867. }
  107868. return DepthSortedParticle;
  107869. }());
  107870. /***/ }),
  107871. /***/ "./Particles/solidParticleSystem.ts":
  107872. /*!******************************************!*\
  107873. !*** ./Particles/solidParticleSystem.ts ***!
  107874. \******************************************/
  107875. /*! exports provided: SolidParticleSystem */
  107876. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107877. "use strict";
  107878. __webpack_require__.r(__webpack_exports__);
  107879. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return SolidParticleSystem; });
  107880. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107881. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  107882. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  107883. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  107884. /* harmony import */ var _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  107885. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  107886. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  107887. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  107888. var depthSortFunction = function (p1, p2) { return p2.sqDistance - p1.sqDistance; };
  107889. /**
  107890. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  107891. *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.
  107892. * The SPS is also a particle system. It provides some methods to manage the particles.
  107893. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  107894. *
  107895. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  107896. */
  107897. var SolidParticleSystem = /** @class */ (function () {
  107898. /**
  107899. * Creates a SPS (Solid Particle System) object.
  107900. * @param name (String) is the SPS name, this will be the underlying mesh name.
  107901. * @param scene (Scene) is the scene in which the SPS is added.
  107902. * @param options defines the options of the sps e.g.
  107903. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  107904. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  107905. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  107906. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  107907. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  107908. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  107909. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  107910. */
  107911. function SolidParticleSystem(name, scene, options) {
  107912. /**
  107913. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  107914. * Example : var p = SPS.particles[i];
  107915. */
  107916. this.particles = new Array();
  107917. /**
  107918. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  107919. */
  107920. this.nbParticles = 0;
  107921. /**
  107922. * If the particles must ever face the camera (default false). Useful for planar particles.
  107923. */
  107924. this.billboard = false;
  107925. /**
  107926. * Recompute normals when adding a shape
  107927. */
  107928. this.recomputeNormals = true;
  107929. /**
  107930. * This a counter ofr your own usage. It's not set by any SPS functions.
  107931. */
  107932. this.counter = 0;
  107933. /**
  107934. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  107935. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  107936. */
  107937. this.vars = {};
  107938. /**
  107939. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  107940. * @hidden
  107941. */
  107942. this._bSphereOnly = false;
  107943. /**
  107944. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  107945. * @hidden
  107946. */
  107947. this._bSphereRadiusFactor = 1.0;
  107948. this._positions = new Array();
  107949. this._indices = new Array();
  107950. this._normals = new Array();
  107951. this._colors = new Array();
  107952. this._uvs = new Array();
  107953. this._index = 0; // indices index
  107954. this._updatable = true;
  107955. this._pickable = false;
  107956. this._isVisibilityBoxLocked = false;
  107957. this._alwaysVisible = false;
  107958. this._depthSort = false;
  107959. this._shapeCounter = 0;
  107960. this._copy = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](0, 0, 0, null, 0, 0, this);
  107961. this._color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  107962. this._computeParticleColor = true;
  107963. this._computeParticleTexture = true;
  107964. this._computeParticleRotation = true;
  107965. this._computeParticleVertex = false;
  107966. this._computeBoundingBox = false;
  107967. this._depthSortParticles = true;
  107968. this._mustUnrotateFixedNormals = false;
  107969. this._particlesIntersect = false;
  107970. this._needs32Bits = false;
  107971. this.name = name;
  107972. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  107973. this._camera = scene.activeCamera;
  107974. this._pickable = options ? options.isPickable : false;
  107975. this._depthSort = options ? options.enableDepthSort : false;
  107976. this._particlesIntersect = options ? options.particleIntersection : false;
  107977. this._bSphereOnly = options ? options.boundingSphereOnly : false;
  107978. this._bSphereRadiusFactor = (options && options.bSphereRadiusFactor) ? options.bSphereRadiusFactor : 1.0;
  107979. if (options && options.updatable !== undefined) {
  107980. this._updatable = options.updatable;
  107981. }
  107982. else {
  107983. this._updatable = true;
  107984. }
  107985. if (this._pickable) {
  107986. this.pickedParticles = [];
  107987. }
  107988. if (this._depthSort) {
  107989. this.depthSortedParticles = [];
  107990. }
  107991. }
  107992. /**
  107993. * Builds the SPS underlying mesh. Returns a standard Mesh.
  107994. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  107995. * @returns the created mesh
  107996. */
  107997. SolidParticleSystem.prototype.buildMesh = function () {
  107998. if (this.nbParticles === 0) {
  107999. var triangle = _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__["DiscBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
  108000. this.addShape(triangle, 1);
  108001. triangle.dispose();
  108002. }
  108003. this._indices32 = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
  108004. this._positions32 = new Float32Array(this._positions);
  108005. this._uvs32 = new Float32Array(this._uvs);
  108006. this._colors32 = new Float32Array(this._colors);
  108007. if (this.recomputeNormals) {
  108008. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(this._positions32, this._indices32, this._normals);
  108009. }
  108010. this._normals32 = new Float32Array(this._normals);
  108011. this._fixedNormal32 = new Float32Array(this._normals);
  108012. if (this._mustUnrotateFixedNormals) { // the particles could be created already rotated in the mesh with a positionFunction
  108013. this._unrotateFixedNormals();
  108014. }
  108015. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  108016. vertexData.indices = (this._depthSort) ? this._indices : this._indices32;
  108017. vertexData.set(this._positions32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  108018. vertexData.set(this._normals32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  108019. if (this._uvs32.length > 0) {
  108020. vertexData.set(this._uvs32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  108021. }
  108022. if (this._colors32.length > 0) {
  108023. vertexData.set(this._colors32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  108024. }
  108025. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this.name, this._scene);
  108026. vertexData.applyToMesh(mesh, this._updatable);
  108027. this.mesh = mesh;
  108028. this.mesh.isPickable = this._pickable;
  108029. // free memory
  108030. if (!this._depthSort) {
  108031. this._indices = null;
  108032. }
  108033. this._positions = null;
  108034. this._normals = null;
  108035. this._uvs = null;
  108036. this._colors = null;
  108037. if (!this._updatable) {
  108038. this.particles.length = 0;
  108039. }
  108040. return mesh;
  108041. };
  108042. /**
  108043. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  108044. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  108045. * Thus the particles generated from `digest()` have their property `position` set yet.
  108046. * @param mesh ( Mesh ) is the mesh to be digested
  108047. * @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
  108048. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  108049. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  108050. * @returns the current SPS
  108051. */
  108052. SolidParticleSystem.prototype.digest = function (mesh, options) {
  108053. var size = (options && options.facetNb) || 1;
  108054. var number = (options && options.number) || 0;
  108055. var delta = (options && options.delta) || 0;
  108056. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  108057. var meshInd = mesh.getIndices();
  108058. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  108059. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  108060. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  108061. var f = 0; // facet counter
  108062. var totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
  108063. // compute size from number
  108064. if (number) {
  108065. number = (number > totalFacets) ? totalFacets : number;
  108066. size = Math.round(totalFacets / number);
  108067. delta = 0;
  108068. }
  108069. else {
  108070. size = (size > totalFacets) ? totalFacets : size;
  108071. }
  108072. var facetPos = []; // submesh positions
  108073. var facetInd = []; // submesh indices
  108074. var facetUV = []; // submesh UV
  108075. var facetCol = []; // submesh colors
  108076. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  108077. var sizeO = size;
  108078. while (f < totalFacets) {
  108079. size = sizeO + Math.floor((1 + delta) * Math.random());
  108080. if (f > totalFacets - size) {
  108081. size = totalFacets - f;
  108082. }
  108083. // reset temp arrays
  108084. facetPos.length = 0;
  108085. facetInd.length = 0;
  108086. facetUV.length = 0;
  108087. facetCol.length = 0;
  108088. // iterate over "size" facets
  108089. var fi = 0;
  108090. for (var j = f * 3; j < (f + size) * 3; j++) {
  108091. facetInd.push(fi);
  108092. var i = meshInd[j];
  108093. facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
  108094. if (meshUV) {
  108095. facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
  108096. }
  108097. if (meshCol) {
  108098. facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
  108099. }
  108100. fi++;
  108101. }
  108102. // create a model shape for each single particle
  108103. var idx = this.nbParticles;
  108104. var shape = this._posToShape(facetPos);
  108105. var shapeUV = this._uvsToShapeUV(facetUV);
  108106. // compute the barycenter of the shape
  108107. var v;
  108108. for (v = 0; v < shape.length; v++) {
  108109. barycenter.addInPlace(shape[v]);
  108110. }
  108111. barycenter.scaleInPlace(1 / shape.length);
  108112. // shift the shape from its barycenter to the origin
  108113. for (v = 0; v < shape.length; v++) {
  108114. shape[v].subtractInPlace(barycenter);
  108115. }
  108116. var bInfo;
  108117. if (this._particlesIntersect) {
  108118. bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](barycenter, barycenter);
  108119. }
  108120. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
  108121. // add the particle in the SPS
  108122. var currentPos = this._positions.length;
  108123. var currentInd = this._indices.length;
  108124. this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
  108125. this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
  108126. // initialize the particle position
  108127. this.particles[this.nbParticles].position.addInPlace(barycenter);
  108128. this._index += shape.length;
  108129. idx++;
  108130. this.nbParticles++;
  108131. this._shapeCounter++;
  108132. f += size;
  108133. }
  108134. return this;
  108135. };
  108136. // unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  108137. SolidParticleSystem.prototype._unrotateFixedNormals = function () {
  108138. var index = 0;
  108139. var idx = 0;
  108140. var tmpNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  108141. var quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  108142. var invertedRotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  108143. for (var p = 0; p < this.particles.length; p++) {
  108144. var particle = this.particles[p];
  108145. var shape = particle._model._shape;
  108146. // computing the inverse of the rotation matrix from the quaternion
  108147. // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
  108148. if (particle.rotationQuaternion) {
  108149. particle.rotationQuaternion.conjugateToRef(quaternion);
  108150. }
  108151. else {
  108152. var rotation = particle.rotation;
  108153. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  108154. quaternion.conjugateInPlace();
  108155. }
  108156. quaternion.toRotationMatrix(invertedRotMatrix);
  108157. for (var pt = 0; pt < shape.length; pt++) {
  108158. idx = index + pt * 3;
  108159. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
  108160. tmpNormal.toArray(this._fixedNormal32, idx);
  108161. }
  108162. index = idx + 3;
  108163. }
  108164. };
  108165. //reset copy
  108166. SolidParticleSystem.prototype._resetCopy = function () {
  108167. var copy = this._copy;
  108168. copy.position.setAll(0);
  108169. copy.rotation.setAll(0);
  108170. copy.rotationQuaternion = null;
  108171. copy.scaling.setAll(1);
  108172. copy.uvs.copyFromFloats(0.0, 0.0, 1.0, 1.0);
  108173. copy.color = null;
  108174. copy.translateFromPivot = false;
  108175. };
  108176. // _meshBuilder : inserts the shape model in the global SPS mesh
  108177. SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options) {
  108178. var i;
  108179. var u = 0;
  108180. var c = 0;
  108181. var n = 0;
  108182. this._resetCopy();
  108183. var copy = this._copy;
  108184. if (options && options.positionFunction) { // call to custom positionFunction
  108185. options.positionFunction(copy, idx, idxInShape);
  108186. this._mustUnrotateFixedNormals = true;
  108187. }
  108188. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  108189. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  108190. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  108191. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  108192. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  108193. copy.getRotationMatrix(rotMatrix);
  108194. copy.pivot.multiplyToRef(copy.scaling, scaledPivot);
  108195. if (copy.translateFromPivot) {
  108196. pivotBackTranslation.setAll(0.0);
  108197. }
  108198. else {
  108199. pivotBackTranslation.copyFrom(scaledPivot);
  108200. }
  108201. for (i = 0; i < shape.length; i++) {
  108202. tmpVertex.copyFrom(shape[i]);
  108203. if (options && options.vertexFunction) {
  108204. options.vertexFunction(copy, tmpVertex, i);
  108205. }
  108206. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  108207. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  108208. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position);
  108209. positions.push(tmpRotated.x, tmpRotated.y, tmpRotated.z);
  108210. if (meshUV) {
  108211. var copyUvs = copy.uvs;
  108212. uvs.push((copyUvs.z - copyUvs.x) * meshUV[u] + copyUvs.x, (copyUvs.w - copyUvs.y) * meshUV[u + 1] + copyUvs.y);
  108213. u += 2;
  108214. }
  108215. if (copy.color) {
  108216. this._color = copy.color;
  108217. }
  108218. else {
  108219. var color = this._color;
  108220. if (meshCol && meshCol[c] !== undefined) {
  108221. color.r = meshCol[c];
  108222. color.g = meshCol[c + 1];
  108223. color.b = meshCol[c + 2];
  108224. color.a = meshCol[c + 3];
  108225. }
  108226. else {
  108227. color.r = 1.0;
  108228. color.g = 1.0;
  108229. color.b = 1.0;
  108230. color.a = 1.0;
  108231. }
  108232. }
  108233. colors.push(this._color.r, this._color.g, this._color.b, this._color.a);
  108234. c += 4;
  108235. if (!this.recomputeNormals && meshNor) {
  108236. tmpVertex.x = meshNor[n];
  108237. tmpVertex.y = meshNor[n + 1];
  108238. tmpVertex.z = meshNor[n + 2];
  108239. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, rotMatrix, tmpVertex);
  108240. normals.push(tmpVertex.x, tmpVertex.y, tmpVertex.z);
  108241. n += 3;
  108242. }
  108243. }
  108244. for (i = 0; i < meshInd.length; i++) {
  108245. var current_ind = p + meshInd[i];
  108246. indices.push(current_ind);
  108247. if (current_ind > 65535) {
  108248. this._needs32Bits = true;
  108249. }
  108250. }
  108251. if (this._pickable) {
  108252. var nbfaces = meshInd.length / 3;
  108253. for (i = 0; i < nbfaces; i++) {
  108254. this.pickedParticles.push({ idx: idx, faceId: i });
  108255. }
  108256. }
  108257. if (this._depthSort) {
  108258. this.depthSortedParticles.push(new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["DepthSortedParticle"]());
  108259. }
  108260. return copy;
  108261. };
  108262. // returns a shape array from positions array
  108263. SolidParticleSystem.prototype._posToShape = function (positions) {
  108264. var shape = [];
  108265. for (var i = 0; i < positions.length; i += 3) {
  108266. shape.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, i));
  108267. }
  108268. return shape;
  108269. };
  108270. // returns a shapeUV array from a Vector4 uvs
  108271. SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
  108272. var shapeUV = [];
  108273. if (uvs) {
  108274. for (var i = 0; i < uvs.length; i++) {
  108275. shapeUV.push(uvs[i]);
  108276. }
  108277. }
  108278. return shapeUV;
  108279. };
  108280. // adds a new particle object in the particles array
  108281. SolidParticleSystem.prototype._addParticle = function (idx, idxpos, idxind, model, shapeId, idxInShape, bInfo) {
  108282. if (bInfo === void 0) { bInfo = null; }
  108283. var sp = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](idx, idxpos, idxind, model, shapeId, idxInShape, this, bInfo);
  108284. this.particles.push(sp);
  108285. return sp;
  108286. };
  108287. /**
  108288. * Adds some particles to the SPS from the model shape. Returns the shape id.
  108289. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  108290. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  108291. * @param nb (positive integer) the number of particles to be created from this model
  108292. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  108293. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  108294. * @returns the number of shapes in the system
  108295. */
  108296. SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
  108297. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  108298. var meshInd = mesh.getIndices();
  108299. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  108300. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  108301. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  108302. var bbInfo;
  108303. if (this._particlesIntersect) {
  108304. bbInfo = mesh.getBoundingInfo();
  108305. }
  108306. var shape = this._posToShape(meshPos);
  108307. var shapeUV = this._uvsToShapeUV(meshUV);
  108308. var posfunc = options ? options.positionFunction : null;
  108309. var vtxfunc = options ? options.vertexFunction : null;
  108310. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
  108311. // particles
  108312. var sp;
  108313. var currentCopy;
  108314. var idx = this.nbParticles;
  108315. for (var i = 0; i < nb; i++) {
  108316. var currentPos = this._positions.length;
  108317. var currentInd = this._indices.length;
  108318. currentCopy = this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, meshNor, this._normals, idx, i, options);
  108319. if (this._updatable) {
  108320. sp = this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, i, bbInfo);
  108321. sp.position.copyFrom(currentCopy.position);
  108322. sp.rotation.copyFrom(currentCopy.rotation);
  108323. if (currentCopy.rotationQuaternion && sp.rotationQuaternion) {
  108324. sp.rotationQuaternion.copyFrom(currentCopy.rotationQuaternion);
  108325. }
  108326. if (currentCopy.color && sp.color) {
  108327. sp.color.copyFrom(currentCopy.color);
  108328. }
  108329. sp.scaling.copyFrom(currentCopy.scaling);
  108330. sp.uvs.copyFrom(currentCopy.uvs);
  108331. }
  108332. this._index += shape.length;
  108333. idx++;
  108334. }
  108335. this.nbParticles += nb;
  108336. this._shapeCounter++;
  108337. return this._shapeCounter - 1;
  108338. };
  108339. // rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  108340. SolidParticleSystem.prototype._rebuildParticle = function (particle) {
  108341. this._resetCopy();
  108342. var copy = this._copy;
  108343. if (particle._model._positionFunction) { // recall to stored custom positionFunction
  108344. particle._model._positionFunction(copy, particle.idx, particle.idxInShape);
  108345. }
  108346. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  108347. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  108348. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  108349. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  108350. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  108351. copy.getRotationMatrix(rotMatrix);
  108352. particle.pivot.multiplyToRef(particle.scaling, scaledPivot);
  108353. if (copy.translateFromPivot) {
  108354. pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
  108355. }
  108356. else {
  108357. pivotBackTranslation.copyFrom(scaledPivot);
  108358. }
  108359. var shape = particle._model._shape;
  108360. for (var pt = 0; pt < shape.length; pt++) {
  108361. tmpVertex.copyFrom(shape[pt]);
  108362. if (particle._model._vertexFunction) {
  108363. particle._model._vertexFunction(copy, tmpVertex, pt); // recall to stored vertexFunction
  108364. }
  108365. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  108366. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  108367. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
  108368. }
  108369. particle.position.setAll(0.0);
  108370. particle.rotation.setAll(0.0);
  108371. particle.rotationQuaternion = null;
  108372. particle.scaling.setAll(1.0);
  108373. particle.uvs.setAll(0.0);
  108374. particle.pivot.setAll(0.0);
  108375. particle.translateFromPivot = false;
  108376. particle.parentId = null;
  108377. };
  108378. /**
  108379. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  108380. * @returns the SPS.
  108381. */
  108382. SolidParticleSystem.prototype.rebuildMesh = function () {
  108383. for (var p = 0; p < this.particles.length; p++) {
  108384. this._rebuildParticle(this.particles[p]);
  108385. }
  108386. this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this._positions32, false, false);
  108387. return this;
  108388. };
  108389. /**
  108390. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  108391. * This method calls `updateParticle()` for each particle of the SPS.
  108392. * For an animated SPS, it is usually called within the render loop.
  108393. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  108394. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  108395. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  108396. * @returns the SPS.
  108397. */
  108398. SolidParticleSystem.prototype.setParticles = function (start, end, update) {
  108399. if (start === void 0) { start = 0; }
  108400. if (end === void 0) { end = this.nbParticles - 1; }
  108401. if (update === void 0) { update = true; }
  108402. if (!this._updatable) {
  108403. return this;
  108404. }
  108405. // custom beforeUpdate
  108406. this.beforeUpdateParticles(start, end, update);
  108407. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  108408. var invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  108409. var mesh = this.mesh;
  108410. var colors32 = this._colors32;
  108411. var positions32 = this._positions32;
  108412. var normals32 = this._normals32;
  108413. var uvs32 = this._uvs32;
  108414. var indices32 = this._indices32;
  108415. var indices = this._indices;
  108416. var fixedNormal32 = this._fixedNormal32;
  108417. var tempVectors = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3;
  108418. var camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
  108419. var camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
  108420. var camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
  108421. var minimum = tempVectors[8].setAll(Number.MAX_VALUE);
  108422. var maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
  108423. var camInvertedPosition = tempVectors[10].setAll(0);
  108424. // cases when the World Matrix is to be computed first
  108425. if (this.billboard || this._depthSort) {
  108426. this.mesh.computeWorldMatrix(true);
  108427. this.mesh._worldMatrix.invertToRef(invertedMatrix);
  108428. }
  108429. // if the particles will always face the camera
  108430. if (this.billboard) {
  108431. // compute the camera position and un-rotate it by the current mesh rotation
  108432. var tmpVertex = tempVectors[0];
  108433. this._camera.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Z, tmpVertex);
  108434. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, invertedMatrix, camAxisZ);
  108435. camAxisZ.normalize();
  108436. // same for camera up vector extracted from the cam view matrix
  108437. var view = this._camera.getViewMatrix(true);
  108438. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], invertedMatrix, camAxisY);
  108439. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(camAxisY, camAxisZ, camAxisX);
  108440. camAxisY.normalize();
  108441. camAxisX.normalize();
  108442. }
  108443. // if depthSort, compute the camera global position in the mesh local system
  108444. if (this._depthSort) {
  108445. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._camera.globalPosition, invertedMatrix, camInvertedPosition); // then un-rotate the camera
  108446. }
  108447. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(rotMatrix);
  108448. var idx = 0; // current position index in the global array positions32
  108449. var index = 0; // position start index in the global array positions32 of the current particle
  108450. var colidx = 0; // current color index in the global array colors32
  108451. var colorIndex = 0; // color start index in the global array colors32 of the current particle
  108452. var uvidx = 0; // current uv index in the global array uvs32
  108453. var uvIndex = 0; // uv start index in the global array uvs32 of the current particle
  108454. var pt = 0; // current index in the particle model shape
  108455. if (this.mesh.isFacetDataEnabled) {
  108456. this._computeBoundingBox = true;
  108457. }
  108458. end = (end >= this.nbParticles) ? this.nbParticles - 1 : end;
  108459. if (this._computeBoundingBox) {
  108460. if (start != 0 || end != this.nbParticles - 1) { // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
  108461. var boundingInfo = this.mesh._boundingInfo;
  108462. if (boundingInfo) {
  108463. minimum.copyFrom(boundingInfo.minimum);
  108464. maximum.copyFrom(boundingInfo.maximum);
  108465. }
  108466. }
  108467. }
  108468. // particle loop
  108469. index = this.particles[start]._pos;
  108470. var vpos = (index / 3) | 0;
  108471. colorIndex = vpos * 4;
  108472. uvIndex = vpos * 2;
  108473. for (var p = start; p <= end; p++) {
  108474. var particle = this.particles[p];
  108475. // call to custom user function to update the particle properties
  108476. this.updateParticle(particle);
  108477. var shape = particle._model._shape;
  108478. var shapeUV = particle._model._shapeUV;
  108479. var particleRotationMatrix = particle._rotationMatrix;
  108480. var particlePosition = particle.position;
  108481. var particleRotation = particle.rotation;
  108482. var particleScaling = particle.scaling;
  108483. var particleGlobalPosition = particle._globalPosition;
  108484. // camera-particle distance for depth sorting
  108485. if (this._depthSort && this._depthSortParticles) {
  108486. var dsp = this.depthSortedParticles[p];
  108487. dsp.ind = particle._ind;
  108488. dsp.indicesLength = particle._model._indicesLength;
  108489. dsp.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(particle.position, camInvertedPosition);
  108490. }
  108491. // skip the computations for inactive or already invisible particles
  108492. if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
  108493. // increment indexes for the next particle
  108494. pt = shape.length;
  108495. index += pt * 3;
  108496. colorIndex += pt * 4;
  108497. uvIndex += pt * 2;
  108498. continue;
  108499. }
  108500. if (particle.isVisible) {
  108501. particle._stillInvisible = false; // un-mark permanent invisibility
  108502. var scaledPivot = tempVectors[12];
  108503. particle.pivot.multiplyToRef(particleScaling, scaledPivot);
  108504. // particle rotation matrix
  108505. if (this.billboard) {
  108506. particleRotation.x = 0.0;
  108507. particleRotation.y = 0.0;
  108508. }
  108509. if (this._computeParticleRotation || this.billboard) {
  108510. particle.getRotationMatrix(rotMatrix);
  108511. }
  108512. var particleHasParent = (particle.parentId !== null);
  108513. if (particleHasParent) {
  108514. var parent_1 = this.particles[particle.parentId];
  108515. var parentRotationMatrix = parent_1._rotationMatrix;
  108516. var parentGlobalPosition = parent_1._globalPosition;
  108517. var rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
  108518. var rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
  108519. var rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
  108520. particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
  108521. particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
  108522. particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
  108523. if (this._computeParticleRotation || this.billboard) {
  108524. var rotMatrixValues = rotMatrix.m;
  108525. particleRotationMatrix[0] = rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
  108526. particleRotationMatrix[1] = rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
  108527. particleRotationMatrix[2] = rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
  108528. particleRotationMatrix[3] = rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
  108529. particleRotationMatrix[4] = rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
  108530. particleRotationMatrix[5] = rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
  108531. particleRotationMatrix[6] = rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
  108532. particleRotationMatrix[7] = rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
  108533. particleRotationMatrix[8] = rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
  108534. }
  108535. }
  108536. else {
  108537. particleGlobalPosition.x = particlePosition.x;
  108538. particleGlobalPosition.y = particlePosition.y;
  108539. particleGlobalPosition.z = particlePosition.z;
  108540. if (this._computeParticleRotation || this.billboard) {
  108541. var rotMatrixValues = rotMatrix.m;
  108542. particleRotationMatrix[0] = rotMatrixValues[0];
  108543. particleRotationMatrix[1] = rotMatrixValues[1];
  108544. particleRotationMatrix[2] = rotMatrixValues[2];
  108545. particleRotationMatrix[3] = rotMatrixValues[4];
  108546. particleRotationMatrix[4] = rotMatrixValues[5];
  108547. particleRotationMatrix[5] = rotMatrixValues[6];
  108548. particleRotationMatrix[6] = rotMatrixValues[8];
  108549. particleRotationMatrix[7] = rotMatrixValues[9];
  108550. particleRotationMatrix[8] = rotMatrixValues[10];
  108551. }
  108552. }
  108553. var pivotBackTranslation = tempVectors[11];
  108554. if (particle.translateFromPivot) {
  108555. pivotBackTranslation.setAll(0.0);
  108556. }
  108557. else {
  108558. pivotBackTranslation.copyFrom(scaledPivot);
  108559. }
  108560. // particle vertex loop
  108561. for (pt = 0; pt < shape.length; pt++) {
  108562. idx = index + pt * 3;
  108563. colidx = colorIndex + pt * 4;
  108564. uvidx = uvIndex + pt * 2;
  108565. var tmpVertex = tempVectors[0];
  108566. tmpVertex.copyFrom(shape[pt]);
  108567. if (this._computeParticleVertex) {
  108568. this.updateParticleVertex(particle, tmpVertex, pt);
  108569. }
  108570. // positions
  108571. var vertexX = tmpVertex.x * particleScaling.x - scaledPivot.x;
  108572. var vertexY = tmpVertex.y * particleScaling.y - scaledPivot.y;
  108573. var vertexZ = tmpVertex.z * particleScaling.z - scaledPivot.z;
  108574. var rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
  108575. var rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
  108576. var rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
  108577. rotatedX += pivotBackTranslation.x;
  108578. rotatedY += pivotBackTranslation.y;
  108579. rotatedZ += pivotBackTranslation.z;
  108580. var px = positions32[idx] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  108581. var py = positions32[idx + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  108582. var pz = positions32[idx + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  108583. if (this._computeBoundingBox) {
  108584. minimum.minimizeInPlaceFromFloats(px, py, pz);
  108585. maximum.maximizeInPlaceFromFloats(px, py, pz);
  108586. }
  108587. // normals : if the particles can't be morphed then just rotate the normals, what is much more faster than ComputeNormals()
  108588. if (!this._computeParticleVertex) {
  108589. var normalx = fixedNormal32[idx];
  108590. var normaly = fixedNormal32[idx + 1];
  108591. var normalz = fixedNormal32[idx + 2];
  108592. var rotatedx = normalx * particleRotationMatrix[0] + normaly * particleRotationMatrix[3] + normalz * particleRotationMatrix[6];
  108593. var rotatedy = normalx * particleRotationMatrix[1] + normaly * particleRotationMatrix[4] + normalz * particleRotationMatrix[7];
  108594. var rotatedz = normalx * particleRotationMatrix[2] + normaly * particleRotationMatrix[5] + normalz * particleRotationMatrix[8];
  108595. normals32[idx] = camAxisX.x * rotatedx + camAxisY.x * rotatedy + camAxisZ.x * rotatedz;
  108596. normals32[idx + 1] = camAxisX.y * rotatedx + camAxisY.y * rotatedy + camAxisZ.y * rotatedz;
  108597. normals32[idx + 2] = camAxisX.z * rotatedx + camAxisY.z * rotatedy + camAxisZ.z * rotatedz;
  108598. }
  108599. if (this._computeParticleColor && particle.color) {
  108600. var color = particle.color;
  108601. var colors32_1 = this._colors32;
  108602. colors32_1[colidx] = color.r;
  108603. colors32_1[colidx + 1] = color.g;
  108604. colors32_1[colidx + 2] = color.b;
  108605. colors32_1[colidx + 3] = color.a;
  108606. }
  108607. if (this._computeParticleTexture) {
  108608. var uvs = particle.uvs;
  108609. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  108610. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  108611. }
  108612. }
  108613. }
  108614. // particle just set invisible : scaled to zero and positioned at the origin
  108615. else {
  108616. particle._stillInvisible = true; // mark the particle as invisible
  108617. for (pt = 0; pt < shape.length; pt++) {
  108618. idx = index + pt * 3;
  108619. colidx = colorIndex + pt * 4;
  108620. uvidx = uvIndex + pt * 2;
  108621. positions32[idx] = positions32[idx + 1] = positions32[idx + 2] = 0;
  108622. normals32[idx] = normals32[idx + 1] = normals32[idx + 2] = 0;
  108623. if (this._computeParticleColor && particle.color) {
  108624. var color = particle.color;
  108625. colors32[colidx] = color.r;
  108626. colors32[colidx + 1] = color.g;
  108627. colors32[colidx + 2] = color.b;
  108628. colors32[colidx + 3] = color.a;
  108629. }
  108630. if (this._computeParticleTexture) {
  108631. var uvs = particle.uvs;
  108632. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  108633. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  108634. }
  108635. }
  108636. }
  108637. // if the particle intersections must be computed : update the bbInfo
  108638. if (this._particlesIntersect) {
  108639. var bInfo = particle._boundingInfo;
  108640. var bBox = bInfo.boundingBox;
  108641. var bSphere = bInfo.boundingSphere;
  108642. var modelBoundingInfo = particle._modelBoundingInfo;
  108643. if (!this._bSphereOnly) {
  108644. // place, scale and rotate the particle bbox within the SPS local system, then update it
  108645. var modelBoundingInfoVectors = modelBoundingInfo.boundingBox.vectors;
  108646. var tempMin = tempVectors[1];
  108647. var tempMax = tempVectors[2];
  108648. tempMin.setAll(Number.MAX_VALUE);
  108649. tempMax.setAll(-Number.MAX_VALUE);
  108650. for (var b = 0; b < 8; b++) {
  108651. var scaledX = modelBoundingInfoVectors[b].x * particleScaling.x;
  108652. var scaledY = modelBoundingInfoVectors[b].y * particleScaling.y;
  108653. var scaledZ = modelBoundingInfoVectors[b].z * particleScaling.z;
  108654. var rotatedX = scaledX * particleRotationMatrix[0] + scaledY * particleRotationMatrix[3] + scaledZ * particleRotationMatrix[6];
  108655. var rotatedY = scaledX * particleRotationMatrix[1] + scaledY * particleRotationMatrix[4] + scaledZ * particleRotationMatrix[7];
  108656. var rotatedZ = scaledX * particleRotationMatrix[2] + scaledY * particleRotationMatrix[5] + scaledZ * particleRotationMatrix[8];
  108657. var x = particlePosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  108658. var y = particlePosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  108659. var z = particlePosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  108660. tempMin.minimizeInPlaceFromFloats(x, y, z);
  108661. tempMax.maximizeInPlaceFromFloats(x, y, z);
  108662. }
  108663. bBox.reConstruct(tempMin, tempMax, mesh._worldMatrix);
  108664. }
  108665. // place and scale the particle bouding sphere in the SPS local system, then update it
  108666. var minBbox = modelBoundingInfo.minimum.multiplyToRef(particleScaling, tempVectors[1]);
  108667. var maxBbox = modelBoundingInfo.maximum.multiplyToRef(particleScaling, tempVectors[2]);
  108668. var bSphereCenter = maxBbox.addToRef(minBbox, tempVectors[3]).scaleInPlace(0.5).addInPlace(particleGlobalPosition);
  108669. var halfDiag = maxBbox.subtractToRef(minBbox, tempVectors[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor);
  108670. var bSphereMinBbox = bSphereCenter.subtractToRef(halfDiag, tempVectors[1]);
  108671. var bSphereMaxBbox = bSphereCenter.addToRef(halfDiag, tempVectors[2]);
  108672. bSphere.reConstruct(bSphereMinBbox, bSphereMaxBbox, mesh._worldMatrix);
  108673. }
  108674. // increment indexes for the next particle
  108675. index = idx + 3;
  108676. colorIndex = colidx + 4;
  108677. uvIndex = uvidx + 2;
  108678. }
  108679. // if the VBO must be updated
  108680. if (update) {
  108681. if (this._computeParticleColor) {
  108682. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, colors32, false, false);
  108683. }
  108684. if (this._computeParticleTexture) {
  108685. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs32, false, false);
  108686. }
  108687. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, positions32, false, false);
  108688. if (!mesh.areNormalsFrozen || mesh.isFacetDataEnabled) {
  108689. if (this._computeParticleVertex || mesh.isFacetDataEnabled) {
  108690. // recompute the normals only if the particles can be morphed, update then also the normal reference array _fixedNormal32[]
  108691. var params = mesh.isFacetDataEnabled ? mesh.getFacetDataParameters() : null;
  108692. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions32, indices32, normals32, params);
  108693. for (var i = 0; i < normals32.length; i++) {
  108694. fixedNormal32[i] = normals32[i];
  108695. }
  108696. }
  108697. if (!mesh.areNormalsFrozen) {
  108698. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals32, false, false);
  108699. }
  108700. }
  108701. if (this._depthSort && this._depthSortParticles) {
  108702. var depthSortedParticles = this.depthSortedParticles;
  108703. depthSortedParticles.sort(depthSortFunction);
  108704. var dspl = depthSortedParticles.length;
  108705. var sid = 0;
  108706. for (var sorted = 0; sorted < dspl; sorted++) {
  108707. var lind = depthSortedParticles[sorted].indicesLength;
  108708. var sind = depthSortedParticles[sorted].ind;
  108709. for (var i = 0; i < lind; i++) {
  108710. indices32[sid] = indices[sind + i];
  108711. sid++;
  108712. }
  108713. }
  108714. mesh.updateIndices(indices32);
  108715. }
  108716. }
  108717. if (this._computeBoundingBox) {
  108718. if (mesh._boundingInfo) {
  108719. mesh._boundingInfo.reConstruct(minimum, maximum, mesh._worldMatrix);
  108720. }
  108721. else {
  108722. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](minimum, maximum, mesh._worldMatrix);
  108723. }
  108724. }
  108725. this.afterUpdateParticles(start, end, update);
  108726. return this;
  108727. };
  108728. /**
  108729. * Disposes the SPS.
  108730. */
  108731. SolidParticleSystem.prototype.dispose = function () {
  108732. this.mesh.dispose();
  108733. this.vars = null;
  108734. // drop references to internal big arrays for the GC
  108735. this._positions = null;
  108736. this._indices = null;
  108737. this._normals = null;
  108738. this._uvs = null;
  108739. this._colors = null;
  108740. this._indices32 = null;
  108741. this._positions32 = null;
  108742. this._normals32 = null;
  108743. this._fixedNormal32 = null;
  108744. this._uvs32 = null;
  108745. this._colors32 = null;
  108746. this.pickedParticles = null;
  108747. };
  108748. /**
  108749. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  108750. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108751. * @returns the SPS.
  108752. */
  108753. SolidParticleSystem.prototype.refreshVisibleSize = function () {
  108754. if (!this._isVisibilityBoxLocked) {
  108755. this.mesh.refreshBoundingInfo();
  108756. }
  108757. return this;
  108758. };
  108759. /**
  108760. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  108761. * @param size the size (float) of the visibility box
  108762. * note : this doesn't lock the SPS mesh bounding box.
  108763. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108764. */
  108765. SolidParticleSystem.prototype.setVisibilityBox = function (size) {
  108766. var vis = size / 2;
  108767. 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));
  108768. };
  108769. Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
  108770. /**
  108771. * Gets whether the SPS as always visible or not
  108772. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108773. */
  108774. get: function () {
  108775. return this._alwaysVisible;
  108776. },
  108777. /**
  108778. * Sets the SPS as always visible or not
  108779. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108780. */
  108781. set: function (val) {
  108782. this._alwaysVisible = val;
  108783. this.mesh.alwaysSelectAsActiveMesh = val;
  108784. },
  108785. enumerable: true,
  108786. configurable: true
  108787. });
  108788. Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
  108789. /**
  108790. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108791. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108792. */
  108793. get: function () {
  108794. return this._isVisibilityBoxLocked;
  108795. },
  108796. /**
  108797. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108798. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  108799. */
  108800. set: function (val) {
  108801. this._isVisibilityBoxLocked = val;
  108802. var boundingInfo = this.mesh.getBoundingInfo();
  108803. boundingInfo.isLocked = val;
  108804. },
  108805. enumerable: true,
  108806. configurable: true
  108807. });
  108808. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
  108809. /**
  108810. * Gets if `setParticles()` computes the particle rotations or not.
  108811. * Default value : true. The SPS is faster when it's set to false.
  108812. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108813. */
  108814. get: function () {
  108815. return this._computeParticleRotation;
  108816. },
  108817. /**
  108818. * Tells to `setParticles()` to compute the particle rotations or not.
  108819. * Default value : true. The SPS is faster when it's set to false.
  108820. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108821. */
  108822. set: function (val) {
  108823. this._computeParticleRotation = val;
  108824. },
  108825. enumerable: true,
  108826. configurable: true
  108827. });
  108828. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
  108829. /**
  108830. * Gets if `setParticles()` computes the particle colors or not.
  108831. * Default value : true. The SPS is faster when it's set to false.
  108832. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108833. */
  108834. get: function () {
  108835. return this._computeParticleColor;
  108836. },
  108837. /**
  108838. * Tells to `setParticles()` to compute the particle colors or not.
  108839. * Default value : true. The SPS is faster when it's set to false.
  108840. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108841. */
  108842. set: function (val) {
  108843. this._computeParticleColor = val;
  108844. },
  108845. enumerable: true,
  108846. configurable: true
  108847. });
  108848. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
  108849. /**
  108850. * Gets if `setParticles()` computes the particle textures or not.
  108851. * Default value : true. The SPS is faster when it's set to false.
  108852. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  108853. */
  108854. get: function () {
  108855. return this._computeParticleTexture;
  108856. },
  108857. set: function (val) {
  108858. this._computeParticleTexture = val;
  108859. },
  108860. enumerable: true,
  108861. configurable: true
  108862. });
  108863. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
  108864. /**
  108865. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  108866. * Default value : false. The SPS is faster when it's set to false.
  108867. * Note : the particle custom vertex positions aren't stored values.
  108868. */
  108869. get: function () {
  108870. return this._computeParticleVertex;
  108871. },
  108872. /**
  108873. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  108874. * Default value : false. The SPS is faster when it's set to false.
  108875. * Note : the particle custom vertex positions aren't stored values.
  108876. */
  108877. set: function (val) {
  108878. this._computeParticleVertex = val;
  108879. },
  108880. enumerable: true,
  108881. configurable: true
  108882. });
  108883. Object.defineProperty(SolidParticleSystem.prototype, "computeBoundingBox", {
  108884. /**
  108885. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  108886. */
  108887. get: function () {
  108888. return this._computeBoundingBox;
  108889. },
  108890. /**
  108891. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  108892. */
  108893. set: function (val) {
  108894. this._computeBoundingBox = val;
  108895. },
  108896. enumerable: true,
  108897. configurable: true
  108898. });
  108899. Object.defineProperty(SolidParticleSystem.prototype, "depthSortParticles", {
  108900. /**
  108901. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  108902. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108903. * Default : `true`
  108904. */
  108905. get: function () {
  108906. return this._depthSortParticles;
  108907. },
  108908. /**
  108909. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  108910. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108911. * Default : `true`
  108912. */
  108913. set: function (val) {
  108914. this._depthSortParticles = val;
  108915. },
  108916. enumerable: true,
  108917. configurable: true
  108918. });
  108919. // =======================================================================
  108920. // Particle behavior logic
  108921. // these following methods may be overwritten by the user to fit his needs
  108922. /**
  108923. * This function does nothing. It may be overwritten to set all the particle first values.
  108924. * The SPS doesn't call this function, you may have to call it by your own.
  108925. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  108926. */
  108927. SolidParticleSystem.prototype.initParticles = function () {
  108928. };
  108929. /**
  108930. * This function does nothing. It may be overwritten to recycle a particle.
  108931. * The SPS doesn't call this function, you may have to call it by your own.
  108932. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  108933. * @param particle The particle to recycle
  108934. * @returns the recycled particle
  108935. */
  108936. SolidParticleSystem.prototype.recycleParticle = function (particle) {
  108937. return particle;
  108938. };
  108939. /**
  108940. * Updates a particle : this function should be overwritten by the user.
  108941. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  108942. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  108943. * @example : just set a particle position or velocity and recycle conditions
  108944. * @param particle The particle to update
  108945. * @returns the updated particle
  108946. */
  108947. SolidParticleSystem.prototype.updateParticle = function (particle) {
  108948. return particle;
  108949. };
  108950. /**
  108951. * Updates a vertex of a particle : it can be overwritten by the user.
  108952. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  108953. * @param particle the current particle
  108954. * @param vertex the current index of the current particle
  108955. * @param pt the index of the current vertex in the particle shape
  108956. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  108957. * @example : just set a vertex particle position
  108958. * @returns the updated vertex
  108959. */
  108960. SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, pt) {
  108961. return vertex;
  108962. };
  108963. /**
  108964. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  108965. * This does nothing and may be overwritten by the user.
  108966. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108967. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108968. * @param update the boolean update value actually passed to setParticles()
  108969. */
  108970. SolidParticleSystem.prototype.beforeUpdateParticles = function (start, stop, update) {
  108971. };
  108972. /**
  108973. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  108974. * This will be passed three parameters.
  108975. * This does nothing and may be overwritten by the user.
  108976. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108977. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108978. * @param update the boolean update value actually passed to setParticles()
  108979. */
  108980. SolidParticleSystem.prototype.afterUpdateParticles = function (start, stop, update) {
  108981. };
  108982. return SolidParticleSystem;
  108983. }());
  108984. /***/ }),
  108985. /***/ "./Particles/subEmitter.ts":
  108986. /*!*********************************!*\
  108987. !*** ./Particles/subEmitter.ts ***!
  108988. \*********************************/
  108989. /*! exports provided: SubEmitterType, SubEmitter */
  108990. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108991. "use strict";
  108992. __webpack_require__.r(__webpack_exports__);
  108993. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return SubEmitterType; });
  108994. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return SubEmitter; });
  108995. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  108996. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  108997. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  108998. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  108999. /**
  109000. * Type of sub emitter
  109001. */
  109002. var SubEmitterType;
  109003. (function (SubEmitterType) {
  109004. /**
  109005. * Attached to the particle over it's lifetime
  109006. */
  109007. SubEmitterType[SubEmitterType["ATTACHED"] = 0] = "ATTACHED";
  109008. /**
  109009. * Created when the particle dies
  109010. */
  109011. SubEmitterType[SubEmitterType["END"] = 1] = "END";
  109012. })(SubEmitterType || (SubEmitterType = {}));
  109013. /**
  109014. * Sub emitter class used to emit particles from an existing particle
  109015. */
  109016. var SubEmitter = /** @class */ (function () {
  109017. /**
  109018. * Creates a sub emitter
  109019. * @param particleSystem the particle system to be used by the sub emitter
  109020. */
  109021. function SubEmitter(
  109022. /**
  109023. * the particle system to be used by the sub emitter
  109024. */
  109025. particleSystem) {
  109026. this.particleSystem = particleSystem;
  109027. /**
  109028. * Type of the submitter (Default: END)
  109029. */
  109030. this.type = SubEmitterType.END;
  109031. /**
  109032. * 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)
  109033. * Note: This only is supported when using an emitter of type Mesh
  109034. */
  109035. this.inheritDirection = false;
  109036. /**
  109037. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  109038. */
  109039. this.inheritedVelocityAmount = 0;
  109040. // Create mesh as emitter to support rotation
  109041. if (!particleSystem.emitter || !particleSystem.emitter.dispose) {
  109042. particleSystem.emitter = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("SubemitterSystemEmitter", particleSystem.getScene());
  109043. }
  109044. // Automatically dispose of subemitter when system is disposed
  109045. particleSystem.onDisposeObservable.add(function () {
  109046. if (particleSystem.emitter && particleSystem.emitter.dispose) {
  109047. particleSystem.emitter.dispose();
  109048. }
  109049. });
  109050. }
  109051. /**
  109052. * Clones the sub emitter
  109053. * @returns the cloned sub emitter
  109054. */
  109055. SubEmitter.prototype.clone = function () {
  109056. // Clone particle system
  109057. var emitter = this.particleSystem.emitter;
  109058. if (!emitter) {
  109059. emitter = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  109060. }
  109061. else if (emitter instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  109062. emitter = emitter.clone();
  109063. }
  109064. else if (emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  109065. emitter = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", emitter.getScene());
  109066. emitter.isVisible = false;
  109067. }
  109068. var clone = new SubEmitter(this.particleSystem.clone("", emitter));
  109069. // Clone properties
  109070. clone.type = this.type;
  109071. clone.inheritDirection = this.inheritDirection;
  109072. clone.inheritedVelocityAmount = this.inheritedVelocityAmount;
  109073. clone.particleSystem._disposeEmitterOnDispose = true;
  109074. clone.particleSystem.disposeOnStop = true;
  109075. return clone;
  109076. };
  109077. /**
  109078. * Serialize current object to a JSON object
  109079. * @returns the serialized object
  109080. */
  109081. SubEmitter.prototype.serialize = function () {
  109082. var serializationObject = {};
  109083. serializationObject.type = this.type;
  109084. serializationObject.inheritDirection = this.inheritDirection;
  109085. serializationObject.inheritedVelocityAmount = this.inheritedVelocityAmount;
  109086. serializationObject.particleSystem = this.particleSystem.serialize();
  109087. return serializationObject;
  109088. };
  109089. /** @hidden */
  109090. SubEmitter._ParseParticleSystem = function (system, scene, rootUrl) {
  109091. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("ParseParticle");
  109092. };
  109093. /**
  109094. * Creates a new SubEmitter from a serialized JSON version
  109095. * @param serializationObject defines the JSON object to read from
  109096. * @param scene defines the hosting scene
  109097. * @param rootUrl defines the rootUrl for data loading
  109098. * @returns a new SubEmitter
  109099. */
  109100. SubEmitter.Parse = function (serializationObject, scene, rootUrl) {
  109101. var system = serializationObject.particleSystem;
  109102. var subEmitter = new SubEmitter(SubEmitter._ParseParticleSystem(system, scene, rootUrl));
  109103. subEmitter.type = serializationObject.type;
  109104. subEmitter.inheritDirection = serializationObject.inheritDirection;
  109105. subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
  109106. subEmitter.particleSystem._isSubEmitter = true;
  109107. return subEmitter;
  109108. };
  109109. /** Release associated resources */
  109110. SubEmitter.prototype.dispose = function () {
  109111. this.particleSystem.dispose();
  109112. };
  109113. return SubEmitter;
  109114. }());
  109115. /***/ }),
  109116. /***/ "./Physics/Plugins/ammoJSPlugin.ts":
  109117. /*!*****************************************!*\
  109118. !*** ./Physics/Plugins/ammoJSPlugin.ts ***!
  109119. \*****************************************/
  109120. /*! exports provided: AmmoJSPlugin */
  109121. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109122. "use strict";
  109123. __webpack_require__.r(__webpack_exports__);
  109124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return AmmoJSPlugin; });
  109125. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  109126. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  109127. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  109128. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  109129. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  109130. /**
  109131. * AmmoJS Physics plugin
  109132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  109133. * @see https://github.com/kripken/ammo.js/
  109134. */
  109135. var AmmoJSPlugin = /** @class */ (function () {
  109136. /**
  109137. * Initializes the ammoJS plugin
  109138. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  109139. * @param ammoInjection can be used to inject your own ammo reference
  109140. */
  109141. function AmmoJSPlugin(_useDeltaForWorldStep, ammoInjection) {
  109142. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  109143. if (ammoInjection === void 0) { ammoInjection = Ammo; }
  109144. var _this = this;
  109145. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  109146. /**
  109147. * Reference to the Ammo library
  109148. */
  109149. this.bjsAMMO = {};
  109150. /**
  109151. * Name of the plugin
  109152. */
  109153. this.name = "AmmoJSPlugin";
  109154. this._timeStep = 1 / 60;
  109155. this._fixedTimeStep = 1 / 60;
  109156. this._maxSteps = 5;
  109157. this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  109158. this._tmpContactCallbackResult = false;
  109159. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  109160. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  109161. if (typeof ammoInjection === "function") {
  109162. ammoInjection(this.bjsAMMO);
  109163. }
  109164. else {
  109165. this.bjsAMMO = ammoInjection;
  109166. }
  109167. if (!this.isSupported()) {
  109168. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("AmmoJS is not available. Please make sure you included the js file.");
  109169. return;
  109170. }
  109171. // Initialize the physics world
  109172. this._collisionConfiguration = new this.bjsAMMO.btDefaultCollisionConfiguration();
  109173. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
  109174. this._overlappingPairCache = new this.bjsAMMO.btDbvtBroadphase();
  109175. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
  109176. this.world = new this.bjsAMMO.btDiscreteDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration);
  109177. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback();
  109178. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function () { _this._tmpContactCallbackResult = true; };
  109179. // Create temp ammo variables
  109180. this._tmpAmmoTransform = new this.bjsAMMO.btTransform();
  109181. this._tmpAmmoTransform.setIdentity();
  109182. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1);
  109183. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0);
  109184. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0);
  109185. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0);
  109186. }
  109187. /**
  109188. * Sets the gravity of the physics world (m/(s^2))
  109189. * @param gravity Gravity to set
  109190. */
  109191. AmmoJSPlugin.prototype.setGravity = function (gravity) {
  109192. this._tmpAmmoVectorA.setValue(gravity.x, gravity.y, gravity.z);
  109193. this.world.setGravity(this._tmpAmmoVectorA);
  109194. };
  109195. /**
  109196. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  109197. * @param timeStep timestep to use in seconds
  109198. */
  109199. AmmoJSPlugin.prototype.setTimeStep = function (timeStep) {
  109200. this._timeStep = timeStep;
  109201. };
  109202. /**
  109203. * 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)
  109204. * @param fixedTimeStep fixedTimeStep to use in seconds
  109205. */
  109206. AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
  109207. this._fixedTimeStep = fixedTimeStep;
  109208. };
  109209. /**
  109210. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  109211. * @param maxSteps the maximum number of steps by the physics engine per frame
  109212. */
  109213. AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
  109214. this._maxSteps = maxSteps;
  109215. };
  109216. /**
  109217. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  109218. * @returns the current timestep in seconds
  109219. */
  109220. AmmoJSPlugin.prototype.getTimeStep = function () {
  109221. return this._timeStep;
  109222. };
  109223. // Ammo's contactTest and contactPairTest take a callback that runs synchronously, wrap them so that they are easier to consume
  109224. AmmoJSPlugin.prototype._isImpostorInContact = function (impostor) {
  109225. this._tmpContactCallbackResult = false;
  109226. this.world.contactTest(impostor.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  109227. return this._tmpContactCallbackResult;
  109228. };
  109229. // Ammo's collision events have some weird quirks
  109230. // contactPairTest fires too many events as it fires events even when objects are close together but contactTest does not
  109231. // so only fire event if both contactTest and contactPairTest have a hit
  109232. AmmoJSPlugin.prototype._isImpostorPairInContact = function (impostorA, impostorB) {
  109233. this._tmpContactCallbackResult = false;
  109234. this.world.contactPairTest(impostorA.physicsBody, impostorB.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  109235. return this._tmpContactCallbackResult;
  109236. };
  109237. // Ammo's behavior when maxSteps > 0 does not behave as described in docs
  109238. // @see http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World
  109239. //
  109240. // When maxSteps is 0 do the entire simulation in one step
  109241. // 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)
  109242. // Note: To get deterministic physics, timeStep would always need to be divisible by fixedTimeStep
  109243. AmmoJSPlugin.prototype._stepSimulation = function (timeStep, maxSteps, fixedTimeStep) {
  109244. if (timeStep === void 0) { timeStep = 1 / 60; }
  109245. if (maxSteps === void 0) { maxSteps = 10; }
  109246. if (fixedTimeStep === void 0) { fixedTimeStep = 1 / 60; }
  109247. if (maxSteps == 0) {
  109248. this.world.stepSimulation(timeStep, 0);
  109249. }
  109250. else {
  109251. while (maxSteps > 0 && timeStep > 0) {
  109252. if (timeStep - fixedTimeStep < fixedTimeStep) {
  109253. this.world.stepSimulation(timeStep, 0);
  109254. timeStep = 0;
  109255. }
  109256. else {
  109257. timeStep -= fixedTimeStep;
  109258. this.world.stepSimulation(fixedTimeStep, 0);
  109259. }
  109260. maxSteps--;
  109261. }
  109262. }
  109263. };
  109264. /**
  109265. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  109266. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  109267. * After the step the babylon meshes are set to the position of the physics imposters
  109268. * @param delta amount of time to step forward
  109269. * @param impostors array of imposters to update before/after the step
  109270. */
  109271. AmmoJSPlugin.prototype.executeStep = function (delta, impostors) {
  109272. for (var _i = 0, impostors_1 = impostors; _i < impostors_1.length; _i++) {
  109273. var impostor = impostors_1[_i];
  109274. // Update physics world objects to match babylon world
  109275. impostor.beforeStep();
  109276. }
  109277. this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
  109278. for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
  109279. var mainImpostor = impostors_2[_a];
  109280. // After physics update make babylon world objects match physics world objects
  109281. mainImpostor.afterStep();
  109282. // Handle collision event
  109283. if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
  109284. if (this._isImpostorInContact(mainImpostor)) {
  109285. for (var _b = 0, _c = mainImpostor._onPhysicsCollideCallbacks; _b < _c.length; _b++) {
  109286. var collideCallback = _c[_b];
  109287. for (var _d = 0, _e = collideCallback.otherImpostors; _d < _e.length; _d++) {
  109288. var otherImpostor = _e[_d];
  109289. if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
  109290. if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
  109291. mainImpostor.onCollide({ body: otherImpostor.physicsBody });
  109292. otherImpostor.onCollide({ body: mainImpostor.physicsBody });
  109293. }
  109294. }
  109295. }
  109296. }
  109297. }
  109298. }
  109299. }
  109300. };
  109301. /**
  109302. * Applies an implulse on the imposter
  109303. * @param impostor imposter to apply impulse
  109304. * @param force amount of force to be applied to the imposter
  109305. * @param contactPoint the location to apply the impulse on the imposter
  109306. */
  109307. AmmoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  109308. impostor.physicsBody.activate();
  109309. var worldPoint = this._tmpAmmoVectorA;
  109310. var impulse = this._tmpAmmoVectorB;
  109311. // Convert contactPoint into world space
  109312. if (impostor.object && impostor.object.getWorldMatrix) {
  109313. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  109314. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  109315. contactPoint = this._tmpVector;
  109316. }
  109317. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  109318. impulse.setValue(force.x, force.y, force.z);
  109319. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  109320. };
  109321. /**
  109322. * Applies a force on the imposter
  109323. * @param impostor imposter to apply force
  109324. * @param force amount of force to be applied to the imposter
  109325. * @param contactPoint the location to apply the force on the imposter
  109326. */
  109327. AmmoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  109328. impostor.physicsBody.activate();
  109329. var worldPoint = this._tmpAmmoVectorA;
  109330. var impulse = this._tmpAmmoVectorB;
  109331. // Convert contactPoint into world space
  109332. if (impostor.object && impostor.object.getWorldMatrix) {
  109333. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  109334. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  109335. contactPoint = this._tmpVector;
  109336. }
  109337. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  109338. impulse.setValue(force.x, force.y, force.z);
  109339. impostor.physicsBody.applyForce(impulse, worldPoint);
  109340. };
  109341. /**
  109342. * Creates a physics body using the plugin
  109343. * @param impostor the imposter to create the physics body on
  109344. */
  109345. AmmoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  109346. impostor._pluginData = { toDispose: [] };
  109347. //parent-child relationship
  109348. if (impostor.parent) {
  109349. if (impostor.physicsBody) {
  109350. this.removePhysicsBody(impostor);
  109351. impostor.forceUpdate();
  109352. }
  109353. return;
  109354. }
  109355. if (impostor.isBodyInitRequired()) {
  109356. var colShape = this._createShape(impostor);
  109357. var mass = impostor.getParam("mass");
  109358. impostor._pluginData.mass = mass;
  109359. var localInertia = new Ammo.btVector3(0, 0, 0);
  109360. var startTransform = new Ammo.btTransform();
  109361. startTransform.setIdentity();
  109362. if (mass !== 0) {
  109363. colShape.calculateLocalInertia(mass, localInertia);
  109364. }
  109365. this._tmpAmmoVectorA.setValue(impostor.object.position.x, impostor.object.position.y, impostor.object.position.z);
  109366. this._tmpAmmoQuaternion.setValue(impostor.object.rotationQuaternion.x, impostor.object.rotationQuaternion.y, impostor.object.rotationQuaternion.z, impostor.object.rotationQuaternion.w);
  109367. startTransform.setOrigin(this._tmpAmmoVectorA);
  109368. startTransform.setRotation(this._tmpAmmoQuaternion);
  109369. var myMotionState = new Ammo.btDefaultMotionState(startTransform);
  109370. var rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
  109371. var body = new Ammo.btRigidBody(rbInfo);
  109372. // Make objects kinematic if it's mass is 0
  109373. if (mass === 0) {
  109374. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
  109375. body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  109376. }
  109377. // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
  109378. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor && !colShape.getChildShape) {
  109379. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
  109380. }
  109381. this.world.addRigidBody(body);
  109382. impostor.physicsBody = body;
  109383. this.setBodyRestitution(impostor, impostor.getParam("restitution"));
  109384. this.setBodyFriction(impostor, impostor.getParam("friction"));
  109385. impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
  109386. }
  109387. };
  109388. /**
  109389. * Removes the physics body from the imposter and disposes of the body's memory
  109390. * @param impostor imposter to remove the physics body from
  109391. */
  109392. AmmoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  109393. var _this = this;
  109394. if (this.world) {
  109395. this.world.removeRigidBody(impostor.physicsBody);
  109396. impostor._pluginData.toDispose.forEach(function (d) {
  109397. _this.bjsAMMO.destroy(d);
  109398. });
  109399. }
  109400. };
  109401. /**
  109402. * Generates a joint
  109403. * @param impostorJoint the imposter joint to create the joint with
  109404. */
  109405. AmmoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  109406. var mainBody = impostorJoint.mainImpostor.physicsBody;
  109407. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  109408. if (!mainBody || !connectedBody) {
  109409. return;
  109410. }
  109411. var jointData = impostorJoint.joint.jointData;
  109412. if (!jointData.mainPivot) {
  109413. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109414. }
  109415. if (!jointData.connectedPivot) {
  109416. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109417. }
  109418. var joint;
  109419. switch (impostorJoint.joint.type) {
  109420. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].DistanceJoint:
  109421. var distance = jointData.maxDistance;
  109422. if (distance) {
  109423. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -distance / 2, 0);
  109424. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, distance / 2, 0);
  109425. }
  109426. 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));
  109427. break;
  109428. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].HingeJoint:
  109429. if (!jointData.mainAxis) {
  109430. jointData.mainAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109431. }
  109432. if (!jointData.connectedAxis) {
  109433. jointData.connectedAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  109434. }
  109435. var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
  109436. var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
  109437. 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);
  109438. break;
  109439. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].BallAndSocketJoint:
  109440. 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));
  109441. break;
  109442. default:
  109443. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint");
  109444. 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));
  109445. break;
  109446. }
  109447. this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
  109448. impostorJoint.joint.physicsJoint = joint;
  109449. };
  109450. /**
  109451. * Removes a joint
  109452. * @param impostorJoint the imposter joint to remove the joint from
  109453. */
  109454. AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  109455. if (this.world) {
  109456. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  109457. }
  109458. };
  109459. // adds all verticies (including child verticies) to the triangle mesh
  109460. AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
  109461. var _this = this;
  109462. var triangleCount = 0;
  109463. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  109464. var indices = object.getIndices();
  109465. if (!indices) {
  109466. indices = [];
  109467. }
  109468. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  109469. if (!vertexPositions) {
  109470. vertexPositions = [];
  109471. }
  109472. object.computeWorldMatrix(false);
  109473. var faceCount = indices.length / 3;
  109474. for (var i = 0; i < faceCount; i++) {
  109475. var triPoints = [];
  109476. for (var point = 0; point < 3; point++) {
  109477. 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]);
  109478. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, object.getWorldMatrix());
  109479. v.subtractInPlace(topLevelObject.position);
  109480. var vec;
  109481. if (point == 0) {
  109482. vec = this._tmpAmmoVectorA;
  109483. }
  109484. else if (point == 1) {
  109485. vec = this._tmpAmmoVectorB;
  109486. }
  109487. else {
  109488. vec = this._tmpAmmoVectorC;
  109489. }
  109490. vec.setValue(v.x, v.y, v.z);
  109491. triPoints.push(vec);
  109492. }
  109493. btTriangleMesh.addTriangle(triPoints[0], triPoints[1], triPoints[2]);
  109494. triangleCount++;
  109495. }
  109496. object.getChildMeshes().forEach(function (m) {
  109497. triangleCount += _this._addMeshVerts(btTriangleMesh, topLevelObject, m);
  109498. });
  109499. }
  109500. return triangleCount;
  109501. };
  109502. AmmoJSPlugin.prototype._createShape = function (impostor, ignoreChildren) {
  109503. var _this = this;
  109504. if (ignoreChildren === void 0) { ignoreChildren = false; }
  109505. var object = impostor.object;
  109506. var returnValue;
  109507. var extendSize = impostor.getObjectExtendSize();
  109508. if (!ignoreChildren) {
  109509. var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
  109510. returnValue = new Ammo.btCompoundShape();
  109511. // Add shape of all children to the compound shape
  109512. var childrenAdded = 0;
  109513. meshChildren.forEach(function (childMesh) {
  109514. var childImpostor = childMesh.getPhysicsImpostor();
  109515. if (childImpostor) {
  109516. var shape = _this._createShape(childImpostor);
  109517. // Position needs to be scaled based on parent's scaling
  109518. var parentMat = childMesh.parent.getWorldMatrix().clone();
  109519. var s = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  109520. parentMat.decompose(s);
  109521. _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
  109522. _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
  109523. _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
  109524. returnValue.addChildShape(_this._tmpAmmoTransform, shape);
  109525. childImpostor.dispose();
  109526. childrenAdded++;
  109527. }
  109528. });
  109529. if (childrenAdded > 0) {
  109530. // Add parents shape as a child if present
  109531. if (impostor.type != _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor) {
  109532. var shape = this._createShape(impostor, true);
  109533. if (shape) {
  109534. this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
  109535. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
  109536. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
  109537. returnValue.addChildShape(this._tmpAmmoTransform, shape);
  109538. }
  109539. }
  109540. return returnValue;
  109541. }
  109542. else {
  109543. // If no children with impostors create the actual shape below instead
  109544. Ammo.destroy(returnValue);
  109545. returnValue = null;
  109546. }
  109547. }
  109548. switch (impostor.type) {
  109549. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SphereImpostor:
  109550. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  109551. break;
  109552. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CylinderImpostor:
  109553. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  109554. returnValue = new Ammo.btCylinderShape(this._tmpAmmoVectorA);
  109555. break;
  109556. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].PlaneImpostor:
  109557. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].BoxImpostor:
  109558. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  109559. returnValue = new Ammo.btBoxShape(this._tmpAmmoVectorA);
  109560. break;
  109561. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor:
  109562. var tetraMesh = new Ammo.btTriangleMesh();
  109563. impostor._pluginData.toDispose.concat([tetraMesh]);
  109564. var triangeCount = this._addMeshVerts(tetraMesh, object, object);
  109565. if (triangeCount == 0) {
  109566. returnValue = new Ammo.btCompoundShape();
  109567. }
  109568. else {
  109569. returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
  109570. }
  109571. break;
  109572. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor:
  109573. // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
  109574. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  109575. break;
  109576. default:
  109577. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The impostor type is not currently supported by the ammo plugin.");
  109578. break;
  109579. }
  109580. return returnValue;
  109581. };
  109582. /**
  109583. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  109584. * @param impostor imposter containing the physics body and babylon object
  109585. */
  109586. AmmoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  109587. impostor.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  109588. impostor.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z());
  109589. if (!impostor.object.rotationQuaternion) {
  109590. if (impostor.object.rotation) {
  109591. this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  109592. this._tmpQuaternion.toEulerAnglesToRef(impostor.object.rotation);
  109593. }
  109594. }
  109595. else {
  109596. impostor.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  109597. }
  109598. };
  109599. /**
  109600. * Sets the babylon object's position/rotation from the physics body's position/rotation
  109601. * @param impostor imposter containing the physics body and babylon object
  109602. * @param newPosition new position
  109603. * @param newRotation new rotation
  109604. */
  109605. AmmoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  109606. var trans = impostor.physicsBody.getWorldTransform();
  109607. // If rotation/position has changed update and activate riged body
  109608. if (trans.getOrigin().x() != newPosition.x ||
  109609. trans.getOrigin().y() != newPosition.y ||
  109610. trans.getOrigin().z() != newPosition.z ||
  109611. trans.getRotation().x() != newRotation.x ||
  109612. trans.getRotation().y() != newRotation.y ||
  109613. trans.getRotation().z() != newRotation.z ||
  109614. trans.getRotation().w() != newRotation.w) {
  109615. this._tmpAmmoVectorA.setValue(newPosition.x, newPosition.y, newPosition.z);
  109616. trans.setOrigin(this._tmpAmmoVectorA);
  109617. this._tmpAmmoQuaternion.setValue(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
  109618. trans.setRotation(this._tmpAmmoQuaternion);
  109619. impostor.physicsBody.setWorldTransform(trans);
  109620. if (impostor.mass == 0) {
  109621. // Kinematic objects must be updated using motion state
  109622. var motionState = impostor.physicsBody.getMotionState();
  109623. if (motionState) {
  109624. motionState.setWorldTransform(trans);
  109625. }
  109626. }
  109627. else {
  109628. impostor.physicsBody.activate();
  109629. }
  109630. }
  109631. };
  109632. /**
  109633. * If this plugin is supported
  109634. * @returns true if its supported
  109635. */
  109636. AmmoJSPlugin.prototype.isSupported = function () {
  109637. return this.bjsAMMO !== undefined;
  109638. };
  109639. /**
  109640. * Sets the linear velocity of the physics body
  109641. * @param impostor imposter to set the velocity on
  109642. * @param velocity velocity to set
  109643. */
  109644. AmmoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  109645. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  109646. impostor.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
  109647. };
  109648. /**
  109649. * Sets the angular velocity of the physics body
  109650. * @param impostor imposter to set the velocity on
  109651. * @param velocity velocity to set
  109652. */
  109653. AmmoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  109654. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  109655. impostor.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
  109656. };
  109657. /**
  109658. * gets the linear velocity
  109659. * @param impostor imposter to get linear velocity from
  109660. * @returns linear velocity
  109661. */
  109662. AmmoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  109663. var v = impostor.physicsBody.getLinearVelocity();
  109664. if (!v) {
  109665. return null;
  109666. }
  109667. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  109668. };
  109669. /**
  109670. * gets the angular velocity
  109671. * @param impostor imposter to get angular velocity from
  109672. * @returns angular velocity
  109673. */
  109674. AmmoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  109675. var v = impostor.physicsBody.getAngularVelocity();
  109676. if (!v) {
  109677. return null;
  109678. }
  109679. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  109680. };
  109681. /**
  109682. * Sets the mass of physics body
  109683. * @param impostor imposter to set the mass on
  109684. * @param mass mass to set
  109685. */
  109686. AmmoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  109687. impostor.physicsBody.setMassProps(mass);
  109688. impostor._pluginData.mass = mass;
  109689. };
  109690. /**
  109691. * Gets the mass of the physics body
  109692. * @param impostor imposter to get the mass from
  109693. * @returns mass
  109694. */
  109695. AmmoJSPlugin.prototype.getBodyMass = function (impostor) {
  109696. return impostor._pluginData.mass;
  109697. };
  109698. /**
  109699. * Gets friction of the impostor
  109700. * @param impostor impostor to get friction from
  109701. * @returns friction value
  109702. */
  109703. AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
  109704. return impostor._pluginData.friction;
  109705. };
  109706. /**
  109707. * Sets friction of the impostor
  109708. * @param impostor impostor to set friction on
  109709. * @param friction friction value
  109710. */
  109711. AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  109712. impostor.physicsBody.setFriction(friction);
  109713. impostor._pluginData.friction = friction;
  109714. };
  109715. /**
  109716. * Gets restitution of the impostor
  109717. * @param impostor impostor to get restitution from
  109718. * @returns restitution value
  109719. */
  109720. AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  109721. return impostor._pluginData.restitution;
  109722. };
  109723. /**
  109724. * Sets resitution of the impostor
  109725. * @param impostor impostor to set resitution on
  109726. * @param restitution resitution value
  109727. */
  109728. AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  109729. impostor.physicsBody.setRestitution(restitution);
  109730. impostor._pluginData.restitution = restitution;
  109731. };
  109732. /**
  109733. * Sleeps the physics body and stops it from being active
  109734. * @param impostor impostor to sleep
  109735. */
  109736. AmmoJSPlugin.prototype.sleepBody = function (impostor) {
  109737. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("sleepBody is not currently supported by the Ammo physics plugin");
  109738. };
  109739. /**
  109740. * Activates the physics body
  109741. * @param impostor impostor to activate
  109742. */
  109743. AmmoJSPlugin.prototype.wakeUpBody = function (impostor) {
  109744. impostor.physicsBody.activate();
  109745. };
  109746. /**
  109747. * Updates the distance parameters of the joint
  109748. * @param joint joint to update
  109749. * @param maxDistance maximum distance of the joint
  109750. * @param minDistance minimum distance of the joint
  109751. */
  109752. AmmoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  109753. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
  109754. };
  109755. /**
  109756. * Sets a motor on the joint
  109757. * @param joint joint to set motor on
  109758. * @param speed speed of the motor
  109759. * @param maxForce maximum force of the motor
  109760. * @param motorIndex index of the motor
  109761. */
  109762. AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  109763. joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
  109764. };
  109765. /**
  109766. * Sets the motors limit
  109767. * @param joint joint to set limit on
  109768. * @param upperLimit upper limit
  109769. * @param lowerLimit lower limit
  109770. */
  109771. AmmoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  109772. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("setLimit is not currently supported by the Ammo physics plugin");
  109773. };
  109774. /**
  109775. * Syncs the position and rotation of a mesh with the impostor
  109776. * @param mesh mesh to sync
  109777. * @param impostor impostor to update the mesh with
  109778. */
  109779. AmmoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  109780. var body = impostor.physicsBody;
  109781. body.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  109782. mesh.position.x = this._tmpAmmoTransform.getOrigin().x();
  109783. mesh.position.y = this._tmpAmmoTransform.getOrigin().y();
  109784. mesh.position.z = this._tmpAmmoTransform.getOrigin().z();
  109785. if (mesh.rotationQuaternion) {
  109786. mesh.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x();
  109787. mesh.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y();
  109788. mesh.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z();
  109789. mesh.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w();
  109790. }
  109791. };
  109792. /**
  109793. * Gets the radius of the impostor
  109794. * @param impostor impostor to get radius from
  109795. * @returns the radius
  109796. */
  109797. AmmoJSPlugin.prototype.getRadius = function (impostor) {
  109798. var exntend = impostor.getObjectExtendSize();
  109799. return exntend.x / 2;
  109800. };
  109801. /**
  109802. * Gets the box size of the impostor
  109803. * @param impostor impostor to get box size from
  109804. * @param result the resulting box size
  109805. */
  109806. AmmoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  109807. var exntend = impostor.getObjectExtendSize();
  109808. result.x = exntend.x;
  109809. result.y = exntend.y;
  109810. result.z = exntend.z;
  109811. };
  109812. /**
  109813. * Disposes of the impostor
  109814. */
  109815. AmmoJSPlugin.prototype.dispose = function () {
  109816. // Dispose of world
  109817. Ammo.destroy(this.world);
  109818. Ammo.destroy(this._solver);
  109819. Ammo.destroy(this._overlappingPairCache);
  109820. Ammo.destroy(this._dispatcher);
  109821. Ammo.destroy(this._collisionConfiguration);
  109822. // Dispose of tmp variables
  109823. Ammo.destroy(this._tmpAmmoVectorA);
  109824. Ammo.destroy(this._tmpAmmoVectorB);
  109825. Ammo.destroy(this._tmpAmmoVectorC);
  109826. Ammo.destroy(this._tmpAmmoTransform);
  109827. Ammo.destroy(this._tmpAmmoQuaternion);
  109828. Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
  109829. this.world = null;
  109830. };
  109831. AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
  109832. AmmoJSPlugin.KINEMATIC_FLAG = 2;
  109833. AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
  109834. return AmmoJSPlugin;
  109835. }());
  109836. /***/ }),
  109837. /***/ "./Physics/Plugins/cannonJSPlugin.ts":
  109838. /*!*******************************************!*\
  109839. !*** ./Physics/Plugins/cannonJSPlugin.ts ***!
  109840. \*******************************************/
  109841. /*! exports provided: CannonJSPlugin */
  109842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109843. "use strict";
  109844. __webpack_require__.r(__webpack_exports__);
  109845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return CannonJSPlugin; });
  109846. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  109847. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  109848. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  109849. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  109850. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  109851. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  109852. /** @hidden */
  109853. var CannonJSPlugin = /** @class */ (function () {
  109854. function CannonJSPlugin(_useDeltaForWorldStep, iterations, cannonInjection) {
  109855. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  109856. if (iterations === void 0) { iterations = 10; }
  109857. if (cannonInjection === void 0) { cannonInjection = CANNON; }
  109858. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  109859. this.name = "CannonJSPlugin";
  109860. this._physicsMaterials = new Array();
  109861. this._fixedTimeStep = 1 / 60;
  109862. this._minus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-0.7071067811865475, 0, 0, 0.7071067811865475);
  109863. this._plus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](0.7071067811865475, 0, 0, 0.7071067811865475);
  109864. this._tmpPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  109865. this._tmpDeltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  109866. this._tmpUnityRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  109867. this.BJSCANNON = cannonInjection;
  109868. if (!this.isSupported()) {
  109869. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("CannonJS is not available. Please make sure you included the js file.");
  109870. return;
  109871. }
  109872. this._extendNamespace();
  109873. this.world = new this.BJSCANNON.World();
  109874. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();
  109875. this.world.solver.iterations = iterations;
  109876. }
  109877. CannonJSPlugin.prototype.setGravity = function (gravity) {
  109878. this.world.gravity.copy(gravity);
  109879. };
  109880. CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
  109881. this._fixedTimeStep = timeStep;
  109882. };
  109883. CannonJSPlugin.prototype.getTimeStep = function () {
  109884. return this._fixedTimeStep;
  109885. };
  109886. CannonJSPlugin.prototype.executeStep = function (delta) {
  109887. this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
  109888. };
  109889. CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  109890. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  109891. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  109892. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  109893. };
  109894. CannonJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  109895. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  109896. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  109897. impostor.physicsBody.applyForce(impulse, worldPoint);
  109898. };
  109899. CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  109900. //parent-child relationship. Does this impostor has a parent impostor?
  109901. if (impostor.parent) {
  109902. if (impostor.physicsBody) {
  109903. this.removePhysicsBody(impostor);
  109904. //TODO is that needed?
  109905. impostor.forceUpdate();
  109906. }
  109907. return;
  109908. }
  109909. //should a new body be created for this impostor?
  109910. if (impostor.isBodyInitRequired()) {
  109911. var shape = this._createShape(impostor);
  109912. //unregister events, if body is being changed
  109913. var oldBody = impostor.physicsBody;
  109914. if (oldBody) {
  109915. this.removePhysicsBody(impostor);
  109916. }
  109917. //create the body and material
  109918. var material = this._addMaterial("mat-" + impostor.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
  109919. var bodyCreationObject = {
  109920. mass: impostor.getParam("mass"),
  109921. material: material
  109922. };
  109923. // A simple extend, in case native options were used.
  109924. var nativeOptions = impostor.getParam("nativeOptions");
  109925. for (var key in nativeOptions) {
  109926. if (nativeOptions.hasOwnProperty(key)) {
  109927. bodyCreationObject[key] = nativeOptions[key];
  109928. }
  109929. }
  109930. impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);
  109931. impostor.physicsBody.addEventListener("collide", impostor.onCollide);
  109932. this.world.addEventListener("preStep", impostor.beforeStep);
  109933. this.world.addEventListener("postStep", impostor.afterStep);
  109934. impostor.physicsBody.addShape(shape);
  109935. this.world.add(impostor.physicsBody);
  109936. //try to keep the body moving in the right direction by taking old properties.
  109937. //Should be tested!
  109938. if (oldBody) {
  109939. ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
  109940. impostor.physicsBody[param].copy(oldBody[param]);
  109941. });
  109942. }
  109943. this._processChildMeshes(impostor);
  109944. }
  109945. //now update the body's transformation
  109946. this._updatePhysicsBodyTransformation(impostor);
  109947. };
  109948. CannonJSPlugin.prototype._processChildMeshes = function (mainImpostor) {
  109949. var _this = this;
  109950. var meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];
  109951. var currentRotation = mainImpostor.object.rotationQuaternion;
  109952. if (meshChildren.length) {
  109953. var processMesh = function (localPosition, mesh) {
  109954. if (!currentRotation || !mesh.rotationQuaternion) {
  109955. return;
  109956. }
  109957. var childImpostor = mesh.getPhysicsImpostor();
  109958. if (childImpostor) {
  109959. var parent = childImpostor.parent;
  109960. if (parent !== mainImpostor) {
  109961. var pPosition = mesh.getAbsolutePosition().subtract(mainImpostor.object.getAbsolutePosition());
  109962. var localRotation = mesh.rotationQuaternion.multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Inverse(currentRotation));
  109963. if (childImpostor.physicsBody) {
  109964. _this.removePhysicsBody(childImpostor);
  109965. childImpostor.physicsBody = null;
  109966. }
  109967. childImpostor.parent = mainImpostor;
  109968. childImpostor.resetUpdateFlags();
  109969. 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));
  109970. //Add the mass of the children.
  109971. mainImpostor.physicsBody.mass += childImpostor.getParam("mass");
  109972. }
  109973. }
  109974. currentRotation.multiplyInPlace(mesh.rotationQuaternion);
  109975. mesh.getChildMeshes(true).filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(_this, mesh.getAbsolutePosition()));
  109976. };
  109977. meshChildren.filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(this, mainImpostor.object.getAbsolutePosition()));
  109978. }
  109979. };
  109980. CannonJSPlugin.prototype.removePhysicsBody = function (impostor) {
  109981. impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
  109982. this.world.removeEventListener("preStep", impostor.beforeStep);
  109983. this.world.removeEventListener("postStep", impostor.afterStep);
  109984. this.world.remove(impostor.physicsBody);
  109985. };
  109986. CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
  109987. var mainBody = impostorJoint.mainImpostor.physicsBody;
  109988. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  109989. if (!mainBody || !connectedBody) {
  109990. return;
  109991. }
  109992. var constraint;
  109993. var jointData = impostorJoint.joint.jointData;
  109994. //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html
  109995. var constraintData = {
  109996. pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().copy(jointData.mainPivot) : null,
  109997. pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().copy(jointData.connectedPivot) : null,
  109998. axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().copy(jointData.mainAxis) : null,
  109999. axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().copy(jointData.connectedAxis) : null,
  110000. maxForce: jointData.nativeParams.maxForce,
  110001. collideConnected: !!jointData.collision
  110002. };
  110003. switch (impostorJoint.joint.type) {
  110004. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].HingeJoint:
  110005. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].Hinge2Joint:
  110006. constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);
  110007. break;
  110008. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].DistanceJoint:
  110009. constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, jointData.maxDistance || 2);
  110010. break;
  110011. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint:
  110012. var springData = jointData;
  110013. constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {
  110014. restLength: springData.length,
  110015. stiffness: springData.stiffness,
  110016. damping: springData.damping,
  110017. localAnchorA: constraintData.pivotA,
  110018. localAnchorB: constraintData.pivotB
  110019. });
  110020. break;
  110021. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].LockJoint:
  110022. constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);
  110023. break;
  110024. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].PointToPointJoint:
  110025. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].BallAndSocketJoint:
  110026. default:
  110027. constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
  110028. break;
  110029. }
  110030. //set the collideConnected flag after the creation, since DistanceJoint ignores it.
  110031. constraint.collideConnected = !!jointData.collision;
  110032. impostorJoint.joint.physicsJoint = constraint;
  110033. //don't add spring as constraint, as it is not one.
  110034. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  110035. this.world.addConstraint(constraint);
  110036. }
  110037. else {
  110038. impostorJoint.joint.jointData.forceApplicationCallback = impostorJoint.joint.jointData.forceApplicationCallback || function () {
  110039. constraint.applyForce();
  110040. };
  110041. impostorJoint.mainImpostor.registerAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  110042. }
  110043. };
  110044. CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
  110045. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  110046. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  110047. }
  110048. else {
  110049. impostorJoint.mainImpostor.unregisterAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  110050. }
  110051. };
  110052. CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
  110053. var index;
  110054. var mat;
  110055. for (index = 0; index < this._physicsMaterials.length; index++) {
  110056. mat = this._physicsMaterials[index];
  110057. if (mat.friction === friction && mat.restitution === restitution) {
  110058. return mat;
  110059. }
  110060. }
  110061. var currentMat = new this.BJSCANNON.Material(name);
  110062. currentMat.friction = friction;
  110063. currentMat.restitution = restitution;
  110064. this._physicsMaterials.push(currentMat);
  110065. return currentMat;
  110066. };
  110067. CannonJSPlugin.prototype._checkWithEpsilon = function (value) {
  110068. return value < _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon ? _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon : value;
  110069. };
  110070. CannonJSPlugin.prototype._createShape = function (impostor) {
  110071. var object = impostor.object;
  110072. var returnValue;
  110073. var extendSize = impostor.getObjectExtendSize();
  110074. switch (impostor.type) {
  110075. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].SphereImpostor:
  110076. var radiusX = extendSize.x;
  110077. var radiusY = extendSize.y;
  110078. var radiusZ = extendSize.z;
  110079. returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
  110080. break;
  110081. //TMP also for cylinder - TODO Cannon supports cylinder natively.
  110082. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor:
  110083. var nativeParams = impostor.getParam("nativeOptions");
  110084. if (!nativeParams) {
  110085. nativeParams = {};
  110086. }
  110087. var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(extendSize.x) / 2;
  110088. var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;
  110089. var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.y);
  110090. var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
  110091. returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
  110092. // Rotate 90 degrees as this shape is horizontal in cannon
  110093. var quat = new this.BJSCANNON.Quaternion();
  110094. quat.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);
  110095. var translation = new this.BJSCANNON.Vec3(0, 0, 0);
  110096. returnValue.transformAllPoints(translation, quat);
  110097. break;
  110098. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].BoxImpostor:
  110099. var box = extendSize.scale(0.5);
  110100. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
  110101. break;
  110102. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor:
  110103. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
  110104. returnValue = new this.BJSCANNON.Plane();
  110105. break;
  110106. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor:
  110107. // should transform the vertex data to world coordinates!!
  110108. var rawVerts = object.getVerticesData ? object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) : [];
  110109. var rawFaces = object.getIndices ? object.getIndices() : [];
  110110. if (!rawVerts) {
  110111. return;
  110112. }
  110113. // get only scale! so the object could transform correctly.
  110114. var oldPosition = object.position.clone();
  110115. var oldRotation = object.rotation && object.rotation.clone();
  110116. var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
  110117. object.position.copyFromFloats(0, 0, 0);
  110118. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  110119. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  110120. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  110121. var transform = object.computeWorldMatrix(true);
  110122. // convert rawVerts to object space
  110123. var temp = new Array();
  110124. var index;
  110125. for (index = 0; index < rawVerts.length; index += 3) {
  110126. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(rawVerts, index), transform).toArray(temp, index);
  110127. }
  110128. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("MeshImpostor only collides against spheres.");
  110129. returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
  110130. //now set back the transformation!
  110131. object.position.copyFrom(oldPosition);
  110132. oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
  110133. oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
  110134. break;
  110135. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor:
  110136. var oldPosition2 = object.position.clone();
  110137. var oldRotation2 = object.rotation && object.rotation.clone();
  110138. var oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();
  110139. object.position.copyFromFloats(0, 0, 0);
  110140. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  110141. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  110142. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  110143. object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);
  110144. returnValue = this._createHeightmap(object);
  110145. object.position.copyFrom(oldPosition2);
  110146. oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);
  110147. oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);
  110148. object.computeWorldMatrix(true);
  110149. break;
  110150. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].ParticleImpostor:
  110151. returnValue = new this.BJSCANNON.Particle();
  110152. break;
  110153. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].NoImpostor:
  110154. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));
  110155. break;
  110156. }
  110157. return returnValue;
  110158. };
  110159. CannonJSPlugin.prototype._createHeightmap = function (object, pointDepth) {
  110160. var pos = (object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  110161. var transform = object.computeWorldMatrix(true);
  110162. // convert rawVerts to object space
  110163. var temp = new Array();
  110164. var index;
  110165. for (index = 0; index < pos.length; index += 3) {
  110166. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(pos, index), transform).toArray(temp, index);
  110167. }
  110168. pos = temp;
  110169. var matrix = new Array();
  110170. //For now pointDepth will not be used and will be automatically calculated.
  110171. //Future reference - try and find the best place to add a reference to the pointDepth variable.
  110172. var arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);
  110173. var boundingInfo = object.getBoundingInfo();
  110174. var dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);
  110175. var minY = boundingInfo.boundingBox.extendSizeWorld.z;
  110176. var elementSize = dim * 2 / arraySize;
  110177. for (var i = 0; i < pos.length; i = i + 3) {
  110178. var x = Math.round((pos[i + 0]) / elementSize + arraySize / 2);
  110179. var z = Math.round(((pos[i + 1]) / elementSize - arraySize / 2) * -1);
  110180. var y = -pos[i + 2] + minY;
  110181. if (!matrix[x]) {
  110182. matrix[x] = [];
  110183. }
  110184. if (!matrix[x][z]) {
  110185. matrix[x][z] = y;
  110186. }
  110187. matrix[x][z] = Math.max(y, matrix[x][z]);
  110188. }
  110189. for (var x = 0; x <= arraySize; ++x) {
  110190. if (!matrix[x]) {
  110191. var loc = 1;
  110192. while (!matrix[(x + loc) % arraySize]) {
  110193. loc++;
  110194. }
  110195. matrix[x] = matrix[(x + loc) % arraySize].slice();
  110196. //console.log("missing x", x);
  110197. }
  110198. for (var z = 0; z <= arraySize; ++z) {
  110199. if (!matrix[x][z]) {
  110200. var loc = 1;
  110201. var newValue;
  110202. while (newValue === undefined) {
  110203. newValue = matrix[x][(z + loc++) % arraySize];
  110204. }
  110205. matrix[x][z] = newValue;
  110206. }
  110207. }
  110208. }
  110209. var shape = new this.BJSCANNON.Heightfield(matrix, {
  110210. elementSize: elementSize
  110211. });
  110212. //For future reference, needed for body transformation
  110213. shape.minY = minY;
  110214. return shape;
  110215. };
  110216. CannonJSPlugin.prototype._updatePhysicsBodyTransformation = function (impostor) {
  110217. var object = impostor.object;
  110218. //make sure it is updated...
  110219. object.computeWorldMatrix && object.computeWorldMatrix(true);
  110220. // The delta between the mesh position and the mesh bounding box center
  110221. var bInfo = object.getBoundingInfo();
  110222. if (!bInfo) {
  110223. return;
  110224. }
  110225. var center = impostor.getObjectCenter();
  110226. //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
  110227. this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
  110228. this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
  110229. this._tmpPosition.copyFrom(center);
  110230. var quaternion = object.rotationQuaternion;
  110231. if (!quaternion) {
  110232. return;
  110233. }
  110234. //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
  110235. //ideally these would be rotated at time of creation like cylinder but they dont extend ConvexPolyhedron
  110236. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  110237. //-90 DEG in X, precalculated
  110238. quaternion = quaternion.multiply(this._minus90X);
  110239. //Invert! (Precalculated, 90 deg in X)
  110240. //No need to clone. this will never change.
  110241. impostor.setDeltaRotation(this._plus90X);
  110242. }
  110243. //If it is a heightfield, if should be centered.
  110244. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  110245. var mesh = object;
  110246. var boundingInfo = mesh.getBoundingInfo();
  110247. //calculate the correct body position:
  110248. var rotationQuaternion = mesh.rotationQuaternion;
  110249. mesh.rotationQuaternion = this._tmpUnityRotation;
  110250. mesh.computeWorldMatrix(true);
  110251. //get original center with no rotation
  110252. var c = center.clone();
  110253. var oldPivot = mesh.getPivotMatrix();
  110254. if (oldPivot) {
  110255. // create a copy the pivot Matrix as it is modified in place
  110256. oldPivot = oldPivot.clone();
  110257. }
  110258. else {
  110259. oldPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  110260. }
  110261. //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
  110262. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
  110263. mesh.setPreTransformMatrix(p);
  110264. mesh.computeWorldMatrix(true);
  110265. //calculate the translation
  110266. var translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();
  110267. this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);
  110268. //add it inverted to the delta
  110269. this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
  110270. this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
  110271. //rotation is back
  110272. mesh.rotationQuaternion = rotationQuaternion;
  110273. mesh.setPreTransformMatrix(oldPivot);
  110274. mesh.computeWorldMatrix(true);
  110275. }
  110276. else if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor) {
  110277. this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  110278. //this._tmpPosition.copyFrom(object.position);
  110279. }
  110280. impostor.setDeltaPosition(this._tmpDeltaPosition);
  110281. //Now update the impostor object
  110282. impostor.physicsBody.position.copy(this._tmpPosition);
  110283. impostor.physicsBody.quaternion.copy(quaternion);
  110284. };
  110285. CannonJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  110286. impostor.object.position.copyFrom(impostor.physicsBody.position);
  110287. if (impostor.object.rotationQuaternion) {
  110288. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
  110289. }
  110290. };
  110291. CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  110292. impostor.physicsBody.position.copy(newPosition);
  110293. impostor.physicsBody.quaternion.copy(newRotation);
  110294. };
  110295. CannonJSPlugin.prototype.isSupported = function () {
  110296. return this.BJSCANNON !== undefined;
  110297. };
  110298. CannonJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  110299. impostor.physicsBody.velocity.copy(velocity);
  110300. };
  110301. CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  110302. impostor.physicsBody.angularVelocity.copy(velocity);
  110303. };
  110304. CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
  110305. var v = impostor.physicsBody.velocity;
  110306. if (!v) {
  110307. return null;
  110308. }
  110309. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  110310. };
  110311. CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
  110312. var v = impostor.physicsBody.angularVelocity;
  110313. if (!v) {
  110314. return null;
  110315. }
  110316. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  110317. };
  110318. CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  110319. impostor.physicsBody.mass = mass;
  110320. impostor.physicsBody.updateMassProperties();
  110321. };
  110322. CannonJSPlugin.prototype.getBodyMass = function (impostor) {
  110323. return impostor.physicsBody.mass;
  110324. };
  110325. CannonJSPlugin.prototype.getBodyFriction = function (impostor) {
  110326. return impostor.physicsBody.material.friction;
  110327. };
  110328. CannonJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  110329. impostor.physicsBody.material.friction = friction;
  110330. };
  110331. CannonJSPlugin.prototype.getBodyRestitution = function (impostor) {
  110332. return impostor.physicsBody.material.restitution;
  110333. };
  110334. CannonJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  110335. impostor.physicsBody.material.restitution = restitution;
  110336. };
  110337. CannonJSPlugin.prototype.sleepBody = function (impostor) {
  110338. impostor.physicsBody.sleep();
  110339. };
  110340. CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
  110341. impostor.physicsBody.wakeUp();
  110342. };
  110343. CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance) {
  110344. joint.physicsJoint.distance = maxDistance;
  110345. };
  110346. // private enableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  110347. // if (!motorIndex) {
  110348. // joint.physicsJoint.enableMotor();
  110349. // }
  110350. // }
  110351. // private disableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  110352. // if (!motorIndex) {
  110353. // joint.physicsJoint.disableMotor();
  110354. // }
  110355. // }
  110356. CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  110357. if (!motorIndex) {
  110358. joint.physicsJoint.enableMotor();
  110359. joint.physicsJoint.setMotorSpeed(speed);
  110360. if (maxForce) {
  110361. this.setLimit(joint, maxForce);
  110362. }
  110363. }
  110364. };
  110365. CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  110366. joint.physicsJoint.motorEquation.maxForce = upperLimit;
  110367. joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
  110368. };
  110369. CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  110370. var body = impostor.physicsBody;
  110371. mesh.position.x = body.position.x;
  110372. mesh.position.y = body.position.y;
  110373. mesh.position.z = body.position.z;
  110374. if (mesh.rotationQuaternion) {
  110375. mesh.rotationQuaternion.x = body.quaternion.x;
  110376. mesh.rotationQuaternion.y = body.quaternion.y;
  110377. mesh.rotationQuaternion.z = body.quaternion.z;
  110378. mesh.rotationQuaternion.w = body.quaternion.w;
  110379. }
  110380. };
  110381. CannonJSPlugin.prototype.getRadius = function (impostor) {
  110382. var shape = impostor.physicsBody.shapes[0];
  110383. return shape.boundingSphereRadius;
  110384. };
  110385. CannonJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  110386. var shape = impostor.physicsBody.shapes[0];
  110387. result.x = shape.halfExtents.x * 2;
  110388. result.y = shape.halfExtents.y * 2;
  110389. result.z = shape.halfExtents.z * 2;
  110390. };
  110391. CannonJSPlugin.prototype.dispose = function () {
  110392. };
  110393. CannonJSPlugin.prototype._extendNamespace = function () {
  110394. //this will force cannon to execute at least one step when using interpolation
  110395. var step_tmp1 = new this.BJSCANNON.Vec3();
  110396. var Engine = this.BJSCANNON;
  110397. this.BJSCANNON.World.prototype.step = function (dt, timeSinceLastCalled, maxSubSteps) {
  110398. maxSubSteps = maxSubSteps || 10;
  110399. timeSinceLastCalled = timeSinceLastCalled || 0;
  110400. if (timeSinceLastCalled === 0) {
  110401. this.internalStep(dt);
  110402. this.time += dt;
  110403. }
  110404. else {
  110405. var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);
  110406. internalSteps = Math.min(internalSteps, maxSubSteps) || 1;
  110407. var t0 = performance.now();
  110408. for (var i = 0; i !== internalSteps; i++) {
  110409. this.internalStep(dt);
  110410. if (performance.now() - t0 > dt * 1000) {
  110411. break;
  110412. }
  110413. }
  110414. this.time += timeSinceLastCalled;
  110415. var h = this.time % dt;
  110416. var h_div_dt = h / dt;
  110417. var interpvelo = step_tmp1;
  110418. var bodies = this.bodies;
  110419. for (var j = 0; j !== bodies.length; j++) {
  110420. var b = bodies[j];
  110421. if (b.type !== Engine.Body.STATIC && b.sleepState !== Engine.Body.SLEEPING) {
  110422. b.position.vsub(b.previousPosition, interpvelo);
  110423. interpvelo.scale(h_div_dt, interpvelo);
  110424. b.position.vadd(interpvelo, b.interpolatedPosition);
  110425. }
  110426. else {
  110427. b.interpolatedPosition.copy(b.position);
  110428. b.interpolatedQuaternion.copy(b.quaternion);
  110429. }
  110430. }
  110431. }
  110432. };
  110433. };
  110434. return CannonJSPlugin;
  110435. }());
  110436. _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].DefaultPluginFactory = function () { return new CannonJSPlugin(); };
  110437. /***/ }),
  110438. /***/ "./Physics/Plugins/index.ts":
  110439. /*!**********************************!*\
  110440. !*** ./Physics/Plugins/index.ts ***!
  110441. \**********************************/
  110442. /*! exports provided: CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  110443. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110444. "use strict";
  110445. __webpack_require__.r(__webpack_exports__);
  110446. /* harmony import */ var _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  110447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  110448. /* harmony import */ var _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  110449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__["AmmoJSPlugin"]; });
  110450. /* harmony import */ var _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  110451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__["OimoJSPlugin"]; });
  110452. /***/ }),
  110453. /***/ "./Physics/Plugins/oimoJSPlugin.ts":
  110454. /*!*****************************************!*\
  110455. !*** ./Physics/Plugins/oimoJSPlugin.ts ***!
  110456. \*****************************************/
  110457. /*! exports provided: OimoJSPlugin */
  110458. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110459. "use strict";
  110460. __webpack_require__.r(__webpack_exports__);
  110461. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return OimoJSPlugin; });
  110462. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  110463. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  110464. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  110465. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  110466. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  110467. /** @hidden */
  110468. var OimoJSPlugin = /** @class */ (function () {
  110469. function OimoJSPlugin(iterations, oimoInjection) {
  110470. if (oimoInjection === void 0) { oimoInjection = OIMO; }
  110471. this.name = "OimoJSPlugin";
  110472. this._tmpImpostorsArray = [];
  110473. this._tmpPositionVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  110474. this.BJSOIMO = oimoInjection;
  110475. this.world = new this.BJSOIMO.World({
  110476. iterations: iterations
  110477. });
  110478. this.world.clear();
  110479. }
  110480. OimoJSPlugin.prototype.setGravity = function (gravity) {
  110481. this.world.gravity.copy(gravity);
  110482. };
  110483. OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
  110484. this.world.timeStep = timeStep;
  110485. };
  110486. OimoJSPlugin.prototype.getTimeStep = function () {
  110487. return this.world.timeStep;
  110488. };
  110489. OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
  110490. var _this = this;
  110491. impostors.forEach(function (impostor) {
  110492. impostor.beforeStep();
  110493. });
  110494. this.world.step();
  110495. impostors.forEach(function (impostor) {
  110496. impostor.afterStep();
  110497. //update the ordered impostors array
  110498. _this._tmpImpostorsArray[impostor.uniqueId] = impostor;
  110499. });
  110500. //check for collisions
  110501. var contact = this.world.contacts;
  110502. while (contact !== null) {
  110503. if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {
  110504. contact = contact.next;
  110505. continue;
  110506. }
  110507. //is this body colliding with any other? get the impostor
  110508. var mainImpostor = this._tmpImpostorsArray[+contact.body1.name];
  110509. var collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];
  110510. if (!mainImpostor || !collidingImpostor) {
  110511. contact = contact.next;
  110512. continue;
  110513. }
  110514. mainImpostor.onCollide({ body: collidingImpostor.physicsBody });
  110515. collidingImpostor.onCollide({ body: mainImpostor.physicsBody });
  110516. contact = contact.next;
  110517. }
  110518. };
  110519. OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  110520. var mass = impostor.physicsBody.mass;
  110521. impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
  110522. };
  110523. OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  110524. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Oimo doesn't support applying force. Using impule instead.");
  110525. this.applyImpulse(impostor, force, contactPoint);
  110526. };
  110527. OimoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  110528. var _this = this;
  110529. //parent-child relationship. Does this impostor has a parent impostor?
  110530. if (impostor.parent) {
  110531. if (impostor.physicsBody) {
  110532. this.removePhysicsBody(impostor);
  110533. //TODO is that needed?
  110534. impostor.forceUpdate();
  110535. }
  110536. return;
  110537. }
  110538. if (impostor.isBodyInitRequired()) {
  110539. var bodyConfig = {
  110540. name: impostor.uniqueId,
  110541. //Oimo must have mass, also for static objects.
  110542. config: [impostor.getParam("mass") || 1, impostor.getParam("friction"), impostor.getParam("restitution")],
  110543. size: [],
  110544. type: [],
  110545. pos: [],
  110546. posShape: [],
  110547. rot: [],
  110548. rotShape: [],
  110549. move: impostor.getParam("mass") !== 0,
  110550. density: impostor.getParam("mass"),
  110551. friction: impostor.getParam("friction"),
  110552. restitution: impostor.getParam("restitution"),
  110553. //Supporting older versions of Oimo
  110554. world: this.world
  110555. };
  110556. var impostors = [impostor];
  110557. var addToArray = function (parent) {
  110558. if (!parent.getChildMeshes) {
  110559. return;
  110560. }
  110561. parent.getChildMeshes().forEach(function (m) {
  110562. if (m.physicsImpostor) {
  110563. impostors.push(m.physicsImpostor);
  110564. //m.physicsImpostor._init();
  110565. }
  110566. });
  110567. };
  110568. addToArray(impostor.object);
  110569. var checkWithEpsilon_1 = function (value) {
  110570. return Math.max(value, _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__["PhysicsEngine"].Epsilon);
  110571. };
  110572. var globalQuaternion_1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  110573. impostors.forEach(function (i) {
  110574. if (!i.object.rotationQuaternion) {
  110575. return;
  110576. }
  110577. //get the correct bounding box
  110578. var oldQuaternion = i.object.rotationQuaternion;
  110579. globalQuaternion_1 = oldQuaternion.clone();
  110580. var rot = oldQuaternion.toEulerAngles();
  110581. var extendSize = i.getObjectExtendSize();
  110582. var radToDeg = 57.295779513082320876;
  110583. if (i === impostor) {
  110584. var center = impostor.getObjectCenter();
  110585. impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
  110586. _this._tmpPositionVector.divideInPlace(impostor.object.scaling);
  110587. //Can also use Array.prototype.push.apply
  110588. bodyConfig.pos.push(center.x);
  110589. bodyConfig.pos.push(center.y);
  110590. bodyConfig.pos.push(center.z);
  110591. bodyConfig.posShape.push(0, 0, 0);
  110592. bodyConfig.rotShape.push(0, 0, 0);
  110593. }
  110594. else {
  110595. var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
  110596. bodyConfig.posShape.push(localPosition.x);
  110597. bodyConfig.posShape.push(localPosition.y);
  110598. bodyConfig.posShape.push(localPosition.z);
  110599. bodyConfig.pos.push(0, 0, 0);
  110600. bodyConfig.rotShape.push(rot.x * radToDeg);
  110601. bodyConfig.rotShape.push(rot.y * radToDeg);
  110602. bodyConfig.rotShape.push(rot.z * radToDeg);
  110603. }
  110604. // register mesh
  110605. switch (i.type) {
  110606. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].ParticleImpostor:
  110607. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  110608. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].SphereImpostor:
  110609. var radiusX = extendSize.x;
  110610. var radiusY = extendSize.y;
  110611. var radiusZ = extendSize.z;
  110612. var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
  110613. bodyConfig.type.push('sphere');
  110614. //due to the way oimo works with compounds, add 3 times
  110615. bodyConfig.size.push(size);
  110616. bodyConfig.size.push(size);
  110617. bodyConfig.size.push(size);
  110618. break;
  110619. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].CylinderImpostor:
  110620. var sizeX = checkWithEpsilon_1(extendSize.x) / 2;
  110621. var sizeY = checkWithEpsilon_1(extendSize.y);
  110622. bodyConfig.type.push('cylinder');
  110623. bodyConfig.size.push(sizeX);
  110624. bodyConfig.size.push(sizeY);
  110625. //due to the way oimo works with compounds, add one more value.
  110626. bodyConfig.size.push(sizeY);
  110627. break;
  110628. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].PlaneImpostor:
  110629. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].BoxImpostor:
  110630. default:
  110631. var sizeX = checkWithEpsilon_1(extendSize.x);
  110632. var sizeY = checkWithEpsilon_1(extendSize.y);
  110633. var sizeZ = checkWithEpsilon_1(extendSize.z);
  110634. bodyConfig.type.push('box');
  110635. //if (i === impostor) {
  110636. bodyConfig.size.push(sizeX);
  110637. bodyConfig.size.push(sizeY);
  110638. bodyConfig.size.push(sizeZ);
  110639. //} else {
  110640. // bodyConfig.size.push(0,0,0);
  110641. //}
  110642. break;
  110643. }
  110644. //actually not needed, but hey...
  110645. i.object.rotationQuaternion = oldQuaternion;
  110646. });
  110647. impostor.physicsBody = this.world.add(bodyConfig);
  110648. // set the quaternion, ignoring the previously defined (euler) rotation
  110649. impostor.physicsBody.resetQuaternion(globalQuaternion_1);
  110650. // update with delta 0, so the body will reveive the new rotation.
  110651. impostor.physicsBody.updatePosition(0);
  110652. }
  110653. else {
  110654. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  110655. }
  110656. impostor.setDeltaPosition(this._tmpPositionVector);
  110657. //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);
  110658. //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);
  110659. };
  110660. OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  110661. //impostor.physicsBody.dispose();
  110662. //Same as : (older oimo versions)
  110663. this.world.removeRigidBody(impostor.physicsBody);
  110664. };
  110665. OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  110666. var mainBody = impostorJoint.mainImpostor.physicsBody;
  110667. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  110668. if (!mainBody || !connectedBody) {
  110669. return;
  110670. }
  110671. var jointData = impostorJoint.joint.jointData;
  110672. var options = jointData.nativeParams || {};
  110673. var type;
  110674. var nativeJointData = {
  110675. body1: mainBody,
  110676. body2: connectedBody,
  110677. axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),
  110678. axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),
  110679. pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),
  110680. pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),
  110681. min: options.min,
  110682. max: options.max,
  110683. collision: options.collision || jointData.collision,
  110684. spring: options.spring,
  110685. //supporting older version of Oimo
  110686. world: this.world
  110687. };
  110688. switch (impostorJoint.joint.type) {
  110689. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].BallAndSocketJoint:
  110690. type = "jointBall";
  110691. break;
  110692. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SpringJoint:
  110693. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  110694. var springData = jointData;
  110695. nativeJointData.min = springData.length || nativeJointData.min;
  110696. //Max should also be set, just make sure it is at least min
  110697. nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);
  110698. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].DistanceJoint:
  110699. type = "jointDistance";
  110700. nativeJointData.max = jointData.maxDistance;
  110701. break;
  110702. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].PrismaticJoint:
  110703. type = "jointPrisme";
  110704. break;
  110705. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SliderJoint:
  110706. type = "jointSlide";
  110707. break;
  110708. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].WheelJoint:
  110709. type = "jointWheel";
  110710. break;
  110711. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].HingeJoint:
  110712. default:
  110713. type = "jointHinge";
  110714. break;
  110715. }
  110716. nativeJointData.type = type;
  110717. impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
  110718. };
  110719. OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  110720. //Bug in Oimo prevents us from disposing a joint in the playground
  110721. //joint.joint.physicsJoint.dispose();
  110722. //So we will bruteforce it!
  110723. try {
  110724. this.world.removeJoint(impostorJoint.joint.physicsJoint);
  110725. }
  110726. catch (e) {
  110727. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn(e);
  110728. }
  110729. };
  110730. OimoJSPlugin.prototype.isSupported = function () {
  110731. return this.BJSOIMO !== undefined;
  110732. };
  110733. OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  110734. if (!impostor.physicsBody.sleeping) {
  110735. //TODO check that
  110736. /*if (impostor.physicsBody.shapes.next) {
  110737. var parentShape = this._getLastShape(impostor.physicsBody);
  110738. impostor.object.position.copyFrom(parentShape.position);
  110739. console.log(parentShape.position);
  110740. } else {*/
  110741. impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
  110742. //}
  110743. if (impostor.object.rotationQuaternion) {
  110744. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
  110745. }
  110746. }
  110747. };
  110748. OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  110749. var body = impostor.physicsBody;
  110750. body.position.copy(newPosition);
  110751. body.orientation.copy(newRotation);
  110752. body.syncShapes();
  110753. body.awake();
  110754. };
  110755. /*private _getLastShape(body: any): any {
  110756. var lastShape = body.shapes;
  110757. while (lastShape.next) {
  110758. lastShape = lastShape.next;
  110759. }
  110760. return lastShape;
  110761. }*/
  110762. OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  110763. impostor.physicsBody.linearVelocity.copy(velocity);
  110764. };
  110765. OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  110766. impostor.physicsBody.angularVelocity.copy(velocity);
  110767. };
  110768. OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  110769. var v = impostor.physicsBody.linearVelocity;
  110770. if (!v) {
  110771. return null;
  110772. }
  110773. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  110774. };
  110775. OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  110776. var v = impostor.physicsBody.angularVelocity;
  110777. if (!v) {
  110778. return null;
  110779. }
  110780. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  110781. };
  110782. OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  110783. var staticBody = mass === 0;
  110784. //this will actually set the body's density and not its mass.
  110785. //But this is how oimo treats the mass variable.
  110786. impostor.physicsBody.shapes.density = staticBody ? 1 : mass;
  110787. impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);
  110788. };
  110789. OimoJSPlugin.prototype.getBodyMass = function (impostor) {
  110790. return impostor.physicsBody.shapes.density;
  110791. };
  110792. OimoJSPlugin.prototype.getBodyFriction = function (impostor) {
  110793. return impostor.physicsBody.shapes.friction;
  110794. };
  110795. OimoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  110796. impostor.physicsBody.shapes.friction = friction;
  110797. };
  110798. OimoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  110799. return impostor.physicsBody.shapes.restitution;
  110800. };
  110801. OimoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  110802. impostor.physicsBody.shapes.restitution = restitution;
  110803. };
  110804. OimoJSPlugin.prototype.sleepBody = function (impostor) {
  110805. impostor.physicsBody.sleep();
  110806. };
  110807. OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
  110808. impostor.physicsBody.awake();
  110809. };
  110810. OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  110811. joint.physicsJoint.limitMotor.upperLimit = maxDistance;
  110812. if (minDistance !== void 0) {
  110813. joint.physicsJoint.limitMotor.lowerLimit = minDistance;
  110814. }
  110815. };
  110816. OimoJSPlugin.prototype.setMotor = function (joint, speed, force, motorIndex) {
  110817. if (force !== undefined) {
  110818. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter");
  110819. }
  110820. else {
  110821. force = 1e6;
  110822. }
  110823. speed *= -1;
  110824. //TODO separate rotational and transational motors.
  110825. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  110826. if (motor) {
  110827. motor.setMotor(speed, force);
  110828. }
  110829. };
  110830. OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
  110831. //TODO separate rotational and transational motors.
  110832. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  110833. if (motor) {
  110834. motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
  110835. }
  110836. };
  110837. OimoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  110838. var body = impostor.physicsBody;
  110839. mesh.position.x = body.position.x;
  110840. mesh.position.y = body.position.y;
  110841. mesh.position.z = body.position.z;
  110842. if (mesh.rotationQuaternion) {
  110843. mesh.rotationQuaternion.x = body.orientation.x;
  110844. mesh.rotationQuaternion.y = body.orientation.y;
  110845. mesh.rotationQuaternion.z = body.orientation.z;
  110846. mesh.rotationQuaternion.w = body.orientation.s;
  110847. }
  110848. };
  110849. OimoJSPlugin.prototype.getRadius = function (impostor) {
  110850. return impostor.physicsBody.shapes.radius;
  110851. };
  110852. OimoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  110853. var shape = impostor.physicsBody.shapes;
  110854. result.x = shape.halfWidth * 2;
  110855. result.y = shape.halfHeight * 2;
  110856. result.z = shape.halfDepth * 2;
  110857. };
  110858. OimoJSPlugin.prototype.dispose = function () {
  110859. this.world.clear();
  110860. };
  110861. return OimoJSPlugin;
  110862. }());
  110863. /***/ }),
  110864. /***/ "./Physics/index.ts":
  110865. /*!**************************!*\
  110866. !*** ./Physics/index.ts ***!
  110867. \**************************/
  110868. /*! exports provided: PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  110869. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110870. "use strict";
  110871. __webpack_require__.r(__webpack_exports__);
  110872. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  110873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _physicsEngine__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  110874. /* harmony import */ var _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./physicsEngineComponent */ "./Physics/physicsEngineComponent.ts");
  110875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__["PhysicsEngineSceneComponent"]; });
  110876. /* harmony import */ var _physicsHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./physicsHelper */ "./Physics/physicsHelper.ts");
  110877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsHelper"]; });
  110878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialExplosionEvent"]; });
  110879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsGravitationalFieldEvent"]; });
  110880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftEvent"]; });
  110881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsVortexEvent"]; });
  110882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialImpulseFalloff"]; });
  110883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftMode"]; });
  110884. /* harmony import */ var _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsImpostor */ "./Physics/physicsImpostor.ts");
  110885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"]; });
  110886. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  110887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"]; });
  110888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["DistanceJoint"]; });
  110889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["MotorEnabledJoint"]; });
  110890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["HingeJoint"]; });
  110891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["Hinge2Joint"]; });
  110892. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Plugins/index */ "./Physics/Plugins/index.ts");
  110893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["CannonJSPlugin"]; });
  110894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["AmmoJSPlugin"]; });
  110895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["OimoJSPlugin"]; });
  110896. /***/ }),
  110897. /***/ "./Physics/physicsEngine.ts":
  110898. /*!**********************************!*\
  110899. !*** ./Physics/physicsEngine.ts ***!
  110900. \**********************************/
  110901. /*! exports provided: PhysicsEngine */
  110902. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110903. "use strict";
  110904. __webpack_require__.r(__webpack_exports__);
  110905. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return PhysicsEngine; });
  110906. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110907. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  110908. /**
  110909. * Class used to control physics engine
  110910. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110911. */
  110912. var PhysicsEngine = /** @class */ (function () {
  110913. /**
  110914. * Creates a new Physics Engine
  110915. * @param gravity defines the gravity vector used by the simulation
  110916. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  110917. */
  110918. function PhysicsEngine(gravity, _physicsPlugin) {
  110919. if (_physicsPlugin === void 0) { _physicsPlugin = PhysicsEngine.DefaultPluginFactory(); }
  110920. this._physicsPlugin = _physicsPlugin;
  110921. this._impostors = [];
  110922. this._joints = [];
  110923. if (!this._physicsPlugin.isSupported()) {
  110924. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. "
  110925. + "Please make sure it is included.");
  110926. }
  110927. gravity = gravity || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -9.807, 0);
  110928. this.setGravity(gravity);
  110929. this.setTimeStep();
  110930. }
  110931. /**
  110932. * Factory used to create the default physics plugin.
  110933. * @returns The default physics plugin
  110934. */
  110935. PhysicsEngine.DefaultPluginFactory = function () {
  110936. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__["_DevTools"].WarnImport("CannonJSPlugin");
  110937. };
  110938. /**
  110939. * Sets the gravity vector used by the simulation
  110940. * @param gravity defines the gravity vector to use
  110941. */
  110942. PhysicsEngine.prototype.setGravity = function (gravity) {
  110943. this.gravity = gravity;
  110944. this._physicsPlugin.setGravity(this.gravity);
  110945. };
  110946. /**
  110947. * Set the time step of the physics engine.
  110948. * Default is 1/60.
  110949. * To slow it down, enter 1/600 for example.
  110950. * To speed it up, 1/30
  110951. * @param newTimeStep defines the new timestep to apply to this world.
  110952. */
  110953. PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
  110954. if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
  110955. this._physicsPlugin.setTimeStep(newTimeStep);
  110956. };
  110957. /**
  110958. * Get the time step of the physics engine.
  110959. * @returns the current time step
  110960. */
  110961. PhysicsEngine.prototype.getTimeStep = function () {
  110962. return this._physicsPlugin.getTimeStep();
  110963. };
  110964. /**
  110965. * Release all resources
  110966. */
  110967. PhysicsEngine.prototype.dispose = function () {
  110968. this._impostors.forEach(function (impostor) {
  110969. impostor.dispose();
  110970. });
  110971. this._physicsPlugin.dispose();
  110972. };
  110973. /**
  110974. * Gets the name of the current physics plugin
  110975. * @returns the name of the plugin
  110976. */
  110977. PhysicsEngine.prototype.getPhysicsPluginName = function () {
  110978. return this._physicsPlugin.name;
  110979. };
  110980. /**
  110981. * Adding a new impostor for the impostor tracking.
  110982. * This will be done by the impostor itself.
  110983. * @param impostor the impostor to add
  110984. */
  110985. PhysicsEngine.prototype.addImpostor = function (impostor) {
  110986. impostor.uniqueId = this._impostors.push(impostor);
  110987. //if no parent, generate the body
  110988. if (!impostor.parent) {
  110989. this._physicsPlugin.generatePhysicsBody(impostor);
  110990. }
  110991. };
  110992. /**
  110993. * Remove an impostor from the engine.
  110994. * This impostor and its mesh will not longer be updated by the physics engine.
  110995. * @param impostor the impostor to remove
  110996. */
  110997. PhysicsEngine.prototype.removeImpostor = function (impostor) {
  110998. var index = this._impostors.indexOf(impostor);
  110999. if (index > -1) {
  111000. var removed = this._impostors.splice(index, 1);
  111001. //Is it needed?
  111002. if (removed.length) {
  111003. //this will also remove it from the world.
  111004. removed[0].physicsBody = null;
  111005. }
  111006. }
  111007. };
  111008. /**
  111009. * Add a joint to the physics engine
  111010. * @param mainImpostor defines the main impostor to which the joint is added.
  111011. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  111012. * @param joint defines the joint that will connect both impostors.
  111013. */
  111014. PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
  111015. var impostorJoint = {
  111016. mainImpostor: mainImpostor,
  111017. connectedImpostor: connectedImpostor,
  111018. joint: joint
  111019. };
  111020. joint.physicsPlugin = this._physicsPlugin;
  111021. this._joints.push(impostorJoint);
  111022. this._physicsPlugin.generateJoint(impostorJoint);
  111023. };
  111024. /**
  111025. * Removes a joint from the simulation
  111026. * @param mainImpostor defines the impostor used with the joint
  111027. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  111028. * @param joint defines the joint to remove
  111029. */
  111030. PhysicsEngine.prototype.removeJoint = function (mainImpostor, connectedImpostor, joint) {
  111031. var matchingJoints = this._joints.filter(function (impostorJoint) {
  111032. return (impostorJoint.connectedImpostor === connectedImpostor
  111033. && impostorJoint.joint === joint
  111034. && impostorJoint.mainImpostor === mainImpostor);
  111035. });
  111036. if (matchingJoints.length) {
  111037. this._physicsPlugin.removeJoint(matchingJoints[0]);
  111038. //TODO remove it from the list as well
  111039. }
  111040. };
  111041. /**
  111042. * Called by the scene. No need to call it.
  111043. * @param delta defines the timespam between frames
  111044. */
  111045. PhysicsEngine.prototype._step = function (delta) {
  111046. var _this = this;
  111047. //check if any mesh has no body / requires an update
  111048. this._impostors.forEach(function (impostor) {
  111049. if (impostor.isBodyInitRequired()) {
  111050. _this._physicsPlugin.generatePhysicsBody(impostor);
  111051. }
  111052. });
  111053. if (delta > 0.1) {
  111054. delta = 0.1;
  111055. }
  111056. else if (delta <= 0) {
  111057. delta = 1.0 / 60.0;
  111058. }
  111059. this._physicsPlugin.executeStep(delta, this._impostors);
  111060. };
  111061. /**
  111062. * Gets the current plugin used to run the simulation
  111063. * @returns current plugin
  111064. */
  111065. PhysicsEngine.prototype.getPhysicsPlugin = function () {
  111066. return this._physicsPlugin;
  111067. };
  111068. /**
  111069. * Gets the list of physic impostors
  111070. * @returns an array of PhysicsImpostor
  111071. */
  111072. PhysicsEngine.prototype.getImpostors = function () {
  111073. return this._impostors;
  111074. };
  111075. /**
  111076. * Gets the impostor for a physics enabled object
  111077. * @param object defines the object impersonated by the impostor
  111078. * @returns the PhysicsImpostor or null if not found
  111079. */
  111080. PhysicsEngine.prototype.getImpostorForPhysicsObject = function (object) {
  111081. for (var i = 0; i < this._impostors.length; ++i) {
  111082. if (this._impostors[i].object === object) {
  111083. return this._impostors[i];
  111084. }
  111085. }
  111086. return null;
  111087. };
  111088. /**
  111089. * Gets the impostor for a physics body object
  111090. * @param body defines physics body used by the impostor
  111091. * @returns the PhysicsImpostor or null if not found
  111092. */
  111093. PhysicsEngine.prototype.getImpostorWithPhysicsBody = function (body) {
  111094. for (var i = 0; i < this._impostors.length; ++i) {
  111095. if (this._impostors[i].physicsBody === body) {
  111096. return this._impostors[i];
  111097. }
  111098. }
  111099. return null;
  111100. };
  111101. /**
  111102. * Global value used to control the smallest number supported by the simulation
  111103. */
  111104. PhysicsEngine.Epsilon = 0.001;
  111105. return PhysicsEngine;
  111106. }());
  111107. /***/ }),
  111108. /***/ "./Physics/physicsEngineComponent.ts":
  111109. /*!*******************************************!*\
  111110. !*** ./Physics/physicsEngineComponent.ts ***!
  111111. \*******************************************/
  111112. /*! exports provided: PhysicsEngineSceneComponent */
  111113. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111114. "use strict";
  111115. __webpack_require__.r(__webpack_exports__);
  111116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return PhysicsEngineSceneComponent; });
  111117. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  111118. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  111119. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  111120. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  111121. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  111122. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  111123. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  111124. /**
  111125. * Gets the current physics engine
  111126. * @returns a IPhysicsEngine or null if none attached
  111127. */
  111128. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.getPhysicsEngine = function () {
  111129. return this._physicsEngine;
  111130. };
  111131. /**
  111132. * Enables physics to the current scene
  111133. * @param gravity defines the scene's gravity for the physics engine
  111134. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  111135. * @return a boolean indicating if the physics engine was initialized
  111136. */
  111137. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.enablePhysics = function (gravity, plugin) {
  111138. if (gravity === void 0) { gravity = null; }
  111139. if (this._physicsEngine) {
  111140. return true;
  111141. }
  111142. // Register the component to the scene
  111143. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE);
  111144. if (!component) {
  111145. component = new PhysicsEngineSceneComponent(this);
  111146. this._addComponent(component);
  111147. }
  111148. try {
  111149. this._physicsEngine = new _physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"](gravity, plugin);
  111150. return true;
  111151. }
  111152. catch (e) {
  111153. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error(e.message);
  111154. return false;
  111155. }
  111156. };
  111157. /**
  111158. * Disables and disposes the physics engine associated with the scene
  111159. */
  111160. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.disablePhysicsEngine = function () {
  111161. if (!this._physicsEngine) {
  111162. return;
  111163. }
  111164. this._physicsEngine.dispose();
  111165. this._physicsEngine = null;
  111166. };
  111167. /**
  111168. * Gets a boolean indicating if there is an active physics engine
  111169. * @returns a boolean indicating if there is an active physics engine
  111170. */
  111171. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.isPhysicsEnabled = function () {
  111172. return this._physicsEngine !== undefined;
  111173. };
  111174. /**
  111175. * Deletes a physics compound impostor
  111176. * @param compound defines the compound to delete
  111177. */
  111178. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.deleteCompoundImpostor = function (compound) {
  111179. var mesh = compound.parts[0].mesh;
  111180. if (mesh.physicsImpostor) {
  111181. mesh.physicsImpostor.dispose( /*true*/);
  111182. mesh.physicsImpostor = null;
  111183. }
  111184. };
  111185. /** @hidden */
  111186. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._advancePhysicsEngineStep = function (step) {
  111187. if (this._physicsEngine) {
  111188. this.onBeforePhysicsObservable.notifyObservers(this);
  111189. this._physicsEngine._step(step / 1000);
  111190. this.onAfterPhysicsObservable.notifyObservers(this);
  111191. }
  111192. };
  111193. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "physicsImpostor", {
  111194. get: function () {
  111195. return this._physicsImpostor;
  111196. },
  111197. set: function (value) {
  111198. var _this = this;
  111199. if (this._physicsImpostor === value) {
  111200. return;
  111201. }
  111202. if (this._disposePhysicsObserver) {
  111203. this.onDisposeObservable.remove(this._disposePhysicsObserver);
  111204. }
  111205. this._physicsImpostor = value;
  111206. if (value) {
  111207. this._disposePhysicsObserver = this.onDisposeObservable.add(function () {
  111208. // Physics
  111209. if (_this.physicsImpostor) {
  111210. _this.physicsImpostor.dispose( /*!doNotRecurse*/);
  111211. _this.physicsImpostor = null;
  111212. }
  111213. });
  111214. }
  111215. },
  111216. enumerable: true,
  111217. configurable: true
  111218. });
  111219. /**
  111220. * Gets the current physics impostor
  111221. * @see http://doc.babylonjs.com/features/physics_engine
  111222. * @returns a physics impostor or null
  111223. */
  111224. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.getPhysicsImpostor = function () {
  111225. return this.physicsImpostor;
  111226. };
  111227. /**
  111228. * Apply a physic impulse to the mesh
  111229. * @param force defines the force to apply
  111230. * @param contactPoint defines where to apply the force
  111231. * @returns the current mesh
  111232. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111233. */
  111234. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.applyImpulse = function (force, contactPoint) {
  111235. if (!this.physicsImpostor) {
  111236. return this;
  111237. }
  111238. this.physicsImpostor.applyImpulse(force, contactPoint);
  111239. return this;
  111240. };
  111241. /**
  111242. * Creates a physic joint between two meshes
  111243. * @param otherMesh defines the other mesh to use
  111244. * @param pivot1 defines the pivot to use on this mesh
  111245. * @param pivot2 defines the pivot to use on the other mesh
  111246. * @param options defines additional options (can be plugin dependent)
  111247. * @returns the current mesh
  111248. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111249. */
  111250. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
  111251. if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
  111252. return this;
  111253. }
  111254. this.physicsImpostor.createJoint(otherMesh.physicsImpostor, _physicsJoint__WEBPACK_IMPORTED_MODULE_6__["PhysicsJoint"].HingeJoint, {
  111255. mainPivot: pivot1,
  111256. connectedPivot: pivot2,
  111257. nativeParams: options
  111258. });
  111259. return this;
  111260. };
  111261. /**
  111262. * Defines the physics engine scene component responsible to manage a physics engine
  111263. */
  111264. var PhysicsEngineSceneComponent = /** @class */ (function () {
  111265. /**
  111266. * Creates a new instance of the component for the given scene
  111267. * @param scene Defines the scene to register the component in
  111268. */
  111269. function PhysicsEngineSceneComponent(scene) {
  111270. var _this = this;
  111271. /**
  111272. * The component name helpful to identify the component in the list of scene components.
  111273. */
  111274. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE;
  111275. this.scene = scene;
  111276. this.scene.onBeforePhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  111277. this.scene.onAfterPhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  111278. // Replace the function used to get the deterministic frame time
  111279. this.scene.getDeterministicFrameTime = function () {
  111280. if (_this.scene._physicsEngine) {
  111281. return _this.scene._physicsEngine.getTimeStep() * 1000;
  111282. }
  111283. return 1000.0 / 60.0;
  111284. };
  111285. }
  111286. /**
  111287. * Registers the component in a given scene
  111288. */
  111289. PhysicsEngineSceneComponent.prototype.register = function () {
  111290. };
  111291. /**
  111292. * Rebuilds the elements related to this component in case of
  111293. * context lost for instance.
  111294. */
  111295. PhysicsEngineSceneComponent.prototype.rebuild = function () {
  111296. // Nothing to do for this component
  111297. };
  111298. /**
  111299. * Disposes the component and the associated ressources
  111300. */
  111301. PhysicsEngineSceneComponent.prototype.dispose = function () {
  111302. this.scene.onBeforePhysicsObservable.clear();
  111303. this.scene.onAfterPhysicsObservable.clear();
  111304. if (this.scene._physicsEngine) {
  111305. this.scene.disablePhysicsEngine();
  111306. }
  111307. };
  111308. return PhysicsEngineSceneComponent;
  111309. }());
  111310. /***/ }),
  111311. /***/ "./Physics/physicsHelper.ts":
  111312. /*!**********************************!*\
  111313. !*** ./Physics/physicsHelper.ts ***!
  111314. \**********************************/
  111315. /*! exports provided: PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode */
  111316. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111317. "use strict";
  111318. __webpack_require__.r(__webpack_exports__);
  111319. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return PhysicsHelper; });
  111320. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return PhysicsRadialExplosionEvent; });
  111321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return PhysicsGravitationalFieldEvent; });
  111322. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return PhysicsUpdraftEvent; });
  111323. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return PhysicsVortexEvent; });
  111324. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return PhysicsRadialImpulseFalloff; });
  111325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return PhysicsUpdraftMode; });
  111326. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  111327. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  111328. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  111329. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  111330. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  111331. /**
  111332. * A helper for physics simulations
  111333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111334. */
  111335. var PhysicsHelper = /** @class */ (function () {
  111336. /**
  111337. * Initializes the Physics helper
  111338. * @param scene Babylon.js scene
  111339. */
  111340. function PhysicsHelper(scene) {
  111341. this._scene = scene;
  111342. this._physicsEngine = this._scene.getPhysicsEngine();
  111343. if (!this._physicsEngine) {
  111344. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
  111345. }
  111346. }
  111347. /**
  111348. * Applies a radial explosion impulse
  111349. * @param origin the origin of the explosion
  111350. * @param radius the explosion radius
  111351. * @param strength the explosion strength
  111352. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111353. * @returns A physics radial explosion event, or null
  111354. */
  111355. PhysicsHelper.prototype.applyRadialExplosionImpulse = function (origin, radius, strength, falloff) {
  111356. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  111357. if (!this._physicsEngine) {
  111358. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call this method.');
  111359. return null;
  111360. }
  111361. var impostors = this._physicsEngine.getImpostors();
  111362. if (impostors.length === 0) {
  111363. return null;
  111364. }
  111365. var event = new PhysicsRadialExplosionEvent(this._scene);
  111366. impostors.forEach(function (impostor) {
  111367. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  111368. if (!impostorForceAndContactPoint) {
  111369. return;
  111370. }
  111371. impostor.applyImpulse(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111372. });
  111373. event.dispose(false);
  111374. return event;
  111375. };
  111376. /**
  111377. * Applies a radial explosion force
  111378. * @param origin the origin of the explosion
  111379. * @param radius the explosion radius
  111380. * @param strength the explosion strength
  111381. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111382. * @returns A physics radial explosion event, or null
  111383. */
  111384. PhysicsHelper.prototype.applyRadialExplosionForce = function (origin, radius, strength, falloff) {
  111385. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  111386. if (!this._physicsEngine) {
  111387. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111388. return null;
  111389. }
  111390. var impostors = this._physicsEngine.getImpostors();
  111391. if (impostors.length === 0) {
  111392. return null;
  111393. }
  111394. var event = new PhysicsRadialExplosionEvent(this._scene);
  111395. impostors.forEach(function (impostor) {
  111396. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  111397. if (!impostorForceAndContactPoint) {
  111398. return;
  111399. }
  111400. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111401. });
  111402. event.dispose(false);
  111403. return event;
  111404. };
  111405. /**
  111406. * Creates a gravitational field
  111407. * @param origin the origin of the explosion
  111408. * @param radius the explosion radius
  111409. * @param strength the explosion strength
  111410. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111411. * @returns A physics gravitational field event, or null
  111412. */
  111413. PhysicsHelper.prototype.gravitationalField = function (origin, radius, strength, falloff) {
  111414. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  111415. if (!this._physicsEngine) {
  111416. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111417. return null;
  111418. }
  111419. var impostors = this._physicsEngine.getImpostors();
  111420. if (impostors.length === 0) {
  111421. return null;
  111422. }
  111423. var event = new PhysicsGravitationalFieldEvent(this, this._scene, origin, radius, strength, falloff);
  111424. event.dispose(false);
  111425. return event;
  111426. };
  111427. /**
  111428. * Creates a physics updraft event
  111429. * @param origin the origin of the updraft
  111430. * @param radius the radius of the updraft
  111431. * @param strength the strength of the updraft
  111432. * @param height the height of the updraft
  111433. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  111434. * @returns A physics updraft event, or null
  111435. */
  111436. PhysicsHelper.prototype.updraft = function (origin, radius, strength, height, updraftMode) {
  111437. if (updraftMode === void 0) { updraftMode = PhysicsUpdraftMode.Center; }
  111438. if (!this._physicsEngine) {
  111439. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111440. return null;
  111441. }
  111442. if (this._physicsEngine.getImpostors().length === 0) {
  111443. return null;
  111444. }
  111445. var event = new PhysicsUpdraftEvent(this._scene, origin, radius, strength, height, updraftMode);
  111446. event.dispose(false);
  111447. return event;
  111448. };
  111449. /**
  111450. * Creates a physics vortex event
  111451. * @param origin the of the vortex
  111452. * @param radius the radius of the vortex
  111453. * @param strength the strength of the vortex
  111454. * @param height the height of the vortex
  111455. * @returns a Physics vortex event, or null
  111456. * A physics vortex event or null
  111457. */
  111458. PhysicsHelper.prototype.vortex = function (origin, radius, strength, height) {
  111459. if (!this._physicsEngine) {
  111460. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  111461. return null;
  111462. }
  111463. if (this._physicsEngine.getImpostors().length === 0) {
  111464. return null;
  111465. }
  111466. var event = new PhysicsVortexEvent(this._scene, origin, radius, strength, height);
  111467. event.dispose(false);
  111468. return event;
  111469. };
  111470. return PhysicsHelper;
  111471. }());
  111472. /**
  111473. * Represents a physics radial explosion event
  111474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111475. */
  111476. var PhysicsRadialExplosionEvent = /** @class */ (function () {
  111477. /**
  111478. * Initializes a radial explosioin event
  111479. * @param scene BabylonJS scene
  111480. */
  111481. function PhysicsRadialExplosionEvent(scene) {
  111482. this._sphereOptions = { segments: 32, diameter: 1 }; // TODO: make configurable
  111483. this._rays = [];
  111484. this._dataFetched = false; // check if the data has been fetched. If not, do cleanup
  111485. this._scene = scene;
  111486. }
  111487. /**
  111488. * Returns the data related to the radial explosion event (sphere & rays).
  111489. * @returns The radial explosion event data
  111490. */
  111491. PhysicsRadialExplosionEvent.prototype.getData = function () {
  111492. this._dataFetched = true;
  111493. return {
  111494. sphere: this._sphere,
  111495. rays: this._rays,
  111496. };
  111497. };
  111498. /**
  111499. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  111500. * @param impostor A physics imposter
  111501. * @param origin the origin of the explosion
  111502. * @param radius the explosion radius
  111503. * @param strength the explosion strength
  111504. * @param falloff possible options: Constant & Linear
  111505. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  111506. */
  111507. PhysicsRadialExplosionEvent.prototype.getImpostorForceAndContactPoint = function (impostor, origin, radius, strength, falloff) {
  111508. if (impostor.mass === 0) {
  111509. return null;
  111510. }
  111511. if (!this._intersectsWithSphere(impostor, origin, radius)) {
  111512. return null;
  111513. }
  111514. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  111515. return null;
  111516. }
  111517. var impostorObjectCenter = impostor.getObjectCenter();
  111518. var direction = impostorObjectCenter.subtract(origin);
  111519. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_4__["Ray"](origin, direction, radius);
  111520. this._rays.push(ray);
  111521. var hit = ray.intersectsMesh(impostor.object);
  111522. var contactPoint = hit.pickedPoint;
  111523. if (!contactPoint) {
  111524. return null;
  111525. }
  111526. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(origin, contactPoint);
  111527. if (distanceFromOrigin > radius) {
  111528. return null;
  111529. }
  111530. var multiplier = falloff === PhysicsRadialImpulseFalloff.Constant
  111531. ? strength
  111532. : strength * (1 - (distanceFromOrigin / radius));
  111533. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  111534. return { force: force, contactPoint: contactPoint };
  111535. };
  111536. /**
  111537. * Disposes the sphere.
  111538. * @param force Specifies if the sphere should be disposed by force
  111539. */
  111540. PhysicsRadialExplosionEvent.prototype.dispose = function (force) {
  111541. var _this = this;
  111542. if (force === void 0) { force = true; }
  111543. if (force) {
  111544. this._sphere.dispose();
  111545. }
  111546. else {
  111547. setTimeout(function () {
  111548. if (!_this._dataFetched) {
  111549. _this._sphere.dispose();
  111550. }
  111551. }, 0);
  111552. }
  111553. };
  111554. /*** Helpers ***/
  111555. PhysicsRadialExplosionEvent.prototype._prepareSphere = function () {
  111556. if (!this._sphere) {
  111557. this._sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__["SphereBuilder"].CreateSphere("radialExplosionEventSphere", this._sphereOptions, this._scene);
  111558. this._sphere.isVisible = false;
  111559. }
  111560. };
  111561. PhysicsRadialExplosionEvent.prototype._intersectsWithSphere = function (impostor, origin, radius) {
  111562. var impostorObject = impostor.object;
  111563. this._prepareSphere();
  111564. this._sphere.position = origin;
  111565. this._sphere.scaling = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](radius * 2, radius * 2, radius * 2);
  111566. this._sphere._updateBoundingInfo();
  111567. this._sphere.computeWorldMatrix(true);
  111568. return this._sphere.intersectsMesh(impostorObject, true);
  111569. };
  111570. return PhysicsRadialExplosionEvent;
  111571. }());
  111572. /**
  111573. * Represents a gravitational field event
  111574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111575. */
  111576. var PhysicsGravitationalFieldEvent = /** @class */ (function () {
  111577. /**
  111578. * Initializes the physics gravitational field event
  111579. * @param physicsHelper A physics helper
  111580. * @param scene BabylonJS scene
  111581. * @param origin The origin position of the gravitational field event
  111582. * @param radius The radius of the gravitational field event
  111583. * @param strength The strength of the gravitational field event
  111584. * @param falloff The falloff for the gravitational field event
  111585. */
  111586. function PhysicsGravitationalFieldEvent(physicsHelper, scene, origin, radius, strength, falloff) {
  111587. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  111588. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  111589. this._physicsHelper = physicsHelper;
  111590. this._scene = scene;
  111591. this._origin = origin;
  111592. this._radius = radius;
  111593. this._strength = strength;
  111594. this._falloff = falloff;
  111595. this._tickCallback = this._tick.bind(this);
  111596. }
  111597. /**
  111598. * Returns the data related to the gravitational field event (sphere).
  111599. * @returns A gravitational field event
  111600. */
  111601. PhysicsGravitationalFieldEvent.prototype.getData = function () {
  111602. this._dataFetched = true;
  111603. return {
  111604. sphere: this._sphere,
  111605. };
  111606. };
  111607. /**
  111608. * Enables the gravitational field.
  111609. */
  111610. PhysicsGravitationalFieldEvent.prototype.enable = function () {
  111611. this._tickCallback.call(this);
  111612. this._scene.registerBeforeRender(this._tickCallback);
  111613. };
  111614. /**
  111615. * Disables the gravitational field.
  111616. */
  111617. PhysicsGravitationalFieldEvent.prototype.disable = function () {
  111618. this._scene.unregisterBeforeRender(this._tickCallback);
  111619. };
  111620. /**
  111621. * Disposes the sphere.
  111622. * @param force The force to dispose from the gravitational field event
  111623. */
  111624. PhysicsGravitationalFieldEvent.prototype.dispose = function (force) {
  111625. var _this = this;
  111626. if (force === void 0) { force = true; }
  111627. if (force) {
  111628. this._sphere.dispose();
  111629. }
  111630. else {
  111631. setTimeout(function () {
  111632. if (!_this._dataFetched) {
  111633. _this._sphere.dispose();
  111634. }
  111635. }, 0);
  111636. }
  111637. };
  111638. PhysicsGravitationalFieldEvent.prototype._tick = function () {
  111639. // Since the params won't change, we fetch the event only once
  111640. if (this._sphere) {
  111641. this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  111642. }
  111643. else {
  111644. var radialExplosionEvent = this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  111645. if (radialExplosionEvent) {
  111646. this._sphere = radialExplosionEvent.getData().sphere.clone('radialExplosionEventSphereClone');
  111647. }
  111648. }
  111649. };
  111650. return PhysicsGravitationalFieldEvent;
  111651. }());
  111652. /**
  111653. * Represents a physics updraft event
  111654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111655. */
  111656. var PhysicsUpdraftEvent = /** @class */ (function () {
  111657. /**
  111658. * Initializes the physics updraft event
  111659. * @param _scene BabylonJS scene
  111660. * @param _origin The origin position of the updraft
  111661. * @param _radius The radius of the updraft
  111662. * @param _strength The strength of the updraft
  111663. * @param _height The height of the updraft
  111664. * @param _updraftMode The mode of the updraft
  111665. */
  111666. function PhysicsUpdraftEvent(_scene, _origin, _radius, _strength, _height, _updraftMode) {
  111667. this._scene = _scene;
  111668. this._origin = _origin;
  111669. this._radius = _radius;
  111670. this._strength = _strength;
  111671. this._height = _height;
  111672. this._updraftMode = _updraftMode;
  111673. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  111674. this._originDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // used if the updraftMode is perpendicular
  111675. 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
  111676. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  111677. this._physicsEngine = this._scene.getPhysicsEngine();
  111678. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  111679. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  111680. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  111681. this._originDirection = this._origin.subtract(this._originTop).normalize();
  111682. }
  111683. this._tickCallback = this._tick.bind(this);
  111684. this._prepareCylinder();
  111685. }
  111686. /**
  111687. * Returns the data related to the updraft event (cylinder).
  111688. * @returns A physics updraft event
  111689. */
  111690. PhysicsUpdraftEvent.prototype.getData = function () {
  111691. this._dataFetched = true;
  111692. return {
  111693. cylinder: this._cylinder,
  111694. };
  111695. };
  111696. /**
  111697. * Enables the updraft.
  111698. */
  111699. PhysicsUpdraftEvent.prototype.enable = function () {
  111700. this._tickCallback.call(this);
  111701. this._scene.registerBeforeRender(this._tickCallback);
  111702. };
  111703. /**
  111704. * Disables the cortex.
  111705. */
  111706. PhysicsUpdraftEvent.prototype.disable = function () {
  111707. this._scene.unregisterBeforeRender(this._tickCallback);
  111708. };
  111709. /**
  111710. * Disposes the sphere.
  111711. * @param force Specifies if the updraft should be disposed by force
  111712. */
  111713. PhysicsUpdraftEvent.prototype.dispose = function (force) {
  111714. var _this = this;
  111715. if (force === void 0) { force = true; }
  111716. if (!this._cylinder) {
  111717. return;
  111718. }
  111719. if (force) {
  111720. this._cylinder.dispose();
  111721. }
  111722. else {
  111723. setTimeout(function () {
  111724. if (!_this._dataFetched) {
  111725. _this._cylinder.dispose();
  111726. }
  111727. }, 0);
  111728. }
  111729. };
  111730. PhysicsUpdraftEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  111731. if (impostor.mass === 0) {
  111732. return null;
  111733. }
  111734. if (!this._intersectsWithCylinder(impostor)) {
  111735. return null;
  111736. }
  111737. var impostorObjectCenter = impostor.getObjectCenter();
  111738. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  111739. var direction = this._originDirection;
  111740. }
  111741. else {
  111742. var direction = impostorObjectCenter.subtract(this._originTop);
  111743. }
  111744. var multiplier = this._strength * -1;
  111745. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  111746. return { force: force, contactPoint: impostorObjectCenter };
  111747. };
  111748. PhysicsUpdraftEvent.prototype._tick = function () {
  111749. var _this = this;
  111750. this._physicsEngine.getImpostors().forEach(function (impostor) {
  111751. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  111752. if (!impostorForceAndContactPoint) {
  111753. return;
  111754. }
  111755. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111756. });
  111757. };
  111758. /*** Helpers ***/
  111759. PhysicsUpdraftEvent.prototype._prepareCylinder = function () {
  111760. if (!this._cylinder) {
  111761. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__["CylinderBuilder"].CreateCylinder("updraftEventCylinder", {
  111762. height: this._height,
  111763. diameter: this._radius * 2,
  111764. }, this._scene);
  111765. this._cylinder.isVisible = false;
  111766. }
  111767. };
  111768. PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
  111769. var impostorObject = impostor.object;
  111770. this._cylinder.position = this._cylinderPosition;
  111771. return this._cylinder.intersectsMesh(impostorObject, true);
  111772. };
  111773. return PhysicsUpdraftEvent;
  111774. }());
  111775. /**
  111776. * Represents a physics vortex event
  111777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111778. */
  111779. var PhysicsVortexEvent = /** @class */ (function () {
  111780. /**
  111781. * Initializes the physics vortex event
  111782. * @param _scene The BabylonJS scene
  111783. * @param _origin The origin position of the vortex
  111784. * @param _radius The radius of the vortex
  111785. * @param _strength The strength of the vortex
  111786. * @param _height The height of the vortex
  111787. */
  111788. function PhysicsVortexEvent(_scene, _origin, _radius, _strength, _height) {
  111789. this._scene = _scene;
  111790. this._origin = _origin;
  111791. this._radius = _radius;
  111792. this._strength = _strength;
  111793. this._height = _height;
  111794. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  111795. this._centripetalForceThreshold = 0.7; // at which distance, relative to the radius the centripetal forces should kick in
  111796. this._updraftMultiplier = 0.02;
  111797. 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
  111798. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  111799. this._physicsEngine = this._scene.getPhysicsEngine();
  111800. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  111801. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  111802. this._tickCallback = this._tick.bind(this);
  111803. this._prepareCylinder();
  111804. }
  111805. /**
  111806. * Returns the data related to the vortex event (cylinder).
  111807. * @returns The physics vortex event data
  111808. */
  111809. PhysicsVortexEvent.prototype.getData = function () {
  111810. this._dataFetched = true;
  111811. return {
  111812. cylinder: this._cylinder,
  111813. };
  111814. };
  111815. /**
  111816. * Enables the vortex.
  111817. */
  111818. PhysicsVortexEvent.prototype.enable = function () {
  111819. this._tickCallback.call(this);
  111820. this._scene.registerBeforeRender(this._tickCallback);
  111821. };
  111822. /**
  111823. * Disables the cortex.
  111824. */
  111825. PhysicsVortexEvent.prototype.disable = function () {
  111826. this._scene.unregisterBeforeRender(this._tickCallback);
  111827. };
  111828. /**
  111829. * Disposes the sphere.
  111830. * @param force
  111831. */
  111832. PhysicsVortexEvent.prototype.dispose = function (force) {
  111833. var _this = this;
  111834. if (force === void 0) { force = true; }
  111835. if (force) {
  111836. this._cylinder.dispose();
  111837. }
  111838. else {
  111839. setTimeout(function () {
  111840. if (!_this._dataFetched) {
  111841. _this._cylinder.dispose();
  111842. }
  111843. }, 0);
  111844. }
  111845. };
  111846. PhysicsVortexEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  111847. if (impostor.mass === 0) {
  111848. return null;
  111849. }
  111850. if (!this._intersectsWithCylinder(impostor)) {
  111851. return null;
  111852. }
  111853. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  111854. return null;
  111855. }
  111856. var impostorObjectCenter = impostor.getObjectCenter();
  111857. 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)
  111858. var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
  111859. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_4__["Ray"](originOnPlane, originToImpostorDirection, this._radius);
  111860. var hit = ray.intersectsMesh(impostor.object);
  111861. var contactPoint = hit.pickedPoint;
  111862. if (!contactPoint) {
  111863. return null;
  111864. }
  111865. var absoluteDistanceFromOrigin = hit.distance / this._radius;
  111866. var perpendicularDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(originOnPlane, impostorObjectCenter).normalize();
  111867. var directionToOrigin = contactPoint.normalize();
  111868. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  111869. directionToOrigin = directionToOrigin.negate();
  111870. }
  111871. // TODO: find a more physically based solution
  111872. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  111873. var forceX = directionToOrigin.x * this._strength / 8;
  111874. var forceY = directionToOrigin.y * this._updraftMultiplier;
  111875. var forceZ = directionToOrigin.z * this._strength / 8;
  111876. }
  111877. else {
  111878. var forceX = (perpendicularDirection.x + directionToOrigin.x) / 2;
  111879. var forceY = this._originTop.y * this._updraftMultiplier;
  111880. var forceZ = (perpendicularDirection.z + directionToOrigin.z) / 2;
  111881. }
  111882. var force = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](forceX, forceY, forceZ);
  111883. force = force.multiplyByFloats(this._strength, this._strength, this._strength);
  111884. return { force: force, contactPoint: impostorObjectCenter };
  111885. };
  111886. PhysicsVortexEvent.prototype._tick = function () {
  111887. var _this = this;
  111888. this._physicsEngine.getImpostors().forEach(function (impostor) {
  111889. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  111890. if (!impostorForceAndContactPoint) {
  111891. return;
  111892. }
  111893. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  111894. });
  111895. };
  111896. /*** Helpers ***/
  111897. PhysicsVortexEvent.prototype._prepareCylinder = function () {
  111898. if (!this._cylinder) {
  111899. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__["CylinderBuilder"].CreateCylinder("vortexEventCylinder", {
  111900. height: this._height,
  111901. diameter: this._radius * 2,
  111902. }, this._scene);
  111903. this._cylinder.isVisible = false;
  111904. }
  111905. };
  111906. PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
  111907. var impostorObject = impostor.object;
  111908. this._cylinder.position = this._cylinderPosition;
  111909. return this._cylinder.intersectsMesh(impostorObject, true);
  111910. };
  111911. return PhysicsVortexEvent;
  111912. }());
  111913. /**
  111914. * The strenght of the force in correspondence to the distance of the affected object
  111915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111916. */
  111917. var PhysicsRadialImpulseFalloff;
  111918. (function (PhysicsRadialImpulseFalloff) {
  111919. /** Defines that impulse is constant in strength across it's whole radius */
  111920. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Constant"] = 0] = "Constant";
  111921. /** DEfines that impulse gets weaker if it's further from the origin */
  111922. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Linear"] = 1] = "Linear";
  111923. })(PhysicsRadialImpulseFalloff || (PhysicsRadialImpulseFalloff = {}));
  111924. /**
  111925. * The strength of the force in correspondence to the distance of the affected object
  111926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111927. */
  111928. var PhysicsUpdraftMode;
  111929. (function (PhysicsUpdraftMode) {
  111930. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  111931. PhysicsUpdraftMode[PhysicsUpdraftMode["Center"] = 0] = "Center";
  111932. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  111933. PhysicsUpdraftMode[PhysicsUpdraftMode["Perpendicular"] = 1] = "Perpendicular";
  111934. })(PhysicsUpdraftMode || (PhysicsUpdraftMode = {}));
  111935. /***/ }),
  111936. /***/ "./Physics/physicsImpostor.ts":
  111937. /*!************************************!*\
  111938. !*** ./Physics/physicsImpostor.ts ***!
  111939. \************************************/
  111940. /*! exports provided: PhysicsImpostor */
  111941. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111942. "use strict";
  111943. __webpack_require__.r(__webpack_exports__);
  111944. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return PhysicsImpostor; });
  111945. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  111946. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  111947. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  111948. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  111949. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  111950. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  111951. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  111952. return new PhysicsImpostor(physicObject, jsonObject.physicsImpostor, {
  111953. mass: jsonObject.physicsMass,
  111954. friction: jsonObject.physicsFriction,
  111955. restitution: jsonObject.physicsRestitution
  111956. }, scene);
  111957. };
  111958. /**
  111959. * Represents a physics imposter
  111960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111961. */
  111962. var PhysicsImpostor = /** @class */ (function () {
  111963. /**
  111964. * Initializes the physics imposter
  111965. * @param object The physics-enabled object used as the physics imposter
  111966. * @param type The type of the physics imposter
  111967. * @param _options The options for the physics imposter
  111968. * @param _scene The Babylon scene
  111969. */
  111970. function PhysicsImpostor(
  111971. /**
  111972. * The physics-enabled object used as the physics imposter
  111973. */
  111974. object,
  111975. /**
  111976. * The type of the physics imposter
  111977. */
  111978. type, _options, _scene) {
  111979. if (_options === void 0) { _options = { mass: 0 }; }
  111980. var _this = this;
  111981. this.object = object;
  111982. this.type = type;
  111983. this._options = _options;
  111984. this._scene = _scene;
  111985. this._bodyUpdateRequired = false;
  111986. this._onBeforePhysicsStepCallbacks = new Array();
  111987. this._onAfterPhysicsStepCallbacks = new Array();
  111988. /** @hidden */
  111989. this._onPhysicsCollideCallbacks = [];
  111990. this._deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  111991. this._isDisposed = false;
  111992. //temp variables for parent rotation calculations
  111993. //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];
  111994. this._tmpQuat = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  111995. this._tmpQuat2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  111996. /**
  111997. * this function is executed by the physics engine.
  111998. */
  111999. this.beforeStep = function () {
  112000. if (!_this._physicsEngine) {
  112001. return;
  112002. }
  112003. _this.object.translate(_this._deltaPosition, -1);
  112004. _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
  112005. _this.object.computeWorldMatrix(false);
  112006. if (_this.object.parent && _this.object.rotationQuaternion) {
  112007. _this.getParentsRotation();
  112008. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this._tmpQuat);
  112009. }
  112010. else {
  112011. _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]());
  112012. }
  112013. if (!_this._options.disableBidirectionalTransformation) {
  112014. _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
  112015. }
  112016. _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
  112017. func(_this);
  112018. });
  112019. };
  112020. /**
  112021. * this function is executed by the physics engine
  112022. */
  112023. this.afterStep = function () {
  112024. if (!_this._physicsEngine) {
  112025. return;
  112026. }
  112027. _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
  112028. func(_this);
  112029. });
  112030. _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
  112031. // object has now its world rotation. needs to be converted to local.
  112032. if (_this.object.parent && _this.object.rotationQuaternion) {
  112033. _this.getParentsRotation();
  112034. _this._tmpQuat.conjugateInPlace();
  112035. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
  112036. }
  112037. // take the position set and make it the absolute position of this object.
  112038. _this.object.setAbsolutePosition(_this.object.position);
  112039. _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
  112040. _this.object.translate(_this._deltaPosition, 1);
  112041. };
  112042. /**
  112043. * Legacy collision detection event support
  112044. */
  112045. this.onCollideEvent = null;
  112046. /**
  112047. * event and body object due to cannon's event-based architecture.
  112048. */
  112049. this.onCollide = function (e) {
  112050. if (!_this._onPhysicsCollideCallbacks.length && !_this.onCollideEvent) {
  112051. return;
  112052. }
  112053. if (!_this._physicsEngine) {
  112054. return;
  112055. }
  112056. var otherImpostor = _this._physicsEngine.getImpostorWithPhysicsBody(e.body);
  112057. if (otherImpostor) {
  112058. // Legacy collision detection event support
  112059. if (_this.onCollideEvent) {
  112060. _this.onCollideEvent(_this, otherImpostor);
  112061. }
  112062. _this._onPhysicsCollideCallbacks.filter(function (obj) {
  112063. return obj.otherImpostors.indexOf(otherImpostor) !== -1;
  112064. }).forEach(function (obj) {
  112065. obj.callback(_this, otherImpostor);
  112066. });
  112067. }
  112068. };
  112069. //sanity check!
  112070. if (!this.object) {
  112071. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("No object was provided. A physics object is obligatory");
  112072. return;
  112073. }
  112074. // Legacy support for old syntax.
  112075. if (!this._scene && object.getScene) {
  112076. this._scene = object.getScene();
  112077. }
  112078. if (!this._scene) {
  112079. return;
  112080. }
  112081. this._physicsEngine = this._scene.getPhysicsEngine();
  112082. if (!this._physicsEngine) {
  112083. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
  112084. }
  112085. else {
  112086. //set the object's quaternion, if not set
  112087. if (!this.object.rotationQuaternion) {
  112088. if (this.object.rotation) {
  112089. this.object.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);
  112090. }
  112091. else {
  112092. this.object.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  112093. }
  112094. }
  112095. //default options params
  112096. this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
  112097. this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
  112098. this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
  112099. this._joints = [];
  112100. //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
  112101. if (!this.object.parent || this._options.ignoreParent) {
  112102. this._init();
  112103. }
  112104. else if (this.object.parent.physicsImpostor) {
  112105. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("You must affect impostors to children before affecting impostor to parent.");
  112106. }
  112107. }
  112108. }
  112109. Object.defineProperty(PhysicsImpostor.prototype, "isDisposed", {
  112110. /**
  112111. * Specifies if the physics imposter is disposed
  112112. */
  112113. get: function () {
  112114. return this._isDisposed;
  112115. },
  112116. enumerable: true,
  112117. configurable: true
  112118. });
  112119. Object.defineProperty(PhysicsImpostor.prototype, "mass", {
  112120. /**
  112121. * Gets the mass of the physics imposter
  112122. */
  112123. get: function () {
  112124. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
  112125. },
  112126. set: function (value) {
  112127. this.setMass(value);
  112128. },
  112129. enumerable: true,
  112130. configurable: true
  112131. });
  112132. Object.defineProperty(PhysicsImpostor.prototype, "friction", {
  112133. /**
  112134. * Gets the coefficient of friction
  112135. */
  112136. get: function () {
  112137. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
  112138. },
  112139. /**
  112140. * Sets the coefficient of friction
  112141. */
  112142. set: function (value) {
  112143. if (!this._physicsEngine) {
  112144. return;
  112145. }
  112146. this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);
  112147. },
  112148. enumerable: true,
  112149. configurable: true
  112150. });
  112151. Object.defineProperty(PhysicsImpostor.prototype, "restitution", {
  112152. /**
  112153. * Gets the coefficient of restitution
  112154. */
  112155. get: function () {
  112156. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
  112157. },
  112158. /**
  112159. * Sets the coefficient of restitution
  112160. */
  112161. set: function (value) {
  112162. if (!this._physicsEngine) {
  112163. return;
  112164. }
  112165. this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);
  112166. },
  112167. enumerable: true,
  112168. configurable: true
  112169. });
  112170. /**
  112171. * This function will completly initialize this impostor.
  112172. * It will create a new body - but only if this mesh has no parent.
  112173. * If it has, this impostor will not be used other than to define the impostor
  112174. * of the child mesh.
  112175. * @hidden
  112176. */
  112177. PhysicsImpostor.prototype._init = function () {
  112178. if (!this._physicsEngine) {
  112179. return;
  112180. }
  112181. this._physicsEngine.removeImpostor(this);
  112182. this.physicsBody = null;
  112183. this._parent = this._parent || this._getPhysicsParent();
  112184. if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {
  112185. this._physicsEngine.addImpostor(this);
  112186. }
  112187. };
  112188. PhysicsImpostor.prototype._getPhysicsParent = function () {
  112189. if (this.object.parent instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]) {
  112190. var parentMesh = this.object.parent;
  112191. return parentMesh.physicsImpostor;
  112192. }
  112193. return null;
  112194. };
  112195. /**
  112196. * Should a new body be generated.
  112197. * @returns boolean specifying if body initialization is required
  112198. */
  112199. PhysicsImpostor.prototype.isBodyInitRequired = function () {
  112200. return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
  112201. };
  112202. /**
  112203. * Sets the updated scaling
  112204. * @param updated Specifies if the scaling is updated
  112205. */
  112206. PhysicsImpostor.prototype.setScalingUpdated = function () {
  112207. this.forceUpdate();
  112208. };
  112209. /**
  112210. * Force a regeneration of this or the parent's impostor's body.
  112211. * Use under cautious - This will remove all joints already implemented.
  112212. */
  112213. PhysicsImpostor.prototype.forceUpdate = function () {
  112214. this._init();
  112215. if (this.parent && !this._options.ignoreParent) {
  112216. this.parent.forceUpdate();
  112217. }
  112218. };
  112219. Object.defineProperty(PhysicsImpostor.prototype, "physicsBody", {
  112220. /*public get mesh(): AbstractMesh {
  112221. return this._mesh;
  112222. }*/
  112223. /**
  112224. * Gets the body that holds this impostor. Either its own, or its parent.
  112225. */
  112226. get: function () {
  112227. return (this._parent && !this._options.ignoreParent) ? this._parent.physicsBody : this._physicsBody;
  112228. },
  112229. /**
  112230. * Set the physics body. Used mainly by the physics engine/plugin
  112231. */
  112232. set: function (physicsBody) {
  112233. if (this._physicsBody && this._physicsEngine) {
  112234. this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);
  112235. }
  112236. this._physicsBody = physicsBody;
  112237. this.resetUpdateFlags();
  112238. },
  112239. enumerable: true,
  112240. configurable: true
  112241. });
  112242. Object.defineProperty(PhysicsImpostor.prototype, "parent", {
  112243. /**
  112244. * Get the parent of the physics imposter
  112245. * @returns Physics imposter or null
  112246. */
  112247. get: function () {
  112248. return !this._options.ignoreParent && this._parent ? this._parent : null;
  112249. },
  112250. /**
  112251. * Sets the parent of the physics imposter
  112252. */
  112253. set: function (value) {
  112254. this._parent = value;
  112255. },
  112256. enumerable: true,
  112257. configurable: true
  112258. });
  112259. /**
  112260. * Resets the update flags
  112261. */
  112262. PhysicsImpostor.prototype.resetUpdateFlags = function () {
  112263. this._bodyUpdateRequired = false;
  112264. };
  112265. /**
  112266. * Gets the object extend size
  112267. * @returns the object extend size
  112268. */
  112269. PhysicsImpostor.prototype.getObjectExtendSize = function () {
  112270. if (this.object.getBoundingInfo) {
  112271. var q = this.object.rotationQuaternion;
  112272. //reset rotation
  112273. this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;
  112274. //calculate the world matrix with no rotation
  112275. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  112276. var boundingInfo = this.object.getBoundingInfo();
  112277. var size = boundingInfo.boundingBox.extendSizeWorld.scale(2);
  112278. //bring back the rotation
  112279. this.object.rotationQuaternion = q;
  112280. //calculate the world matrix with the new rotation
  112281. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  112282. return size;
  112283. }
  112284. else {
  112285. return PhysicsImpostor.DEFAULT_OBJECT_SIZE;
  112286. }
  112287. };
  112288. /**
  112289. * Gets the object center
  112290. * @returns The object center
  112291. */
  112292. PhysicsImpostor.prototype.getObjectCenter = function () {
  112293. if (this.object.getBoundingInfo) {
  112294. var boundingInfo = this.object.getBoundingInfo();
  112295. return boundingInfo.boundingBox.centerWorld;
  112296. }
  112297. else {
  112298. return this.object.position;
  112299. }
  112300. };
  112301. /**
  112302. * Get a specific parametes from the options parameter
  112303. * @param paramName The object parameter name
  112304. * @returns The object parameter
  112305. */
  112306. PhysicsImpostor.prototype.getParam = function (paramName) {
  112307. return this._options[paramName];
  112308. };
  112309. /**
  112310. * Sets a specific parameter in the options given to the physics plugin
  112311. * @param paramName The parameter name
  112312. * @param value The value of the parameter
  112313. */
  112314. PhysicsImpostor.prototype.setParam = function (paramName, value) {
  112315. this._options[paramName] = value;
  112316. this._bodyUpdateRequired = true;
  112317. };
  112318. /**
  112319. * Specifically change the body's mass option. Won't recreate the physics body object
  112320. * @param mass The mass of the physics imposter
  112321. */
  112322. PhysicsImpostor.prototype.setMass = function (mass) {
  112323. if (this.getParam("mass") !== mass) {
  112324. this.setParam("mass", mass);
  112325. }
  112326. if (this._physicsEngine) {
  112327. this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
  112328. }
  112329. };
  112330. /**
  112331. * Gets the linear velocity
  112332. * @returns linear velocity or null
  112333. */
  112334. PhysicsImpostor.prototype.getLinearVelocity = function () {
  112335. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  112336. };
  112337. /**
  112338. * Sets the linear velocity
  112339. * @param velocity linear velocity or null
  112340. */
  112341. PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
  112342. if (this._physicsEngine) {
  112343. this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
  112344. }
  112345. };
  112346. /**
  112347. * Gets the angular velocity
  112348. * @returns angular velocity or null
  112349. */
  112350. PhysicsImpostor.prototype.getAngularVelocity = function () {
  112351. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  112352. };
  112353. /**
  112354. * Sets the angular velocity
  112355. * @param velocity The velocity or null
  112356. */
  112357. PhysicsImpostor.prototype.setAngularVelocity = function (velocity) {
  112358. if (this._physicsEngine) {
  112359. this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);
  112360. }
  112361. };
  112362. /**
  112363. * Execute a function with the physics plugin native code
  112364. * Provide a function the will have two variables - the world object and the physics body object
  112365. * @param func The function to execute with the physics plugin native code
  112366. */
  112367. PhysicsImpostor.prototype.executeNativeFunction = function (func) {
  112368. if (this._physicsEngine) {
  112369. func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
  112370. }
  112371. };
  112372. /**
  112373. * Register a function that will be executed before the physics world is stepping forward
  112374. * @param func The function to execute before the physics world is stepped forward
  112375. */
  112376. PhysicsImpostor.prototype.registerBeforePhysicsStep = function (func) {
  112377. this._onBeforePhysicsStepCallbacks.push(func);
  112378. };
  112379. /**
  112380. * Unregister a function that will be executed before the physics world is stepping forward
  112381. * @param func The function to execute before the physics world is stepped forward
  112382. */
  112383. PhysicsImpostor.prototype.unregisterBeforePhysicsStep = function (func) {
  112384. var index = this._onBeforePhysicsStepCallbacks.indexOf(func);
  112385. if (index > -1) {
  112386. this._onBeforePhysicsStepCallbacks.splice(index, 1);
  112387. }
  112388. else {
  112389. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  112390. }
  112391. };
  112392. /**
  112393. * Register a function that will be executed after the physics step
  112394. * @param func The function to execute after physics step
  112395. */
  112396. PhysicsImpostor.prototype.registerAfterPhysicsStep = function (func) {
  112397. this._onAfterPhysicsStepCallbacks.push(func);
  112398. };
  112399. /**
  112400. * Unregisters a function that will be executed after the physics step
  112401. * @param func The function to execute after physics step
  112402. */
  112403. PhysicsImpostor.prototype.unregisterAfterPhysicsStep = function (func) {
  112404. var index = this._onAfterPhysicsStepCallbacks.indexOf(func);
  112405. if (index > -1) {
  112406. this._onAfterPhysicsStepCallbacks.splice(index, 1);
  112407. }
  112408. else {
  112409. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  112410. }
  112411. };
  112412. /**
  112413. * register a function that will be executed when this impostor collides against a different body
  112414. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  112415. * @param func Callback that is executed on collision
  112416. */
  112417. PhysicsImpostor.prototype.registerOnPhysicsCollide = function (collideAgainst, func) {
  112418. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  112419. this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });
  112420. };
  112421. /**
  112422. * Unregisters the physics imposter on contact
  112423. * @param collideAgainst The physics object to collide against
  112424. * @param func Callback to execute on collision
  112425. */
  112426. PhysicsImpostor.prototype.unregisterOnPhysicsCollide = function (collideAgainst, func) {
  112427. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  112428. var index = -1;
  112429. var found = this._onPhysicsCollideCallbacks.some(function (cbDef, idx) {
  112430. if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {
  112431. // chcek the arrays match
  112432. var sameList = cbDef.otherImpostors.every(function (impostor) {
  112433. return collidedAgainstList.indexOf(impostor) > -1;
  112434. });
  112435. if (sameList) {
  112436. index = idx;
  112437. }
  112438. return sameList;
  112439. }
  112440. return false;
  112441. });
  112442. if (found) {
  112443. this._onPhysicsCollideCallbacks.splice(index, 1);
  112444. }
  112445. else {
  112446. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  112447. }
  112448. };
  112449. /**
  112450. * Get the parent rotation
  112451. * @returns The parent rotation
  112452. */
  112453. PhysicsImpostor.prototype.getParentsRotation = function () {
  112454. var parent = this.object.parent;
  112455. this._tmpQuat.copyFromFloats(0, 0, 0, 1);
  112456. while (parent) {
  112457. if (parent.rotationQuaternion) {
  112458. this._tmpQuat2.copyFrom(parent.rotationQuaternion);
  112459. }
  112460. else {
  112461. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);
  112462. }
  112463. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);
  112464. parent = parent.parent;
  112465. }
  112466. return this._tmpQuat;
  112467. };
  112468. /**
  112469. * Apply a force
  112470. * @param force The force to apply
  112471. * @param contactPoint The contact point for the force
  112472. * @returns The physics imposter
  112473. */
  112474. PhysicsImpostor.prototype.applyForce = function (force, contactPoint) {
  112475. if (this._physicsEngine) {
  112476. this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);
  112477. }
  112478. return this;
  112479. };
  112480. /**
  112481. * Apply an impulse
  112482. * @param force The impulse force
  112483. * @param contactPoint The contact point for the impulse force
  112484. * @returns The physics imposter
  112485. */
  112486. PhysicsImpostor.prototype.applyImpulse = function (force, contactPoint) {
  112487. if (this._physicsEngine) {
  112488. this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);
  112489. }
  112490. return this;
  112491. };
  112492. /**
  112493. * A help function to create a joint
  112494. * @param otherImpostor A physics imposter used to create a joint
  112495. * @param jointType The type of joint
  112496. * @param jointData The data for the joint
  112497. * @returns The physics imposter
  112498. */
  112499. PhysicsImpostor.prototype.createJoint = function (otherImpostor, jointType, jointData) {
  112500. var joint = new _physicsJoint__WEBPACK_IMPORTED_MODULE_5__["PhysicsJoint"](jointType, jointData);
  112501. this.addJoint(otherImpostor, joint);
  112502. return this;
  112503. };
  112504. /**
  112505. * Add a joint to this impostor with a different impostor
  112506. * @param otherImpostor A physics imposter used to add a joint
  112507. * @param joint The joint to add
  112508. * @returns The physics imposter
  112509. */
  112510. PhysicsImpostor.prototype.addJoint = function (otherImpostor, joint) {
  112511. this._joints.push({
  112512. otherImpostor: otherImpostor,
  112513. joint: joint
  112514. });
  112515. if (this._physicsEngine) {
  112516. this._physicsEngine.addJoint(this, otherImpostor, joint);
  112517. }
  112518. return this;
  112519. };
  112520. /**
  112521. * Will keep this body still, in a sleep mode.
  112522. * @returns the physics imposter
  112523. */
  112524. PhysicsImpostor.prototype.sleep = function () {
  112525. if (this._physicsEngine) {
  112526. this._physicsEngine.getPhysicsPlugin().sleepBody(this);
  112527. }
  112528. return this;
  112529. };
  112530. /**
  112531. * Wake the body up.
  112532. * @returns The physics imposter
  112533. */
  112534. PhysicsImpostor.prototype.wakeUp = function () {
  112535. if (this._physicsEngine) {
  112536. this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);
  112537. }
  112538. return this;
  112539. };
  112540. /**
  112541. * Clones the physics imposter
  112542. * @param newObject The physics imposter clones to this physics-enabled object
  112543. * @returns A nullable physics imposter
  112544. */
  112545. PhysicsImpostor.prototype.clone = function (newObject) {
  112546. if (!newObject) {
  112547. return null;
  112548. }
  112549. return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
  112550. };
  112551. /**
  112552. * Disposes the physics imposter
  112553. */
  112554. PhysicsImpostor.prototype.dispose = function ( /*disposeChildren: boolean = true*/) {
  112555. var _this = this;
  112556. //no dispose if no physics engine is available.
  112557. if (!this._physicsEngine) {
  112558. return;
  112559. }
  112560. this._joints.forEach(function (j) {
  112561. if (_this._physicsEngine) {
  112562. _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
  112563. }
  112564. });
  112565. //dispose the physics body
  112566. this._physicsEngine.removeImpostor(this);
  112567. if (this.parent) {
  112568. this.parent.forceUpdate();
  112569. }
  112570. else {
  112571. /*this._object.getChildMeshes().forEach(function(mesh) {
  112572. if (mesh.physicsImpostor) {
  112573. if (disposeChildren) {
  112574. mesh.physicsImpostor.dispose();
  112575. mesh.physicsImpostor = null;
  112576. }
  112577. }
  112578. })*/
  112579. }
  112580. this._isDisposed = true;
  112581. };
  112582. /**
  112583. * Sets the delta position
  112584. * @param position The delta position amount
  112585. */
  112586. PhysicsImpostor.prototype.setDeltaPosition = function (position) {
  112587. this._deltaPosition.copyFrom(position);
  112588. };
  112589. /**
  112590. * Sets the delta rotation
  112591. * @param rotation The delta rotation amount
  112592. */
  112593. PhysicsImpostor.prototype.setDeltaRotation = function (rotation) {
  112594. if (!this._deltaRotation) {
  112595. this._deltaRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  112596. }
  112597. this._deltaRotation.copyFrom(rotation);
  112598. this._deltaRotationConjugated = this._deltaRotation.conjugate();
  112599. };
  112600. /**
  112601. * Gets the box size of the physics imposter and stores the result in the input parameter
  112602. * @param result Stores the box size
  112603. * @returns The physics imposter
  112604. */
  112605. PhysicsImpostor.prototype.getBoxSizeToRef = function (result) {
  112606. if (this._physicsEngine) {
  112607. this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);
  112608. }
  112609. return this;
  112610. };
  112611. /**
  112612. * Gets the radius of the physics imposter
  112613. * @returns Radius of the physics imposter
  112614. */
  112615. PhysicsImpostor.prototype.getRadius = function () {
  112616. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
  112617. };
  112618. /**
  112619. * Sync a bone with this impostor
  112620. * @param bone The bone to sync to the impostor.
  112621. * @param boneMesh The mesh that the bone is influencing.
  112622. * @param jointPivot The pivot of the joint / bone in local space.
  112623. * @param distToJoint Optional distance from the impostor to the joint.
  112624. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  112625. */
  112626. PhysicsImpostor.prototype.syncBoneWithImpostor = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation) {
  112627. var tempVec = PhysicsImpostor._tmpVecs[0];
  112628. var mesh = this.object;
  112629. if (mesh.rotationQuaternion) {
  112630. if (adjustRotation) {
  112631. var tempQuat = PhysicsImpostor._tmpQuat;
  112632. mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);
  112633. bone.setRotationQuaternion(tempQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  112634. }
  112635. else {
  112636. bone.setRotationQuaternion(mesh.rotationQuaternion, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  112637. }
  112638. }
  112639. tempVec.x = 0;
  112640. tempVec.y = 0;
  112641. tempVec.z = 0;
  112642. if (jointPivot) {
  112643. tempVec.x = jointPivot.x;
  112644. tempVec.y = jointPivot.y;
  112645. tempVec.z = jointPivot.z;
  112646. bone.getDirectionToRef(tempVec, boneMesh, tempVec);
  112647. if (distToJoint === undefined || distToJoint === null) {
  112648. distToJoint = jointPivot.length();
  112649. }
  112650. tempVec.x *= distToJoint;
  112651. tempVec.y *= distToJoint;
  112652. tempVec.z *= distToJoint;
  112653. }
  112654. if (bone.getParent()) {
  112655. tempVec.addInPlace(mesh.getAbsolutePosition());
  112656. bone.setAbsolutePosition(tempVec, boneMesh);
  112657. }
  112658. else {
  112659. boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());
  112660. boneMesh.position.x -= tempVec.x;
  112661. boneMesh.position.y -= tempVec.y;
  112662. boneMesh.position.z -= tempVec.z;
  112663. }
  112664. };
  112665. /**
  112666. * Sync impostor to a bone
  112667. * @param bone The bone that the impostor will be synced to.
  112668. * @param boneMesh The mesh that the bone is influencing.
  112669. * @param jointPivot The pivot of the joint / bone in local space.
  112670. * @param distToJoint Optional distance from the impostor to the joint.
  112671. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  112672. * @param boneAxis Optional vector3 axis the bone is aligned with
  112673. */
  112674. PhysicsImpostor.prototype.syncImpostorWithBone = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
  112675. var mesh = this.object;
  112676. if (mesh.rotationQuaternion) {
  112677. if (adjustRotation) {
  112678. var tempQuat = PhysicsImpostor._tmpQuat;
  112679. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, tempQuat);
  112680. tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
  112681. }
  112682. else {
  112683. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, mesh.rotationQuaternion);
  112684. }
  112685. }
  112686. var pos = PhysicsImpostor._tmpVecs[0];
  112687. var boneDir = PhysicsImpostor._tmpVecs[1];
  112688. if (!boneAxis) {
  112689. boneAxis = PhysicsImpostor._tmpVecs[2];
  112690. boneAxis.x = 0;
  112691. boneAxis.y = 1;
  112692. boneAxis.z = 0;
  112693. }
  112694. bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
  112695. bone.getAbsolutePositionToRef(boneMesh, pos);
  112696. if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
  112697. distToJoint = jointPivot.length();
  112698. }
  112699. if (distToJoint !== undefined && distToJoint !== null) {
  112700. pos.x += boneDir.x * distToJoint;
  112701. pos.y += boneDir.y * distToJoint;
  112702. pos.z += boneDir.z * distToJoint;
  112703. }
  112704. mesh.setAbsolutePosition(pos);
  112705. };
  112706. /**
  112707. * The default object size of the imposter
  112708. */
  112709. PhysicsImpostor.DEFAULT_OBJECT_SIZE = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  112710. /**
  112711. * The identity quaternion of the imposter
  112712. */
  112713. PhysicsImpostor.IDENTITY_QUATERNION = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  112714. PhysicsImpostor._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero);
  112715. PhysicsImpostor._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  112716. //Impostor types
  112717. /**
  112718. * No-Imposter type
  112719. */
  112720. PhysicsImpostor.NoImpostor = 0;
  112721. /**
  112722. * Sphere-Imposter type
  112723. */
  112724. PhysicsImpostor.SphereImpostor = 1;
  112725. /**
  112726. * Box-Imposter type
  112727. */
  112728. PhysicsImpostor.BoxImpostor = 2;
  112729. /**
  112730. * Plane-Imposter type
  112731. */
  112732. PhysicsImpostor.PlaneImpostor = 3;
  112733. /**
  112734. * Mesh-imposter type
  112735. */
  112736. PhysicsImpostor.MeshImpostor = 4;
  112737. /**
  112738. * Cylinder-Imposter type
  112739. */
  112740. PhysicsImpostor.CylinderImpostor = 7;
  112741. /**
  112742. * Particle-Imposter type
  112743. */
  112744. PhysicsImpostor.ParticleImpostor = 8;
  112745. /**
  112746. * Heightmap-Imposter type
  112747. */
  112748. PhysicsImpostor.HeightmapImpostor = 9;
  112749. return PhysicsImpostor;
  112750. }());
  112751. /***/ }),
  112752. /***/ "./Physics/physicsJoint.ts":
  112753. /*!*********************************!*\
  112754. !*** ./Physics/physicsJoint.ts ***!
  112755. \*********************************/
  112756. /*! exports provided: PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint */
  112757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112758. "use strict";
  112759. __webpack_require__.r(__webpack_exports__);
  112760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return PhysicsJoint; });
  112761. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return DistanceJoint; });
  112762. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return MotorEnabledJoint; });
  112763. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return HingeJoint; });
  112764. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return Hinge2Joint; });
  112765. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  112766. /**
  112767. * This is a holder class for the physics joint created by the physics plugin
  112768. * It holds a set of functions to control the underlying joint
  112769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112770. */
  112771. var PhysicsJoint = /** @class */ (function () {
  112772. /**
  112773. * Initializes the physics joint
  112774. * @param type The type of the physics joint
  112775. * @param jointData The data for the physics joint
  112776. */
  112777. function PhysicsJoint(
  112778. /**
  112779. * The type of the physics joint
  112780. */
  112781. type,
  112782. /**
  112783. * The data for the physics joint
  112784. */
  112785. jointData) {
  112786. this.type = type;
  112787. this.jointData = jointData;
  112788. jointData.nativeParams = jointData.nativeParams || {};
  112789. }
  112790. Object.defineProperty(PhysicsJoint.prototype, "physicsJoint", {
  112791. /**
  112792. * Gets the physics joint
  112793. */
  112794. get: function () {
  112795. return this._physicsJoint;
  112796. },
  112797. /**
  112798. * Sets the physics joint
  112799. */
  112800. set: function (newJoint) {
  112801. if (this._physicsJoint) {
  112802. //remove from the wolrd
  112803. }
  112804. this._physicsJoint = newJoint;
  112805. },
  112806. enumerable: true,
  112807. configurable: true
  112808. });
  112809. Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
  112810. /**
  112811. * Sets the physics plugin
  112812. */
  112813. set: function (physicsPlugin) {
  112814. this._physicsPlugin = physicsPlugin;
  112815. },
  112816. enumerable: true,
  112817. configurable: true
  112818. });
  112819. /**
  112820. * Execute a function that is physics-plugin specific.
  112821. * @param {Function} func the function that will be executed.
  112822. * It accepts two parameters: the physics world and the physics joint
  112823. */
  112824. PhysicsJoint.prototype.executeNativeFunction = function (func) {
  112825. func(this._physicsPlugin.world, this._physicsJoint);
  112826. };
  112827. //TODO check if the native joints are the same
  112828. //Joint Types
  112829. /**
  112830. * Distance-Joint type
  112831. */
  112832. PhysicsJoint.DistanceJoint = 0;
  112833. /**
  112834. * Hinge-Joint type
  112835. */
  112836. PhysicsJoint.HingeJoint = 1;
  112837. /**
  112838. * Ball-and-Socket joint type
  112839. */
  112840. PhysicsJoint.BallAndSocketJoint = 2;
  112841. /**
  112842. * Wheel-Joint type
  112843. */
  112844. PhysicsJoint.WheelJoint = 3;
  112845. /**
  112846. * Slider-Joint type
  112847. */
  112848. PhysicsJoint.SliderJoint = 4;
  112849. //OIMO
  112850. /**
  112851. * Prismatic-Joint type
  112852. */
  112853. PhysicsJoint.PrismaticJoint = 5;
  112854. //
  112855. /**
  112856. * Universal-Joint type
  112857. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112858. */
  112859. PhysicsJoint.UniversalJoint = 6;
  112860. /**
  112861. * Hinge-Joint 2 type
  112862. */
  112863. PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
  112864. //Cannon
  112865. /**
  112866. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112867. */
  112868. PhysicsJoint.PointToPointJoint = 8;
  112869. //Cannon only at the moment
  112870. /**
  112871. * Spring-Joint type
  112872. */
  112873. PhysicsJoint.SpringJoint = 9;
  112874. /**
  112875. * Lock-Joint type
  112876. */
  112877. PhysicsJoint.LockJoint = 10;
  112878. return PhysicsJoint;
  112879. }());
  112880. /**
  112881. * A class representing a physics distance joint
  112882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112883. */
  112884. var DistanceJoint = /** @class */ (function (_super) {
  112885. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DistanceJoint, _super);
  112886. /**
  112887. *
  112888. * @param jointData The data for the Distance-Joint
  112889. */
  112890. function DistanceJoint(jointData) {
  112891. return _super.call(this, PhysicsJoint.DistanceJoint, jointData) || this;
  112892. }
  112893. /**
  112894. * Update the predefined distance.
  112895. * @param maxDistance The maximum preferred distance
  112896. * @param minDistance The minimum preferred distance
  112897. */
  112898. DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
  112899. this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
  112900. };
  112901. return DistanceJoint;
  112902. }(PhysicsJoint));
  112903. /**
  112904. * Represents a Motor-Enabled Joint
  112905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112906. */
  112907. var MotorEnabledJoint = /** @class */ (function (_super) {
  112908. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotorEnabledJoint, _super);
  112909. /**
  112910. * Initializes the Motor-Enabled Joint
  112911. * @param type The type of the joint
  112912. * @param jointData The physica joint data for the joint
  112913. */
  112914. function MotorEnabledJoint(type, jointData) {
  112915. return _super.call(this, type, jointData) || this;
  112916. }
  112917. /**
  112918. * Set the motor values.
  112919. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112920. * @param force the force to apply
  112921. * @param maxForce max force for this motor.
  112922. */
  112923. MotorEnabledJoint.prototype.setMotor = function (force, maxForce) {
  112924. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  112925. };
  112926. /**
  112927. * Set the motor's limits.
  112928. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112929. * @param upperLimit The upper limit of the motor
  112930. * @param lowerLimit The lower limit of the motor
  112931. */
  112932. MotorEnabledJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  112933. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  112934. };
  112935. return MotorEnabledJoint;
  112936. }(PhysicsJoint));
  112937. /**
  112938. * This class represents a single physics Hinge-Joint
  112939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112940. */
  112941. var HingeJoint = /** @class */ (function (_super) {
  112942. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HingeJoint, _super);
  112943. /**
  112944. * Initializes the Hinge-Joint
  112945. * @param jointData The joint data for the Hinge-Joint
  112946. */
  112947. function HingeJoint(jointData) {
  112948. return _super.call(this, PhysicsJoint.HingeJoint, jointData) || this;
  112949. }
  112950. /**
  112951. * Set the motor values.
  112952. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112953. * @param {number} force the force to apply
  112954. * @param {number} maxForce max force for this motor.
  112955. */
  112956. HingeJoint.prototype.setMotor = function (force, maxForce) {
  112957. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  112958. };
  112959. /**
  112960. * Set the motor's limits.
  112961. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112962. * @param upperLimit The upper limit of the motor
  112963. * @param lowerLimit The lower limit of the motor
  112964. */
  112965. HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  112966. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  112967. };
  112968. return HingeJoint;
  112969. }(MotorEnabledJoint));
  112970. /**
  112971. * This class represents a dual hinge physics joint (same as wheel joint)
  112972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112973. */
  112974. var Hinge2Joint = /** @class */ (function (_super) {
  112975. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Hinge2Joint, _super);
  112976. /**
  112977. * Initializes the Hinge2-Joint
  112978. * @param jointData The joint data for the Hinge2-Joint
  112979. */
  112980. function Hinge2Joint(jointData) {
  112981. return _super.call(this, PhysicsJoint.Hinge2Joint, jointData) || this;
  112982. }
  112983. /**
  112984. * Set the motor values.
  112985. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112986. * @param {number} targetSpeed the speed the motor is to reach
  112987. * @param {number} maxForce max force for this motor.
  112988. * @param {motorIndex} the motor's index, 0 or 1.
  112989. */
  112990. Hinge2Joint.prototype.setMotor = function (targetSpeed, maxForce, motorIndex) {
  112991. if (motorIndex === void 0) { motorIndex = 0; }
  112992. this._physicsPlugin.setMotor(this, targetSpeed || 0, maxForce, motorIndex);
  112993. };
  112994. /**
  112995. * Set the motor limits.
  112996. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112997. * @param {number} upperLimit the upper limit
  112998. * @param {number} lowerLimit lower limit
  112999. * @param {motorIndex} the motor's index, 0 or 1.
  113000. */
  113001. Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
  113002. if (motorIndex === void 0) { motorIndex = 0; }
  113003. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
  113004. };
  113005. return Hinge2Joint;
  113006. }(MotorEnabledJoint));
  113007. /***/ }),
  113008. /***/ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts":
  113009. /*!****************************************************************************!*\
  113010. !*** ./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts ***!
  113011. \****************************************************************************/
  113012. /*! exports provided: DefaultRenderingPipeline */
  113013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113014. "use strict";
  113015. __webpack_require__.r(__webpack_exports__);
  113016. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return DefaultRenderingPipeline; });
  113017. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  113018. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  113019. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  113020. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  113021. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  113022. /* harmony import */ var _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Layers/glowLayer */ "./Layers/glowLayer.ts");
  113023. /* harmony import */ var _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  113024. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  113025. /* harmony import */ var _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  113026. /* harmony import */ var _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  113027. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  113028. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  113029. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  113030. /* harmony import */ var _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../PostProcesses/depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  113031. /* harmony import */ var _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../PostProcesses/bloomEffect */ "./PostProcesses/bloomEffect.ts");
  113032. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  113033. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  113034. /**
  113035. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  113036. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113037. */
  113038. var DefaultRenderingPipeline = /** @class */ (function (_super) {
  113039. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DefaultRenderingPipeline, _super);
  113040. /**
  113041. * @constructor
  113042. * @param name - The rendering pipeline name (default: "")
  113043. * @param hdr - If high dynamic range textures should be used (default: true)
  113044. * @param scene - The scene linked to this pipeline (default: the last created scene)
  113045. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  113046. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  113047. */
  113048. function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
  113049. if (name === void 0) { name = ""; }
  113050. if (hdr === void 0) { hdr = true; }
  113051. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene; }
  113052. if (automaticBuild === void 0) { automaticBuild = true; }
  113053. var _this = _super.call(this, scene.getEngine(), name) || this;
  113054. _this._camerasToBeAttached = [];
  113055. /**
  113056. * ID of the sharpen post process,
  113057. */
  113058. _this.SharpenPostProcessId = "SharpenPostProcessEffect";
  113059. /**
  113060. * @ignore
  113061. * ID of the image processing post process;
  113062. */
  113063. _this.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect";
  113064. /**
  113065. * @ignore
  113066. * ID of the Fast Approximate Anti-Aliasing post process;
  113067. */
  113068. _this.FxaaPostProcessId = "FxaaPostProcessEffect";
  113069. /**
  113070. * ID of the chromatic aberration post process,
  113071. */
  113072. _this.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect";
  113073. /**
  113074. * ID of the grain post process
  113075. */
  113076. _this.GrainPostProcessId = "GrainPostProcessEffect";
  113077. /**
  113078. * Glow post process which adds a glow to emissive areas of the image
  113079. */
  113080. _this._glowLayer = null;
  113081. /**
  113082. * Animations which can be used to tweak settings over a period of time
  113083. */
  113084. _this.animations = [];
  113085. _this._imageProcessingConfigurationObserver = null;
  113086. // Values
  113087. _this._sharpenEnabled = false;
  113088. _this._bloomEnabled = false;
  113089. _this._depthOfFieldEnabled = false;
  113090. _this._depthOfFieldBlurLevel = _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffectBlurLevel"].Low;
  113091. _this._fxaaEnabled = false;
  113092. _this._imageProcessingEnabled = true;
  113093. _this._bloomScale = 0.5;
  113094. _this._chromaticAberrationEnabled = false;
  113095. _this._grainEnabled = false;
  113096. _this._buildAllowed = true;
  113097. _this._resizeObserver = null;
  113098. _this._hardwareScaleLevel = 1.0;
  113099. _this._bloomKernel = 64;
  113100. /**
  113101. * Specifies the weight of the bloom in the final rendering
  113102. */
  113103. _this._bloomWeight = 0.15;
  113104. /**
  113105. * Specifies the luma threshold for the area that will be blurred by the bloom
  113106. */
  113107. _this._bloomThreshold = 0.9;
  113108. _this._samples = 1;
  113109. _this._hasCleared = false;
  113110. _this._prevPostProcess = null;
  113111. _this._prevPrevPostProcess = null;
  113112. _this._depthOfFieldSceneObserver = null;
  113113. _this._cameras = cameras || scene.cameras;
  113114. _this._cameras = _this._cameras.slice();
  113115. _this._camerasToBeAttached = _this._cameras.slice();
  113116. _this._buildAllowed = automaticBuild;
  113117. // Initialize
  113118. _this._scene = scene;
  113119. var caps = _this._scene.getEngine().getCaps();
  113120. _this._hdr = hdr && (caps.textureHalfFloatRender || caps.textureFloatRender);
  113121. // Misc
  113122. if (_this._hdr) {
  113123. if (caps.textureHalfFloatRender) {
  113124. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_HALF_FLOAT;
  113125. }
  113126. else if (caps.textureFloatRender) {
  113127. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_FLOAT;
  113128. }
  113129. }
  113130. else {
  113131. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  113132. }
  113133. // Attach
  113134. scene.postProcessRenderPipelineManager.addPipeline(_this);
  113135. var engine = _this._scene.getEngine();
  113136. // Create post processes before hand so they can be modified before enabled.
  113137. // Block compilation flag is set to true to avoid compilation prior to use, these will be updated on first use in build pipeline.
  113138. _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);
  113139. _this._sharpenEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.SharpenPostProcessId, function () { return _this.sharpen; }, true);
  113140. _this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](_this._scene, null, _this._depthOfFieldBlurLevel, _this._defaultPipelineTextureType, true);
  113141. _this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](_this._scene, _this._bloomScale, _this._bloomWeight, _this.bloomKernel, _this._defaultPipelineTextureType, true);
  113142. _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);
  113143. _this._chromaticAberrationEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.ChromaticAberrationPostProcessId, function () { return _this.chromaticAberration; }, true);
  113144. _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);
  113145. _this._grainEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.GrainPostProcessId, function () { return _this.grain; }, true);
  113146. _this._resizeObserver = engine.onResizeObservable.add(function () {
  113147. _this._hardwareScaleLevel = engine.getHardwareScalingLevel();
  113148. _this.bloomKernel = _this.bloomKernel;
  113149. });
  113150. _this._imageProcessingConfigurationObserver = _this._scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  113151. _this.bloom._downscale._exposure = _this._scene.imageProcessingConfiguration.exposure;
  113152. });
  113153. _this._buildPipeline();
  113154. return _this;
  113155. }
  113156. Object.defineProperty(DefaultRenderingPipeline.prototype, "scene", {
  113157. /**
  113158. * Gets active scene
  113159. */
  113160. get: function () {
  113161. return this._scene;
  113162. },
  113163. enumerable: true,
  113164. configurable: true
  113165. });
  113166. Object.defineProperty(DefaultRenderingPipeline.prototype, "sharpenEnabled", {
  113167. get: function () {
  113168. return this._sharpenEnabled;
  113169. },
  113170. /**
  113171. * Enable or disable the sharpen process from the pipeline
  113172. */
  113173. set: function (enabled) {
  113174. if (this._sharpenEnabled === enabled) {
  113175. return;
  113176. }
  113177. this._sharpenEnabled = enabled;
  113178. this._buildPipeline();
  113179. },
  113180. enumerable: true,
  113181. configurable: true
  113182. });
  113183. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomKernel", {
  113184. /**
  113185. * Specifies the size of the bloom blur kernel, relative to the final output size
  113186. */
  113187. get: function () {
  113188. return this._bloomKernel;
  113189. },
  113190. set: function (value) {
  113191. this._bloomKernel = value;
  113192. this.bloom.kernel = value / this._hardwareScaleLevel;
  113193. },
  113194. enumerable: true,
  113195. configurable: true
  113196. });
  113197. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomWeight", {
  113198. get: function () {
  113199. return this._bloomWeight;
  113200. },
  113201. /**
  113202. * The strength of the bloom.
  113203. */
  113204. set: function (value) {
  113205. if (this._bloomWeight === value) {
  113206. return;
  113207. }
  113208. this.bloom.weight = value;
  113209. this._bloomWeight = value;
  113210. },
  113211. enumerable: true,
  113212. configurable: true
  113213. });
  113214. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomThreshold", {
  113215. get: function () {
  113216. return this._bloomThreshold;
  113217. },
  113218. /**
  113219. * The strength of the bloom.
  113220. */
  113221. set: function (value) {
  113222. if (this._bloomThreshold === value) {
  113223. return;
  113224. }
  113225. this.bloom.threshold = value;
  113226. this._bloomThreshold = value;
  113227. },
  113228. enumerable: true,
  113229. configurable: true
  113230. });
  113231. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomScale", {
  113232. get: function () {
  113233. return this._bloomScale;
  113234. },
  113235. /**
  113236. * The scale of the bloom, lower value will provide better performance.
  113237. */
  113238. set: function (value) {
  113239. if (this._bloomScale === value) {
  113240. return;
  113241. }
  113242. this._bloomScale = value;
  113243. // recreate bloom and dispose old as this setting is not dynamic
  113244. this._rebuildBloom();
  113245. this._buildPipeline();
  113246. },
  113247. enumerable: true,
  113248. configurable: true
  113249. });
  113250. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomEnabled", {
  113251. get: function () {
  113252. return this._bloomEnabled;
  113253. },
  113254. /**
  113255. * Enable or disable the bloom from the pipeline
  113256. */
  113257. set: function (enabled) {
  113258. if (this._bloomEnabled === enabled) {
  113259. return;
  113260. }
  113261. this._bloomEnabled = enabled;
  113262. this._buildPipeline();
  113263. },
  113264. enumerable: true,
  113265. configurable: true
  113266. });
  113267. DefaultRenderingPipeline.prototype._rebuildBloom = function () {
  113268. // recreate bloom and dispose old as this setting is not dynamic
  113269. var oldBloom = this.bloom;
  113270. this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, false);
  113271. this.bloom.threshold = oldBloom.threshold;
  113272. for (var i = 0; i < this._cameras.length; i++) {
  113273. oldBloom.disposeEffects(this._cameras[i]);
  113274. }
  113275. };
  113276. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", {
  113277. /**
  113278. * If the depth of field is enabled.
  113279. */
  113280. get: function () {
  113281. return this._depthOfFieldEnabled;
  113282. },
  113283. set: function (enabled) {
  113284. if (this._depthOfFieldEnabled === enabled) {
  113285. return;
  113286. }
  113287. this._depthOfFieldEnabled = enabled;
  113288. this._buildPipeline();
  113289. },
  113290. enumerable: true,
  113291. configurable: true
  113292. });
  113293. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", {
  113294. /**
  113295. * Blur level of the depth of field effect. (Higher blur will effect performance)
  113296. */
  113297. get: function () {
  113298. return this._depthOfFieldBlurLevel;
  113299. },
  113300. set: function (value) {
  113301. if (this._depthOfFieldBlurLevel === value) {
  113302. return;
  113303. }
  113304. this._depthOfFieldBlurLevel = value;
  113305. // recreate dof and dispose old as this setting is not dynamic
  113306. var oldDof = this.depthOfField;
  113307. this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, false);
  113308. this.depthOfField.focalLength = oldDof.focalLength;
  113309. this.depthOfField.focusDistance = oldDof.focusDistance;
  113310. this.depthOfField.fStop = oldDof.fStop;
  113311. this.depthOfField.lensSize = oldDof.lensSize;
  113312. for (var i = 0; i < this._cameras.length; i++) {
  113313. oldDof.disposeEffects(this._cameras[i]);
  113314. }
  113315. this._buildPipeline();
  113316. },
  113317. enumerable: true,
  113318. configurable: true
  113319. });
  113320. Object.defineProperty(DefaultRenderingPipeline.prototype, "fxaaEnabled", {
  113321. get: function () {
  113322. return this._fxaaEnabled;
  113323. },
  113324. /**
  113325. * If the anti aliasing is enabled.
  113326. */
  113327. set: function (enabled) {
  113328. if (this._fxaaEnabled === enabled) {
  113329. return;
  113330. }
  113331. this._fxaaEnabled = enabled;
  113332. this._buildPipeline();
  113333. },
  113334. enumerable: true,
  113335. configurable: true
  113336. });
  113337. Object.defineProperty(DefaultRenderingPipeline.prototype, "samples", {
  113338. get: function () {
  113339. return this._samples;
  113340. },
  113341. /**
  113342. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113343. */
  113344. set: function (sampleCount) {
  113345. if (this._samples === sampleCount) {
  113346. return;
  113347. }
  113348. this._samples = sampleCount;
  113349. this._buildPipeline();
  113350. },
  113351. enumerable: true,
  113352. configurable: true
  113353. });
  113354. Object.defineProperty(DefaultRenderingPipeline.prototype, "imageProcessingEnabled", {
  113355. get: function () {
  113356. return this._imageProcessingEnabled;
  113357. },
  113358. /**
  113359. * If image processing is enabled.
  113360. */
  113361. set: function (enabled) {
  113362. if (this._imageProcessingEnabled === enabled) {
  113363. return;
  113364. }
  113365. this._imageProcessingEnabled = enabled;
  113366. this._buildPipeline();
  113367. },
  113368. enumerable: true,
  113369. configurable: true
  113370. });
  113371. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayerEnabled", {
  113372. get: function () {
  113373. return this._glowLayer != null;
  113374. },
  113375. /**
  113376. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  113377. */
  113378. set: function (enabled) {
  113379. if (enabled && !this._glowLayer) {
  113380. this._glowLayer = new _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__["GlowLayer"]("", this._scene);
  113381. }
  113382. else if (!enabled && this._glowLayer) {
  113383. this._glowLayer.dispose();
  113384. this._glowLayer = null;
  113385. }
  113386. },
  113387. enumerable: true,
  113388. configurable: true
  113389. });
  113390. Object.defineProperty(DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", {
  113391. get: function () {
  113392. return this._chromaticAberrationEnabled;
  113393. },
  113394. /**
  113395. * Enable or disable the chromaticAberration process from the pipeline
  113396. */
  113397. set: function (enabled) {
  113398. if (this._chromaticAberrationEnabled === enabled) {
  113399. return;
  113400. }
  113401. this._chromaticAberrationEnabled = enabled;
  113402. this._buildPipeline();
  113403. },
  113404. enumerable: true,
  113405. configurable: true
  113406. });
  113407. Object.defineProperty(DefaultRenderingPipeline.prototype, "grainEnabled", {
  113408. get: function () {
  113409. return this._grainEnabled;
  113410. },
  113411. /**
  113412. * Enable or disable the grain process from the pipeline
  113413. */
  113414. set: function (enabled) {
  113415. if (this._grainEnabled === enabled) {
  113416. return;
  113417. }
  113418. this._grainEnabled = enabled;
  113419. this._buildPipeline();
  113420. },
  113421. enumerable: true,
  113422. configurable: true
  113423. });
  113424. /**
  113425. * Get the class name
  113426. * @returns "DefaultRenderingPipeline"
  113427. */
  113428. DefaultRenderingPipeline.prototype.getClassName = function () {
  113429. return "DefaultRenderingPipeline";
  113430. };
  113431. /**
  113432. * Force the compilation of the entire pipeline.
  113433. */
  113434. DefaultRenderingPipeline.prototype.prepare = function () {
  113435. var previousState = this._buildAllowed;
  113436. this._buildAllowed = true;
  113437. this._buildPipeline();
  113438. this._buildAllowed = previousState;
  113439. };
  113440. DefaultRenderingPipeline.prototype._setAutoClearAndTextureSharing = function (postProcess, skipTextureSharing) {
  113441. if (skipTextureSharing === void 0) { skipTextureSharing = false; }
  113442. if (this._hasCleared) {
  113443. postProcess.autoClear = false;
  113444. }
  113445. else {
  113446. postProcess.autoClear = true;
  113447. this._scene.autoClear = false;
  113448. this._hasCleared = true;
  113449. }
  113450. if (!skipTextureSharing) {
  113451. if (this._prevPrevPostProcess) {
  113452. postProcess.shareOutputWith(this._prevPrevPostProcess);
  113453. }
  113454. else {
  113455. postProcess.useOwnOutput();
  113456. }
  113457. if (this._prevPostProcess) {
  113458. this._prevPrevPostProcess = this._prevPostProcess;
  113459. }
  113460. this._prevPostProcess = postProcess;
  113461. }
  113462. };
  113463. DefaultRenderingPipeline.prototype._buildPipeline = function () {
  113464. var _this = this;
  113465. if (!this._buildAllowed) {
  113466. return;
  113467. }
  113468. this._scene.autoClear = true;
  113469. var engine = this._scene.getEngine();
  113470. this._disposePostProcesses();
  113471. if (this._cameras !== null) {
  113472. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  113473. // get back cameras to be used to reattach pipeline
  113474. this._cameras = this._camerasToBeAttached.slice();
  113475. }
  113476. this._reset();
  113477. this._prevPostProcess = null;
  113478. this._prevPrevPostProcess = null;
  113479. this._hasCleared = false;
  113480. if (this.depthOfFieldEnabled) {
  113481. // Multi camera suport
  113482. if (this._cameras.length > 1) {
  113483. for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
  113484. var camera = _a[_i];
  113485. var depthRenderer = this._scene.enableDepthRenderer(camera);
  113486. depthRenderer.useOnlyInActiveCamera = true;
  113487. }
  113488. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function (scene) {
  113489. if (_this._cameras.indexOf(scene.activeCamera) > -1) {
  113490. _this.depthOfField.depthTexture = scene.enableDepthRenderer(scene.activeCamera).getDepthMap();
  113491. }
  113492. });
  113493. }
  113494. else {
  113495. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  113496. var depthRenderer = this._scene.enableDepthRenderer(this._cameras[0]);
  113497. this.depthOfField.depthTexture = depthRenderer.getDepthMap();
  113498. }
  113499. if (!this.depthOfField._isReady()) {
  113500. this.depthOfField._updateEffects();
  113501. }
  113502. this.addEffect(this.depthOfField);
  113503. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], true);
  113504. }
  113505. else {
  113506. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  113507. }
  113508. if (this.bloomEnabled) {
  113509. if (!this.bloom._isReady()) {
  113510. this.bloom._updateEffects();
  113511. }
  113512. this.addEffect(this.bloom);
  113513. this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
  113514. }
  113515. if (this._imageProcessingEnabled) {
  113516. 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);
  113517. if (this._hdr) {
  113518. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.ImageProcessingPostProcessId, function () { return _this.imageProcessing; }, true));
  113519. this._setAutoClearAndTextureSharing(this.imageProcessing);
  113520. }
  113521. else {
  113522. this._scene.imageProcessingConfiguration.applyByPostProcess = false;
  113523. }
  113524. }
  113525. if (this.sharpenEnabled) {
  113526. if (!this.sharpen.isReady()) {
  113527. this.sharpen.updateEffect();
  113528. }
  113529. this.addEffect(this._sharpenEffect);
  113530. this._setAutoClearAndTextureSharing(this.sharpen);
  113531. }
  113532. if (this.grainEnabled) {
  113533. if (!this.grain.isReady()) {
  113534. this.grain.updateEffect();
  113535. }
  113536. this.addEffect(this._grainEffect);
  113537. this._setAutoClearAndTextureSharing(this.grain);
  113538. }
  113539. if (this.chromaticAberrationEnabled) {
  113540. if (!this.chromaticAberration.isReady()) {
  113541. this.chromaticAberration.updateEffect();
  113542. }
  113543. this.addEffect(this._chromaticAberrationEffect);
  113544. this._setAutoClearAndTextureSharing(this.chromaticAberration);
  113545. }
  113546. if (this.fxaaEnabled) {
  113547. 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);
  113548. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.FxaaPostProcessId, function () { return _this.fxaa; }, true));
  113549. this._setAutoClearAndTextureSharing(this.fxaa, true);
  113550. }
  113551. if (this._cameras !== null) {
  113552. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  113553. }
  113554. if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
  113555. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  113556. }
  113557. };
  113558. DefaultRenderingPipeline.prototype._disposePostProcesses = function (disposeNonRecreated) {
  113559. if (disposeNonRecreated === void 0) { disposeNonRecreated = false; }
  113560. for (var i = 0; i < this._cameras.length; i++) {
  113561. var camera = this._cameras[i];
  113562. if (this.imageProcessing) {
  113563. this.imageProcessing.dispose(camera);
  113564. }
  113565. if (this.fxaa) {
  113566. this.fxaa.dispose(camera);
  113567. }
  113568. // These are created in the constructor and should not be disposed on every pipeline change
  113569. if (disposeNonRecreated) {
  113570. if (this.sharpen) {
  113571. this.sharpen.dispose(camera);
  113572. }
  113573. if (this.depthOfField) {
  113574. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  113575. this.depthOfField.disposeEffects(camera);
  113576. }
  113577. if (this.bloom) {
  113578. this.bloom.disposeEffects(camera);
  113579. }
  113580. if (this.chromaticAberration) {
  113581. this.chromaticAberration.dispose(camera);
  113582. }
  113583. if (this.grain) {
  113584. this.grain.dispose(camera);
  113585. }
  113586. if (this._glowLayer) {
  113587. this._glowLayer.dispose();
  113588. }
  113589. }
  113590. }
  113591. this.imageProcessing = null;
  113592. this.fxaa = null;
  113593. if (disposeNonRecreated) {
  113594. this.sharpen = null;
  113595. this._sharpenEffect = null;
  113596. this.depthOfField = null;
  113597. this.bloom = null;
  113598. this.chromaticAberration = null;
  113599. this._chromaticAberrationEffect = null;
  113600. this.grain = null;
  113601. this._grainEffect = null;
  113602. this._glowLayer = null;
  113603. }
  113604. };
  113605. /**
  113606. * Adds a camera to the pipeline
  113607. * @param camera the camera to be added
  113608. */
  113609. DefaultRenderingPipeline.prototype.addCamera = function (camera) {
  113610. this._camerasToBeAttached.push(camera);
  113611. this._buildPipeline();
  113612. };
  113613. /**
  113614. * Removes a camera from the pipeline
  113615. * @param camera the camera to remove
  113616. */
  113617. DefaultRenderingPipeline.prototype.removeCamera = function (camera) {
  113618. var index = this._camerasToBeAttached.indexOf(camera);
  113619. this._camerasToBeAttached.splice(index, 1);
  113620. this._buildPipeline();
  113621. };
  113622. /**
  113623. * Dispose of the pipeline and stop all post processes
  113624. */
  113625. DefaultRenderingPipeline.prototype.dispose = function () {
  113626. this._disposePostProcesses(true);
  113627. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  113628. this._scene.autoClear = true;
  113629. if (this._resizeObserver) {
  113630. this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  113631. this._resizeObserver = null;
  113632. }
  113633. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver);
  113634. _super.prototype.dispose.call(this);
  113635. };
  113636. /**
  113637. * Serialize the rendering pipeline (Used when exporting)
  113638. * @returns the serialized object
  113639. */
  113640. DefaultRenderingPipeline.prototype.serialize = function () {
  113641. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  113642. serializationObject.customType = "DefaultRenderingPipeline";
  113643. return serializationObject;
  113644. };
  113645. /**
  113646. * Parse the serialized pipeline
  113647. * @param source Source pipeline.
  113648. * @param scene The scene to load the pipeline to.
  113649. * @param rootUrl The URL of the serialized pipeline.
  113650. * @returns An instantiated pipeline from the serialized object.
  113651. */
  113652. DefaultRenderingPipeline.Parse = function (source, scene, rootUrl) {
  113653. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DefaultRenderingPipeline(source._name, source._name._hdr, scene); }, source, scene, rootUrl);
  113654. };
  113655. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113656. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113657. ], DefaultRenderingPipeline.prototype, "sharpenEnabled", null);
  113658. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113659. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113660. ], DefaultRenderingPipeline.prototype, "bloomKernel", null);
  113661. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113662. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113663. ], DefaultRenderingPipeline.prototype, "_bloomWeight", void 0);
  113664. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113665. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113666. ], DefaultRenderingPipeline.prototype, "_bloomThreshold", void 0);
  113667. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113668. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113669. ], DefaultRenderingPipeline.prototype, "_hdr", void 0);
  113670. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113671. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113672. ], DefaultRenderingPipeline.prototype, "bloomWeight", null);
  113673. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113674. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113675. ], DefaultRenderingPipeline.prototype, "bloomThreshold", null);
  113676. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113677. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113678. ], DefaultRenderingPipeline.prototype, "bloomScale", null);
  113679. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113680. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113681. ], DefaultRenderingPipeline.prototype, "bloomEnabled", null);
  113682. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113683. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113684. ], DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", null);
  113685. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113686. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113687. ], DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", null);
  113688. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113689. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113690. ], DefaultRenderingPipeline.prototype, "fxaaEnabled", null);
  113691. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113692. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113693. ], DefaultRenderingPipeline.prototype, "samples", null);
  113694. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113695. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113696. ], DefaultRenderingPipeline.prototype, "imageProcessingEnabled", null);
  113697. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113698. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113699. ], DefaultRenderingPipeline.prototype, "glowLayerEnabled", null);
  113700. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113701. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113702. ], DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", null);
  113703. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113704. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  113705. ], DefaultRenderingPipeline.prototype, "grainEnabled", null);
  113706. return DefaultRenderingPipeline;
  113707. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__["PostProcessRenderPipeline"]));
  113708. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__["_TypeStore"].RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = DefaultRenderingPipeline;
  113709. /***/ }),
  113710. /***/ "./PostProcesses/RenderPipeline/Pipelines/index.ts":
  113711. /*!*********************************************************!*\
  113712. !*** ./PostProcesses/RenderPipeline/Pipelines/index.ts ***!
  113713. \*********************************************************/
  113714. /*! exports provided: DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  113715. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113716. "use strict";
  113717. __webpack_require__.r(__webpack_exports__);
  113718. /* harmony import */ var _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts");
  113719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  113720. /* harmony import */ var _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts");
  113721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__["LensRenderingPipeline"]; });
  113722. /* harmony import */ var _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ssao2RenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts");
  113723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__["SSAO2RenderingPipeline"]; });
  113724. /* harmony import */ var _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ssaoRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts");
  113725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__["SSAORenderingPipeline"]; });
  113726. /* harmony import */ var _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./standardRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts");
  113727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__["StandardRenderingPipeline"]; });
  113728. /***/ }),
  113729. /***/ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts":
  113730. /*!*************************************************************************!*\
  113731. !*** ./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts ***!
  113732. \*************************************************************************/
  113733. /*! exports provided: LensRenderingPipeline */
  113734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113735. "use strict";
  113736. __webpack_require__.r(__webpack_exports__);
  113737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return LensRenderingPipeline; });
  113738. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  113739. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  113740. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  113741. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  113742. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  113743. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  113744. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  113745. /* harmony import */ var _Shaders_lensHighlights_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Shaders/lensHighlights.fragment */ "./Shaders/lensHighlights.fragment.ts");
  113746. /* harmony import */ var _Shaders_depthOfField_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../Shaders/depthOfField.fragment */ "./Shaders/depthOfField.fragment.ts");
  113747. /**
  113748. * BABYLON.JS Chromatic Aberration GLSL Shader
  113749. * Author: Olivier Guyot
  113750. * Separates very slightly R, G and B colors on the edges of the screen
  113751. * Inspired by Francois Tarlier & Martins Upitis
  113752. */
  113753. var LensRenderingPipeline = /** @class */ (function (_super) {
  113754. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensRenderingPipeline, _super);
  113755. /**
  113756. * @constructor
  113757. *
  113758. * Effect parameters are as follow:
  113759. * {
  113760. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113761. * edge_blur: number; // from 0 to x (1 for realism)
  113762. * distortion: number; // from 0 to x (1 for realism)
  113763. * grain_amount: number; // from 0 to 1
  113764. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113765. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113766. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113767. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113768. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113769. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113770. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113771. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113772. * }
  113773. * Note: if an effect parameter is unset, effect is disabled
  113774. *
  113775. * @param name The rendering pipeline name
  113776. * @param parameters - An object containing all parameters (see above)
  113777. * @param scene The scene linked to this pipeline
  113778. * @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)
  113779. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113780. */
  113781. function LensRenderingPipeline(name, parameters, scene, ratio, cameras) {
  113782. if (ratio === void 0) { ratio = 1.0; }
  113783. var _this = _super.call(this, scene.getEngine(), name) || this;
  113784. // Lens effects can be of the following:
  113785. // - chromatic aberration (slight shift of RGB colors)
  113786. // - blur on the edge of the lens
  113787. // - lens distortion
  113788. // - depth-of-field blur & highlights enhancing
  113789. // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)
  113790. // - grain effect (noise or custom texture)
  113791. // Two additional texture samplers are needed:
  113792. // - depth map (for depth-of-field)
  113793. // - grain texture
  113794. /**
  113795. * @ignore
  113796. * The chromatic aberration PostProcess id in the pipeline
  113797. */
  113798. _this.LensChromaticAberrationEffect = "LensChromaticAberrationEffect";
  113799. /**
  113800. * @ignore
  113801. * The highlights enhancing PostProcess id in the pipeline
  113802. */
  113803. _this.HighlightsEnhancingEffect = "HighlightsEnhancingEffect";
  113804. /**
  113805. * @ignore
  113806. * The depth-of-field PostProcess id in the pipeline
  113807. */
  113808. _this.LensDepthOfFieldEffect = "LensDepthOfFieldEffect";
  113809. _this._scene = scene;
  113810. // Fetch texture samplers
  113811. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  113812. if (parameters.grain_texture) {
  113813. _this._grainTexture = parameters.grain_texture;
  113814. }
  113815. else {
  113816. _this._createGrainTexture();
  113817. }
  113818. // save parameters
  113819. _this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;
  113820. _this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;
  113821. _this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;
  113822. _this._distortion = parameters.distortion ? parameters.distortion : 0;
  113823. _this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;
  113824. _this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;
  113825. _this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;
  113826. _this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;
  113827. _this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;
  113828. _this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;
  113829. _this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;
  113830. // Create effects
  113831. _this._createChromaticAberrationPostProcess(ratio);
  113832. _this._createHighlightsPostProcess(ratio);
  113833. _this._createDepthOfFieldPostProcess(ratio / 4);
  113834. // Set up pipeline
  113835. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
  113836. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
  113837. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
  113838. if (_this._highlightsGain === -1) {
  113839. _this._disableEffect(_this.HighlightsEnhancingEffect, null);
  113840. }
  113841. // Finish
  113842. scene.postProcessRenderPipelineManager.addPipeline(_this);
  113843. if (cameras) {
  113844. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  113845. }
  113846. return _this;
  113847. }
  113848. // public methods (self explanatory)
  113849. /**
  113850. * Sets the amount of blur at the edges
  113851. * @param amount blur amount
  113852. */
  113853. LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
  113854. /**
  113855. * Sets edge blur to 0
  113856. */
  113857. LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
  113858. /**
  113859. * Sets the amout of grain
  113860. * @param amount Amount of grain
  113861. */
  113862. LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
  113863. /**
  113864. * Set grain amount to 0
  113865. */
  113866. LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
  113867. /**
  113868. * Sets the chromatic aberration amount
  113869. * @param amount amount of chromatic aberration
  113870. */
  113871. LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
  113872. /**
  113873. * Sets chromatic aberration amount to 0
  113874. */
  113875. LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
  113876. /**
  113877. * Sets the EdgeDistortion amount
  113878. * @param amount amount of EdgeDistortion
  113879. */
  113880. LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
  113881. /**
  113882. * Sets edge distortion to 0
  113883. */
  113884. LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
  113885. /**
  113886. * Sets the FocusDistance amount
  113887. * @param amount amount of FocusDistance
  113888. */
  113889. LensRenderingPipeline.prototype.setFocusDistance = function (amount) { this._dofDistance = amount; };
  113890. /**
  113891. * Disables depth of field
  113892. */
  113893. LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDistance = -1; };
  113894. /**
  113895. * Sets the Aperture amount
  113896. * @param amount amount of Aperture
  113897. */
  113898. LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
  113899. /**
  113900. * Sets the DarkenOutOfFocus amount
  113901. * @param amount amount of DarkenOutOfFocus
  113902. */
  113903. LensRenderingPipeline.prototype.setDarkenOutOfFocus = function (amount) { this._dofDarken = amount; };
  113904. /**
  113905. * Creates a pentagon bokeh effect
  113906. */
  113907. LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
  113908. this._highlightsPostProcess.updateEffect("#define PENTAGON\n");
  113909. };
  113910. /**
  113911. * Disables the pentagon bokeh effect
  113912. */
  113913. LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
  113914. this._highlightsPostProcess.updateEffect();
  113915. };
  113916. /**
  113917. * Enables noise blur
  113918. */
  113919. LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
  113920. /**
  113921. * Disables noise blur
  113922. */
  113923. LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
  113924. /**
  113925. * Sets the HighlightsGain amount
  113926. * @param amount amount of HighlightsGain
  113927. */
  113928. LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
  113929. this._highlightsGain = amount;
  113930. };
  113931. /**
  113932. * Sets the HighlightsThreshold amount
  113933. * @param amount amount of HighlightsThreshold
  113934. */
  113935. LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
  113936. if (this._highlightsGain === -1) {
  113937. this._highlightsGain = 1.0;
  113938. }
  113939. this._highlightsThreshold = amount;
  113940. };
  113941. /**
  113942. * Disables highlights
  113943. */
  113944. LensRenderingPipeline.prototype.disableHighlights = function () {
  113945. this._highlightsGain = -1;
  113946. };
  113947. /**
  113948. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  113949. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  113950. */
  113951. LensRenderingPipeline.prototype.dispose = function (disableDepthRender) {
  113952. if (disableDepthRender === void 0) { disableDepthRender = false; }
  113953. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  113954. this._chromaticAberrationPostProcess = null;
  113955. this._highlightsPostProcess = null;
  113956. this._depthOfFieldPostProcess = null;
  113957. this._grainTexture.dispose();
  113958. if (disableDepthRender) {
  113959. this._scene.disableDepthRenderer();
  113960. }
  113961. };
  113962. // colors shifting and distortion
  113963. LensRenderingPipeline.prototype._createChromaticAberrationPostProcess = function (ratio) {
  113964. var _this = this;
  113965. this._chromaticAberrationPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], // uniforms
  113966. [], // samplers
  113967. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  113968. this._chromaticAberrationPostProcess.onApply = function (effect) {
  113969. effect.setFloat('chromatic_aberration', _this._chromaticAberration);
  113970. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  113971. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  113972. effect.setFloat('radialIntensity', 1);
  113973. effect.setFloat2('direction', 17, 17);
  113974. effect.setFloat2('centerPosition', 0.5, 0.5);
  113975. };
  113976. };
  113977. // highlights enhancing
  113978. LensRenderingPipeline.prototype._createHighlightsPostProcess = function (ratio) {
  113979. var _this = this;
  113980. this._highlightsPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], // uniforms
  113981. [], // samplers
  113982. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? "#define PENTAGON\n" : "");
  113983. this._highlightsPostProcess.onApply = function (effect) {
  113984. effect.setFloat('gain', _this._highlightsGain);
  113985. effect.setFloat('threshold', _this._highlightsThreshold);
  113986. effect.setTextureFromPostProcess("textureSampler", _this._chromaticAberrationPostProcess);
  113987. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  113988. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  113989. };
  113990. };
  113991. // colors shifting and distortion
  113992. LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
  113993. var _this = this;
  113994. this._depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensDepthOfField", "depthOfField", [
  113995. "grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled",
  113996. "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"
  113997. ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  113998. this._depthOfFieldPostProcess.onApply = function (effect) {
  113999. effect.setTexture("depthSampler", _this._depthTexture);
  114000. effect.setTexture("grainSampler", _this._grainTexture);
  114001. effect.setTextureFromPostProcess("textureSampler", _this._highlightsPostProcess);
  114002. effect.setTextureFromPostProcess("highlightsSampler", _this._depthOfFieldPostProcess);
  114003. effect.setFloat('grain_amount', _this._grainAmount);
  114004. effect.setBool('blur_noise', _this._blurNoise);
  114005. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  114006. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  114007. effect.setFloat('distortion', _this._distortion);
  114008. effect.setBool('dof_enabled', (_this._dofDistance !== -1));
  114009. effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
  114010. effect.setFloat('aperture', _this._dofAperture);
  114011. effect.setFloat('darken', _this._dofDarken);
  114012. effect.setFloat('edge_blur', _this._edgeBlur);
  114013. effect.setBool('highlights', (_this._highlightsGain !== -1));
  114014. if (_this._scene.activeCamera) {
  114015. effect.setFloat('near', _this._scene.activeCamera.minZ);
  114016. effect.setFloat('far', _this._scene.activeCamera.maxZ);
  114017. }
  114018. };
  114019. };
  114020. // creates a black and white random noise texture, 512x512
  114021. LensRenderingPipeline.prototype._createGrainTexture = function () {
  114022. var size = 512;
  114023. 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);
  114024. this._grainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  114025. this._grainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  114026. var context = this._grainTexture.getContext();
  114027. var rand = function (min, max) {
  114028. return Math.random() * (max - min) + min;
  114029. };
  114030. var value;
  114031. for (var x = 0; x < size; x++) {
  114032. for (var y = 0; y < size; y++) {
  114033. value = Math.floor(rand(0.42, 0.58) * 255);
  114034. context.fillStyle = 'rgb(' + value + ', ' + value + ', ' + value + ')';
  114035. context.fillRect(x, y, 1, 1);
  114036. }
  114037. }
  114038. this._grainTexture.update(false);
  114039. };
  114040. return LensRenderingPipeline;
  114041. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipeline"]));
  114042. /***/ }),
  114043. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts":
  114044. /*!**************************************************************************!*\
  114045. !*** ./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts ***!
  114046. \**************************************************************************/
  114047. /*! exports provided: SSAO2RenderingPipeline */
  114048. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114049. "use strict";
  114050. __webpack_require__.r(__webpack_exports__);
  114051. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return SSAO2RenderingPipeline; });
  114052. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114053. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  114054. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  114055. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  114056. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  114057. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  114058. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  114059. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  114060. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  114061. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  114062. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  114063. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  114064. /* harmony import */ var _Shaders_ssao2_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssao2.fragment */ "./Shaders/ssao2.fragment.ts");
  114065. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  114066. /**
  114067. * Render pipeline to produce ssao effect
  114068. */
  114069. var SSAO2RenderingPipeline = /** @class */ (function (_super) {
  114070. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAO2RenderingPipeline, _super);
  114071. /**
  114072. * @constructor
  114073. * @param name The rendering pipeline name
  114074. * @param scene The scene linked to this pipeline
  114075. * @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 }
  114076. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114077. */
  114078. function SSAO2RenderingPipeline(name, scene, ratio, cameras) {
  114079. var _this = _super.call(this, scene.getEngine(), name) || this;
  114080. // Members
  114081. /**
  114082. * @ignore
  114083. * The PassPostProcess id in the pipeline that contains the original scene color
  114084. */
  114085. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  114086. /**
  114087. * @ignore
  114088. * The SSAO PostProcess id in the pipeline
  114089. */
  114090. _this.SSAORenderEffect = "SSAORenderEffect";
  114091. /**
  114092. * @ignore
  114093. * The horizontal blur PostProcess id in the pipeline
  114094. */
  114095. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  114096. /**
  114097. * @ignore
  114098. * The vertical blur PostProcess id in the pipeline
  114099. */
  114100. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  114101. /**
  114102. * @ignore
  114103. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114104. */
  114105. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  114106. /**
  114107. * The output strength of the SSAO post-process. Default value is 1.0.
  114108. */
  114109. _this.totalStrength = 1.0;
  114110. /**
  114111. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  114112. */
  114113. _this.maxZ = 100.0;
  114114. /**
  114115. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  114116. */
  114117. _this.minZAspect = 0.2;
  114118. _this._samples = 8;
  114119. _this._textureSamples = 1;
  114120. _this._expensiveBlur = true;
  114121. /**
  114122. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  114123. */
  114124. _this.radius = 2.0;
  114125. /**
  114126. * The base color of the SSAO post-process
  114127. * The final result is "base + ssao" between [0, 1]
  114128. */
  114129. _this.base = 0;
  114130. _this._firstUpdate = true;
  114131. _this._bits = new Uint32Array(1);
  114132. _this._scene = scene;
  114133. _this._ratio = ratio;
  114134. if (!_this.isSupported) {
  114135. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("SSAO 2 needs WebGL 2 support.");
  114136. return _this;
  114137. }
  114138. var ssaoRatio = _this._ratio.ssaoRatio || ratio;
  114139. var blurRatio = _this._ratio.blurRatio || ratio;
  114140. // Set up assets
  114141. var geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  114142. _this._createRandomTexture();
  114143. _this._depthTexture = geometryBufferRenderer.getGBuffer().textures[0];
  114144. _this._normalTexture = geometryBufferRenderer.getGBuffer().textures[1];
  114145. _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);
  114146. _this._originalColorPostProcess.samples = _this.textureSamples;
  114147. _this._createSSAOPostProcess(1.0);
  114148. _this._createBlurPostProcess(ssaoRatio, blurRatio);
  114149. _this._createSSAOCombinePostProcess(blurRatio);
  114150. // Set up pipeline
  114151. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  114152. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  114153. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  114154. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  114155. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  114156. // Finish
  114157. scene.postProcessRenderPipelineManager.addPipeline(_this);
  114158. if (cameras) {
  114159. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  114160. }
  114161. return _this;
  114162. }
  114163. Object.defineProperty(SSAO2RenderingPipeline.prototype, "samples", {
  114164. get: function () {
  114165. return this._samples;
  114166. },
  114167. /**
  114168. * Number of samples used for the SSAO calculations. Default value is 8
  114169. */
  114170. set: function (n) {
  114171. this._ssaoPostProcess.updateEffect("#define SAMPLES " + n + "\n#define SSAO");
  114172. this._samples = n;
  114173. this._sampleSphere = this._generateHemisphere();
  114174. this._firstUpdate = true;
  114175. },
  114176. enumerable: true,
  114177. configurable: true
  114178. });
  114179. Object.defineProperty(SSAO2RenderingPipeline.prototype, "textureSamples", {
  114180. get: function () {
  114181. return this._textureSamples;
  114182. },
  114183. /**
  114184. * Number of samples to use for antialiasing
  114185. */
  114186. set: function (n) {
  114187. this._textureSamples = n;
  114188. this._originalColorPostProcess.samples = n;
  114189. this._blurHPostProcess.samples = n;
  114190. this._blurVPostProcess.samples = n;
  114191. this._ssaoPostProcess.samples = n;
  114192. this._ssaoCombinePostProcess.samples = n;
  114193. },
  114194. enumerable: true,
  114195. configurable: true
  114196. });
  114197. Object.defineProperty(SSAO2RenderingPipeline.prototype, "expensiveBlur", {
  114198. get: function () {
  114199. return this._expensiveBlur;
  114200. },
  114201. /**
  114202. * If bilateral blur should be used
  114203. */
  114204. set: function (b) {
  114205. 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"]);
  114206. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  114207. this._expensiveBlur = b;
  114208. this._firstUpdate = true;
  114209. },
  114210. enumerable: true,
  114211. configurable: true
  114212. });
  114213. Object.defineProperty(SSAO2RenderingPipeline, "IsSupported", {
  114214. /**
  114215. * Support test.
  114216. */
  114217. get: function () {
  114218. var engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__["EngineStore"].LastCreatedEngine;
  114219. if (!engine) {
  114220. return false;
  114221. }
  114222. return engine.getCaps().drawBuffersExtension;
  114223. },
  114224. enumerable: true,
  114225. configurable: true
  114226. });
  114227. Object.defineProperty(SSAO2RenderingPipeline.prototype, "scene", {
  114228. /**
  114229. * Gets active scene
  114230. */
  114231. get: function () {
  114232. return this._scene;
  114233. },
  114234. enumerable: true,
  114235. configurable: true
  114236. });
  114237. // Public Methods
  114238. /**
  114239. * Get the class name
  114240. * @returns "SSAO2RenderingPipeline"
  114241. */
  114242. SSAO2RenderingPipeline.prototype.getClassName = function () {
  114243. return "SSAO2RenderingPipeline";
  114244. };
  114245. /**
  114246. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114247. */
  114248. SSAO2RenderingPipeline.prototype.dispose = function (disableGeometryBufferRenderer) {
  114249. if (disableGeometryBufferRenderer === void 0) { disableGeometryBufferRenderer = false; }
  114250. for (var i = 0; i < this._scene.cameras.length; i++) {
  114251. var camera = this._scene.cameras[i];
  114252. this._originalColorPostProcess.dispose(camera);
  114253. this._ssaoPostProcess.dispose(camera);
  114254. this._blurHPostProcess.dispose(camera);
  114255. this._blurVPostProcess.dispose(camera);
  114256. this._ssaoCombinePostProcess.dispose(camera);
  114257. }
  114258. this._randomTexture.dispose();
  114259. if (disableGeometryBufferRenderer) {
  114260. this._scene.disableGeometryBufferRenderer();
  114261. }
  114262. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  114263. _super.prototype.dispose.call(this);
  114264. };
  114265. // Private Methods
  114266. SSAO2RenderingPipeline.prototype._createBlurPostProcess = function (ssaoRatio, blurRatio) {
  114267. var _this = this;
  114268. this._samplerOffsets = [];
  114269. var expensive = this.expensiveBlur;
  114270. for (var i = -8; i < 8; i++) {
  114271. this._samplerOffsets.push(i * 2 + 0.5);
  114272. }
  114273. 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");
  114274. this._blurHPostProcess.onApply = function (effect) {
  114275. if (!_this._scene.activeCamera) {
  114276. return;
  114277. }
  114278. effect.setFloat("outSize", _this._ssaoCombinePostProcess.width > 0 ? _this._ssaoCombinePostProcess.width : _this._originalColorPostProcess.width);
  114279. effect.setFloat("near", _this._scene.activeCamera.minZ);
  114280. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  114281. effect.setFloat("radius", _this.radius);
  114282. effect.setTexture("depthSampler", _this._depthTexture);
  114283. if (_this._firstUpdate) {
  114284. effect.setArray("samplerOffsets", _this._samplerOffsets);
  114285. }
  114286. };
  114287. 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");
  114288. this._blurVPostProcess.onApply = function (effect) {
  114289. if (!_this._scene.activeCamera) {
  114290. return;
  114291. }
  114292. effect.setFloat("outSize", _this._ssaoCombinePostProcess.height > 0 ? _this._ssaoCombinePostProcess.height : _this._originalColorPostProcess.height);
  114293. effect.setFloat("near", _this._scene.activeCamera.minZ);
  114294. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  114295. effect.setFloat("radius", _this.radius);
  114296. effect.setTexture("depthSampler", _this._depthTexture);
  114297. if (_this._firstUpdate) {
  114298. effect.setArray("samplerOffsets", _this._samplerOffsets);
  114299. _this._firstUpdate = false;
  114300. }
  114301. };
  114302. this._blurHPostProcess.samples = this.textureSamples;
  114303. this._blurVPostProcess.samples = this.textureSamples;
  114304. };
  114305. /** @hidden */
  114306. SSAO2RenderingPipeline.prototype._rebuild = function () {
  114307. this._firstUpdate = true;
  114308. _super.prototype._rebuild.call(this);
  114309. };
  114310. //Van der Corput radical inverse
  114311. SSAO2RenderingPipeline.prototype._radicalInverse_VdC = function (i) {
  114312. this._bits[0] = i;
  114313. this._bits[0] = ((this._bits[0] << 16) | (this._bits[0] >> 16)) >>> 0;
  114314. this._bits[0] = ((this._bits[0] & 0x55555555) << 1) | ((this._bits[0] & 0xAAAAAAAA) >>> 1) >>> 0;
  114315. this._bits[0] = ((this._bits[0] & 0x33333333) << 2) | ((this._bits[0] & 0xCCCCCCCC) >>> 2) >>> 0;
  114316. this._bits[0] = ((this._bits[0] & 0x0F0F0F0F) << 4) | ((this._bits[0] & 0xF0F0F0F0) >>> 4) >>> 0;
  114317. this._bits[0] = ((this._bits[0] & 0x00FF00FF) << 8) | ((this._bits[0] & 0xFF00FF00) >>> 8) >>> 0;
  114318. return this._bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
  114319. };
  114320. SSAO2RenderingPipeline.prototype._hammersley = function (i, n) {
  114321. return [i / n, this._radicalInverse_VdC(i)];
  114322. };
  114323. SSAO2RenderingPipeline.prototype._hemisphereSample_uniform = function (u, v) {
  114324. var phi = v * 2.0 * Math.PI;
  114325. // rejecting samples that are close to tangent plane to avoid z-fighting artifacts
  114326. var cosTheta = 1.0 - (u * 0.85 + 0.15);
  114327. var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
  114328. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.cos(phi) * sinTheta, Math.sin(phi) * sinTheta, cosTheta);
  114329. };
  114330. SSAO2RenderingPipeline.prototype._generateHemisphere = function () {
  114331. var numSamples = this.samples;
  114332. var result = [];
  114333. var vector;
  114334. var i = 0;
  114335. while (i < numSamples) {
  114336. if (numSamples < 16) {
  114337. vector = this._hemisphereSample_uniform(Math.random(), Math.random());
  114338. }
  114339. else {
  114340. var rand = this._hammersley(i, numSamples);
  114341. vector = this._hemisphereSample_uniform(rand[0], rand[1]);
  114342. }
  114343. result.push(vector.x, vector.y, vector.z);
  114344. i++;
  114345. }
  114346. return result;
  114347. };
  114348. SSAO2RenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  114349. var _this = this;
  114350. var numSamples = this.samples;
  114351. this._sampleSphere = this._generateHemisphere();
  114352. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssao2", "ssao2", [
  114353. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  114354. "base", "range", "projection", "near", "far", "texelSize",
  114355. "xViewport", "yViewport", "maxZ", "minZAspect"
  114356. ], ["randomSampler", "normalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  114357. this._ssaoPostProcess.onApply = function (effect) {
  114358. if (_this._firstUpdate) {
  114359. effect.setArray3("sampleSphere", _this._sampleSphere);
  114360. effect.setFloat("randTextureTiles", 32.0);
  114361. }
  114362. if (!_this._scene.activeCamera) {
  114363. return;
  114364. }
  114365. effect.setFloat("samplesFactor", 1 / _this.samples);
  114366. effect.setFloat("totalStrength", _this.totalStrength);
  114367. effect.setFloat2("texelSize", 1 / _this._ssaoPostProcess.width, 1 / _this._ssaoPostProcess.height);
  114368. effect.setFloat("radius", _this.radius);
  114369. effect.setFloat("maxZ", _this.maxZ);
  114370. effect.setFloat("minZAspect", _this.minZAspect);
  114371. effect.setFloat("base", _this.base);
  114372. effect.setFloat("near", _this._scene.activeCamera.minZ);
  114373. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  114374. effect.setFloat("xViewport", Math.tan(_this._scene.activeCamera.fov / 2) * _this._scene.getEngine().getAspectRatio(_this._scene.activeCamera, true));
  114375. effect.setFloat("yViewport", Math.tan(_this._scene.activeCamera.fov / 2));
  114376. effect.setMatrix("projection", _this._scene.getProjectionMatrix());
  114377. effect.setTexture("textureSampler", _this._depthTexture);
  114378. effect.setTexture("normalSampler", _this._normalTexture);
  114379. effect.setTexture("randomSampler", _this._randomTexture);
  114380. };
  114381. this._ssaoPostProcess.samples = this.textureSamples;
  114382. };
  114383. SSAO2RenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  114384. var _this = this;
  114385. 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);
  114386. this._ssaoCombinePostProcess.onApply = function (effect) {
  114387. var viewport = _this._scene.activeCamera.viewport;
  114388. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
  114389. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  114390. };
  114391. this._ssaoCombinePostProcess.samples = this.textureSamples;
  114392. };
  114393. SSAO2RenderingPipeline.prototype._createRandomTexture = function () {
  114394. var size = 128;
  114395. 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);
  114396. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  114397. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  114398. var context = this._randomTexture.getContext();
  114399. var rand = function (min, max) {
  114400. return Math.random() * (max - min) + min;
  114401. };
  114402. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  114403. for (var x = 0; x < size; x++) {
  114404. for (var y = 0; y < size; y++) {
  114405. randVector.x = rand(0.0, 1.0);
  114406. randVector.y = rand(0.0, 1.0);
  114407. randVector.z = 0.0;
  114408. randVector.normalize();
  114409. randVector.scaleInPlace(255);
  114410. randVector.x = Math.floor(randVector.x);
  114411. randVector.y = Math.floor(randVector.y);
  114412. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  114413. context.fillRect(x, y, 1, 1);
  114414. }
  114415. }
  114416. this._randomTexture.update(false);
  114417. };
  114418. /**
  114419. * Serialize the rendering pipeline (Used when exporting)
  114420. * @returns the serialized object
  114421. */
  114422. SSAO2RenderingPipeline.prototype.serialize = function () {
  114423. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Serialize(this);
  114424. serializationObject.customType = "SSAO2RenderingPipeline";
  114425. return serializationObject;
  114426. };
  114427. /**
  114428. * Parse the serialized pipeline
  114429. * @param source Source pipeline.
  114430. * @param scene The scene to load the pipeline to.
  114431. * @param rootUrl The URL of the serialized pipeline.
  114432. * @returns An instantiated pipeline from the serialized object.
  114433. */
  114434. SSAO2RenderingPipeline.Parse = function (source, scene, rootUrl) {
  114435. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Parse(function () { return new SSAO2RenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  114436. };
  114437. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114438. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114439. ], SSAO2RenderingPipeline.prototype, "totalStrength", void 0);
  114440. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114441. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114442. ], SSAO2RenderingPipeline.prototype, "maxZ", void 0);
  114443. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114444. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114445. ], SSAO2RenderingPipeline.prototype, "minZAspect", void 0);
  114446. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114447. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("samples")
  114448. ], SSAO2RenderingPipeline.prototype, "_samples", void 0);
  114449. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114450. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("textureSamples")
  114451. ], SSAO2RenderingPipeline.prototype, "_textureSamples", void 0);
  114452. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114453. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114454. ], SSAO2RenderingPipeline.prototype, "_ratio", void 0);
  114455. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114456. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("expensiveBlur")
  114457. ], SSAO2RenderingPipeline.prototype, "_expensiveBlur", void 0);
  114458. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114459. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114460. ], SSAO2RenderingPipeline.prototype, "radius", void 0);
  114461. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114462. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114463. ], SSAO2RenderingPipeline.prototype, "base", void 0);
  114464. return SSAO2RenderingPipeline;
  114465. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  114466. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__["_TypeStore"].RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = SSAO2RenderingPipeline;
  114467. /***/ }),
  114468. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts":
  114469. /*!*************************************************************************!*\
  114470. !*** ./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts ***!
  114471. \*************************************************************************/
  114472. /*! exports provided: SSAORenderingPipeline */
  114473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114474. "use strict";
  114475. __webpack_require__.r(__webpack_exports__);
  114476. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return SSAORenderingPipeline; });
  114477. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114478. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  114479. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  114480. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  114481. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  114482. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  114483. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  114484. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  114485. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  114486. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  114487. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  114488. /* harmony import */ var _Shaders_ssao_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Shaders/ssao.fragment */ "./Shaders/ssao.fragment.ts");
  114489. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  114490. /**
  114491. * Render pipeline to produce ssao effect
  114492. */
  114493. var SSAORenderingPipeline = /** @class */ (function (_super) {
  114494. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAORenderingPipeline, _super);
  114495. /**
  114496. * @constructor
  114497. * @param name - The rendering pipeline name
  114498. * @param scene - The scene linked to this pipeline
  114499. * @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 }
  114500. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  114501. */
  114502. function SSAORenderingPipeline(name, scene, ratio, cameras) {
  114503. var _this = _super.call(this, scene.getEngine(), name) || this;
  114504. // Members
  114505. /**
  114506. * @ignore
  114507. * The PassPostProcess id in the pipeline that contains the original scene color
  114508. */
  114509. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  114510. /**
  114511. * @ignore
  114512. * The SSAO PostProcess id in the pipeline
  114513. */
  114514. _this.SSAORenderEffect = "SSAORenderEffect";
  114515. /**
  114516. * @ignore
  114517. * The horizontal blur PostProcess id in the pipeline
  114518. */
  114519. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  114520. /**
  114521. * @ignore
  114522. * The vertical blur PostProcess id in the pipeline
  114523. */
  114524. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  114525. /**
  114526. * @ignore
  114527. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114528. */
  114529. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  114530. /**
  114531. * The output strength of the SSAO post-process. Default value is 1.0.
  114532. */
  114533. _this.totalStrength = 1.0;
  114534. /**
  114535. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  114536. */
  114537. _this.radius = 0.0001;
  114538. /**
  114539. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  114540. * Must not be equal to fallOff and superior to fallOff.
  114541. * Default value is 0.0075
  114542. */
  114543. _this.area = 0.0075;
  114544. /**
  114545. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  114546. * Must not be equal to area and inferior to area.
  114547. * Default value is 0.000001
  114548. */
  114549. _this.fallOff = 0.000001;
  114550. /**
  114551. * The base color of the SSAO post-process
  114552. * The final result is "base + ssao" between [0, 1]
  114553. */
  114554. _this.base = 0.5;
  114555. _this._firstUpdate = true;
  114556. _this._scene = scene;
  114557. // Set up assets
  114558. _this._createRandomTexture();
  114559. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  114560. var ssaoRatio = ratio.ssaoRatio || ratio;
  114561. var combineRatio = ratio.combineRatio || ratio;
  114562. _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);
  114563. _this._createSSAOPostProcess(ssaoRatio);
  114564. _this._createBlurPostProcess(ssaoRatio);
  114565. _this._createSSAOCombinePostProcess(combineRatio);
  114566. // Set up pipeline
  114567. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  114568. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  114569. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  114570. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  114571. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  114572. // Finish
  114573. scene.postProcessRenderPipelineManager.addPipeline(_this);
  114574. if (cameras) {
  114575. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  114576. }
  114577. return _this;
  114578. }
  114579. Object.defineProperty(SSAORenderingPipeline.prototype, "scene", {
  114580. /**
  114581. * Gets active scene
  114582. */
  114583. get: function () {
  114584. return this._scene;
  114585. },
  114586. enumerable: true,
  114587. configurable: true
  114588. });
  114589. // Public Methods
  114590. /**
  114591. * Get the class name
  114592. * @returns "SSAORenderingPipeline"
  114593. */
  114594. SSAORenderingPipeline.prototype.getClassName = function () {
  114595. return "SSAORenderingPipeline";
  114596. };
  114597. /**
  114598. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114599. */
  114600. SSAORenderingPipeline.prototype.dispose = function (disableDepthRender) {
  114601. if (disableDepthRender === void 0) { disableDepthRender = false; }
  114602. for (var i = 0; i < this._scene.cameras.length; i++) {
  114603. var camera = this._scene.cameras[i];
  114604. this._originalColorPostProcess.dispose(camera);
  114605. this._ssaoPostProcess.dispose(camera);
  114606. this._blurHPostProcess.dispose(camera);
  114607. this._blurVPostProcess.dispose(camera);
  114608. this._ssaoCombinePostProcess.dispose(camera);
  114609. }
  114610. this._randomTexture.dispose();
  114611. if (disableDepthRender) {
  114612. this._scene.disableDepthRenderer();
  114613. }
  114614. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  114615. _super.prototype.dispose.call(this);
  114616. };
  114617. // Private Methods
  114618. SSAORenderingPipeline.prototype._createBlurPostProcess = function (ratio) {
  114619. var _this = this;
  114620. var size = 16;
  114621. 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);
  114622. 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);
  114623. this._blurHPostProcess.onActivateObservable.add(function () {
  114624. var dw = _this._blurHPostProcess.width / _this._scene.getEngine().getRenderWidth();
  114625. _this._blurHPostProcess.kernel = size * dw;
  114626. });
  114627. this._blurVPostProcess.onActivateObservable.add(function () {
  114628. var dw = _this._blurVPostProcess.height / _this._scene.getEngine().getRenderHeight();
  114629. _this._blurVPostProcess.kernel = size * dw;
  114630. });
  114631. };
  114632. /** @hidden */
  114633. SSAORenderingPipeline.prototype._rebuild = function () {
  114634. this._firstUpdate = true;
  114635. _super.prototype._rebuild.call(this);
  114636. };
  114637. SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  114638. var _this = this;
  114639. var numSamples = 16;
  114640. var sampleSphere = [
  114641. 0.5381, 0.1856, -0.4319,
  114642. 0.1379, 0.2486, 0.4430,
  114643. 0.3371, 0.5679, -0.0057,
  114644. -0.6999, -0.0451, -0.0019,
  114645. 0.0689, -0.1598, -0.8547,
  114646. 0.0560, 0.0069, -0.1843,
  114647. -0.0146, 0.1402, 0.0762,
  114648. 0.0100, -0.1924, -0.0344,
  114649. -0.3577, -0.5301, -0.4358,
  114650. -0.3169, 0.1063, 0.0158,
  114651. 0.0103, -0.5869, 0.0046,
  114652. -0.0897, -0.4940, 0.3287,
  114653. 0.7119, -0.0154, -0.0918,
  114654. -0.0533, 0.0596, -0.5411,
  114655. 0.0352, -0.0631, 0.5460,
  114656. -0.4776, 0.2847, -0.0271
  114657. ];
  114658. var samplesFactor = 1.0 / numSamples;
  114659. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssao", "ssao", [
  114660. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  114661. "area", "fallOff", "base", "range", "viewport"
  114662. ], ["randomSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  114663. this._ssaoPostProcess.onApply = function (effect) {
  114664. if (_this._firstUpdate) {
  114665. effect.setArray3("sampleSphere", sampleSphere);
  114666. effect.setFloat("samplesFactor", samplesFactor);
  114667. effect.setFloat("randTextureTiles", 4.0);
  114668. }
  114669. effect.setFloat("totalStrength", _this.totalStrength);
  114670. effect.setFloat("radius", _this.radius);
  114671. effect.setFloat("area", _this.area);
  114672. effect.setFloat("fallOff", _this.fallOff);
  114673. effect.setFloat("base", _this.base);
  114674. effect.setTexture("textureSampler", _this._depthTexture);
  114675. effect.setTexture("randomSampler", _this._randomTexture);
  114676. };
  114677. };
  114678. SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  114679. var _this = this;
  114680. 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);
  114681. this._ssaoCombinePostProcess.onApply = function (effect) {
  114682. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));
  114683. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  114684. };
  114685. };
  114686. SSAORenderingPipeline.prototype._createRandomTexture = function () {
  114687. var size = 512;
  114688. 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);
  114689. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  114690. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  114691. var context = this._randomTexture.getContext();
  114692. var rand = function (min, max) {
  114693. return Math.random() * (max - min) + min;
  114694. };
  114695. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  114696. for (var x = 0; x < size; x++) {
  114697. for (var y = 0; y < size; y++) {
  114698. randVector.x = Math.floor(rand(-1.0, 1.0) * 255);
  114699. randVector.y = Math.floor(rand(-1.0, 1.0) * 255);
  114700. randVector.z = Math.floor(rand(-1.0, 1.0) * 255);
  114701. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  114702. context.fillRect(x, y, 1, 1);
  114703. }
  114704. }
  114705. this._randomTexture.update(false);
  114706. };
  114707. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114708. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114709. ], SSAORenderingPipeline.prototype, "totalStrength", void 0);
  114710. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114711. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114712. ], SSAORenderingPipeline.prototype, "radius", void 0);
  114713. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114714. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114715. ], SSAORenderingPipeline.prototype, "area", void 0);
  114716. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114717. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114718. ], SSAORenderingPipeline.prototype, "fallOff", void 0);
  114719. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114720. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  114721. ], SSAORenderingPipeline.prototype, "base", void 0);
  114722. return SSAORenderingPipeline;
  114723. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderPipeline"]));
  114724. /***/ }),
  114725. /***/ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts":
  114726. /*!*****************************************************************************!*\
  114727. !*** ./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts ***!
  114728. \*****************************************************************************/
  114729. /*! exports provided: StandardRenderingPipeline */
  114730. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114731. "use strict";
  114732. __webpack_require__.r(__webpack_exports__);
  114733. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return StandardRenderingPipeline; });
  114734. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114735. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  114736. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  114737. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  114738. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  114739. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  114740. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  114741. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  114742. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  114743. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  114744. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  114745. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  114746. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  114747. /* harmony import */ var _Shaders_standard_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/standard.fragment */ "./Shaders/standard.fragment.ts");
  114748. /**
  114749. * Standard rendering pipeline
  114750. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114751. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  114752. */
  114753. var StandardRenderingPipeline = /** @class */ (function (_super) {
  114754. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardRenderingPipeline, _super);
  114755. /**
  114756. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114757. * @constructor
  114758. * @param name The rendering pipeline name
  114759. * @param scene The scene linked to this pipeline
  114760. * @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)
  114761. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  114762. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114763. */
  114764. function StandardRenderingPipeline(name, scene, ratio, originalPostProcess, cameras) {
  114765. if (originalPostProcess === void 0) { originalPostProcess = null; }
  114766. var _this = _super.call(this, scene.getEngine(), name) || this;
  114767. /**
  114768. * Post-process used to down scale an image x4
  114769. */
  114770. _this.downSampleX4PostProcess = null;
  114771. /**
  114772. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  114773. */
  114774. _this.brightPassPostProcess = null;
  114775. /**
  114776. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  114777. */
  114778. _this.blurHPostProcesses = [];
  114779. /**
  114780. * Post-process array storing all the vertical blur post-processes used by the pipeline
  114781. */
  114782. _this.blurVPostProcesses = [];
  114783. /**
  114784. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  114785. */
  114786. _this.textureAdderPostProcess = null;
  114787. /**
  114788. * Post-process used to create volumetric lighting effect
  114789. */
  114790. _this.volumetricLightPostProcess = null;
  114791. /**
  114792. * Post-process used to smooth the previous volumetric light post-process on the X axis
  114793. */
  114794. _this.volumetricLightSmoothXPostProcess = null;
  114795. /**
  114796. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  114797. */
  114798. _this.volumetricLightSmoothYPostProcess = null;
  114799. /**
  114800. * Post-process used to merge the volumetric light effect and the real scene color
  114801. */
  114802. _this.volumetricLightMergePostProces = null;
  114803. /**
  114804. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  114805. */
  114806. _this.volumetricLightFinalPostProcess = null;
  114807. /**
  114808. * Base post-process used to calculate the average luminance of the final image for HDR
  114809. */
  114810. _this.luminancePostProcess = null;
  114811. /**
  114812. * Post-processes used to create down sample post-processes in order to get
  114813. * the average luminance of the final image for HDR
  114814. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  114815. */
  114816. _this.luminanceDownSamplePostProcesses = [];
  114817. /**
  114818. * Post-process used to create a HDR effect (light adaptation)
  114819. */
  114820. _this.hdrPostProcess = null;
  114821. /**
  114822. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  114823. */
  114824. _this.textureAdderFinalPostProcess = null;
  114825. /**
  114826. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  114827. */
  114828. _this.lensFlareFinalPostProcess = null;
  114829. /**
  114830. * Post-process used to merge the final HDR post-process and the real scene color
  114831. */
  114832. _this.hdrFinalPostProcess = null;
  114833. /**
  114834. * Post-process used to create a lens flare effect
  114835. */
  114836. _this.lensFlarePostProcess = null;
  114837. /**
  114838. * Post-process that merges the result of the lens flare post-process and the real scene color
  114839. */
  114840. _this.lensFlareComposePostProcess = null;
  114841. /**
  114842. * Post-process used to create a motion blur effect
  114843. */
  114844. _this.motionBlurPostProcess = null;
  114845. /**
  114846. * Post-process used to create a depth of field effect
  114847. */
  114848. _this.depthOfFieldPostProcess = null;
  114849. /**
  114850. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  114851. */
  114852. _this.fxaaPostProcess = null;
  114853. // Values
  114854. /**
  114855. * Represents the brightness threshold in order to configure the illuminated surfaces
  114856. */
  114857. _this.brightThreshold = 1.0;
  114858. /**
  114859. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  114860. */
  114861. _this.blurWidth = 512.0;
  114862. /**
  114863. * Sets if the blur for highlighted surfaces must be only horizontal
  114864. */
  114865. _this.horizontalBlur = false;
  114866. /**
  114867. * Sets the overall exposure used by the pipeline
  114868. */
  114869. _this.exposure = 1.0;
  114870. /**
  114871. * Texture used typically to simulate "dirty" on camera lens
  114872. */
  114873. _this.lensTexture = null;
  114874. /**
  114875. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  114876. */
  114877. _this.volumetricLightCoefficient = 0.2;
  114878. /**
  114879. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  114880. */
  114881. _this.volumetricLightPower = 4.0;
  114882. /**
  114883. * Used the set the blur intensity to smooth the volumetric lights
  114884. */
  114885. _this.volumetricLightBlurScale = 64.0;
  114886. /**
  114887. * Light (spot or directional) used to generate the volumetric lights rays
  114888. * The source light must have a shadow generate so the pipeline can get its
  114889. * depth map
  114890. */
  114891. _this.sourceLight = null;
  114892. /**
  114893. * For eye adaptation, represents the minimum luminance the eye can see
  114894. */
  114895. _this.hdrMinimumLuminance = 1.0;
  114896. /**
  114897. * For eye adaptation, represents the decrease luminance speed
  114898. */
  114899. _this.hdrDecreaseRate = 0.5;
  114900. /**
  114901. * For eye adaptation, represents the increase luminance speed
  114902. */
  114903. _this.hdrIncreaseRate = 0.5;
  114904. /**
  114905. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  114906. */
  114907. _this.lensColorTexture = null;
  114908. /**
  114909. * The overall strengh for the lens flare effect
  114910. */
  114911. _this.lensFlareStrength = 20.0;
  114912. /**
  114913. * Dispersion coefficient for lens flare ghosts
  114914. */
  114915. _this.lensFlareGhostDispersal = 1.4;
  114916. /**
  114917. * Main lens flare halo width
  114918. */
  114919. _this.lensFlareHaloWidth = 0.7;
  114920. /**
  114921. * Based on the lens distortion effect, defines how much the lens flare result
  114922. * is distorted
  114923. */
  114924. _this.lensFlareDistortionStrength = 16.0;
  114925. /**
  114926. * Lens star texture must be used to simulate rays on the flares and is available
  114927. * in the documentation
  114928. */
  114929. _this.lensStarTexture = null;
  114930. /**
  114931. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  114932. * flare effect by taking account of the dirt texture
  114933. */
  114934. _this.lensFlareDirtTexture = null;
  114935. /**
  114936. * Represents the focal length for the depth of field effect
  114937. */
  114938. _this.depthOfFieldDistance = 10.0;
  114939. /**
  114940. * Represents the blur intensity for the blurred part of the depth of field effect
  114941. */
  114942. _this.depthOfFieldBlurWidth = 64.0;
  114943. /**
  114944. * For motion blur, defines how much the image is blurred by the movement
  114945. */
  114946. _this.motionStrength = 1.0;
  114947. /**
  114948. * List of animations for the pipeline (IAnimatable implementation)
  114949. */
  114950. _this.animations = [];
  114951. _this._currentDepthOfFieldSource = null;
  114952. _this._hdrCurrentLuminance = 1.0;
  114953. // Getters and setters
  114954. _this._bloomEnabled = false;
  114955. _this._depthOfFieldEnabled = false;
  114956. _this._vlsEnabled = false;
  114957. _this._lensFlareEnabled = false;
  114958. _this._hdrEnabled = false;
  114959. _this._motionBlurEnabled = false;
  114960. _this._fxaaEnabled = false;
  114961. _this._motionBlurSamples = 64.0;
  114962. _this._volumetricLightStepsCount = 50.0;
  114963. _this._samples = 1;
  114964. _this._cameras = cameras || [];
  114965. // Initialize
  114966. _this._scene = scene;
  114967. _this._basePostProcess = originalPostProcess;
  114968. _this._ratio = ratio;
  114969. // Misc
  114970. _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;
  114971. // Finish
  114972. scene.postProcessRenderPipelineManager.addPipeline(_this);
  114973. _this._buildPipeline();
  114974. return _this;
  114975. }
  114976. Object.defineProperty(StandardRenderingPipeline.prototype, "BloomEnabled", {
  114977. /**
  114978. * @ignore
  114979. * Specifies if the bloom pipeline is enabled
  114980. */
  114981. get: function () {
  114982. return this._bloomEnabled;
  114983. },
  114984. set: function (enabled) {
  114985. if (this._bloomEnabled === enabled) {
  114986. return;
  114987. }
  114988. this._bloomEnabled = enabled;
  114989. this._buildPipeline();
  114990. },
  114991. enumerable: true,
  114992. configurable: true
  114993. });
  114994. Object.defineProperty(StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", {
  114995. /**
  114996. * @ignore
  114997. * Specifies if the depth of field pipeline is enabed
  114998. */
  114999. get: function () {
  115000. return this._depthOfFieldEnabled;
  115001. },
  115002. set: function (enabled) {
  115003. if (this._depthOfFieldEnabled === enabled) {
  115004. return;
  115005. }
  115006. this._depthOfFieldEnabled = enabled;
  115007. this._buildPipeline();
  115008. },
  115009. enumerable: true,
  115010. configurable: true
  115011. });
  115012. Object.defineProperty(StandardRenderingPipeline.prototype, "LensFlareEnabled", {
  115013. /**
  115014. * @ignore
  115015. * Specifies if the lens flare pipeline is enabed
  115016. */
  115017. get: function () {
  115018. return this._lensFlareEnabled;
  115019. },
  115020. set: function (enabled) {
  115021. if (this._lensFlareEnabled === enabled) {
  115022. return;
  115023. }
  115024. this._lensFlareEnabled = enabled;
  115025. this._buildPipeline();
  115026. },
  115027. enumerable: true,
  115028. configurable: true
  115029. });
  115030. Object.defineProperty(StandardRenderingPipeline.prototype, "HDREnabled", {
  115031. /**
  115032. * @ignore
  115033. * Specifies if the HDR pipeline is enabled
  115034. */
  115035. get: function () {
  115036. return this._hdrEnabled;
  115037. },
  115038. set: function (enabled) {
  115039. if (this._hdrEnabled === enabled) {
  115040. return;
  115041. }
  115042. this._hdrEnabled = enabled;
  115043. this._buildPipeline();
  115044. },
  115045. enumerable: true,
  115046. configurable: true
  115047. });
  115048. Object.defineProperty(StandardRenderingPipeline.prototype, "VLSEnabled", {
  115049. /**
  115050. * @ignore
  115051. * Specifies if the volumetric lights scattering effect is enabled
  115052. */
  115053. get: function () {
  115054. return this._vlsEnabled;
  115055. },
  115056. set: function (enabled) {
  115057. if (this._vlsEnabled === enabled) {
  115058. return;
  115059. }
  115060. if (enabled) {
  115061. var geometry = this._scene.enableGeometryBufferRenderer();
  115062. if (!geometry) {
  115063. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  115064. return;
  115065. }
  115066. }
  115067. this._vlsEnabled = enabled;
  115068. this._buildPipeline();
  115069. },
  115070. enumerable: true,
  115071. configurable: true
  115072. });
  115073. Object.defineProperty(StandardRenderingPipeline.prototype, "MotionBlurEnabled", {
  115074. /**
  115075. * @ignore
  115076. * Specifies if the motion blur effect is enabled
  115077. */
  115078. get: function () {
  115079. return this._motionBlurEnabled;
  115080. },
  115081. set: function (enabled) {
  115082. if (this._motionBlurEnabled === enabled) {
  115083. return;
  115084. }
  115085. this._motionBlurEnabled = enabled;
  115086. this._buildPipeline();
  115087. },
  115088. enumerable: true,
  115089. configurable: true
  115090. });
  115091. Object.defineProperty(StandardRenderingPipeline.prototype, "fxaaEnabled", {
  115092. /**
  115093. * Specifies if anti-aliasing is enabled
  115094. */
  115095. get: function () {
  115096. return this._fxaaEnabled;
  115097. },
  115098. set: function (enabled) {
  115099. if (this._fxaaEnabled === enabled) {
  115100. return;
  115101. }
  115102. this._fxaaEnabled = enabled;
  115103. this._buildPipeline();
  115104. },
  115105. enumerable: true,
  115106. configurable: true
  115107. });
  115108. Object.defineProperty(StandardRenderingPipeline.prototype, "volumetricLightStepsCount", {
  115109. /**
  115110. * Specifies the number of steps used to calculate the volumetric lights
  115111. * Typically in interval [50, 200]
  115112. */
  115113. get: function () {
  115114. return this._volumetricLightStepsCount;
  115115. },
  115116. set: function (count) {
  115117. if (this.volumetricLightPostProcess) {
  115118. this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
  115119. }
  115120. this._volumetricLightStepsCount = count;
  115121. },
  115122. enumerable: true,
  115123. configurable: true
  115124. });
  115125. Object.defineProperty(StandardRenderingPipeline.prototype, "motionBlurSamples", {
  115126. /**
  115127. * Specifies the number of samples used for the motion blur effect
  115128. * Typically in interval [16, 64]
  115129. */
  115130. get: function () {
  115131. return this._motionBlurSamples;
  115132. },
  115133. set: function (samples) {
  115134. if (this.motionBlurPostProcess) {
  115135. this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
  115136. }
  115137. this._motionBlurSamples = samples;
  115138. },
  115139. enumerable: true,
  115140. configurable: true
  115141. });
  115142. Object.defineProperty(StandardRenderingPipeline.prototype, "samples", {
  115143. /**
  115144. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  115145. */
  115146. get: function () {
  115147. return this._samples;
  115148. },
  115149. set: function (sampleCount) {
  115150. if (this._samples === sampleCount) {
  115151. return;
  115152. }
  115153. this._samples = sampleCount;
  115154. this._buildPipeline();
  115155. },
  115156. enumerable: true,
  115157. configurable: true
  115158. });
  115159. StandardRenderingPipeline.prototype._buildPipeline = function () {
  115160. var _this = this;
  115161. var ratio = this._ratio;
  115162. var scene = this._scene;
  115163. this._disposePostProcesses();
  115164. this._reset();
  115165. // Create pass post-process
  115166. if (!this._basePostProcess) {
  115167. 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);
  115168. this.originalPostProcess.onApply = function () {
  115169. _this._currentDepthOfFieldSource = _this.originalPostProcess;
  115170. };
  115171. }
  115172. else {
  115173. this.originalPostProcess = this._basePostProcess;
  115174. }
  115175. if (this._bloomEnabled || this._vlsEnabled || this._lensFlareEnabled || this._depthOfFieldEnabled || this._motionBlurEnabled) {
  115176. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPassPostProcess", function () { return _this.originalPostProcess; }, true));
  115177. }
  115178. this._currentDepthOfFieldSource = this.originalPostProcess;
  115179. if (this._bloomEnabled) {
  115180. // Create down sample X4 post-process
  115181. this._createDownSampleX4PostProcess(scene, ratio / 2);
  115182. // Create bright pass post-process
  115183. this._createBrightPassPostProcess(scene, ratio / 2);
  115184. // Create gaussian blur post-processes (down sampling blurs)
  115185. this._createBlurPostProcesses(scene, ratio / 4, 1);
  115186. // Create texture adder post-process
  115187. this._createTextureAdderPostProcess(scene, ratio);
  115188. // Create depth-of-field source post-process
  115189. 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);
  115190. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBaseDepthOfFieldSource", function () { return _this.textureAdderFinalPostProcess; }, true));
  115191. }
  115192. if (this._vlsEnabled) {
  115193. // Create volumetric light
  115194. this._createVolumetricLightPostProcess(scene, ratio);
  115195. // Create volumetric light final post-process
  115196. 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);
  115197. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSFinal", function () { return _this.volumetricLightFinalPostProcess; }, true));
  115198. }
  115199. if (this._lensFlareEnabled) {
  115200. // Create lens flare post-process
  115201. this._createLensFlarePostProcess(scene, ratio);
  115202. // Create depth-of-field source post-process post lens-flare and disable it now
  115203. 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);
  115204. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function () { return _this.lensFlareFinalPostProcess; }, true));
  115205. }
  115206. if (this._hdrEnabled) {
  115207. // Create luminance
  115208. this._createLuminancePostProcesses(scene, this._floatTextureType);
  115209. // Create HDR
  115210. this._createHdrPostProcess(scene, ratio);
  115211. // Create depth-of-field source post-process post hdr and disable it now
  115212. 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);
  115213. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostHDReDepthOfFieldSource", function () { return _this.hdrFinalPostProcess; }, true));
  115214. }
  115215. if (this._depthOfFieldEnabled) {
  115216. // Create gaussian blur used by depth-of-field
  115217. this._createBlurPostProcesses(scene, ratio / 2, 3, "depthOfFieldBlurWidth");
  115218. // Create depth-of-field post-process
  115219. this._createDepthOfFieldPostProcess(scene, ratio);
  115220. }
  115221. if (this._motionBlurEnabled) {
  115222. // Create motion blur post-process
  115223. this._createMotionBlurPostProcess(scene, ratio);
  115224. }
  115225. if (this._fxaaEnabled) {
  115226. // Create fxaa post-process
  115227. 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);
  115228. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRFxaa", function () { return _this.fxaaPostProcess; }, true));
  115229. }
  115230. if (this._cameras !== null) {
  115231. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  115232. }
  115233. if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
  115234. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  115235. }
  115236. };
  115237. // Down Sample X4 Post-Processs
  115238. StandardRenderingPipeline.prototype._createDownSampleX4PostProcess = function (scene, ratio) {
  115239. var _this = this;
  115240. var downSampleX4Offsets = new Array(32);
  115241. 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);
  115242. this.downSampleX4PostProcess.onApply = function (effect) {
  115243. var id = 0;
  115244. var width = _this.downSampleX4PostProcess.width;
  115245. var height = _this.downSampleX4PostProcess.height;
  115246. for (var i = -2; i < 2; i++) {
  115247. for (var j = -2; j < 2; j++) {
  115248. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / width);
  115249. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / height);
  115250. id += 2;
  115251. }
  115252. }
  115253. effect.setArray2("dsOffsets", downSampleX4Offsets);
  115254. };
  115255. // Add to pipeline
  115256. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDownSampleX4", function () { return _this.downSampleX4PostProcess; }, true));
  115257. };
  115258. // Brightpass Post-Process
  115259. StandardRenderingPipeline.prototype._createBrightPassPostProcess = function (scene, ratio) {
  115260. var _this = this;
  115261. var brightOffsets = new Array(8);
  115262. 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);
  115263. this.brightPassPostProcess.onApply = function (effect) {
  115264. var sU = (1.0 / _this.brightPassPostProcess.width);
  115265. var sV = (1.0 / _this.brightPassPostProcess.height);
  115266. brightOffsets[0] = -0.5 * sU;
  115267. brightOffsets[1] = 0.5 * sV;
  115268. brightOffsets[2] = 0.5 * sU;
  115269. brightOffsets[3] = 0.5 * sV;
  115270. brightOffsets[4] = -0.5 * sU;
  115271. brightOffsets[5] = -0.5 * sV;
  115272. brightOffsets[6] = 0.5 * sU;
  115273. brightOffsets[7] = -0.5 * sV;
  115274. effect.setArray2("dsOffsets", brightOffsets);
  115275. effect.setFloat("brightThreshold", _this.brightThreshold);
  115276. };
  115277. // Add to pipeline
  115278. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBrightPass", function () { return _this.brightPassPostProcess; }, true));
  115279. };
  115280. // Create blur H&V post-processes
  115281. StandardRenderingPipeline.prototype._createBlurPostProcesses = function (scene, ratio, indice, blurWidthKey) {
  115282. var _this = this;
  115283. if (blurWidthKey === void 0) { blurWidthKey = "blurWidth"; }
  115284. var engine = scene.getEngine();
  115285. 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);
  115286. 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);
  115287. blurX.onActivateObservable.add(function () {
  115288. var dw = blurX.width / engine.getRenderWidth();
  115289. blurX.kernel = _this[blurWidthKey] * dw;
  115290. });
  115291. blurY.onActivateObservable.add(function () {
  115292. var dw = blurY.height / engine.getRenderHeight();
  115293. blurY.kernel = _this.horizontalBlur ? 64 * dw : _this[blurWidthKey] * dw;
  115294. });
  115295. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurH" + indice, function () { return blurX; }, true));
  115296. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurV" + indice, function () { return blurY; }, true));
  115297. this.blurHPostProcesses.push(blurX);
  115298. this.blurVPostProcesses.push(blurY);
  115299. };
  115300. // Create texture adder post-process
  115301. StandardRenderingPipeline.prototype._createTextureAdderPostProcess = function (scene, ratio) {
  115302. var _this = this;
  115303. 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);
  115304. this.textureAdderPostProcess.onApply = function (effect) {
  115305. effect.setTextureFromPostProcess("otherSampler", _this._vlsEnabled ? _this._currentDepthOfFieldSource : _this.originalPostProcess);
  115306. effect.setTexture("lensSampler", _this.lensTexture);
  115307. effect.setFloat("exposure", _this.exposure);
  115308. _this._currentDepthOfFieldSource = _this.textureAdderFinalPostProcess;
  115309. };
  115310. // Add to pipeline
  115311. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRTextureAdder", function () { return _this.textureAdderPostProcess; }, true));
  115312. };
  115313. StandardRenderingPipeline.prototype._createVolumetricLightPostProcess = function (scene, ratio) {
  115314. var _this = this;
  115315. var geometryRenderer = scene.enableGeometryBufferRenderer();
  115316. geometryRenderer.enablePosition = true;
  115317. var geometry = geometryRenderer.getGBuffer();
  115318. // Base post-process
  115319. 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));
  115320. var depthValues = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  115321. this.volumetricLightPostProcess.onApply = function (effect) {
  115322. if (_this.sourceLight && _this.sourceLight.getShadowGenerator() && _this._scene.activeCamera) {
  115323. var generator = _this.sourceLight.getShadowGenerator();
  115324. effect.setTexture("shadowMapSampler", generator.getShadowMap());
  115325. effect.setTexture("positionSampler", geometry.textures[2]);
  115326. effect.setColor3("sunColor", _this.sourceLight.diffuse);
  115327. effect.setVector3("sunDirection", _this.sourceLight.getShadowDirection());
  115328. effect.setVector3("cameraPosition", _this._scene.activeCamera.globalPosition);
  115329. effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
  115330. effect.setFloat("scatteringCoefficient", _this.volumetricLightCoefficient);
  115331. effect.setFloat("scatteringPower", _this.volumetricLightPower);
  115332. depthValues.x = _this.sourceLight.getDepthMinZ(_this._scene.activeCamera);
  115333. depthValues.y = _this.sourceLight.getDepthMaxZ(_this._scene.activeCamera);
  115334. effect.setVector2("depthValues", depthValues);
  115335. }
  115336. };
  115337. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLS", function () { return _this.volumetricLightPostProcess; }, true));
  115338. // Smooth
  115339. this._createBlurPostProcesses(scene, ratio / 4, 0, "volumetricLightBlurScale");
  115340. // Merge
  115341. 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");
  115342. this.volumetricLightMergePostProces.onApply = function (effect) {
  115343. effect.setTextureFromPostProcess("originalSampler", _this._bloomEnabled ? _this.textureAdderFinalPostProcess : _this.originalPostProcess);
  115344. _this._currentDepthOfFieldSource = _this.volumetricLightFinalPostProcess;
  115345. };
  115346. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSMerge", function () { return _this.volumetricLightMergePostProces; }, true));
  115347. };
  115348. // Create luminance
  115349. StandardRenderingPipeline.prototype._createLuminancePostProcesses = function (scene, textureType) {
  115350. var _this = this;
  115351. // Create luminance
  115352. var size = Math.pow(3, StandardRenderingPipeline.LuminanceSteps);
  115353. 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);
  115354. var offsets = [];
  115355. this.luminancePostProcess.onApply = function (effect) {
  115356. var sU = (1.0 / _this.luminancePostProcess.width);
  115357. var sV = (1.0 / _this.luminancePostProcess.height);
  115358. offsets[0] = -0.5 * sU;
  115359. offsets[1] = 0.5 * sV;
  115360. offsets[2] = 0.5 * sU;
  115361. offsets[3] = 0.5 * sV;
  115362. offsets[4] = -0.5 * sU;
  115363. offsets[5] = -0.5 * sV;
  115364. offsets[6] = 0.5 * sU;
  115365. offsets[7] = -0.5 * sV;
  115366. effect.setArray2("lumOffsets", offsets);
  115367. };
  115368. // Add to pipeline
  115369. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminance", function () { return _this.luminancePostProcess; }, true));
  115370. // Create down sample luminance
  115371. for (var i = StandardRenderingPipeline.LuminanceSteps - 1; i >= 0; i--) {
  115372. var size = Math.pow(3, i);
  115373. var defines = "#define LUMINANCE_DOWN_SAMPLE\n";
  115374. if (i === 0) {
  115375. defines += "#define FINAL_DOWN_SAMPLER";
  115376. }
  115377. 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);
  115378. this.luminanceDownSamplePostProcesses.push(postProcess);
  115379. }
  115380. // Create callbacks and add effects
  115381. var lastLuminance = this.luminancePostProcess;
  115382. this.luminanceDownSamplePostProcesses.forEach(function (pp, index) {
  115383. var downSampleOffsets = new Array(18);
  115384. pp.onApply = function (effect) {
  115385. if (!lastLuminance) {
  115386. return;
  115387. }
  115388. var id = 0;
  115389. for (var x = -1; x < 2; x++) {
  115390. for (var y = -1; y < 2; y++) {
  115391. downSampleOffsets[id] = x / lastLuminance.width;
  115392. downSampleOffsets[id + 1] = y / lastLuminance.height;
  115393. id += 2;
  115394. }
  115395. }
  115396. effect.setArray2("dsOffsets", downSampleOffsets);
  115397. effect.setFloat("halfDestPixelSize", 0.5 / lastLuminance.width);
  115398. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  115399. lastLuminance = _this.luminancePostProcess;
  115400. }
  115401. else {
  115402. lastLuminance = pp;
  115403. }
  115404. };
  115405. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  115406. pp.onAfterRender = function () {
  115407. var pixel = scene.getEngine().readPixels(0, 0, 1, 1);
  115408. 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);
  115409. _this._hdrCurrentLuminance = (pixel[0] * bit_shift.x + pixel[1] * bit_shift.y + pixel[2] * bit_shift.z + pixel[3] * bit_shift.w) / 100.0;
  115410. };
  115411. }
  115412. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminanceDownSample" + index, function () { return pp; }, true));
  115413. });
  115414. };
  115415. // Create HDR post-process
  115416. StandardRenderingPipeline.prototype._createHdrPostProcess = function (scene, ratio) {
  115417. var _this = this;
  115418. 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);
  115419. var outputLiminance = 1;
  115420. var time = 0;
  115421. var lastTime = 0;
  115422. this.hdrPostProcess.onApply = function (effect) {
  115423. effect.setTextureFromPostProcess("textureAdderSampler", _this._currentDepthOfFieldSource);
  115424. time += scene.getEngine().getDeltaTime();
  115425. if (outputLiminance < 0) {
  115426. outputLiminance = _this._hdrCurrentLuminance;
  115427. }
  115428. else {
  115429. var dt = (lastTime - time) / 1000.0;
  115430. if (_this._hdrCurrentLuminance < outputLiminance + _this.hdrDecreaseRate * dt) {
  115431. outputLiminance += _this.hdrDecreaseRate * dt;
  115432. }
  115433. else if (_this._hdrCurrentLuminance > outputLiminance - _this.hdrIncreaseRate * dt) {
  115434. outputLiminance -= _this.hdrIncreaseRate * dt;
  115435. }
  115436. else {
  115437. outputLiminance = _this._hdrCurrentLuminance;
  115438. }
  115439. }
  115440. outputLiminance = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(outputLiminance, _this.hdrMinimumLuminance, 1e20);
  115441. effect.setFloat("averageLuminance", outputLiminance);
  115442. lastTime = time;
  115443. _this._currentDepthOfFieldSource = _this.hdrFinalPostProcess;
  115444. };
  115445. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDR", function () { return _this.hdrPostProcess; }, true));
  115446. };
  115447. // Create lens flare post-process
  115448. StandardRenderingPipeline.prototype._createLensFlarePostProcess = function (scene, ratio) {
  115449. var _this = this;
  115450. 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);
  115451. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlare", function () { return _this.lensFlarePostProcess; }, true));
  115452. this._createBlurPostProcesses(scene, ratio / 4, 2);
  115453. 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);
  115454. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlareCompose", function () { return _this.lensFlareComposePostProcess; }, true));
  115455. var resolution = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  115456. // Lens flare
  115457. this.lensFlarePostProcess.onApply = function (effect) {
  115458. effect.setTextureFromPostProcess("textureSampler", _this._bloomEnabled ? _this.blurHPostProcesses[0] : _this.originalPostProcess);
  115459. effect.setTexture("lensColorSampler", _this.lensColorTexture);
  115460. effect.setFloat("strength", _this.lensFlareStrength);
  115461. effect.setFloat("ghostDispersal", _this.lensFlareGhostDispersal);
  115462. effect.setFloat("haloWidth", _this.lensFlareHaloWidth);
  115463. // Shift
  115464. resolution.x = _this.lensFlarePostProcess.width;
  115465. resolution.y = _this.lensFlarePostProcess.height;
  115466. effect.setVector2("resolution", resolution);
  115467. effect.setFloat("distortionStrength", _this.lensFlareDistortionStrength);
  115468. };
  115469. // Compose
  115470. 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);
  115471. 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);
  115472. this.lensFlareComposePostProcess.onApply = function (effect) {
  115473. if (!_this._scene.activeCamera) {
  115474. return;
  115475. }
  115476. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  115477. effect.setTexture("lensDirtSampler", _this.lensFlareDirtTexture);
  115478. effect.setTexture("lensStarSampler", _this.lensStarTexture);
  115479. // Lens start rotation matrix
  115480. var camerax = _this._scene.activeCamera.getViewMatrix().getRow(0);
  115481. var cameraz = _this._scene.activeCamera.getViewMatrix().getRow(2);
  115482. 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));
  115483. camRot *= 4.0;
  115484. 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);
  115485. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  115486. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  115487. _this._currentDepthOfFieldSource = _this.lensFlareFinalPostProcess;
  115488. };
  115489. };
  115490. // Create depth-of-field post-process
  115491. StandardRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (scene, ratio) {
  115492. var _this = this;
  115493. 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);
  115494. this.depthOfFieldPostProcess.onApply = function (effect) {
  115495. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  115496. effect.setTexture("depthSampler", _this._getDepthTexture());
  115497. effect.setFloat("distance", _this.depthOfFieldDistance);
  115498. };
  115499. // Add to pipeline
  115500. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDepthOfField", function () { return _this.depthOfFieldPostProcess; }, true));
  115501. };
  115502. // Create motion blur post-process
  115503. StandardRenderingPipeline.prototype._createMotionBlurPostProcess = function (scene, ratio) {
  115504. var _this = this;
  115505. 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);
  115506. var motionScale = 0;
  115507. var prevViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  115508. var invViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  115509. var viewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  115510. var screenSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  115511. this.motionBlurPostProcess.onApply = function (effect) {
  115512. viewProjection = scene.getProjectionMatrix().multiply(scene.getViewMatrix());
  115513. viewProjection.invertToRef(invViewProjection);
  115514. effect.setMatrix("inverseViewProjection", invViewProjection);
  115515. effect.setMatrix("prevViewProjection", prevViewProjection);
  115516. prevViewProjection = viewProjection;
  115517. screenSize.x = _this.motionBlurPostProcess.width;
  115518. screenSize.y = _this.motionBlurPostProcess.height;
  115519. effect.setVector2("screenSize", screenSize);
  115520. motionScale = scene.getEngine().getFps() / 60.0;
  115521. effect.setFloat("motionScale", motionScale);
  115522. effect.setFloat("motionStrength", _this.motionStrength);
  115523. effect.setTexture("depthSampler", _this._getDepthTexture());
  115524. };
  115525. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRMotionBlur", function () { return _this.motionBlurPostProcess; }, true));
  115526. };
  115527. StandardRenderingPipeline.prototype._getDepthTexture = function () {
  115528. if (this._scene.getEngine().getCaps().drawBuffersExtension) {
  115529. var renderer = this._scene.enableGeometryBufferRenderer();
  115530. return renderer.getGBuffer().textures[0];
  115531. }
  115532. return this._scene.enableDepthRenderer().getDepthMap();
  115533. };
  115534. StandardRenderingPipeline.prototype._disposePostProcesses = function () {
  115535. for (var i = 0; i < this._cameras.length; i++) {
  115536. var camera = this._cameras[i];
  115537. if (this.originalPostProcess) {
  115538. this.originalPostProcess.dispose(camera);
  115539. }
  115540. if (this.downSampleX4PostProcess) {
  115541. this.downSampleX4PostProcess.dispose(camera);
  115542. }
  115543. if (this.brightPassPostProcess) {
  115544. this.brightPassPostProcess.dispose(camera);
  115545. }
  115546. if (this.textureAdderPostProcess) {
  115547. this.textureAdderPostProcess.dispose(camera);
  115548. }
  115549. if (this.textureAdderFinalPostProcess) {
  115550. this.textureAdderFinalPostProcess.dispose(camera);
  115551. }
  115552. if (this.volumetricLightPostProcess) {
  115553. this.volumetricLightPostProcess.dispose(camera);
  115554. }
  115555. if (this.volumetricLightSmoothXPostProcess) {
  115556. this.volumetricLightSmoothXPostProcess.dispose(camera);
  115557. }
  115558. if (this.volumetricLightSmoothYPostProcess) {
  115559. this.volumetricLightSmoothYPostProcess.dispose(camera);
  115560. }
  115561. if (this.volumetricLightMergePostProces) {
  115562. this.volumetricLightMergePostProces.dispose(camera);
  115563. }
  115564. if (this.volumetricLightFinalPostProcess) {
  115565. this.volumetricLightFinalPostProcess.dispose(camera);
  115566. }
  115567. if (this.lensFlarePostProcess) {
  115568. this.lensFlarePostProcess.dispose(camera);
  115569. }
  115570. if (this.lensFlareComposePostProcess) {
  115571. this.lensFlareComposePostProcess.dispose(camera);
  115572. }
  115573. for (var j = 0; j < this.luminanceDownSamplePostProcesses.length; j++) {
  115574. this.luminanceDownSamplePostProcesses[j].dispose(camera);
  115575. }
  115576. if (this.luminancePostProcess) {
  115577. this.luminancePostProcess.dispose(camera);
  115578. }
  115579. if (this.hdrPostProcess) {
  115580. this.hdrPostProcess.dispose(camera);
  115581. }
  115582. if (this.hdrFinalPostProcess) {
  115583. this.hdrFinalPostProcess.dispose(camera);
  115584. }
  115585. if (this.depthOfFieldPostProcess) {
  115586. this.depthOfFieldPostProcess.dispose(camera);
  115587. }
  115588. if (this.motionBlurPostProcess) {
  115589. this.motionBlurPostProcess.dispose(camera);
  115590. }
  115591. if (this.fxaaPostProcess) {
  115592. this.fxaaPostProcess.dispose(camera);
  115593. }
  115594. for (var j = 0; j < this.blurHPostProcesses.length; j++) {
  115595. this.blurHPostProcesses[j].dispose(camera);
  115596. }
  115597. for (var j = 0; j < this.blurVPostProcesses.length; j++) {
  115598. this.blurVPostProcesses[j].dispose(camera);
  115599. }
  115600. }
  115601. this.originalPostProcess = null;
  115602. this.downSampleX4PostProcess = null;
  115603. this.brightPassPostProcess = null;
  115604. this.textureAdderPostProcess = null;
  115605. this.textureAdderFinalPostProcess = null;
  115606. this.volumetricLightPostProcess = null;
  115607. this.volumetricLightSmoothXPostProcess = null;
  115608. this.volumetricLightSmoothYPostProcess = null;
  115609. this.volumetricLightMergePostProces = null;
  115610. this.volumetricLightFinalPostProcess = null;
  115611. this.lensFlarePostProcess = null;
  115612. this.lensFlareComposePostProcess = null;
  115613. this.luminancePostProcess = null;
  115614. this.hdrPostProcess = null;
  115615. this.hdrFinalPostProcess = null;
  115616. this.depthOfFieldPostProcess = null;
  115617. this.motionBlurPostProcess = null;
  115618. this.fxaaPostProcess = null;
  115619. this.luminanceDownSamplePostProcesses = [];
  115620. this.blurHPostProcesses = [];
  115621. this.blurVPostProcesses = [];
  115622. };
  115623. /**
  115624. * Dispose of the pipeline and stop all post processes
  115625. */
  115626. StandardRenderingPipeline.prototype.dispose = function () {
  115627. this._disposePostProcesses();
  115628. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  115629. _super.prototype.dispose.call(this);
  115630. };
  115631. /**
  115632. * Serialize the rendering pipeline (Used when exporting)
  115633. * @returns the serialized object
  115634. */
  115635. StandardRenderingPipeline.prototype.serialize = function () {
  115636. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  115637. if (this.sourceLight) {
  115638. serializationObject.sourceLightId = this.sourceLight.id;
  115639. }
  115640. serializationObject.customType = "StandardRenderingPipeline";
  115641. return serializationObject;
  115642. };
  115643. /**
  115644. * Parse the serialized pipeline
  115645. * @param source Source pipeline.
  115646. * @param scene The scene to load the pipeline to.
  115647. * @param rootUrl The URL of the serialized pipeline.
  115648. * @returns An instantiated pipeline from the serialized object.
  115649. */
  115650. StandardRenderingPipeline.Parse = function (source, scene, rootUrl) {
  115651. var p = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardRenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  115652. if (source.sourceLightId) {
  115653. p.sourceLight = scene.getLightByID(source.sourceLightId);
  115654. }
  115655. return p;
  115656. };
  115657. /**
  115658. * Luminance steps
  115659. */
  115660. StandardRenderingPipeline.LuminanceSteps = 6;
  115661. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115662. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115663. ], StandardRenderingPipeline.prototype, "brightThreshold", void 0);
  115664. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115665. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115666. ], StandardRenderingPipeline.prototype, "blurWidth", void 0);
  115667. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115668. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115669. ], StandardRenderingPipeline.prototype, "horizontalBlur", void 0);
  115670. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115671. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115672. ], StandardRenderingPipeline.prototype, "exposure", void 0);
  115673. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115674. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensTexture")
  115675. ], StandardRenderingPipeline.prototype, "lensTexture", void 0);
  115676. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115677. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115678. ], StandardRenderingPipeline.prototype, "volumetricLightCoefficient", void 0);
  115679. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115680. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115681. ], StandardRenderingPipeline.prototype, "volumetricLightPower", void 0);
  115682. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115683. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115684. ], StandardRenderingPipeline.prototype, "volumetricLightBlurScale", void 0);
  115685. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115686. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115687. ], StandardRenderingPipeline.prototype, "hdrMinimumLuminance", void 0);
  115688. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115689. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115690. ], StandardRenderingPipeline.prototype, "hdrDecreaseRate", void 0);
  115691. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115692. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115693. ], StandardRenderingPipeline.prototype, "hdrIncreaseRate", void 0);
  115694. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115695. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensColorTexture")
  115696. ], StandardRenderingPipeline.prototype, "lensColorTexture", void 0);
  115697. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115698. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115699. ], StandardRenderingPipeline.prototype, "lensFlareStrength", void 0);
  115700. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115701. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115702. ], StandardRenderingPipeline.prototype, "lensFlareGhostDispersal", void 0);
  115703. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115704. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115705. ], StandardRenderingPipeline.prototype, "lensFlareHaloWidth", void 0);
  115706. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115707. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115708. ], StandardRenderingPipeline.prototype, "lensFlareDistortionStrength", void 0);
  115709. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115710. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensStarTexture")
  115711. ], StandardRenderingPipeline.prototype, "lensStarTexture", void 0);
  115712. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115713. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensFlareDirtTexture")
  115714. ], StandardRenderingPipeline.prototype, "lensFlareDirtTexture", void 0);
  115715. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115716. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115717. ], StandardRenderingPipeline.prototype, "depthOfFieldDistance", void 0);
  115718. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115719. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115720. ], StandardRenderingPipeline.prototype, "depthOfFieldBlurWidth", void 0);
  115721. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115722. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115723. ], StandardRenderingPipeline.prototype, "motionStrength", void 0);
  115724. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115725. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115726. ], StandardRenderingPipeline.prototype, "_ratio", void 0);
  115727. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115728. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115729. ], StandardRenderingPipeline.prototype, "BloomEnabled", null);
  115730. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115731. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115732. ], StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", null);
  115733. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115734. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115735. ], StandardRenderingPipeline.prototype, "LensFlareEnabled", null);
  115736. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115737. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115738. ], StandardRenderingPipeline.prototype, "HDREnabled", null);
  115739. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115740. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115741. ], StandardRenderingPipeline.prototype, "VLSEnabled", null);
  115742. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115743. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115744. ], StandardRenderingPipeline.prototype, "MotionBlurEnabled", null);
  115745. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115746. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115747. ], StandardRenderingPipeline.prototype, "fxaaEnabled", null);
  115748. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115749. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115750. ], StandardRenderingPipeline.prototype, "volumetricLightStepsCount", null);
  115751. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115752. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115753. ], StandardRenderingPipeline.prototype, "motionBlurSamples", null);
  115754. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115755. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  115756. ], StandardRenderingPipeline.prototype, "samples", null);
  115757. return StandardRenderingPipeline;
  115758. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  115759. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardRenderingPipeline"] = StandardRenderingPipeline;
  115760. /***/ }),
  115761. /***/ "./PostProcesses/RenderPipeline/index.ts":
  115762. /*!***********************************************!*\
  115763. !*** ./PostProcesses/RenderPipeline/index.ts ***!
  115764. \***********************************************/
  115765. /*! exports provided: PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  115766. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115767. "use strict";
  115768. __webpack_require__.r(__webpack_exports__);
  115769. /* harmony import */ var _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pipelines/index */ "./PostProcesses/RenderPipeline/Pipelines/index.ts");
  115770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  115771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  115772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  115773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  115774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  115775. /* harmony import */ var _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  115776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]; });
  115777. /* harmony import */ var _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  115778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__["PostProcessRenderPipeline"]; });
  115779. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  115780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderPipelineManager"]; });
  115781. /* harmony import */ var _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  115782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipelineManagerSceneComponent"]; });
  115783. /***/ }),
  115784. /***/ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts":
  115785. /*!*****************************************************************!*\
  115786. !*** ./PostProcesses/RenderPipeline/postProcessRenderEffect.ts ***!
  115787. \*****************************************************************/
  115788. /*! exports provided: PostProcessRenderEffect */
  115789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115790. "use strict";
  115791. __webpack_require__.r(__webpack_exports__);
  115792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return PostProcessRenderEffect; });
  115793. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  115794. /**
  115795. * This represents a set of one or more post processes in Babylon.
  115796. * A post process can be used to apply a shader to a texture after it is rendered.
  115797. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  115798. */
  115799. var PostProcessRenderEffect = /** @class */ (function () {
  115800. /**
  115801. * Instantiates a post process render effect.
  115802. * A post process can be used to apply a shader to a texture after it is rendered.
  115803. * @param engine The engine the effect is tied to
  115804. * @param name The name of the effect
  115805. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  115806. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  115807. */
  115808. function PostProcessRenderEffect(engine, name, getPostProcesses, singleInstance) {
  115809. this._name = name;
  115810. this._singleInstance = singleInstance || true;
  115811. this._getPostProcesses = getPostProcesses;
  115812. this._cameras = {};
  115813. this._indicesForCamera = {};
  115814. this._postProcesses = {};
  115815. }
  115816. Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
  115817. /**
  115818. * Checks if all the post processes in the effect are supported.
  115819. */
  115820. get: function () {
  115821. for (var index in this._postProcesses) {
  115822. if (this._postProcesses.hasOwnProperty(index)) {
  115823. var pps = this._postProcesses[index];
  115824. for (var ppIndex = 0; ppIndex < pps.length; ppIndex++) {
  115825. if (!pps[ppIndex].isSupported) {
  115826. return false;
  115827. }
  115828. }
  115829. }
  115830. }
  115831. return true;
  115832. },
  115833. enumerable: true,
  115834. configurable: true
  115835. });
  115836. /**
  115837. * Updates the current state of the effect
  115838. * @hidden
  115839. */
  115840. PostProcessRenderEffect.prototype._update = function () {
  115841. };
  115842. /**
  115843. * Attaches the effect on cameras
  115844. * @param cameras The camera to attach to.
  115845. * @hidden
  115846. */
  115847. PostProcessRenderEffect.prototype._attachCameras = function (cameras) {
  115848. var _this = this;
  115849. var cameraKey;
  115850. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115851. if (!cams) {
  115852. return;
  115853. }
  115854. for (var i = 0; i < cams.length; i++) {
  115855. var camera = cams[i];
  115856. var cameraName = camera.name;
  115857. if (this._singleInstance) {
  115858. cameraKey = 0;
  115859. }
  115860. else {
  115861. cameraKey = cameraName;
  115862. }
  115863. if (!this._postProcesses[cameraKey]) {
  115864. var postProcess = this._getPostProcesses();
  115865. if (postProcess) {
  115866. this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];
  115867. }
  115868. }
  115869. if (!this._indicesForCamera[cameraName]) {
  115870. this._indicesForCamera[cameraName] = [];
  115871. }
  115872. this._postProcesses[cameraKey].forEach(function (postProcess) {
  115873. var index = camera.attachPostProcess(postProcess);
  115874. _this._indicesForCamera[cameraName].push(index);
  115875. });
  115876. if (!this._cameras[cameraName]) {
  115877. this._cameras[cameraName] = camera;
  115878. }
  115879. }
  115880. };
  115881. /**
  115882. * Detatches the effect on cameras
  115883. * @param cameras The camera to detatch from.
  115884. * @hidden
  115885. */
  115886. PostProcessRenderEffect.prototype._detachCameras = function (cameras) {
  115887. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115888. if (!cams) {
  115889. return;
  115890. }
  115891. for (var i = 0; i < cams.length; i++) {
  115892. var camera = cams[i];
  115893. var cameraName = camera.name;
  115894. var postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];
  115895. if (postProcesses) {
  115896. postProcesses.forEach(function (postProcess) {
  115897. camera.detachPostProcess(postProcess);
  115898. });
  115899. }
  115900. if (this._cameras[cameraName]) {
  115901. this._cameras[cameraName] = null;
  115902. }
  115903. }
  115904. };
  115905. /**
  115906. * Enables the effect on given cameras
  115907. * @param cameras The camera to enable.
  115908. * @hidden
  115909. */
  115910. PostProcessRenderEffect.prototype._enable = function (cameras) {
  115911. var _this = this;
  115912. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115913. if (!cams) {
  115914. return;
  115915. }
  115916. for (var i = 0; i < cams.length; i++) {
  115917. var camera = cams[i];
  115918. var cameraName = camera.name;
  115919. for (var j = 0; j < this._indicesForCamera[cameraName].length; j++) {
  115920. if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {
  115921. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  115922. cams[i].attachPostProcess(postProcess, _this._indicesForCamera[cameraName][j]);
  115923. });
  115924. }
  115925. }
  115926. }
  115927. };
  115928. /**
  115929. * Disables the effect on the given cameras
  115930. * @param cameras The camera to disable.
  115931. * @hidden
  115932. */
  115933. PostProcessRenderEffect.prototype._disable = function (cameras) {
  115934. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  115935. if (!cams) {
  115936. return;
  115937. }
  115938. for (var i = 0; i < cams.length; i++) {
  115939. var camera = cams[i];
  115940. var cameraName = camera.name;
  115941. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  115942. camera.detachPostProcess(postProcess);
  115943. });
  115944. }
  115945. };
  115946. /**
  115947. * Gets a list of the post processes contained in the effect.
  115948. * @param camera The camera to get the post processes on.
  115949. * @returns The list of the post processes in the effect.
  115950. */
  115951. PostProcessRenderEffect.prototype.getPostProcesses = function (camera) {
  115952. if (this._singleInstance) {
  115953. return this._postProcesses[0];
  115954. }
  115955. else {
  115956. if (!camera) {
  115957. return null;
  115958. }
  115959. return this._postProcesses[camera.name];
  115960. }
  115961. };
  115962. return PostProcessRenderEffect;
  115963. }());
  115964. /***/ }),
  115965. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts":
  115966. /*!*******************************************************************!*\
  115967. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts ***!
  115968. \*******************************************************************/
  115969. /*! exports provided: PostProcessRenderPipeline */
  115970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115971. "use strict";
  115972. __webpack_require__.r(__webpack_exports__);
  115973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return PostProcessRenderPipeline; });
  115974. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115975. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  115976. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  115977. /**
  115978. * PostProcessRenderPipeline
  115979. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  115980. */
  115981. var PostProcessRenderPipeline = /** @class */ (function () {
  115982. /**
  115983. * Initializes a PostProcessRenderPipeline
  115984. * @param engine engine to add the pipeline to
  115985. * @param name name of the pipeline
  115986. */
  115987. function PostProcessRenderPipeline(engine, name) {
  115988. this.engine = engine;
  115989. this._name = name;
  115990. this._renderEffects = {};
  115991. this._renderEffectsForIsolatedPass = new Array();
  115992. this._cameras = [];
  115993. }
  115994. Object.defineProperty(PostProcessRenderPipeline.prototype, "name", {
  115995. /**
  115996. * Gets pipeline name
  115997. */
  115998. get: function () {
  115999. return this._name;
  116000. },
  116001. enumerable: true,
  116002. configurable: true
  116003. });
  116004. /**
  116005. * Gets the class name
  116006. * @returns "PostProcessRenderPipeline"
  116007. */
  116008. PostProcessRenderPipeline.prototype.getClassName = function () {
  116009. return "PostProcessRenderPipeline";
  116010. };
  116011. Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
  116012. /**
  116013. * If all the render effects in the pipeline are supported
  116014. */
  116015. get: function () {
  116016. for (var renderEffectName in this._renderEffects) {
  116017. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  116018. if (!this._renderEffects[renderEffectName].isSupported) {
  116019. return false;
  116020. }
  116021. }
  116022. }
  116023. return true;
  116024. },
  116025. enumerable: true,
  116026. configurable: true
  116027. });
  116028. /**
  116029. * Adds an effect to the pipeline
  116030. * @param renderEffect the effect to add
  116031. */
  116032. PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
  116033. this._renderEffects[renderEffect._name] = renderEffect;
  116034. };
  116035. // private
  116036. /** @hidden */
  116037. PostProcessRenderPipeline.prototype._rebuild = function () {
  116038. };
  116039. /** @hidden */
  116040. PostProcessRenderPipeline.prototype._enableEffect = function (renderEffectName, cameras) {
  116041. var renderEffects = this._renderEffects[renderEffectName];
  116042. if (!renderEffects) {
  116043. return;
  116044. }
  116045. renderEffects._enable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  116046. };
  116047. /** @hidden */
  116048. PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
  116049. var renderEffects = this._renderEffects[renderEffectName];
  116050. if (!renderEffects) {
  116051. return;
  116052. }
  116053. renderEffects._disable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  116054. };
  116055. /** @hidden */
  116056. PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
  116057. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  116058. if (!cams) {
  116059. return;
  116060. }
  116061. var indicesToDelete = [];
  116062. var i;
  116063. for (i = 0; i < cams.length; i++) {
  116064. var camera = cams[i];
  116065. var cameraName = camera.name;
  116066. if (this._cameras.indexOf(camera) === -1) {
  116067. this._cameras[cameraName] = camera;
  116068. }
  116069. else if (unique) {
  116070. indicesToDelete.push(i);
  116071. }
  116072. }
  116073. for (i = 0; i < indicesToDelete.length; i++) {
  116074. cameras.splice(indicesToDelete[i], 1);
  116075. }
  116076. for (var renderEffectName in this._renderEffects) {
  116077. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  116078. this._renderEffects[renderEffectName]._attachCameras(cams);
  116079. }
  116080. }
  116081. };
  116082. /** @hidden */
  116083. PostProcessRenderPipeline.prototype._detachCameras = function (cameras) {
  116084. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  116085. if (!cams) {
  116086. return;
  116087. }
  116088. for (var renderEffectName in this._renderEffects) {
  116089. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  116090. this._renderEffects[renderEffectName]._detachCameras(cams);
  116091. }
  116092. }
  116093. for (var i = 0; i < cams.length; i++) {
  116094. this._cameras.splice(this._cameras.indexOf(cams[i]), 1);
  116095. }
  116096. };
  116097. /** @hidden */
  116098. PostProcessRenderPipeline.prototype._update = function () {
  116099. for (var renderEffectName in this._renderEffects) {
  116100. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  116101. this._renderEffects[renderEffectName]._update();
  116102. }
  116103. }
  116104. for (var i = 0; i < this._cameras.length; i++) {
  116105. var cameraName = this._cameras[i].name;
  116106. if (this._renderEffectsForIsolatedPass[cameraName]) {
  116107. this._renderEffectsForIsolatedPass[cameraName]._update();
  116108. }
  116109. }
  116110. };
  116111. /** @hidden */
  116112. PostProcessRenderPipeline.prototype._reset = function () {
  116113. this._renderEffects = {};
  116114. this._renderEffectsForIsolatedPass = new Array();
  116115. };
  116116. PostProcessRenderPipeline.prototype._enableMSAAOnFirstPostProcess = function (sampleCount) {
  116117. // 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)
  116118. var effectKeys = Object.keys(this._renderEffects);
  116119. if (this.engine.webGLVersion >= 2 && effectKeys.length > 0) {
  116120. var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
  116121. if (postProcesses) {
  116122. postProcesses[0].samples = sampleCount;
  116123. return true;
  116124. }
  116125. }
  116126. return false;
  116127. };
  116128. /**
  116129. * Disposes of the pipeline
  116130. */
  116131. PostProcessRenderPipeline.prototype.dispose = function () {
  116132. // Must be implemented by children
  116133. };
  116134. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116135. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  116136. ], PostProcessRenderPipeline.prototype, "_name", void 0);
  116137. return PostProcessRenderPipeline;
  116138. }());
  116139. /***/ }),
  116140. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts":
  116141. /*!**************************************************************************!*\
  116142. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts ***!
  116143. \**************************************************************************/
  116144. /*! exports provided: PostProcessRenderPipelineManager */
  116145. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116146. "use strict";
  116147. __webpack_require__.r(__webpack_exports__);
  116148. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return PostProcessRenderPipelineManager; });
  116149. /**
  116150. * PostProcessRenderPipelineManager class
  116151. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  116152. */
  116153. var PostProcessRenderPipelineManager = /** @class */ (function () {
  116154. /**
  116155. * Initializes a PostProcessRenderPipelineManager
  116156. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  116157. */
  116158. function PostProcessRenderPipelineManager() {
  116159. this._renderPipelines = {};
  116160. }
  116161. Object.defineProperty(PostProcessRenderPipelineManager.prototype, "supportedPipelines", {
  116162. /**
  116163. * Gets the list of supported render pipelines
  116164. */
  116165. get: function () {
  116166. var result = [];
  116167. for (var renderPipelineName in this._renderPipelines) {
  116168. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  116169. var pipeline = this._renderPipelines[renderPipelineName];
  116170. if (pipeline.isSupported) {
  116171. result.push(pipeline);
  116172. }
  116173. }
  116174. }
  116175. return result;
  116176. },
  116177. enumerable: true,
  116178. configurable: true
  116179. });
  116180. /**
  116181. * Adds a pipeline to the manager
  116182. * @param renderPipeline The pipeline to add
  116183. */
  116184. PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
  116185. this._renderPipelines[renderPipeline._name] = renderPipeline;
  116186. };
  116187. /**
  116188. * Attaches a camera to the pipeline
  116189. * @param renderPipelineName The name of the pipeline to attach to
  116190. * @param cameras the camera to attach
  116191. * @param unique if the camera can be attached multiple times to the pipeline
  116192. */
  116193. PostProcessRenderPipelineManager.prototype.attachCamerasToRenderPipeline = function (renderPipelineName, cameras, unique) {
  116194. if (unique === void 0) { unique = false; }
  116195. var renderPipeline = this._renderPipelines[renderPipelineName];
  116196. if (!renderPipeline) {
  116197. return;
  116198. }
  116199. renderPipeline._attachCameras(cameras, unique);
  116200. };
  116201. /**
  116202. * Detaches a camera from the pipeline
  116203. * @param renderPipelineName The name of the pipeline to detach from
  116204. * @param cameras the camera to detach
  116205. */
  116206. PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
  116207. var renderPipeline = this._renderPipelines[renderPipelineName];
  116208. if (!renderPipeline) {
  116209. return;
  116210. }
  116211. renderPipeline._detachCameras(cameras);
  116212. };
  116213. /**
  116214. * Enables an effect by name on a pipeline
  116215. * @param renderPipelineName the name of the pipeline to enable the effect in
  116216. * @param renderEffectName the name of the effect to enable
  116217. * @param cameras the cameras that the effect should be enabled on
  116218. */
  116219. PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  116220. var renderPipeline = this._renderPipelines[renderPipelineName];
  116221. if (!renderPipeline) {
  116222. return;
  116223. }
  116224. renderPipeline._enableEffect(renderEffectName, cameras);
  116225. };
  116226. /**
  116227. * Disables an effect by name on a pipeline
  116228. * @param renderPipelineName the name of the pipeline to disable the effect in
  116229. * @param renderEffectName the name of the effect to disable
  116230. * @param cameras the cameras that the effect should be disabled on
  116231. */
  116232. PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  116233. var renderPipeline = this._renderPipelines[renderPipelineName];
  116234. if (!renderPipeline) {
  116235. return;
  116236. }
  116237. renderPipeline._disableEffect(renderEffectName, cameras);
  116238. };
  116239. /**
  116240. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  116241. */
  116242. PostProcessRenderPipelineManager.prototype.update = function () {
  116243. for (var renderPipelineName in this._renderPipelines) {
  116244. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  116245. var pipeline = this._renderPipelines[renderPipelineName];
  116246. if (!pipeline.isSupported) {
  116247. pipeline.dispose();
  116248. delete this._renderPipelines[renderPipelineName];
  116249. }
  116250. else {
  116251. pipeline._update();
  116252. }
  116253. }
  116254. }
  116255. };
  116256. /** @hidden */
  116257. PostProcessRenderPipelineManager.prototype._rebuild = function () {
  116258. for (var renderPipelineName in this._renderPipelines) {
  116259. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  116260. var pipeline = this._renderPipelines[renderPipelineName];
  116261. pipeline._rebuild();
  116262. }
  116263. }
  116264. };
  116265. /**
  116266. * Disposes of the manager and pipelines
  116267. */
  116268. PostProcessRenderPipelineManager.prototype.dispose = function () {
  116269. for (var renderPipelineName in this._renderPipelines) {
  116270. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  116271. var pipeline = this._renderPipelines[renderPipelineName];
  116272. pipeline.dispose();
  116273. }
  116274. }
  116275. };
  116276. return PostProcessRenderPipelineManager;
  116277. }());
  116278. /***/ }),
  116279. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts":
  116280. /*!****************************************************************************************!*\
  116281. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts ***!
  116282. \****************************************************************************************/
  116283. /*! exports provided: PostProcessRenderPipelineManagerSceneComponent */
  116284. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116285. "use strict";
  116286. __webpack_require__.r(__webpack_exports__);
  116287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return PostProcessRenderPipelineManagerSceneComponent; });
  116288. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  116289. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  116290. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  116291. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype, "postProcessRenderPipelineManager", {
  116292. get: function () {
  116293. if (!this._postProcessRenderPipelineManager) {
  116294. // Register the G Buffer component to the scene.
  116295. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  116296. if (!component) {
  116297. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  116298. this._addComponent(component);
  116299. }
  116300. this._postProcessRenderPipelineManager = new _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderPipelineManager"]();
  116301. }
  116302. return this._postProcessRenderPipelineManager;
  116303. },
  116304. enumerable: true,
  116305. configurable: true
  116306. });
  116307. /**
  116308. * Defines the Render Pipeline scene component responsible to rendering pipelines
  116309. */
  116310. var PostProcessRenderPipelineManagerSceneComponent = /** @class */ (function () {
  116311. /**
  116312. * Creates a new instance of the component for the given scene
  116313. * @param scene Defines the scene to register the component in
  116314. */
  116315. function PostProcessRenderPipelineManagerSceneComponent(scene) {
  116316. /**
  116317. * The component name helpfull to identify the component in the list of scene components.
  116318. */
  116319. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  116320. this.scene = scene;
  116321. }
  116322. /**
  116323. * Registers the component in a given scene
  116324. */
  116325. PostProcessRenderPipelineManagerSceneComponent.prototype.register = function () {
  116326. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  116327. };
  116328. /**
  116329. * Rebuilds the elements related to this component in case of
  116330. * context lost for instance.
  116331. */
  116332. PostProcessRenderPipelineManagerSceneComponent.prototype.rebuild = function () {
  116333. if (this.scene._postProcessRenderPipelineManager) {
  116334. this.scene._postProcessRenderPipelineManager._rebuild();
  116335. }
  116336. };
  116337. /**
  116338. * Disposes the component and the associated ressources
  116339. */
  116340. PostProcessRenderPipelineManagerSceneComponent.prototype.dispose = function () {
  116341. if (this.scene._postProcessRenderPipelineManager) {
  116342. this.scene._postProcessRenderPipelineManager.dispose();
  116343. }
  116344. };
  116345. PostProcessRenderPipelineManagerSceneComponent.prototype._gatherRenderTargets = function () {
  116346. if (this.scene._postProcessRenderPipelineManager) {
  116347. this.scene._postProcessRenderPipelineManager.update();
  116348. }
  116349. };
  116350. return PostProcessRenderPipelineManagerSceneComponent;
  116351. }());
  116352. /***/ }),
  116353. /***/ "./PostProcesses/anaglyphPostProcess.ts":
  116354. /*!**********************************************!*\
  116355. !*** ./PostProcesses/anaglyphPostProcess.ts ***!
  116356. \**********************************************/
  116357. /*! exports provided: AnaglyphPostProcess */
  116358. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116359. "use strict";
  116360. __webpack_require__.r(__webpack_exports__);
  116361. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return AnaglyphPostProcess; });
  116362. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116363. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116364. /* harmony import */ var _Shaders_anaglyph_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/anaglyph.fragment */ "./Shaders/anaglyph.fragment.ts");
  116365. /**
  116366. * Postprocess used to generate anaglyphic rendering
  116367. */
  116368. var AnaglyphPostProcess = /** @class */ (function (_super) {
  116369. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphPostProcess, _super);
  116370. /**
  116371. * Creates a new AnaglyphPostProcess
  116372. * @param name defines postprocess name
  116373. * @param options defines creation options or target ratio scale
  116374. * @param rigCameras defines cameras using this postprocess
  116375. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  116376. * @param engine defines hosting engine
  116377. * @param reusable defines if the postprocess will be reused multiple times per frame
  116378. */
  116379. function AnaglyphPostProcess(name, options, rigCameras, samplingMode, engine, reusable) {
  116380. var _this = _super.call(this, name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable) || this;
  116381. _this._passedProcess = rigCameras[0]._rigPostProcess;
  116382. _this.onApplyObservable.add(function (effect) {
  116383. effect.setTextureFromPostProcess("leftSampler", _this._passedProcess);
  116384. });
  116385. return _this;
  116386. }
  116387. return AnaglyphPostProcess;
  116388. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116389. /***/ }),
  116390. /***/ "./PostProcesses/blackAndWhitePostProcess.ts":
  116391. /*!***************************************************!*\
  116392. !*** ./PostProcesses/blackAndWhitePostProcess.ts ***!
  116393. \***************************************************/
  116394. /*! exports provided: BlackAndWhitePostProcess */
  116395. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116396. "use strict";
  116397. __webpack_require__.r(__webpack_exports__);
  116398. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return BlackAndWhitePostProcess; });
  116399. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116400. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116401. /* harmony import */ var _Shaders_blackAndWhite_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/blackAndWhite.fragment */ "./Shaders/blackAndWhite.fragment.ts");
  116402. /**
  116403. * Post process used to render in black and white
  116404. */
  116405. var BlackAndWhitePostProcess = /** @class */ (function (_super) {
  116406. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlackAndWhitePostProcess, _super);
  116407. /**
  116408. * Creates a black and white post process
  116409. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  116410. * @param name The name of the effect.
  116411. * @param options The required width/height ratio to downsize to before computing the render pass.
  116412. * @param camera The camera to apply the render pass to.
  116413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116414. * @param engine The engine which the post process will be applied. (default: current engine)
  116415. * @param reusable If the post process can be reused on the same frame. (default: false)
  116416. */
  116417. function BlackAndWhitePostProcess(name, options, camera, samplingMode, engine, reusable) {
  116418. var _this = _super.call(this, name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable) || this;
  116419. /**
  116420. * Linear about to convert he result to black and white (default: 1)
  116421. */
  116422. _this.degree = 1;
  116423. _this.onApplyObservable.add(function (effect) {
  116424. effect.setFloat("degree", _this.degree);
  116425. });
  116426. return _this;
  116427. }
  116428. return BlackAndWhitePostProcess;
  116429. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116430. /***/ }),
  116431. /***/ "./PostProcesses/bloomEffect.ts":
  116432. /*!**************************************!*\
  116433. !*** ./PostProcesses/bloomEffect.ts ***!
  116434. \**************************************/
  116435. /*! exports provided: BloomEffect */
  116436. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116437. "use strict";
  116438. __webpack_require__.r(__webpack_exports__);
  116439. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return BloomEffect; });
  116440. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116441. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  116442. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  116443. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  116444. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  116445. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116446. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116447. /**
  116448. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  116449. */
  116450. var BloomEffect = /** @class */ (function (_super) {
  116451. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomEffect, _super);
  116452. /**
  116453. * Creates a new instance of @see BloomEffect
  116454. * @param scene The scene the effect belongs to.
  116455. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  116456. * @param bloomKernel The size of the kernel to be used when applying the blur.
  116457. * @param bloomWeight The the strength of bloom.
  116458. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  116459. * @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)
  116460. */
  116461. function BloomEffect(scene, bloomScale, bloomWeight, bloomKernel, pipelineTextureType, blockCompilation) {
  116462. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  116463. if (blockCompilation === void 0) { blockCompilation = false; }
  116464. var _this = _super.call(this, scene.getEngine(), "bloom", function () {
  116465. return _this._effects;
  116466. }, true) || this;
  116467. _this.bloomScale = bloomScale;
  116468. /**
  116469. * @hidden Internal
  116470. */
  116471. _this._effects = [];
  116472. _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);
  116473. _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);
  116474. _this._blurX.alwaysForcePOT = true;
  116475. _this._blurX.autoClear = false;
  116476. _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);
  116477. _this._blurY.alwaysForcePOT = true;
  116478. _this._blurY.autoClear = false;
  116479. _this.kernel = bloomKernel;
  116480. _this._effects = [_this._downscale, _this._blurX, _this._blurY];
  116481. _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);
  116482. _this._merge.autoClear = false;
  116483. _this._effects.push(_this._merge);
  116484. return _this;
  116485. }
  116486. Object.defineProperty(BloomEffect.prototype, "threshold", {
  116487. /**
  116488. * The luminance threshold to find bright areas of the image to bloom.
  116489. */
  116490. get: function () {
  116491. return this._downscale.threshold;
  116492. },
  116493. set: function (value) {
  116494. this._downscale.threshold = value;
  116495. },
  116496. enumerable: true,
  116497. configurable: true
  116498. });
  116499. Object.defineProperty(BloomEffect.prototype, "weight", {
  116500. /**
  116501. * The strength of the bloom.
  116502. */
  116503. get: function () {
  116504. return this._merge.weight;
  116505. },
  116506. set: function (value) {
  116507. this._merge.weight = value;
  116508. },
  116509. enumerable: true,
  116510. configurable: true
  116511. });
  116512. Object.defineProperty(BloomEffect.prototype, "kernel", {
  116513. /**
  116514. * Specifies the size of the bloom blur kernel, relative to the final output size
  116515. */
  116516. get: function () {
  116517. return this._blurX.kernel / this.bloomScale;
  116518. },
  116519. set: function (value) {
  116520. this._blurX.kernel = value * this.bloomScale;
  116521. this._blurY.kernel = value * this.bloomScale;
  116522. },
  116523. enumerable: true,
  116524. configurable: true
  116525. });
  116526. /**
  116527. * Disposes each of the internal effects for a given camera.
  116528. * @param camera The camera to dispose the effect on.
  116529. */
  116530. BloomEffect.prototype.disposeEffects = function (camera) {
  116531. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116532. this._effects[effectIndex].dispose(camera);
  116533. }
  116534. };
  116535. /**
  116536. * @hidden Internal
  116537. */
  116538. BloomEffect.prototype._updateEffects = function () {
  116539. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116540. this._effects[effectIndex].updateEffect();
  116541. }
  116542. };
  116543. /**
  116544. * Internal
  116545. * @returns if all the contained post processes are ready.
  116546. * @hidden
  116547. */
  116548. BloomEffect.prototype._isReady = function () {
  116549. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116550. if (!this._effects[effectIndex].isReady()) {
  116551. return false;
  116552. }
  116553. }
  116554. return true;
  116555. };
  116556. return BloomEffect;
  116557. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]));
  116558. /***/ }),
  116559. /***/ "./PostProcesses/bloomMergePostProcess.ts":
  116560. /*!************************************************!*\
  116561. !*** ./PostProcesses/bloomMergePostProcess.ts ***!
  116562. \************************************************/
  116563. /*! exports provided: BloomMergePostProcess */
  116564. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116565. "use strict";
  116566. __webpack_require__.r(__webpack_exports__);
  116567. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return BloomMergePostProcess; });
  116568. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116569. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116570. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116571. /* harmony import */ var _Shaders_bloomMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/bloomMerge.fragment */ "./Shaders/bloomMerge.fragment.ts");
  116572. /**
  116573. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  116574. */
  116575. var BloomMergePostProcess = /** @class */ (function (_super) {
  116576. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomMergePostProcess, _super);
  116577. /**
  116578. * Creates a new instance of @see BloomMergePostProcess
  116579. * @param name The name of the effect.
  116580. * @param originalFromInput Post process which's input will be used for the merge.
  116581. * @param blurred Blurred highlights post process which's output will be used.
  116582. * @param weight Weight of the bloom to be added to the original input.
  116583. * @param options The required width/height ratio to downsize to before computing the render pass.
  116584. * @param camera The camera to apply the render pass to.
  116585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116586. * @param engine The engine which the post process will be applied. (default: current engine)
  116587. * @param reusable If the post process can be reused on the same frame. (default: false)
  116588. * @param textureType Type of textures used when performing the post process. (default: 0)
  116589. * @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)
  116590. */
  116591. function BloomMergePostProcess(name, originalFromInput, blurred,
  116592. /** Weight of the bloom to be added to the original input. */
  116593. weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116594. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116595. if (blockCompilation === void 0) { blockCompilation = false; }
  116596. var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  116597. _this.weight = weight;
  116598. _this.onApplyObservable.add(function (effect) {
  116599. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  116600. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  116601. effect.setFloat("bloomWeight", _this.weight);
  116602. });
  116603. if (!blockCompilation) {
  116604. _this.updateEffect();
  116605. }
  116606. return _this;
  116607. }
  116608. return BloomMergePostProcess;
  116609. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116610. /***/ }),
  116611. /***/ "./PostProcesses/blurPostProcess.ts":
  116612. /*!******************************************!*\
  116613. !*** ./PostProcesses/blurPostProcess.ts ***!
  116614. \******************************************/
  116615. /*! exports provided: BlurPostProcess */
  116616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116617. "use strict";
  116618. __webpack_require__.r(__webpack_exports__);
  116619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return BlurPostProcess; });
  116620. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116621. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116622. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116623. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116624. /* harmony import */ var _Shaders_kernelBlur_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/kernelBlur.fragment */ "./Shaders/kernelBlur.fragment.ts");
  116625. /* harmony import */ var _Shaders_kernelBlur_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/kernelBlur.vertex */ "./Shaders/kernelBlur.vertex.ts");
  116626. /**
  116627. * The Blur Post Process which blurs an image based on a kernel and direction.
  116628. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  116629. */
  116630. var BlurPostProcess = /** @class */ (function (_super) {
  116631. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlurPostProcess, _super);
  116632. /**
  116633. * Creates a new instance BlurPostProcess
  116634. * @param name The name of the effect.
  116635. * @param direction The direction in which to blur the image.
  116636. * @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.
  116637. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  116638. * @param camera The camera to apply the render pass to.
  116639. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116640. * @param engine The engine which the post process will be applied. (default: current engine)
  116641. * @param reusable If the post process can be reused on the same frame. (default: false)
  116642. * @param textureType Type of textures used when performing the post process. (default: 0)
  116643. * @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)
  116644. */
  116645. function BlurPostProcess(name,
  116646. /** The direction in which to blur the image. */
  116647. direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
  116648. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  116649. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116650. if (defines === void 0) { defines = ""; }
  116651. if (blockCompilation === void 0) { blockCompilation = false; }
  116652. 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;
  116653. _this.direction = direction;
  116654. _this.blockCompilation = blockCompilation;
  116655. _this._packedFloat = false;
  116656. _this._staticDefines = "";
  116657. _this._staticDefines = defines;
  116658. _this.onApplyObservable.add(function (effect) {
  116659. if (_this._outputTexture) {
  116660. effect.setFloat2('delta', (1 / _this._outputTexture.width) * _this.direction.x, (1 / _this._outputTexture.height) * _this.direction.y);
  116661. }
  116662. else {
  116663. effect.setFloat2('delta', (1 / _this.width) * _this.direction.x, (1 / _this.height) * _this.direction.y);
  116664. }
  116665. });
  116666. _this.kernel = kernel;
  116667. return _this;
  116668. }
  116669. Object.defineProperty(BlurPostProcess.prototype, "kernel", {
  116670. /**
  116671. * Gets the length in pixels of the blur sample region
  116672. */
  116673. get: function () {
  116674. return this._idealKernel;
  116675. },
  116676. /**
  116677. * Sets the length in pixels of the blur sample region
  116678. */
  116679. set: function (v) {
  116680. if (this._idealKernel === v) {
  116681. return;
  116682. }
  116683. v = Math.max(v, 1);
  116684. this._idealKernel = v;
  116685. this._kernel = this._nearestBestKernel(v);
  116686. if (!this.blockCompilation) {
  116687. this._updateParameters();
  116688. }
  116689. },
  116690. enumerable: true,
  116691. configurable: true
  116692. });
  116693. Object.defineProperty(BlurPostProcess.prototype, "packedFloat", {
  116694. /**
  116695. * Gets wether or not the blur is unpacking/repacking floats
  116696. */
  116697. get: function () {
  116698. return this._packedFloat;
  116699. },
  116700. /**
  116701. * Sets wether or not the blur needs to unpack/repack floats
  116702. */
  116703. set: function (v) {
  116704. if (this._packedFloat === v) {
  116705. return;
  116706. }
  116707. this._packedFloat = v;
  116708. if (!this.blockCompilation) {
  116709. this._updateParameters();
  116710. }
  116711. },
  116712. enumerable: true,
  116713. configurable: true
  116714. });
  116715. /**
  116716. * Updates the effect with the current post process compile time values and recompiles the shader.
  116717. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  116718. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  116719. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  116720. * @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
  116721. * @param onCompiled Called when the shader has been compiled.
  116722. * @param onError Called if there is an error when compiling a shader.
  116723. */
  116724. BlurPostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  116725. if (defines === void 0) { defines = null; }
  116726. if (uniforms === void 0) { uniforms = null; }
  116727. if (samplers === void 0) { samplers = null; }
  116728. this._updateParameters(onCompiled, onError);
  116729. };
  116730. BlurPostProcess.prototype._updateParameters = function (onCompiled, onError) {
  116731. // Generate sampling offsets and weights
  116732. var N = this._kernel;
  116733. var centerIndex = (N - 1) / 2;
  116734. // Generate Gaussian sampling weights over kernel
  116735. var offsets = [];
  116736. var weights = [];
  116737. var totalWeight = 0;
  116738. for (var i = 0; i < N; i++) {
  116739. var u = i / (N - 1);
  116740. var w = this._gaussianWeight(u * 2.0 - 1);
  116741. offsets[i] = (i - centerIndex);
  116742. weights[i] = w;
  116743. totalWeight += w;
  116744. }
  116745. // Normalize weights
  116746. for (var i = 0; i < weights.length; i++) {
  116747. weights[i] /= totalWeight;
  116748. }
  116749. // Optimize: combine samples to take advantage of hardware linear sampling
  116750. // Walk from left to center, combining pairs (symmetrically)
  116751. var linearSamplingWeights = [];
  116752. var linearSamplingOffsets = [];
  116753. var linearSamplingMap = [];
  116754. for (var i = 0; i <= centerIndex; i += 2) {
  116755. var j = Math.min(i + 1, Math.floor(centerIndex));
  116756. var singleCenterSample = i === j;
  116757. if (singleCenterSample) {
  116758. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  116759. }
  116760. else {
  116761. var sharedCell = j === centerIndex;
  116762. var weightLinear = (weights[i] + weights[j] * (sharedCell ? .5 : 1.));
  116763. var offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
  116764. if (offsetLinear === 0) {
  116765. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  116766. linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
  116767. }
  116768. else {
  116769. linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
  116770. linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
  116771. }
  116772. }
  116773. }
  116774. for (var i = 0; i < linearSamplingMap.length; i++) {
  116775. linearSamplingOffsets[i] = linearSamplingMap[i].o;
  116776. linearSamplingWeights[i] = linearSamplingMap[i].w;
  116777. }
  116778. // Replace with optimized
  116779. offsets = linearSamplingOffsets;
  116780. weights = linearSamplingWeights;
  116781. // Generate shaders
  116782. var maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
  116783. var freeVaryingVec2 = Math.max(maxVaryingRows, 0.) - 1; // Because of sampleCenter
  116784. var varyingCount = Math.min(offsets.length, freeVaryingVec2);
  116785. var defines = "";
  116786. defines += this._staticDefines;
  116787. // The DOF fragment should ignore the center pixel when looping as it is handled manualy in the fragment shader.
  116788. if (this._staticDefines.indexOf("DOF") != -1) {
  116789. defines += "#define CENTER_WEIGHT " + this._glslFloat(weights[varyingCount - 1]) + "\r\n";
  116790. varyingCount--;
  116791. }
  116792. for (var i = 0; i < varyingCount; i++) {
  116793. defines += "#define KERNEL_OFFSET" + i + " " + this._glslFloat(offsets[i]) + "\r\n";
  116794. defines += "#define KERNEL_WEIGHT" + i + " " + this._glslFloat(weights[i]) + "\r\n";
  116795. }
  116796. var depCount = 0;
  116797. for (var i = freeVaryingVec2; i < offsets.length; i++) {
  116798. defines += "#define KERNEL_DEP_OFFSET" + depCount + " " + this._glslFloat(offsets[i]) + "\r\n";
  116799. defines += "#define KERNEL_DEP_WEIGHT" + depCount + " " + this._glslFloat(weights[i]) + "\r\n";
  116800. depCount++;
  116801. }
  116802. if (this.packedFloat) {
  116803. defines += "#define PACKEDFLOAT 1";
  116804. }
  116805. this.blockCompilation = false;
  116806. _super.prototype.updateEffect.call(this, defines, null, null, {
  116807. varyingCount: varyingCount,
  116808. depCount: depCount
  116809. }, onCompiled, onError);
  116810. };
  116811. /**
  116812. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  116813. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  116814. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  116815. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  116816. * The gaps between physical kernels are compensated for in the weighting of the samples
  116817. * @param idealKernel Ideal blur kernel.
  116818. * @return Nearest best kernel.
  116819. */
  116820. BlurPostProcess.prototype._nearestBestKernel = function (idealKernel) {
  116821. var v = Math.round(idealKernel);
  116822. for (var _i = 0, _a = [v, v - 1, v + 1, v - 2, v + 2]; _i < _a.length; _i++) {
  116823. var k = _a[_i];
  116824. if (((k % 2) !== 0) && ((Math.floor(k / 2) % 2) === 0) && k > 0) {
  116825. return Math.max(k, 3);
  116826. }
  116827. }
  116828. return Math.max(v, 3);
  116829. };
  116830. /**
  116831. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  116832. * @param x The point on the Gaussian distribution to sample.
  116833. * @return the value of the Gaussian function at x.
  116834. */
  116835. BlurPostProcess.prototype._gaussianWeight = function (x) {
  116836. //reference: Engines/ImageProcessingBlur.cpp #dcc760
  116837. // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
  116838. // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
  116839. // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
  116840. // truncated at around 1.3% of peak strength.
  116841. //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
  116842. var sigma = (1 / 3);
  116843. var denominator = Math.sqrt(2.0 * Math.PI) * sigma;
  116844. var exponent = -((x * x) / (2.0 * sigma * sigma));
  116845. var weight = (1.0 / denominator) * Math.exp(exponent);
  116846. return weight;
  116847. };
  116848. /**
  116849. * Generates a string that can be used as a floating point number in GLSL.
  116850. * @param x Value to print.
  116851. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  116852. * @return GLSL float string.
  116853. */
  116854. BlurPostProcess.prototype._glslFloat = function (x, decimalFigures) {
  116855. if (decimalFigures === void 0) { decimalFigures = 8; }
  116856. return x.toFixed(decimalFigures).replace(/0+$/, '');
  116857. };
  116858. return BlurPostProcess;
  116859. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116860. /***/ }),
  116861. /***/ "./PostProcesses/chromaticAberrationPostProcess.ts":
  116862. /*!*********************************************************!*\
  116863. !*** ./PostProcesses/chromaticAberrationPostProcess.ts ***!
  116864. \*********************************************************/
  116865. /*! exports provided: ChromaticAberrationPostProcess */
  116866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116867. "use strict";
  116868. __webpack_require__.r(__webpack_exports__);
  116869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return ChromaticAberrationPostProcess; });
  116870. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116871. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116872. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116873. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116874. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  116875. /**
  116876. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  116877. */
  116878. var ChromaticAberrationPostProcess = /** @class */ (function (_super) {
  116879. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ChromaticAberrationPostProcess, _super);
  116880. /**
  116881. * Creates a new instance ChromaticAberrationPostProcess
  116882. * @param name The name of the effect.
  116883. * @param screenWidth The width of the screen to apply the effect on.
  116884. * @param screenHeight The height of the screen to apply the effect on.
  116885. * @param options The required width/height ratio to downsize to before computing the render pass.
  116886. * @param camera The camera to apply the render pass to.
  116887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116888. * @param engine The engine which the post process will be applied. (default: current engine)
  116889. * @param reusable If the post process can be reused on the same frame. (default: false)
  116890. * @param textureType Type of textures used when performing the post process. (default: 0)
  116891. * @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)
  116892. */
  116893. function ChromaticAberrationPostProcess(name, screenWidth, screenHeight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116894. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116895. if (blockCompilation === void 0) { blockCompilation = false; }
  116896. 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;
  116897. /**
  116898. * The amount of seperation of rgb channels (default: 30)
  116899. */
  116900. _this.aberrationAmount = 30;
  116901. /**
  116902. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  116903. */
  116904. _this.radialIntensity = 0;
  116905. /**
  116906. * 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))
  116907. */
  116908. _this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.707, 0.707);
  116909. /**
  116910. * 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))
  116911. */
  116912. _this.centerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.5, 0.5);
  116913. _this.onApplyObservable.add(function (effect) {
  116914. effect.setFloat('chromatic_aberration', _this.aberrationAmount);
  116915. effect.setFloat('screen_width', screenWidth);
  116916. effect.setFloat('screen_height', screenHeight);
  116917. effect.setFloat('radialIntensity', _this.radialIntensity);
  116918. effect.setFloat2('direction', _this.direction.x, _this.direction.y);
  116919. effect.setFloat2('centerPosition', _this.centerPosition.x, _this.centerPosition.y);
  116920. });
  116921. return _this;
  116922. }
  116923. return ChromaticAberrationPostProcess;
  116924. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  116925. /***/ }),
  116926. /***/ "./PostProcesses/circleOfConfusionPostProcess.ts":
  116927. /*!*******************************************************!*\
  116928. !*** ./PostProcesses/circleOfConfusionPostProcess.ts ***!
  116929. \*******************************************************/
  116930. /*! exports provided: CircleOfConfusionPostProcess */
  116931. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116932. "use strict";
  116933. __webpack_require__.r(__webpack_exports__);
  116934. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return CircleOfConfusionPostProcess; });
  116935. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116936. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116937. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  116938. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116939. /* harmony import */ var _Shaders_circleOfConfusion_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/circleOfConfusion.fragment */ "./Shaders/circleOfConfusion.fragment.ts");
  116940. /**
  116941. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  116942. */
  116943. var CircleOfConfusionPostProcess = /** @class */ (function (_super) {
  116944. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleOfConfusionPostProcess, _super);
  116945. /**
  116946. * Creates a new instance CircleOfConfusionPostProcess
  116947. * @param name The name of the effect.
  116948. * @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.
  116949. * @param options The required width/height ratio to downsize to before computing the render pass.
  116950. * @param camera The camera to apply the render pass to.
  116951. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116952. * @param engine The engine which the post process will be applied. (default: current engine)
  116953. * @param reusable If the post process can be reused on the same frame. (default: false)
  116954. * @param textureType Type of textures used when performing the post process. (default: 0)
  116955. * @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)
  116956. */
  116957. function CircleOfConfusionPostProcess(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116958. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116959. if (blockCompilation === void 0) { blockCompilation = false; }
  116960. var _this = _super.call(this, name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  116961. /**
  116962. * 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.
  116963. */
  116964. _this.lensSize = 50;
  116965. /**
  116966. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  116967. */
  116968. _this.fStop = 1.4;
  116969. /**
  116970. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  116971. */
  116972. _this.focusDistance = 2000;
  116973. /**
  116974. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  116975. */
  116976. _this.focalLength = 50;
  116977. _this._depthTexture = null;
  116978. _this._depthTexture = depthTexture;
  116979. _this.onApplyObservable.add(function (effect) {
  116980. if (!_this._depthTexture) {
  116981. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("No depth texture set on CircleOfConfusionPostProcess");
  116982. return;
  116983. }
  116984. effect.setTexture("depthSampler", _this._depthTexture);
  116985. // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
  116986. var aperture = _this.lensSize / _this.fStop;
  116987. var cocPrecalculation = ((aperture * _this.focalLength) / ((_this.focusDistance - _this.focalLength))); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
  116988. effect.setFloat('focusDistance', _this.focusDistance);
  116989. effect.setFloat('cocPrecalculation', cocPrecalculation);
  116990. effect.setFloat2('cameraMinMaxZ', _this._depthTexture.activeCamera.minZ, _this._depthTexture.activeCamera.maxZ);
  116991. });
  116992. return _this;
  116993. }
  116994. Object.defineProperty(CircleOfConfusionPostProcess.prototype, "depthTexture", {
  116995. /**
  116996. * 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.
  116997. */
  116998. set: function (value) {
  116999. this._depthTexture = value;
  117000. },
  117001. enumerable: true,
  117002. configurable: true
  117003. });
  117004. return CircleOfConfusionPostProcess;
  117005. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117006. /***/ }),
  117007. /***/ "./PostProcesses/colorCorrectionPostProcess.ts":
  117008. /*!*****************************************************!*\
  117009. !*** ./PostProcesses/colorCorrectionPostProcess.ts ***!
  117010. \*****************************************************/
  117011. /*! exports provided: ColorCorrectionPostProcess */
  117012. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117013. "use strict";
  117014. __webpack_require__.r(__webpack_exports__);
  117015. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return ColorCorrectionPostProcess; });
  117016. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117017. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117018. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117019. /* harmony import */ var _Shaders_colorCorrection_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/colorCorrection.fragment */ "./Shaders/colorCorrection.fragment.ts");
  117020. /**
  117021. *
  117022. * This post-process allows the modification of rendered colors by using
  117023. * a 'look-up table' (LUT). This effect is also called Color Grading.
  117024. *
  117025. * The object needs to be provided an url to a texture containing the color
  117026. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  117027. * Use an image editing software to tweak the LUT to match your needs.
  117028. *
  117029. * For an example of a color LUT, see here:
  117030. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  117031. * For explanations on color grading, see here:
  117032. * @see http://udn.epicgames.com/Three/ColorGrading.html
  117033. *
  117034. */
  117035. var ColorCorrectionPostProcess = /** @class */ (function (_super) {
  117036. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorCorrectionPostProcess, _super);
  117037. function ColorCorrectionPostProcess(name, colorTableUrl, options, camera, samplingMode, engine, reusable) {
  117038. var _this = _super.call(this, name, 'colorCorrection', null, ['colorTable'], options, camera, samplingMode, engine, reusable) || this;
  117039. _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);
  117040. _this._colorTableTexture.anisotropicFilteringLevel = 1;
  117041. _this._colorTableTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  117042. _this._colorTableTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  117043. _this.onApply = function (effect) {
  117044. effect.setTexture("colorTable", _this._colorTableTexture);
  117045. };
  117046. return _this;
  117047. }
  117048. return ColorCorrectionPostProcess;
  117049. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117050. /***/ }),
  117051. /***/ "./PostProcesses/convolutionPostProcess.ts":
  117052. /*!*************************************************!*\
  117053. !*** ./PostProcesses/convolutionPostProcess.ts ***!
  117054. \*************************************************/
  117055. /*! exports provided: ConvolutionPostProcess */
  117056. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117057. "use strict";
  117058. __webpack_require__.r(__webpack_exports__);
  117059. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return ConvolutionPostProcess; });
  117060. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117061. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117062. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117063. /* harmony import */ var _Shaders_convolution_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/convolution.fragment */ "./Shaders/convolution.fragment.ts");
  117064. /**
  117065. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  117066. * input texture to perform effects such as edge detection or sharpening
  117067. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  117068. */
  117069. var ConvolutionPostProcess = /** @class */ (function (_super) {
  117070. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ConvolutionPostProcess, _super);
  117071. /**
  117072. * Creates a new instance ConvolutionPostProcess
  117073. * @param name The name of the effect.
  117074. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  117075. * @param options The required width/height ratio to downsize to before computing the render pass.
  117076. * @param camera The camera to apply the render pass to.
  117077. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117078. * @param engine The engine which the post process will be applied. (default: current engine)
  117079. * @param reusable If the post process can be reused on the same frame. (default: false)
  117080. * @param textureType Type of textures used when performing the post process. (default: 0)
  117081. */
  117082. function ConvolutionPostProcess(name,
  117083. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  117084. kernel, options, camera, samplingMode, engine, reusable, textureType) {
  117085. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117086. var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  117087. _this.kernel = kernel;
  117088. _this.onApply = function (effect) {
  117089. effect.setFloat2("screenSize", _this.width, _this.height);
  117090. effect.setArray("kernel", _this.kernel);
  117091. };
  117092. return _this;
  117093. }
  117094. // Statics
  117095. /**
  117096. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117097. */
  117098. ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
  117099. /**
  117100. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117101. */
  117102. ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
  117103. /**
  117104. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117105. */
  117106. ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
  117107. /**
  117108. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117109. */
  117110. ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
  117111. /**
  117112. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117113. */
  117114. ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
  117115. /**
  117116. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117117. */
  117118. ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
  117119. return ConvolutionPostProcess;
  117120. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117121. /***/ }),
  117122. /***/ "./PostProcesses/depthOfFieldBlurPostProcess.ts":
  117123. /*!******************************************************!*\
  117124. !*** ./PostProcesses/depthOfFieldBlurPostProcess.ts ***!
  117125. \******************************************************/
  117126. /*! exports provided: DepthOfFieldBlurPostProcess */
  117127. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117128. "use strict";
  117129. __webpack_require__.r(__webpack_exports__);
  117130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return DepthOfFieldBlurPostProcess; });
  117131. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117132. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117133. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  117134. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117135. /**
  117136. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  117137. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  117138. * based on samples that have a large difference in distance than the center pixel.
  117139. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  117140. */
  117141. var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
  117142. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldBlurPostProcess, _super);
  117143. /**
  117144. * Creates a new instance CircleOfConfusionPostProcess
  117145. * @param name The name of the effect.
  117146. * @param scene The scene the effect belongs to.
  117147. * @param direction The direction the blur should be applied.
  117148. * @param kernel The size of the kernel used to blur.
  117149. * @param options The required width/height ratio to downsize to before computing the render pass.
  117150. * @param camera The camera to apply the render pass to.
  117151. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  117152. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  117153. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117154. * @param engine The engine which the post process will be applied. (default: current engine)
  117155. * @param reusable If the post process can be reused on the same frame. (default: false)
  117156. * @param textureType Type of textures used when performing the post process. (default: 0)
  117157. * @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)
  117158. */
  117159. function DepthOfFieldBlurPostProcess(name, scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur, samplingMode, engine, reusable, textureType, blockCompilation) {
  117160. if (imageToBlur === void 0) { imageToBlur = null; }
  117161. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  117162. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117163. if (blockCompilation === void 0) { blockCompilation = false; }
  117164. 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;
  117165. _this.direction = direction;
  117166. _this.onApplyObservable.add(function (effect) {
  117167. if (imageToBlur != null) {
  117168. effect.setTextureFromPostProcess("textureSampler", imageToBlur);
  117169. }
  117170. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  117171. if (scene.activeCamera) {
  117172. effect.setFloat2('cameraMinMaxZ', scene.activeCamera.minZ, scene.activeCamera.maxZ);
  117173. }
  117174. });
  117175. return _this;
  117176. }
  117177. return DepthOfFieldBlurPostProcess;
  117178. }(_blurPostProcess__WEBPACK_IMPORTED_MODULE_2__["BlurPostProcess"]));
  117179. /***/ }),
  117180. /***/ "./PostProcesses/depthOfFieldEffect.ts":
  117181. /*!*********************************************!*\
  117182. !*** ./PostProcesses/depthOfFieldEffect.ts ***!
  117183. \*********************************************/
  117184. /*! exports provided: DepthOfFieldEffectBlurLevel, DepthOfFieldEffect */
  117185. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117186. "use strict";
  117187. __webpack_require__.r(__webpack_exports__);
  117188. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return DepthOfFieldEffectBlurLevel; });
  117189. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return DepthOfFieldEffect; });
  117190. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117191. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117192. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117193. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  117194. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  117195. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  117196. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  117197. /**
  117198. * Specifies the level of max blur that should be applied when using the depth of field effect
  117199. */
  117200. var DepthOfFieldEffectBlurLevel;
  117201. (function (DepthOfFieldEffectBlurLevel) {
  117202. /**
  117203. * Subtle blur
  117204. */
  117205. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Low"] = 0] = "Low";
  117206. /**
  117207. * Medium blur
  117208. */
  117209. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Medium"] = 1] = "Medium";
  117210. /**
  117211. * Large blur
  117212. */
  117213. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["High"] = 2] = "High";
  117214. })(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  117215. /**
  117216. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  117217. */
  117218. var DepthOfFieldEffect = /** @class */ (function (_super) {
  117219. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldEffect, _super);
  117220. /**
  117221. * Creates a new instance DepthOfFieldEffect
  117222. * @param scene The scene the effect belongs to.
  117223. * @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.
  117224. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117225. * @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)
  117226. */
  117227. function DepthOfFieldEffect(scene, depthTexture, blurLevel, pipelineTextureType, blockCompilation) {
  117228. if (blurLevel === void 0) { blurLevel = DepthOfFieldEffectBlurLevel.Low; }
  117229. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  117230. if (blockCompilation === void 0) { blockCompilation = false; }
  117231. var _this = _super.call(this, scene.getEngine(), "depth of field", function () {
  117232. return _this._effects;
  117233. }, true) || this;
  117234. /**
  117235. * @hidden Internal post processes in depth of field effect
  117236. */
  117237. _this._effects = [];
  117238. // Circle of confusion value for each pixel is used to determine how much to blur that pixel
  117239. _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);
  117240. // 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)
  117241. // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
  117242. // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  117243. _this._depthOfFieldBlurY = [];
  117244. _this._depthOfFieldBlurX = [];
  117245. var blurCount = 1;
  117246. var kernelSize = 15;
  117247. switch (blurLevel) {
  117248. case DepthOfFieldEffectBlurLevel.High: {
  117249. blurCount = 3;
  117250. kernelSize = 51;
  117251. break;
  117252. }
  117253. case DepthOfFieldEffectBlurLevel.Medium: {
  117254. blurCount = 2;
  117255. kernelSize = 31;
  117256. break;
  117257. }
  117258. default: {
  117259. kernelSize = 15;
  117260. blurCount = 1;
  117261. break;
  117262. }
  117263. }
  117264. var adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
  117265. var ratio = 1.0;
  117266. for (var i = 0; i < blurCount; i++) {
  117267. 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);
  117268. blurY.autoClear = false;
  117269. ratio = 0.75 / Math.pow(2, i);
  117270. 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);
  117271. blurX.autoClear = false;
  117272. _this._depthOfFieldBlurY.push(blurY);
  117273. _this._depthOfFieldBlurX.push(blurX);
  117274. }
  117275. // Set all post processes on the effect.
  117276. _this._effects = [_this._circleOfConfusion];
  117277. for (var i = 0; i < _this._depthOfFieldBlurX.length; i++) {
  117278. _this._effects.push(_this._depthOfFieldBlurY[i]);
  117279. _this._effects.push(_this._depthOfFieldBlurX[i]);
  117280. }
  117281. // Merge blurred images with original image based on circleOfConfusion
  117282. _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);
  117283. _this._dofMerge.autoClear = false;
  117284. _this._effects.push(_this._dofMerge);
  117285. return _this;
  117286. }
  117287. Object.defineProperty(DepthOfFieldEffect.prototype, "focalLength", {
  117288. get: function () {
  117289. return this._circleOfConfusion.focalLength;
  117290. },
  117291. /**
  117292. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  117293. */
  117294. set: function (value) {
  117295. this._circleOfConfusion.focalLength = value;
  117296. },
  117297. enumerable: true,
  117298. configurable: true
  117299. });
  117300. Object.defineProperty(DepthOfFieldEffect.prototype, "fStop", {
  117301. get: function () {
  117302. return this._circleOfConfusion.fStop;
  117303. },
  117304. /**
  117305. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117306. */
  117307. set: function (value) {
  117308. this._circleOfConfusion.fStop = value;
  117309. },
  117310. enumerable: true,
  117311. configurable: true
  117312. });
  117313. Object.defineProperty(DepthOfFieldEffect.prototype, "focusDistance", {
  117314. get: function () {
  117315. return this._circleOfConfusion.focusDistance;
  117316. },
  117317. /**
  117318. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117319. */
  117320. set: function (value) {
  117321. this._circleOfConfusion.focusDistance = value;
  117322. },
  117323. enumerable: true,
  117324. configurable: true
  117325. });
  117326. Object.defineProperty(DepthOfFieldEffect.prototype, "lensSize", {
  117327. get: function () {
  117328. return this._circleOfConfusion.lensSize;
  117329. },
  117330. /**
  117331. * 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.
  117332. */
  117333. set: function (value) {
  117334. this._circleOfConfusion.lensSize = value;
  117335. },
  117336. enumerable: true,
  117337. configurable: true
  117338. });
  117339. Object.defineProperty(DepthOfFieldEffect.prototype, "depthTexture", {
  117340. /**
  117341. * 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.
  117342. */
  117343. set: function (value) {
  117344. this._circleOfConfusion.depthTexture = value;
  117345. },
  117346. enumerable: true,
  117347. configurable: true
  117348. });
  117349. /**
  117350. * Disposes each of the internal effects for a given camera.
  117351. * @param camera The camera to dispose the effect on.
  117352. */
  117353. DepthOfFieldEffect.prototype.disposeEffects = function (camera) {
  117354. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  117355. this._effects[effectIndex].dispose(camera);
  117356. }
  117357. };
  117358. /**
  117359. * @hidden Internal
  117360. */
  117361. DepthOfFieldEffect.prototype._updateEffects = function () {
  117362. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  117363. this._effects[effectIndex].updateEffect();
  117364. }
  117365. };
  117366. /**
  117367. * Internal
  117368. * @returns if all the contained post processes are ready.
  117369. * @hidden
  117370. */
  117371. DepthOfFieldEffect.prototype._isReady = function () {
  117372. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  117373. if (!this._effects[effectIndex].isReady()) {
  117374. return false;
  117375. }
  117376. }
  117377. return true;
  117378. };
  117379. return DepthOfFieldEffect;
  117380. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderEffect"]));
  117381. /***/ }),
  117382. /***/ "./PostProcesses/depthOfFieldMergePostProcess.ts":
  117383. /*!*******************************************************!*\
  117384. !*** ./PostProcesses/depthOfFieldMergePostProcess.ts ***!
  117385. \*******************************************************/
  117386. /*! exports provided: DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess */
  117387. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117388. "use strict";
  117389. __webpack_require__.r(__webpack_exports__);
  117390. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return DepthOfFieldMergePostProcessOptions; });
  117391. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return DepthOfFieldMergePostProcess; });
  117392. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117393. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117394. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117395. /* harmony import */ var _Shaders_depthOfFieldMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/depthOfFieldMerge.fragment */ "./Shaders/depthOfFieldMerge.fragment.ts");
  117396. /**
  117397. * Options to be set when merging outputs from the default pipeline.
  117398. */
  117399. var DepthOfFieldMergePostProcessOptions = /** @class */ (function () {
  117400. function DepthOfFieldMergePostProcessOptions() {
  117401. }
  117402. return DepthOfFieldMergePostProcessOptions;
  117403. }());
  117404. /**
  117405. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117406. */
  117407. var DepthOfFieldMergePostProcess = /** @class */ (function (_super) {
  117408. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldMergePostProcess, _super);
  117409. /**
  117410. * Creates a new instance of DepthOfFieldMergePostProcess
  117411. * @param name The name of the effect.
  117412. * @param originalFromInput Post process which's input will be used for the merge.
  117413. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  117414. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  117415. * @param options The required width/height ratio to downsize to before computing the render pass.
  117416. * @param camera The camera to apply the render pass to.
  117417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117418. * @param engine The engine which the post process will be applied. (default: current engine)
  117419. * @param reusable If the post process can be reused on the same frame. (default: false)
  117420. * @param textureType Type of textures used when performing the post process. (default: 0)
  117421. * @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)
  117422. */
  117423. function DepthOfFieldMergePostProcess(name, originalFromInput, circleOfConfusion, blurSteps, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117424. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117425. if (blockCompilation === void 0) { blockCompilation = false; }
  117426. var _this = _super.call(this, name, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  117427. _this.blurSteps = blurSteps;
  117428. _this.onApplyObservable.add(function (effect) {
  117429. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  117430. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  117431. blurSteps.forEach(function (step, index) {
  117432. effect.setTextureFromPostProcessOutput("blurStep" + (blurSteps.length - index - 1), step);
  117433. });
  117434. });
  117435. if (!blockCompilation) {
  117436. _this.updateEffect();
  117437. }
  117438. return _this;
  117439. }
  117440. /**
  117441. * Updates the effect with the current post process compile time values and recompiles the shader.
  117442. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  117443. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  117444. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  117445. * @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
  117446. * @param onCompiled Called when the shader has been compiled.
  117447. * @param onError Called if there is an error when compiling a shader.
  117448. */
  117449. DepthOfFieldMergePostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  117450. if (defines === void 0) { defines = null; }
  117451. if (uniforms === void 0) { uniforms = null; }
  117452. if (samplers === void 0) { samplers = null; }
  117453. if (!defines) {
  117454. defines = "";
  117455. defines += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + "\n";
  117456. }
  117457. _super.prototype.updateEffect.call(this, defines, uniforms, samplers, indexParameters, onCompiled, onError);
  117458. };
  117459. return DepthOfFieldMergePostProcess;
  117460. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117461. /***/ }),
  117462. /***/ "./PostProcesses/displayPassPostProcess.ts":
  117463. /*!*************************************************!*\
  117464. !*** ./PostProcesses/displayPassPostProcess.ts ***!
  117465. \*************************************************/
  117466. /*! exports provided: DisplayPassPostProcess */
  117467. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117468. "use strict";
  117469. __webpack_require__.r(__webpack_exports__);
  117470. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return DisplayPassPostProcess; });
  117471. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117472. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117473. /* harmony import */ var _Shaders_displayPass_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/displayPass.fragment */ "./Shaders/displayPass.fragment.ts");
  117474. /**
  117475. * DisplayPassPostProcess which produces an output the same as it's input
  117476. */
  117477. var DisplayPassPostProcess = /** @class */ (function (_super) {
  117478. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayPassPostProcess, _super);
  117479. /**
  117480. * Creates the DisplayPassPostProcess
  117481. * @param name The name of the effect.
  117482. * @param options The required width/height ratio to downsize to before computing the render pass.
  117483. * @param camera The camera to apply the render pass to.
  117484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117485. * @param engine The engine which the post process will be applied. (default: current engine)
  117486. * @param reusable If the post process can be reused on the same frame. (default: false)
  117487. */
  117488. function DisplayPassPostProcess(name, options, camera, samplingMode, engine, reusable) {
  117489. return _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable) || this;
  117490. }
  117491. return DisplayPassPostProcess;
  117492. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117493. /***/ }),
  117494. /***/ "./PostProcesses/extractHighlightsPostProcess.ts":
  117495. /*!*******************************************************!*\
  117496. !*** ./PostProcesses/extractHighlightsPostProcess.ts ***!
  117497. \*******************************************************/
  117498. /*! exports provided: ExtractHighlightsPostProcess */
  117499. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117500. "use strict";
  117501. __webpack_require__.r(__webpack_exports__);
  117502. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return ExtractHighlightsPostProcess; });
  117503. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117504. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117505. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117506. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117507. /* harmony import */ var _Shaders_extractHighlights_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/extractHighlights.fragment */ "./Shaders/extractHighlights.fragment.ts");
  117508. /**
  117509. * 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.
  117510. */
  117511. var ExtractHighlightsPostProcess = /** @class */ (function (_super) {
  117512. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExtractHighlightsPostProcess, _super);
  117513. function ExtractHighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117514. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117515. if (blockCompilation === void 0) { blockCompilation = false; }
  117516. var _this = _super.call(this, name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  117517. /**
  117518. * The luminance threshold, pixels below this value will be set to black.
  117519. */
  117520. _this.threshold = 0.9;
  117521. /** @hidden */
  117522. _this._exposure = 1;
  117523. /**
  117524. * Post process which has the input texture to be used when performing highlight extraction
  117525. * @hidden
  117526. */
  117527. _this._inputPostProcess = null;
  117528. _this.onApplyObservable.add(function (effect) {
  117529. if (_this._inputPostProcess) {
  117530. effect.setTextureFromPostProcess("textureSampler", _this._inputPostProcess);
  117531. }
  117532. effect.setFloat('threshold', Math.pow(_this.threshold, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]));
  117533. effect.setFloat('exposure', _this._exposure);
  117534. });
  117535. return _this;
  117536. }
  117537. return ExtractHighlightsPostProcess;
  117538. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117539. /***/ }),
  117540. /***/ "./PostProcesses/filterPostProcess.ts":
  117541. /*!********************************************!*\
  117542. !*** ./PostProcesses/filterPostProcess.ts ***!
  117543. \********************************************/
  117544. /*! exports provided: FilterPostProcess */
  117545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117546. "use strict";
  117547. __webpack_require__.r(__webpack_exports__);
  117548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return FilterPostProcess; });
  117549. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117550. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117551. /* harmony import */ var _Shaders_filter_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/filter.fragment */ "./Shaders/filter.fragment.ts");
  117552. /**
  117553. * Applies a kernel filter to the image
  117554. */
  117555. var FilterPostProcess = /** @class */ (function (_super) {
  117556. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FilterPostProcess, _super);
  117557. /**
  117558. *
  117559. * @param name The name of the effect.
  117560. * @param kernelMatrix The matrix to be applied to the image
  117561. * @param options The required width/height ratio to downsize to before computing the render pass.
  117562. * @param camera The camera to apply the render pass to.
  117563. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117564. * @param engine The engine which the post process will be applied. (default: current engine)
  117565. * @param reusable If the post process can be reused on the same frame. (default: false)
  117566. */
  117567. function FilterPostProcess(name,
  117568. /** The matrix to be applied to the image */
  117569. kernelMatrix, options, camera, samplingMode, engine, reusable) {
  117570. var _this = _super.call(this, name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable) || this;
  117571. _this.kernelMatrix = kernelMatrix;
  117572. _this.onApply = function (effect) {
  117573. effect.setMatrix("kernelMatrix", _this.kernelMatrix);
  117574. };
  117575. return _this;
  117576. }
  117577. return FilterPostProcess;
  117578. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117579. /***/ }),
  117580. /***/ "./PostProcesses/fxaaPostProcess.ts":
  117581. /*!******************************************!*\
  117582. !*** ./PostProcesses/fxaaPostProcess.ts ***!
  117583. \******************************************/
  117584. /*! exports provided: FxaaPostProcess */
  117585. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117586. "use strict";
  117587. __webpack_require__.r(__webpack_exports__);
  117588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return FxaaPostProcess; });
  117589. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117590. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117591. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117592. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117593. /* harmony import */ var _Shaders_fxaa_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/fxaa.fragment */ "./Shaders/fxaa.fragment.ts");
  117594. /* harmony import */ var _Shaders_fxaa_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/fxaa.vertex */ "./Shaders/fxaa.vertex.ts");
  117595. /**
  117596. * Fxaa post process
  117597. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  117598. */
  117599. var FxaaPostProcess = /** @class */ (function (_super) {
  117600. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FxaaPostProcess, _super);
  117601. function FxaaPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  117602. if (camera === void 0) { camera = null; }
  117603. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117604. 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;
  117605. var defines = _this._getDefines();
  117606. _this.updateEffect(defines);
  117607. _this.onApplyObservable.add(function (effect) {
  117608. var texelSize = _this.texelSize;
  117609. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  117610. });
  117611. return _this;
  117612. }
  117613. FxaaPostProcess.prototype._getDefines = function () {
  117614. var engine = this.getEngine();
  117615. if (!engine) {
  117616. return null;
  117617. }
  117618. var glInfo = engine.getGlInfo();
  117619. if (glInfo && glInfo.renderer && glInfo.renderer.toLowerCase().indexOf("mali") > -1) {
  117620. return "#define MALI 1\n";
  117621. }
  117622. return null;
  117623. };
  117624. return FxaaPostProcess;
  117625. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  117626. /***/ }),
  117627. /***/ "./PostProcesses/grainPostProcess.ts":
  117628. /*!*******************************************!*\
  117629. !*** ./PostProcesses/grainPostProcess.ts ***!
  117630. \*******************************************/
  117631. /*! exports provided: GrainPostProcess */
  117632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117633. "use strict";
  117634. __webpack_require__.r(__webpack_exports__);
  117635. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return GrainPostProcess; });
  117636. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117637. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117638. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117639. /* harmony import */ var _Shaders_grain_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/grain.fragment */ "./Shaders/grain.fragment.ts");
  117640. /**
  117641. * The GrainPostProcess adds noise to the image at mid luminance levels
  117642. */
  117643. var GrainPostProcess = /** @class */ (function (_super) {
  117644. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GrainPostProcess, _super);
  117645. /**
  117646. * Creates a new instance of @see GrainPostProcess
  117647. * @param name The name of the effect.
  117648. * @param options The required width/height ratio to downsize to before computing the render pass.
  117649. * @param camera The camera to apply the render pass to.
  117650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117651. * @param engine The engine which the post process will be applied. (default: current engine)
  117652. * @param reusable If the post process can be reused on the same frame. (default: false)
  117653. * @param textureType Type of textures used when performing the post process. (default: 0)
  117654. * @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)
  117655. */
  117656. function GrainPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117657. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117658. if (blockCompilation === void 0) { blockCompilation = false; }
  117659. var _this = _super.call(this, name, "grain", ["intensity", "animatedSeed"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  117660. /**
  117661. * The intensity of the grain added (default: 30)
  117662. */
  117663. _this.intensity = 30;
  117664. /**
  117665. * If the grain should be randomized on every frame
  117666. */
  117667. _this.animated = false;
  117668. _this.onApplyObservable.add(function (effect) {
  117669. effect.setFloat('intensity', _this.intensity);
  117670. effect.setFloat('animatedSeed', _this.animated ? Math.random() + 1 : 1);
  117671. });
  117672. return _this;
  117673. }
  117674. return GrainPostProcess;
  117675. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117676. /***/ }),
  117677. /***/ "./PostProcesses/highlightsPostProcess.ts":
  117678. /*!************************************************!*\
  117679. !*** ./PostProcesses/highlightsPostProcess.ts ***!
  117680. \************************************************/
  117681. /*! exports provided: HighlightsPostProcess */
  117682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117683. "use strict";
  117684. __webpack_require__.r(__webpack_exports__);
  117685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return HighlightsPostProcess; });
  117686. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117687. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117688. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117689. /* harmony import */ var _Shaders_highlights_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/highlights.fragment */ "./Shaders/highlights.fragment.ts");
  117690. /**
  117691. * Extracts highlights from the image
  117692. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117693. */
  117694. var HighlightsPostProcess = /** @class */ (function (_super) {
  117695. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightsPostProcess, _super);
  117696. /**
  117697. * Extracts highlights from the image
  117698. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117699. * @param name The name of the effect.
  117700. * @param options The required width/height ratio to downsize to before computing the render pass.
  117701. * @param camera The camera to apply the render pass to.
  117702. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117703. * @param engine The engine which the post process will be applied. (default: current engine)
  117704. * @param reusable If the post process can be reused on the same frame. (default: false)
  117705. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  117706. */
  117707. function HighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  117708. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117709. return _super.call(this, name, "highlights", null, null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  117710. }
  117711. return HighlightsPostProcess;
  117712. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117713. /***/ }),
  117714. /***/ "./PostProcesses/imageProcessingPostProcess.ts":
  117715. /*!*****************************************************!*\
  117716. !*** ./PostProcesses/imageProcessingPostProcess.ts ***!
  117717. \*****************************************************/
  117718. /*! exports provided: ImageProcessingPostProcess */
  117719. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117720. "use strict";
  117721. __webpack_require__.r(__webpack_exports__);
  117722. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return ImageProcessingPostProcess; });
  117723. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117724. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  117725. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  117726. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117727. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  117728. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117729. /* harmony import */ var _Shaders_imageProcessing_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/imageProcessing.fragment */ "./Shaders/imageProcessing.fragment.ts");
  117730. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  117731. /**
  117732. * ImageProcessingPostProcess
  117733. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  117734. */
  117735. var ImageProcessingPostProcess = /** @class */ (function (_super) {
  117736. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingPostProcess, _super);
  117737. function ImageProcessingPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, imageProcessingConfiguration) {
  117738. if (camera === void 0) { camera = null; }
  117739. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117740. var _this = _super.call(this, name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, null, textureType, "postprocess", null, true) || this;
  117741. _this._fromLinearSpace = true;
  117742. /**
  117743. * Defines cache preventing GC.
  117744. */
  117745. _this._defines = {
  117746. IMAGEPROCESSING: false,
  117747. VIGNETTE: false,
  117748. VIGNETTEBLENDMODEMULTIPLY: false,
  117749. VIGNETTEBLENDMODEOPAQUE: false,
  117750. TONEMAPPING: false,
  117751. TONEMAPPING_ACES: false,
  117752. CONTRAST: false,
  117753. COLORCURVES: false,
  117754. COLORGRADING: false,
  117755. COLORGRADING3D: false,
  117756. FROMLINEARSPACE: false,
  117757. SAMPLER3DGREENDEPTH: false,
  117758. SAMPLER3DBGRMAP: false,
  117759. IMAGEPROCESSINGPOSTPROCESS: false,
  117760. EXPOSURE: false,
  117761. };
  117762. // Setup the configuration as forced by the constructor. This would then not force the
  117763. // scene materials output in linear space and let untouched the default forward pass.
  117764. if (imageProcessingConfiguration) {
  117765. imageProcessingConfiguration.applyByPostProcess = true;
  117766. _this._attachImageProcessingConfiguration(imageProcessingConfiguration, true);
  117767. // This will cause the shader to be compiled
  117768. _this.fromLinearSpace = false;
  117769. }
  117770. // Setup the default processing configuration to the scene.
  117771. else {
  117772. _this._attachImageProcessingConfiguration(null, true);
  117773. _this.imageProcessingConfiguration.applyByPostProcess = true;
  117774. }
  117775. _this.onApply = function (effect) {
  117776. _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
  117777. };
  117778. return _this;
  117779. }
  117780. Object.defineProperty(ImageProcessingPostProcess.prototype, "imageProcessingConfiguration", {
  117781. /**
  117782. * Gets the image processing configuration used either in this material.
  117783. */
  117784. get: function () {
  117785. return this._imageProcessingConfiguration;
  117786. },
  117787. /**
  117788. * Sets the Default image processing configuration used either in the this material.
  117789. *
  117790. * If sets to null, the scene one is in use.
  117791. */
  117792. set: function (value) {
  117793. this._attachImageProcessingConfiguration(value);
  117794. },
  117795. enumerable: true,
  117796. configurable: true
  117797. });
  117798. /**
  117799. * Attaches a new image processing configuration to the PBR Material.
  117800. * @param configuration
  117801. */
  117802. ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
  117803. var _this = this;
  117804. if (doNotBuild === void 0) { doNotBuild = false; }
  117805. if (configuration === this._imageProcessingConfiguration) {
  117806. return;
  117807. }
  117808. // Detaches observer.
  117809. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  117810. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  117811. }
  117812. // Pick the scene configuration if needed.
  117813. if (!configuration) {
  117814. var scene = null;
  117815. var engine = this.getEngine();
  117816. var camera = this.getCamera();
  117817. if (camera) {
  117818. scene = camera.getScene();
  117819. }
  117820. else if (engine && engine.scenes) {
  117821. var scenes = engine.scenes;
  117822. scene = scenes[scenes.length - 1];
  117823. }
  117824. else {
  117825. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  117826. }
  117827. this._imageProcessingConfiguration = scene.imageProcessingConfiguration;
  117828. }
  117829. else {
  117830. this._imageProcessingConfiguration = configuration;
  117831. }
  117832. // Attaches observer.
  117833. if (this._imageProcessingConfiguration) {
  117834. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  117835. _this._updateParameters();
  117836. });
  117837. }
  117838. // Ensure the effect will be rebuilt.
  117839. if (!doNotBuild) {
  117840. this._updateParameters();
  117841. }
  117842. };
  117843. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
  117844. /**
  117845. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  117846. */
  117847. get: function () {
  117848. return this.imageProcessingConfiguration.colorCurves;
  117849. },
  117850. /**
  117851. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  117852. */
  117853. set: function (value) {
  117854. this.imageProcessingConfiguration.colorCurves = value;
  117855. },
  117856. enumerable: true,
  117857. configurable: true
  117858. });
  117859. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurvesEnabled", {
  117860. /**
  117861. * Gets wether the color curves effect is enabled.
  117862. */
  117863. get: function () {
  117864. return this.imageProcessingConfiguration.colorCurvesEnabled;
  117865. },
  117866. /**
  117867. * Sets wether the color curves effect is enabled.
  117868. */
  117869. set: function (value) {
  117870. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  117871. },
  117872. enumerable: true,
  117873. configurable: true
  117874. });
  117875. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingTexture", {
  117876. /**
  117877. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  117878. */
  117879. get: function () {
  117880. return this.imageProcessingConfiguration.colorGradingTexture;
  117881. },
  117882. /**
  117883. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  117884. */
  117885. set: function (value) {
  117886. this.imageProcessingConfiguration.colorGradingTexture = value;
  117887. },
  117888. enumerable: true,
  117889. configurable: true
  117890. });
  117891. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingEnabled", {
  117892. /**
  117893. * Gets wether the color grading effect is enabled.
  117894. */
  117895. get: function () {
  117896. return this.imageProcessingConfiguration.colorGradingEnabled;
  117897. },
  117898. /**
  117899. * Gets wether the color grading effect is enabled.
  117900. */
  117901. set: function (value) {
  117902. this.imageProcessingConfiguration.colorGradingEnabled = value;
  117903. },
  117904. enumerable: true,
  117905. configurable: true
  117906. });
  117907. Object.defineProperty(ImageProcessingPostProcess.prototype, "exposure", {
  117908. /**
  117909. * Gets exposure used in the effect.
  117910. */
  117911. get: function () {
  117912. return this.imageProcessingConfiguration.exposure;
  117913. },
  117914. /**
  117915. * Sets exposure used in the effect.
  117916. */
  117917. set: function (value) {
  117918. this.imageProcessingConfiguration.exposure = value;
  117919. },
  117920. enumerable: true,
  117921. configurable: true
  117922. });
  117923. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingEnabled", {
  117924. /**
  117925. * Gets wether tonemapping is enabled or not.
  117926. */
  117927. get: function () {
  117928. return this._imageProcessingConfiguration.toneMappingEnabled;
  117929. },
  117930. /**
  117931. * Sets wether tonemapping is enabled or not
  117932. */
  117933. set: function (value) {
  117934. this._imageProcessingConfiguration.toneMappingEnabled = value;
  117935. },
  117936. enumerable: true,
  117937. configurable: true
  117938. });
  117939. Object.defineProperty(ImageProcessingPostProcess.prototype, "contrast", {
  117940. /**
  117941. * Gets contrast used in the effect.
  117942. */
  117943. get: function () {
  117944. return this.imageProcessingConfiguration.contrast;
  117945. },
  117946. /**
  117947. * Sets contrast used in the effect.
  117948. */
  117949. set: function (value) {
  117950. this.imageProcessingConfiguration.contrast = value;
  117951. },
  117952. enumerable: true,
  117953. configurable: true
  117954. });
  117955. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteStretch", {
  117956. /**
  117957. * Gets Vignette stretch size.
  117958. */
  117959. get: function () {
  117960. return this.imageProcessingConfiguration.vignetteStretch;
  117961. },
  117962. /**
  117963. * Sets Vignette stretch size.
  117964. */
  117965. set: function (value) {
  117966. this.imageProcessingConfiguration.vignetteStretch = value;
  117967. },
  117968. enumerable: true,
  117969. configurable: true
  117970. });
  117971. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreX", {
  117972. /**
  117973. * Gets Vignette centre X Offset.
  117974. */
  117975. get: function () {
  117976. return this.imageProcessingConfiguration.vignetteCentreX;
  117977. },
  117978. /**
  117979. * Sets Vignette centre X Offset.
  117980. */
  117981. set: function (value) {
  117982. this.imageProcessingConfiguration.vignetteCentreX = value;
  117983. },
  117984. enumerable: true,
  117985. configurable: true
  117986. });
  117987. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreY", {
  117988. /**
  117989. * Gets Vignette centre Y Offset.
  117990. */
  117991. get: function () {
  117992. return this.imageProcessingConfiguration.vignetteCentreY;
  117993. },
  117994. /**
  117995. * Sets Vignette centre Y Offset.
  117996. */
  117997. set: function (value) {
  117998. this.imageProcessingConfiguration.vignetteCentreY = value;
  117999. },
  118000. enumerable: true,
  118001. configurable: true
  118002. });
  118003. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteWeight", {
  118004. /**
  118005. * Gets Vignette weight or intensity of the vignette effect.
  118006. */
  118007. get: function () {
  118008. return this.imageProcessingConfiguration.vignetteWeight;
  118009. },
  118010. /**
  118011. * Sets Vignette weight or intensity of the vignette effect.
  118012. */
  118013. set: function (value) {
  118014. this.imageProcessingConfiguration.vignetteWeight = value;
  118015. },
  118016. enumerable: true,
  118017. configurable: true
  118018. });
  118019. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteColor", {
  118020. /**
  118021. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  118022. * if vignetteEnabled is set to true.
  118023. */
  118024. get: function () {
  118025. return this.imageProcessingConfiguration.vignetteColor;
  118026. },
  118027. /**
  118028. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  118029. * if vignetteEnabled is set to true.
  118030. */
  118031. set: function (value) {
  118032. this.imageProcessingConfiguration.vignetteColor = value;
  118033. },
  118034. enumerable: true,
  118035. configurable: true
  118036. });
  118037. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCameraFov", {
  118038. /**
  118039. * Gets Camera field of view used by the Vignette effect.
  118040. */
  118041. get: function () {
  118042. return this.imageProcessingConfiguration.vignetteCameraFov;
  118043. },
  118044. /**
  118045. * Sets Camera field of view used by the Vignette effect.
  118046. */
  118047. set: function (value) {
  118048. this.imageProcessingConfiguration.vignetteCameraFov = value;
  118049. },
  118050. enumerable: true,
  118051. configurable: true
  118052. });
  118053. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteBlendMode", {
  118054. /**
  118055. * Gets the vignette blend mode allowing different kind of effect.
  118056. */
  118057. get: function () {
  118058. return this.imageProcessingConfiguration.vignetteBlendMode;
  118059. },
  118060. /**
  118061. * Sets the vignette blend mode allowing different kind of effect.
  118062. */
  118063. set: function (value) {
  118064. this.imageProcessingConfiguration.vignetteBlendMode = value;
  118065. },
  118066. enumerable: true,
  118067. configurable: true
  118068. });
  118069. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteEnabled", {
  118070. /**
  118071. * Gets wether the vignette effect is enabled.
  118072. */
  118073. get: function () {
  118074. return this.imageProcessingConfiguration.vignetteEnabled;
  118075. },
  118076. /**
  118077. * Sets wether the vignette effect is enabled.
  118078. */
  118079. set: function (value) {
  118080. this.imageProcessingConfiguration.vignetteEnabled = value;
  118081. },
  118082. enumerable: true,
  118083. configurable: true
  118084. });
  118085. Object.defineProperty(ImageProcessingPostProcess.prototype, "fromLinearSpace", {
  118086. /**
  118087. * Gets wether the input of the processing is in Gamma or Linear Space.
  118088. */
  118089. get: function () {
  118090. return this._fromLinearSpace;
  118091. },
  118092. /**
  118093. * Sets wether the input of the processing is in Gamma or Linear Space.
  118094. */
  118095. set: function (value) {
  118096. if (this._fromLinearSpace === value) {
  118097. return;
  118098. }
  118099. this._fromLinearSpace = value;
  118100. this._updateParameters();
  118101. },
  118102. enumerable: true,
  118103. configurable: true
  118104. });
  118105. /**
  118106. * "ImageProcessingPostProcess"
  118107. * @returns "ImageProcessingPostProcess"
  118108. */
  118109. ImageProcessingPostProcess.prototype.getClassName = function () {
  118110. return "ImageProcessingPostProcess";
  118111. };
  118112. ImageProcessingPostProcess.prototype._updateParameters = function () {
  118113. this._defines.FROMLINEARSPACE = this._fromLinearSpace;
  118114. this.imageProcessingConfiguration.prepareDefines(this._defines, true);
  118115. var defines = "";
  118116. for (var define in this._defines) {
  118117. if (this._defines[define]) {
  118118. defines += "#define " + define + ";\r\n";
  118119. }
  118120. }
  118121. var samplers = ["textureSampler"];
  118122. var uniforms = ["scale"];
  118123. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"]) {
  118124. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._defines);
  118125. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._defines);
  118126. }
  118127. this.updateEffect(defines, uniforms, samplers);
  118128. };
  118129. ImageProcessingPostProcess.prototype.dispose = function (camera) {
  118130. _super.prototype.dispose.call(this, camera);
  118131. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  118132. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  118133. }
  118134. if (this._imageProcessingConfiguration) {
  118135. this.imageProcessingConfiguration.applyByPostProcess = false;
  118136. }
  118137. };
  118138. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118139. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118140. ], ImageProcessingPostProcess.prototype, "_fromLinearSpace", void 0);
  118141. return ImageProcessingPostProcess;
  118142. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  118143. /***/ }),
  118144. /***/ "./PostProcesses/index.ts":
  118145. /*!********************************!*\
  118146. !*** ./PostProcesses/index.ts ***!
  118147. \********************************/
  118148. /*! 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 */
  118149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118150. "use strict";
  118151. __webpack_require__.r(__webpack_exports__);
  118152. /* harmony import */ var _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  118153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  118154. /* harmony import */ var _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./blackAndWhitePostProcess */ "./PostProcesses/blackAndWhitePostProcess.ts");
  118155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__["BlackAndWhitePostProcess"]; });
  118156. /* harmony import */ var _bloomEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bloomEffect */ "./PostProcesses/bloomEffect.ts");
  118157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _bloomEffect__WEBPACK_IMPORTED_MODULE_2__["BloomEffect"]; });
  118158. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  118159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__["BloomMergePostProcess"]; });
  118160. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  118161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]; });
  118162. /* harmony import */ var _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  118163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__["ChromaticAberrationPostProcess"]; });
  118164. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  118165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__["CircleOfConfusionPostProcess"]; });
  118166. /* harmony import */ var _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./colorCorrectionPostProcess */ "./PostProcesses/colorCorrectionPostProcess.ts");
  118167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__["ColorCorrectionPostProcess"]; });
  118168. /* harmony import */ var _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./convolutionPostProcess */ "./PostProcesses/convolutionPostProcess.ts");
  118169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__["ConvolutionPostProcess"]; });
  118170. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  118171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__["DepthOfFieldBlurPostProcess"]; });
  118172. /* harmony import */ var _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  118173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffectBlurLevel"]; });
  118174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffect"]; });
  118175. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  118176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcessOptions"]; });
  118177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcess"]; });
  118178. /* harmony import */ var _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./displayPassPostProcess */ "./PostProcesses/displayPassPostProcess.ts");
  118179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__["DisplayPassPostProcess"]; });
  118180. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  118181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__["ExtractHighlightsPostProcess"]; });
  118182. /* harmony import */ var _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./filterPostProcess */ "./PostProcesses/filterPostProcess.ts");
  118183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__["FilterPostProcess"]; });
  118184. /* harmony import */ var _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  118185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__["FxaaPostProcess"]; });
  118186. /* harmony import */ var _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  118187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__["GrainPostProcess"]; });
  118188. /* harmony import */ var _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./highlightsPostProcess */ "./PostProcesses/highlightsPostProcess.ts");
  118189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__["HighlightsPostProcess"]; });
  118190. /* harmony import */ var _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  118191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__["ImageProcessingPostProcess"]; });
  118192. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  118193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__["MotionBlurPostProcess"]; });
  118194. /* harmony import */ var _passPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./passPostProcess */ "./PostProcesses/passPostProcess.ts");
  118195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassPostProcess"]; });
  118196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassCubePostProcess"]; });
  118197. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _postProcess__WEBPACK_IMPORTED_MODULE_21__["PostProcess"]; });
  118199. /* harmony import */ var _postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./postProcessManager */ "./PostProcesses/postProcessManager.ts");
  118200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]; });
  118201. /* harmony import */ var _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./refractionPostProcess */ "./PostProcesses/refractionPostProcess.ts");
  118202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__["RefractionPostProcess"]; });
  118203. /* harmony import */ var _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./RenderPipeline/index */ "./PostProcesses/RenderPipeline/index.ts");
  118204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderEffect"]; });
  118205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipeline"]; });
  118206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManager"]; });
  118207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManagerSceneComponent"]; });
  118208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["DefaultRenderingPipeline"]; });
  118209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["LensRenderingPipeline"]; });
  118210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAO2RenderingPipeline"]; });
  118211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAORenderingPipeline"]; });
  118212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["StandardRenderingPipeline"]; });
  118213. /* harmony import */ var _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  118214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__["SharpenPostProcess"]; });
  118215. /* harmony import */ var _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  118216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__["StereoscopicInterlacePostProcess"]; });
  118217. /* harmony import */ var _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./tonemapPostProcess */ "./PostProcesses/tonemapPostProcess.ts");
  118218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemappingOperator"]; });
  118219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemapPostProcess"]; });
  118220. /* harmony import */ var _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./volumetricLightScatteringPostProcess */ "./PostProcesses/volumetricLightScatteringPostProcess.ts");
  118221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__["VolumetricLightScatteringPostProcess"]; });
  118222. /* harmony import */ var _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  118223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  118224. /***/ }),
  118225. /***/ "./PostProcesses/motionBlurPostProcess.ts":
  118226. /*!************************************************!*\
  118227. !*** ./PostProcesses/motionBlurPostProcess.ts ***!
  118228. \************************************************/
  118229. /*! exports provided: MotionBlurPostProcess */
  118230. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118231. "use strict";
  118232. __webpack_require__.r(__webpack_exports__);
  118233. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return MotionBlurPostProcess; });
  118234. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118235. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  118236. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118237. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118238. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118239. /* harmony import */ var _Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  118240. /* harmony import */ var _Shaders_motionBlur_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/motionBlur.fragment */ "./Shaders/motionBlur.fragment.ts");
  118241. /**
  118242. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  118243. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  118244. * As an example, all you have to do is to create the post-process:
  118245. * var mb = new BABYLON.MotionBlurPostProcess(
  118246. * 'mb', // The name of the effect.
  118247. * scene, // The scene containing the objects to blur according to their velocity.
  118248. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  118249. * camera // The camera to apply the render pass to.
  118250. * );
  118251. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  118252. */
  118253. var MotionBlurPostProcess = /** @class */ (function (_super) {
  118254. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotionBlurPostProcess, _super);
  118255. /**
  118256. * Creates a new instance MotionBlurPostProcess
  118257. * @param name The name of the effect.
  118258. * @param scene The scene containing the objects to blur according to their velocity.
  118259. * @param options The required width/height ratio to downsize to before computing the render pass.
  118260. * @param camera The camera to apply the render pass to.
  118261. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118262. * @param engine The engine which the post process will be applied. (default: current engine)
  118263. * @param reusable If the post process can be reused on the same frame. (default: false)
  118264. * @param textureType Type of textures used when performing the post process. (default: 0)
  118265. * @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)
  118266. */
  118267. function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118268. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118269. if (blockCompilation === void 0) { blockCompilation = false; }
  118270. 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;
  118271. /**
  118272. * Defines how much the image is blurred by the movement. Default value is equal to 1
  118273. */
  118274. _this.motionStrength = 1;
  118275. _this._motionBlurSamples = 32;
  118276. _this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  118277. if (!_this._geometryBufferRenderer) {
  118278. // Geometry buffer renderer is not supported. So, work as a passthrough.
  118279. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Multiple Render Target support needed to compute object based motion blur");
  118280. _this.updateEffect();
  118281. }
  118282. else {
  118283. // Geometry buffer renderer is supported.
  118284. _this._geometryBufferRenderer.enableVelocity = true;
  118285. _this.onApply = function (effect) {
  118286. effect.setVector2("screenSize", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](_this.width, _this.height));
  118287. effect.setFloat("motionScale", scene.getAnimationRatio());
  118288. effect.setFloat("motionStrength", _this.motionStrength);
  118289. if (_this._geometryBufferRenderer) {
  118290. var velocityIndex = _this._geometryBufferRenderer.getTextureIndex(_Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRenderer"].VELOCITY_TEXTURE_TYPE);
  118291. effect.setTexture("velocitySampler", _this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
  118292. }
  118293. };
  118294. }
  118295. return _this;
  118296. }
  118297. Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
  118298. /**
  118299. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  118300. */
  118301. get: function () {
  118302. return this._motionBlurSamples;
  118303. },
  118304. /**
  118305. * Sets the number of iterations to be used for motion blur quality
  118306. */
  118307. set: function (samples) {
  118308. this._motionBlurSamples = samples;
  118309. if (this._geometryBufferRenderer) {
  118310. this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES " + samples.toFixed(1));
  118311. }
  118312. },
  118313. enumerable: true,
  118314. configurable: true
  118315. });
  118316. /**
  118317. * Disposes the post process.
  118318. * @param camera The camera to dispose the post process on.
  118319. */
  118320. MotionBlurPostProcess.prototype.dispose = function (camera) {
  118321. if (this._geometryBufferRenderer) {
  118322. // Clear previous transformation matrices dictionary used to compute objects velocities
  118323. this._geometryBufferRenderer._previousTransformationMatrices = {};
  118324. }
  118325. _super.prototype.dispose.call(this, camera);
  118326. };
  118327. return MotionBlurPostProcess;
  118328. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  118329. /***/ }),
  118330. /***/ "./PostProcesses/passPostProcess.ts":
  118331. /*!******************************************!*\
  118332. !*** ./PostProcesses/passPostProcess.ts ***!
  118333. \******************************************/
  118334. /*! exports provided: PassPostProcess, PassCubePostProcess */
  118335. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118336. "use strict";
  118337. __webpack_require__.r(__webpack_exports__);
  118338. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return PassPostProcess; });
  118339. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return PassCubePostProcess; });
  118340. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118341. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118342. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118343. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  118344. /* harmony import */ var _Shaders_pass_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/pass.fragment */ "./Shaders/pass.fragment.ts");
  118345. /* harmony import */ var _Shaders_passCube_fragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/passCube.fragment */ "./Shaders/passCube.fragment.ts");
  118346. /**
  118347. * PassPostProcess which produces an output the same as it's input
  118348. */
  118349. var PassPostProcess = /** @class */ (function (_super) {
  118350. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassPostProcess, _super);
  118351. /**
  118352. * Creates the PassPostProcess
  118353. * @param name The name of the effect.
  118354. * @param options The required width/height ratio to downsize to before computing the render pass.
  118355. * @param camera The camera to apply the render pass to.
  118356. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118357. * @param engine The engine which the post process will be applied. (default: current engine)
  118358. * @param reusable If the post process can be reused on the same frame. (default: false)
  118359. * @param textureType The type of texture to be used when performing the post processing.
  118360. * @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)
  118361. */
  118362. function PassPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118363. if (camera === void 0) { camera = null; }
  118364. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118365. if (blockCompilation === void 0) { blockCompilation = false; }
  118366. return _super.call(this, name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation) || this;
  118367. }
  118368. return PassPostProcess;
  118369. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  118370. /**
  118371. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  118372. */
  118373. var PassCubePostProcess = /** @class */ (function (_super) {
  118374. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassCubePostProcess, _super);
  118375. /**
  118376. * Creates the PassCubePostProcess
  118377. * @param name The name of the effect.
  118378. * @param options The required width/height ratio to downsize to before computing the render pass.
  118379. * @param camera The camera to apply the render pass to.
  118380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118381. * @param engine The engine which the post process will be applied. (default: current engine)
  118382. * @param reusable If the post process can be reused on the same frame. (default: false)
  118383. * @param textureType The type of texture to be used when performing the post processing.
  118384. * @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)
  118385. */
  118386. function PassCubePostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118387. if (camera === void 0) { camera = null; }
  118388. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118389. if (blockCompilation === void 0) { blockCompilation = false; }
  118390. var _this = _super.call(this, name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation) || this;
  118391. _this._face = 0;
  118392. return _this;
  118393. }
  118394. Object.defineProperty(PassCubePostProcess.prototype, "face", {
  118395. /**
  118396. * Gets or sets the cube face to display.
  118397. * * 0 is +X
  118398. * * 1 is -X
  118399. * * 2 is +Y
  118400. * * 3 is -Y
  118401. * * 4 is +Z
  118402. * * 5 is -Z
  118403. */
  118404. get: function () {
  118405. return this._face;
  118406. },
  118407. set: function (value) {
  118408. if (value < 0 || value > 5) {
  118409. return;
  118410. }
  118411. this._face = value;
  118412. switch (this._face) {
  118413. case 0:
  118414. this.updateEffect("#define POSITIVEX");
  118415. break;
  118416. case 1:
  118417. this.updateEffect("#define NEGATIVEX");
  118418. break;
  118419. case 2:
  118420. this.updateEffect("#define POSITIVEY");
  118421. break;
  118422. case 3:
  118423. this.updateEffect("#define NEGATIVEY");
  118424. break;
  118425. case 4:
  118426. this.updateEffect("#define POSITIVEZ");
  118427. break;
  118428. case 5:
  118429. this.updateEffect("#define NEGATIVEZ");
  118430. break;
  118431. }
  118432. },
  118433. enumerable: true,
  118434. configurable: true
  118435. });
  118436. return PassCubePostProcess;
  118437. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  118438. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"]._RescalePostProcessFactory = function (engine) {
  118439. 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);
  118440. };
  118441. /***/ }),
  118442. /***/ "./PostProcesses/postProcess.ts":
  118443. /*!**************************************!*\
  118444. !*** ./PostProcesses/postProcess.ts ***!
  118445. \**************************************/
  118446. /*! exports provided: PostProcess */
  118447. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118448. "use strict";
  118449. __webpack_require__.r(__webpack_exports__);
  118450. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return PostProcess; });
  118451. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  118452. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  118453. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  118454. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118455. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118456. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  118457. /**
  118458. * PostProcess can be used to apply a shader to a texture after it has been rendered
  118459. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118460. */
  118461. var PostProcess = /** @class */ (function () {
  118462. /**
  118463. * Creates a new instance PostProcess
  118464. * @param name The name of the PostProcess.
  118465. * @param fragmentUrl The url of the fragment shader to be used.
  118466. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  118467. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  118468. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  118469. * @param camera The camera to apply the render pass to.
  118470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118471. * @param engine The engine which the post process will be applied. (default: current engine)
  118472. * @param reusable If the post process can be reused on the same frame. (default: false)
  118473. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  118474. * @param textureType Type of textures used when performing the post process. (default: 0)
  118475. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  118476. * @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
  118477. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  118478. */
  118479. function PostProcess(
  118480. /** Name of the PostProcess. */
  118481. name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
  118482. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE; }
  118483. if (defines === void 0) { defines = null; }
  118484. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118485. if (vertexUrl === void 0) { vertexUrl = "postprocess"; }
  118486. if (blockCompilation === void 0) { blockCompilation = false; }
  118487. this.name = name;
  118488. /**
  118489. * Width of the texture to apply the post process on
  118490. */
  118491. this.width = -1;
  118492. /**
  118493. * Height of the texture to apply the post process on
  118494. */
  118495. this.height = -1;
  118496. /**
  118497. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  118498. * @hidden
  118499. */
  118500. this._outputTexture = null;
  118501. /**
  118502. * If the buffer needs to be cleared before applying the post process. (default: true)
  118503. * Should be set to false if shader will overwrite all previous pixels.
  118504. */
  118505. this.autoClear = true;
  118506. /**
  118507. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  118508. */
  118509. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE;
  118510. /**
  118511. * Animations to be used for the post processing
  118512. */
  118513. this.animations = new Array();
  118514. /**
  118515. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  118516. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  118517. */
  118518. this.enablePixelPerfectMode = false;
  118519. /**
  118520. * Force the postprocess to be applied without taking in account viewport
  118521. */
  118522. this.forceFullscreenViewport = true;
  118523. /**
  118524. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  118525. *
  118526. * | Value | Type | Description |
  118527. * | ----- | ----------------------------------- | ----------- |
  118528. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  118529. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  118530. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  118531. *
  118532. */
  118533. this.scaleMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].SCALEMODE_FLOOR;
  118534. /**
  118535. * Force textures to be a power of two (default: false)
  118536. */
  118537. this.alwaysForcePOT = false;
  118538. this._samples = 1;
  118539. /**
  118540. * Modify the scale of the post process to be the same as the viewport (default: false)
  118541. */
  118542. this.adaptScaleToCurrentViewport = false;
  118543. this._reusable = false;
  118544. /**
  118545. * Smart array of input and output textures for the post process.
  118546. * @hidden
  118547. */
  118548. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  118549. /**
  118550. * The index in _textures that corresponds to the output texture.
  118551. * @hidden
  118552. */
  118553. this._currentRenderTextureInd = 0;
  118554. this._scaleRatio = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 1);
  118555. this._texelSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  118556. // Events
  118557. /**
  118558. * An event triggered when the postprocess is activated.
  118559. */
  118560. this.onActivateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118561. /**
  118562. * An event triggered when the postprocess changes its size.
  118563. */
  118564. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118565. /**
  118566. * An event triggered when the postprocess applies its effect.
  118567. */
  118568. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118569. /**
  118570. * An event triggered before rendering the postprocess
  118571. */
  118572. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118573. /**
  118574. * An event triggered after rendering the postprocess
  118575. */
  118576. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  118577. if (camera != null) {
  118578. this._camera = camera;
  118579. this._scene = camera.getScene();
  118580. camera.attachPostProcess(this);
  118581. this._engine = this._scene.getEngine();
  118582. this._scene.postProcesses.push(this);
  118583. this.uniqueId = this._scene.getUniqueId();
  118584. }
  118585. else if (engine) {
  118586. this._engine = engine;
  118587. this._engine.postProcesses.push(this);
  118588. }
  118589. this._options = options;
  118590. this.renderTargetSamplingMode = samplingMode ? samplingMode : _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  118591. this._reusable = reusable || false;
  118592. this._textureType = textureType;
  118593. this._samplers = samplers || [];
  118594. this._samplers.push("textureSampler");
  118595. this._fragmentUrl = fragmentUrl;
  118596. this._vertexUrl = vertexUrl;
  118597. this._parameters = parameters || [];
  118598. this._parameters.push("scale");
  118599. this._indexParameters = indexParameters;
  118600. if (!blockCompilation) {
  118601. this.updateEffect(defines);
  118602. }
  118603. }
  118604. Object.defineProperty(PostProcess.prototype, "samples", {
  118605. /**
  118606. * Number of sample textures (default: 1)
  118607. */
  118608. get: function () {
  118609. return this._samples;
  118610. },
  118611. set: function (n) {
  118612. var _this = this;
  118613. this._samples = n;
  118614. this._textures.forEach(function (texture) {
  118615. if (texture.samples !== _this._samples) {
  118616. _this._engine.updateRenderTargetTextureSampleCount(texture, _this._samples);
  118617. }
  118618. });
  118619. },
  118620. enumerable: true,
  118621. configurable: true
  118622. });
  118623. /**
  118624. * Returns the fragment url or shader name used in the post process.
  118625. * @returns the fragment url or name in the shader store.
  118626. */
  118627. PostProcess.prototype.getEffectName = function () {
  118628. return this._fragmentUrl;
  118629. };
  118630. Object.defineProperty(PostProcess.prototype, "onActivate", {
  118631. /**
  118632. * A function that is added to the onActivateObservable
  118633. */
  118634. set: function (callback) {
  118635. if (this._onActivateObserver) {
  118636. this.onActivateObservable.remove(this._onActivateObserver);
  118637. }
  118638. if (callback) {
  118639. this._onActivateObserver = this.onActivateObservable.add(callback);
  118640. }
  118641. },
  118642. enumerable: true,
  118643. configurable: true
  118644. });
  118645. Object.defineProperty(PostProcess.prototype, "onSizeChanged", {
  118646. /**
  118647. * A function that is added to the onSizeChangedObservable
  118648. */
  118649. set: function (callback) {
  118650. if (this._onSizeChangedObserver) {
  118651. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  118652. }
  118653. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  118654. },
  118655. enumerable: true,
  118656. configurable: true
  118657. });
  118658. Object.defineProperty(PostProcess.prototype, "onApply", {
  118659. /**
  118660. * A function that is added to the onApplyObservable
  118661. */
  118662. set: function (callback) {
  118663. if (this._onApplyObserver) {
  118664. this.onApplyObservable.remove(this._onApplyObserver);
  118665. }
  118666. this._onApplyObserver = this.onApplyObservable.add(callback);
  118667. },
  118668. enumerable: true,
  118669. configurable: true
  118670. });
  118671. Object.defineProperty(PostProcess.prototype, "onBeforeRender", {
  118672. /**
  118673. * A function that is added to the onBeforeRenderObservable
  118674. */
  118675. set: function (callback) {
  118676. if (this._onBeforeRenderObserver) {
  118677. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  118678. }
  118679. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  118680. },
  118681. enumerable: true,
  118682. configurable: true
  118683. });
  118684. Object.defineProperty(PostProcess.prototype, "onAfterRender", {
  118685. /**
  118686. * A function that is added to the onAfterRenderObservable
  118687. */
  118688. set: function (callback) {
  118689. if (this._onAfterRenderObserver) {
  118690. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  118691. }
  118692. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  118693. },
  118694. enumerable: true,
  118695. configurable: true
  118696. });
  118697. Object.defineProperty(PostProcess.prototype, "inputTexture", {
  118698. /**
  118699. * 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
  118700. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  118701. */
  118702. get: function () {
  118703. return this._textures.data[this._currentRenderTextureInd];
  118704. },
  118705. set: function (value) {
  118706. this._forcedOutputTexture = value;
  118707. },
  118708. enumerable: true,
  118709. configurable: true
  118710. });
  118711. /**
  118712. * Gets the camera which post process is applied to.
  118713. * @returns The camera the post process is applied to.
  118714. */
  118715. PostProcess.prototype.getCamera = function () {
  118716. return this._camera;
  118717. };
  118718. Object.defineProperty(PostProcess.prototype, "texelSize", {
  118719. /**
  118720. * Gets the texel size of the postprocess.
  118721. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  118722. */
  118723. get: function () {
  118724. if (this._shareOutputWithPostProcess) {
  118725. return this._shareOutputWithPostProcess.texelSize;
  118726. }
  118727. if (this._forcedOutputTexture) {
  118728. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  118729. }
  118730. return this._texelSize;
  118731. },
  118732. enumerable: true,
  118733. configurable: true
  118734. });
  118735. /**
  118736. * Gets a string idenfifying the name of the class
  118737. * @returns "PostProcess" string
  118738. */
  118739. PostProcess.prototype.getClassName = function () {
  118740. return "PostProcess";
  118741. };
  118742. /**
  118743. * Gets the engine which this post process belongs to.
  118744. * @returns The engine the post process was enabled with.
  118745. */
  118746. PostProcess.prototype.getEngine = function () {
  118747. return this._engine;
  118748. };
  118749. /**
  118750. * The effect that is created when initializing the post process.
  118751. * @returns The created effect corrisponding the the postprocess.
  118752. */
  118753. PostProcess.prototype.getEffect = function () {
  118754. return this._effect;
  118755. };
  118756. /**
  118757. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  118758. * @param postProcess The post process to share the output with.
  118759. * @returns This post process.
  118760. */
  118761. PostProcess.prototype.shareOutputWith = function (postProcess) {
  118762. this._disposeTextures();
  118763. this._shareOutputWithPostProcess = postProcess;
  118764. return this;
  118765. };
  118766. /**
  118767. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  118768. * This should be called if the post process that shares output with this post process is disabled/disposed.
  118769. */
  118770. PostProcess.prototype.useOwnOutput = function () {
  118771. if (this._textures.length == 0) {
  118772. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  118773. }
  118774. this._shareOutputWithPostProcess = null;
  118775. };
  118776. /**
  118777. * Updates the effect with the current post process compile time values and recompiles the shader.
  118778. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  118779. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  118780. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  118781. * @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
  118782. * @param onCompiled Called when the shader has been compiled.
  118783. * @param onError Called if there is an error when compiling a shader.
  118784. */
  118785. PostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  118786. if (defines === void 0) { defines = null; }
  118787. if (uniforms === void 0) { uniforms = null; }
  118788. if (samplers === void 0) { samplers = null; }
  118789. 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);
  118790. };
  118791. /**
  118792. * The post process is reusable if it can be used multiple times within one frame.
  118793. * @returns If the post process is reusable
  118794. */
  118795. PostProcess.prototype.isReusable = function () {
  118796. return this._reusable;
  118797. };
  118798. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  118799. PostProcess.prototype.markTextureDirty = function () {
  118800. this.width = -1;
  118801. };
  118802. /**
  118803. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  118804. * 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.
  118805. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  118806. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  118807. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  118808. * @returns The target texture that was bound to be written to.
  118809. */
  118810. PostProcess.prototype.activate = function (camera, sourceTexture, forceDepthStencil) {
  118811. var _this = this;
  118812. if (sourceTexture === void 0) { sourceTexture = null; }
  118813. camera = camera || this._camera;
  118814. var scene = camera.getScene();
  118815. var engine = scene.getEngine();
  118816. var maxSize = engine.getCaps().maxTextureSize;
  118817. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
  118818. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
  118819. // 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
  118820. var webVRCamera = camera.parent;
  118821. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  118822. requiredWidth /= 2;
  118823. }
  118824. var desiredWidth = (this._options.width || requiredWidth);
  118825. var desiredHeight = this._options.height || requiredHeight;
  118826. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  118827. if (this.adaptScaleToCurrentViewport) {
  118828. var currentViewport = engine.currentViewport;
  118829. if (currentViewport) {
  118830. desiredWidth *= currentViewport.width;
  118831. desiredHeight *= currentViewport.height;
  118832. }
  118833. }
  118834. if (this.renderTargetSamplingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  118835. if (!this._options.width) {
  118836. desiredWidth = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  118837. }
  118838. if (!this._options.height) {
  118839. desiredHeight = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  118840. }
  118841. }
  118842. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  118843. if (this._textures.length > 0) {
  118844. for (var i = 0; i < this._textures.length; i++) {
  118845. this._engine._releaseTexture(this._textures.data[i]);
  118846. }
  118847. this._textures.reset();
  118848. }
  118849. this.width = desiredWidth;
  118850. this.height = desiredHeight;
  118851. var textureSize = { width: this.width, height: this.height };
  118852. var textureOptions = {
  118853. generateMipMaps: false,
  118854. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  118855. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  118856. samplingMode: this.renderTargetSamplingMode,
  118857. type: this._textureType
  118858. };
  118859. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  118860. if (this._reusable) {
  118861. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  118862. }
  118863. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  118864. this.onSizeChangedObservable.notifyObservers(this);
  118865. }
  118866. this._textures.forEach(function (texture) {
  118867. if (texture.samples !== _this.samples) {
  118868. _this._engine.updateRenderTargetTextureSampleCount(texture, _this.samples);
  118869. }
  118870. });
  118871. }
  118872. var target;
  118873. if (this._shareOutputWithPostProcess) {
  118874. target = this._shareOutputWithPostProcess.inputTexture;
  118875. }
  118876. else if (this._forcedOutputTexture) {
  118877. target = this._forcedOutputTexture;
  118878. this.width = this._forcedOutputTexture.width;
  118879. this.height = this._forcedOutputTexture.height;
  118880. }
  118881. else {
  118882. target = this.inputTexture;
  118883. }
  118884. // Bind the input of this post process to be used as the output of the previous post process.
  118885. if (this.enablePixelPerfectMode) {
  118886. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  118887. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  118888. }
  118889. else {
  118890. this._scaleRatio.copyFromFloats(1, 1);
  118891. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  118892. }
  118893. this.onActivateObservable.notifyObservers(camera);
  118894. // Clear
  118895. if (this.autoClear && this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE) {
  118896. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  118897. }
  118898. if (this._reusable) {
  118899. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  118900. }
  118901. return target;
  118902. };
  118903. Object.defineProperty(PostProcess.prototype, "isSupported", {
  118904. /**
  118905. * If the post process is supported.
  118906. */
  118907. get: function () {
  118908. return this._effect.isSupported;
  118909. },
  118910. enumerable: true,
  118911. configurable: true
  118912. });
  118913. Object.defineProperty(PostProcess.prototype, "aspectRatio", {
  118914. /**
  118915. * The aspect ratio of the output texture.
  118916. */
  118917. get: function () {
  118918. if (this._shareOutputWithPostProcess) {
  118919. return this._shareOutputWithPostProcess.aspectRatio;
  118920. }
  118921. if (this._forcedOutputTexture) {
  118922. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  118923. }
  118924. return this.width / this.height;
  118925. },
  118926. enumerable: true,
  118927. configurable: true
  118928. });
  118929. /**
  118930. * Get a value indicating if the post-process is ready to be used
  118931. * @returns true if the post-process is ready (shader is compiled)
  118932. */
  118933. PostProcess.prototype.isReady = function () {
  118934. return this._effect && this._effect.isReady();
  118935. };
  118936. /**
  118937. * Binds all textures and uniforms to the shader, this will be run on every pass.
  118938. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  118939. */
  118940. PostProcess.prototype.apply = function () {
  118941. // Check
  118942. if (!this._effect || !this._effect.isReady()) {
  118943. return null;
  118944. }
  118945. // States
  118946. this._engine.enableEffect(this._effect);
  118947. this._engine.setState(false);
  118948. this._engine.setDepthBuffer(false);
  118949. this._engine.setDepthWrite(false);
  118950. // Alpha
  118951. this._engine.setAlphaMode(this.alphaMode);
  118952. if (this.alphaConstants) {
  118953. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  118954. }
  118955. // Bind the output texture of the preivous post process as the input to this post process.
  118956. var source;
  118957. if (this._shareOutputWithPostProcess) {
  118958. source = this._shareOutputWithPostProcess.inputTexture;
  118959. }
  118960. else if (this._forcedOutputTexture) {
  118961. source = this._forcedOutputTexture;
  118962. }
  118963. else {
  118964. source = this.inputTexture;
  118965. }
  118966. this._effect._bindTexture("textureSampler", source);
  118967. // Parameters
  118968. this._effect.setVector2("scale", this._scaleRatio);
  118969. this.onApplyObservable.notifyObservers(this._effect);
  118970. return this._effect;
  118971. };
  118972. PostProcess.prototype._disposeTextures = function () {
  118973. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  118974. return;
  118975. }
  118976. if (this._textures.length > 0) {
  118977. for (var i = 0; i < this._textures.length; i++) {
  118978. this._engine._releaseTexture(this._textures.data[i]);
  118979. }
  118980. }
  118981. this._textures.dispose();
  118982. };
  118983. /**
  118984. * Disposes the post process.
  118985. * @param camera The camera to dispose the post process on.
  118986. */
  118987. PostProcess.prototype.dispose = function (camera) {
  118988. camera = camera || this._camera;
  118989. this._disposeTextures();
  118990. if (this._scene) {
  118991. var index_1 = this._scene.postProcesses.indexOf(this);
  118992. if (index_1 !== -1) {
  118993. this._scene.postProcesses.splice(index_1, 1);
  118994. }
  118995. }
  118996. else {
  118997. var index_2 = this._engine.postProcesses.indexOf(this);
  118998. if (index_2 !== -1) {
  118999. this._engine.postProcesses.splice(index_2, 1);
  119000. }
  119001. }
  119002. if (!camera) {
  119003. return;
  119004. }
  119005. camera.detachPostProcess(this);
  119006. var index = camera._postProcesses.indexOf(this);
  119007. if (index === 0 && camera._postProcesses.length > 0) {
  119008. var firstPostProcess = this._camera._getFirstPostProcess();
  119009. if (firstPostProcess) {
  119010. firstPostProcess.markTextureDirty();
  119011. }
  119012. }
  119013. this.onActivateObservable.clear();
  119014. this.onAfterRenderObservable.clear();
  119015. this.onApplyObservable.clear();
  119016. this.onBeforeRenderObservable.clear();
  119017. this.onSizeChangedObservable.clear();
  119018. };
  119019. return PostProcess;
  119020. }());
  119021. /***/ }),
  119022. /***/ "./PostProcesses/postProcessManager.ts":
  119023. /*!*********************************************!*\
  119024. !*** ./PostProcesses/postProcessManager.ts ***!
  119025. \*********************************************/
  119026. /*! exports provided: PostProcessManager */
  119027. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119028. "use strict";
  119029. __webpack_require__.r(__webpack_exports__);
  119030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return PostProcessManager; });
  119031. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  119032. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  119033. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119034. /**
  119035. * PostProcessManager is used to manage one or more post processes or post process pipelines
  119036. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  119037. */
  119038. var PostProcessManager = /** @class */ (function () {
  119039. /**
  119040. * Creates a new instance PostProcess
  119041. * @param scene The scene that the post process is associated with.
  119042. */
  119043. function PostProcessManager(scene) {
  119044. this._vertexBuffers = {};
  119045. this._scene = scene;
  119046. }
  119047. PostProcessManager.prototype._prepareBuffers = function () {
  119048. if (this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind]) {
  119049. return;
  119050. }
  119051. // VBO
  119052. var vertices = [];
  119053. vertices.push(1, 1);
  119054. vertices.push(-1, 1);
  119055. vertices.push(-1, -1);
  119056. vertices.push(1, -1);
  119057. 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);
  119058. this._buildIndexBuffer();
  119059. };
  119060. PostProcessManager.prototype._buildIndexBuffer = function () {
  119061. // Indices
  119062. var indices = [];
  119063. indices.push(0);
  119064. indices.push(1);
  119065. indices.push(2);
  119066. indices.push(0);
  119067. indices.push(2);
  119068. indices.push(3);
  119069. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  119070. };
  119071. /**
  119072. * Rebuilds the vertex buffers of the manager.
  119073. * @hidden
  119074. */
  119075. PostProcessManager.prototype._rebuild = function () {
  119076. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119077. if (!vb) {
  119078. return;
  119079. }
  119080. vb._rebuild();
  119081. this._buildIndexBuffer();
  119082. };
  119083. // Methods
  119084. /**
  119085. * Prepares a frame to be run through a post process.
  119086. * @param sourceTexture The input texture to the post procesess. (default: null)
  119087. * @param postProcesses An array of post processes to be run. (default: null)
  119088. * @returns True if the post processes were able to be run.
  119089. * @hidden
  119090. */
  119091. PostProcessManager.prototype._prepareFrame = function (sourceTexture, postProcesses) {
  119092. if (sourceTexture === void 0) { sourceTexture = null; }
  119093. if (postProcesses === void 0) { postProcesses = null; }
  119094. var camera = this._scene.activeCamera;
  119095. if (!camera) {
  119096. return false;
  119097. }
  119098. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  119099. if (!postProcesses || postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  119100. return false;
  119101. }
  119102. postProcesses[0].activate(camera, sourceTexture, postProcesses !== null && postProcesses !== undefined);
  119103. return true;
  119104. };
  119105. /**
  119106. * Manually render a set of post processes to a texture.
  119107. * @param postProcesses An array of post processes to be run.
  119108. * @param targetTexture The target texture to render to.
  119109. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  119110. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  119111. * @param lodLevel defines which lod of the texture to render to
  119112. */
  119113. PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport, faceIndex, lodLevel) {
  119114. if (targetTexture === void 0) { targetTexture = null; }
  119115. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  119116. if (faceIndex === void 0) { faceIndex = 0; }
  119117. if (lodLevel === void 0) { lodLevel = 0; }
  119118. var engine = this._scene.getEngine();
  119119. for (var index = 0; index < postProcesses.length; index++) {
  119120. if (index < postProcesses.length - 1) {
  119121. postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture);
  119122. }
  119123. else {
  119124. if (targetTexture) {
  119125. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport, undefined, lodLevel);
  119126. }
  119127. else {
  119128. engine.restoreDefaultFramebuffer();
  119129. }
  119130. }
  119131. var pp = postProcesses[index];
  119132. var effect = pp.apply();
  119133. if (effect) {
  119134. pp.onBeforeRenderObservable.notifyObservers(effect);
  119135. // VBOs
  119136. this._prepareBuffers();
  119137. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  119138. // Draw order
  119139. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  119140. pp.onAfterRenderObservable.notifyObservers(effect);
  119141. }
  119142. }
  119143. // Restore depth buffer
  119144. engine.setDepthBuffer(true);
  119145. engine.setDepthWrite(true);
  119146. };
  119147. /**
  119148. * Finalize the result of the output of the postprocesses.
  119149. * @param doNotPresent If true the result will not be displayed to the screen.
  119150. * @param targetTexture The target texture to render to.
  119151. * @param faceIndex The index of the face to bind the target texture to.
  119152. * @param postProcesses The array of post processes to render.
  119153. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  119154. * @hidden
  119155. */
  119156. PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, faceIndex, postProcesses, forceFullscreenViewport) {
  119157. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  119158. var camera = this._scene.activeCamera;
  119159. if (!camera) {
  119160. return;
  119161. }
  119162. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  119163. if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  119164. return;
  119165. }
  119166. var engine = this._scene.getEngine();
  119167. for (var index = 0, len = postProcesses.length; index < len; index++) {
  119168. var pp = postProcesses[index];
  119169. if (index < len - 1) {
  119170. pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
  119171. }
  119172. else {
  119173. if (targetTexture) {
  119174. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport);
  119175. pp._outputTexture = targetTexture;
  119176. }
  119177. else {
  119178. engine.restoreDefaultFramebuffer();
  119179. pp._outputTexture = null;
  119180. }
  119181. }
  119182. if (doNotPresent) {
  119183. break;
  119184. }
  119185. var effect = pp.apply();
  119186. if (effect) {
  119187. pp.onBeforeRenderObservable.notifyObservers(effect);
  119188. // VBOs
  119189. this._prepareBuffers();
  119190. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  119191. // Draw order
  119192. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  119193. pp.onAfterRenderObservable.notifyObservers(effect);
  119194. }
  119195. }
  119196. // Restore states
  119197. engine.setDepthBuffer(true);
  119198. engine.setDepthWrite(true);
  119199. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  119200. };
  119201. /**
  119202. * Disposes of the post process manager.
  119203. */
  119204. PostProcessManager.prototype.dispose = function () {
  119205. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119206. if (buffer) {
  119207. buffer.dispose();
  119208. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  119209. }
  119210. if (this._indexBuffer) {
  119211. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  119212. this._indexBuffer = null;
  119213. }
  119214. };
  119215. return PostProcessManager;
  119216. }());
  119217. /***/ }),
  119218. /***/ "./PostProcesses/refractionPostProcess.ts":
  119219. /*!************************************************!*\
  119220. !*** ./PostProcesses/refractionPostProcess.ts ***!
  119221. \************************************************/
  119222. /*! exports provided: RefractionPostProcess */
  119223. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119224. "use strict";
  119225. __webpack_require__.r(__webpack_exports__);
  119226. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return RefractionPostProcess; });
  119227. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119228. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119229. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119230. /* harmony import */ var _Shaders_refraction_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/refraction.fragment */ "./Shaders/refraction.fragment.ts");
  119231. /**
  119232. * Post process which applies a refractin texture
  119233. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  119234. */
  119235. var RefractionPostProcess = /** @class */ (function (_super) {
  119236. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionPostProcess, _super);
  119237. /**
  119238. * Initializes the RefractionPostProcess
  119239. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  119240. * @param name The name of the effect.
  119241. * @param refractionTextureUrl Url of the refraction texture to use
  119242. * @param color the base color of the refraction (used to taint the rendering)
  119243. * @param depth simulated refraction depth
  119244. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  119245. * @param camera The camera to apply the render pass to.
  119246. * @param options The required width/height ratio to downsize to before computing the render pass.
  119247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119248. * @param engine The engine which the post process will be applied. (default: current engine)
  119249. * @param reusable If the post process can be reused on the same frame. (default: false)
  119250. */
  119251. function RefractionPostProcess(name, refractionTextureUrl,
  119252. /** the base color of the refraction (used to taint the rendering) */
  119253. color,
  119254. /** simulated refraction depth */
  119255. depth,
  119256. /** the coefficient of the base color (0 to remove base color tainting) */
  119257. colorLevel, options, camera, samplingMode, engine, reusable) {
  119258. var _this = _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable) || this;
  119259. _this.color = color;
  119260. _this.depth = depth;
  119261. _this.colorLevel = colorLevel;
  119262. _this._ownRefractionTexture = true;
  119263. _this.onActivateObservable.add(function (cam) {
  119264. _this._refTexture = _this._refTexture || new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](refractionTextureUrl, cam.getScene());
  119265. });
  119266. _this.onApplyObservable.add(function (effect) {
  119267. effect.setColor3("baseColor", _this.color);
  119268. effect.setFloat("depth", _this.depth);
  119269. effect.setFloat("colorLevel", _this.colorLevel);
  119270. effect.setTexture("refractionSampler", _this._refTexture);
  119271. });
  119272. return _this;
  119273. }
  119274. Object.defineProperty(RefractionPostProcess.prototype, "refractionTexture", {
  119275. /**
  119276. * Gets or sets the refraction texture
  119277. * Please note that you are responsible for disposing the texture if you set it manually
  119278. */
  119279. get: function () {
  119280. return this._refTexture;
  119281. },
  119282. set: function (value) {
  119283. if (this._refTexture && this._ownRefractionTexture) {
  119284. this._refTexture.dispose();
  119285. }
  119286. this._refTexture = value;
  119287. this._ownRefractionTexture = false;
  119288. },
  119289. enumerable: true,
  119290. configurable: true
  119291. });
  119292. // Methods
  119293. /**
  119294. * Disposes of the post process
  119295. * @param camera Camera to dispose post process on
  119296. */
  119297. RefractionPostProcess.prototype.dispose = function (camera) {
  119298. if (this._refTexture && this._ownRefractionTexture) {
  119299. this._refTexture.dispose();
  119300. this._refTexture = null;
  119301. }
  119302. _super.prototype.dispose.call(this, camera);
  119303. };
  119304. return RefractionPostProcess;
  119305. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  119306. /***/ }),
  119307. /***/ "./PostProcesses/sharpenPostProcess.ts":
  119308. /*!*********************************************!*\
  119309. !*** ./PostProcesses/sharpenPostProcess.ts ***!
  119310. \*********************************************/
  119311. /*! exports provided: SharpenPostProcess */
  119312. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119313. "use strict";
  119314. __webpack_require__.r(__webpack_exports__);
  119315. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return SharpenPostProcess; });
  119316. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119317. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119318. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119319. /* harmony import */ var _Shaders_sharpen_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/sharpen.fragment */ "./Shaders/sharpen.fragment.ts");
  119320. /**
  119321. * The SharpenPostProcess applies a sharpen kernel to every pixel
  119322. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  119323. */
  119324. var SharpenPostProcess = /** @class */ (function (_super) {
  119325. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SharpenPostProcess, _super);
  119326. /**
  119327. * Creates a new instance ConvolutionPostProcess
  119328. * @param name The name of the effect.
  119329. * @param options The required width/height ratio to downsize to before computing the render pass.
  119330. * @param camera The camera to apply the render pass to.
  119331. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119332. * @param engine The engine which the post process will be applied. (default: current engine)
  119333. * @param reusable If the post process can be reused on the same frame. (default: false)
  119334. * @param textureType Type of textures used when performing the post process. (default: 0)
  119335. * @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)
  119336. */
  119337. function SharpenPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  119338. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119339. if (blockCompilation === void 0) { blockCompilation = false; }
  119340. var _this = _super.call(this, name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  119341. /**
  119342. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  119343. */
  119344. _this.colorAmount = 1.0;
  119345. /**
  119346. * How much sharpness should be applied (default: 0.3)
  119347. */
  119348. _this.edgeAmount = 0.3;
  119349. _this.onApply = function (effect) {
  119350. effect.setFloat2("screenSize", _this.width, _this.height);
  119351. effect.setFloat2("sharpnessAmounts", _this.edgeAmount, _this.colorAmount);
  119352. };
  119353. return _this;
  119354. }
  119355. return SharpenPostProcess;
  119356. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119357. /***/ }),
  119358. /***/ "./PostProcesses/stereoscopicInterlacePostProcess.ts":
  119359. /*!***********************************************************!*\
  119360. !*** ./PostProcesses/stereoscopicInterlacePostProcess.ts ***!
  119361. \***********************************************************/
  119362. /*! exports provided: StereoscopicInterlacePostProcess */
  119363. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119364. "use strict";
  119365. __webpack_require__.r(__webpack_exports__);
  119366. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return StereoscopicInterlacePostProcess; });
  119367. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119368. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119369. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119370. /* harmony import */ var _Shaders_stereoscopicInterlace_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/stereoscopicInterlace.fragment */ "./Shaders/stereoscopicInterlace.fragment.ts");
  119371. /**
  119372. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  119373. */
  119374. var StereoscopicInterlacePostProcess = /** @class */ (function (_super) {
  119375. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicInterlacePostProcess, _super);
  119376. /**
  119377. * Initializes a StereoscopicInterlacePostProcess
  119378. * @param name The name of the effect.
  119379. * @param rigCameras The rig cameras to be appled to the post process
  119380. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  119381. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119382. * @param engine The engine which the post process will be applied. (default: current engine)
  119383. * @param reusable If the post process can be reused on the same frame. (default: false)
  119384. */
  119385. function StereoscopicInterlacePostProcess(name, rigCameras, isStereoscopicHoriz, samplingMode, engine, reusable) {
  119386. var _this = _super.call(this, name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined) || this;
  119387. _this._passedProcess = rigCameras[0]._rigPostProcess;
  119388. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  119389. _this.onSizeChangedObservable.add(function () {
  119390. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  119391. });
  119392. _this.onApplyObservable.add(function (effect) {
  119393. effect.setTextureFromPostProcess("camASampler", _this._passedProcess);
  119394. effect.setFloat2("stepSize", _this._stepSize.x, _this._stepSize.y);
  119395. });
  119396. return _this;
  119397. }
  119398. return StereoscopicInterlacePostProcess;
  119399. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  119400. /***/ }),
  119401. /***/ "./PostProcesses/tonemapPostProcess.ts":
  119402. /*!*********************************************!*\
  119403. !*** ./PostProcesses/tonemapPostProcess.ts ***!
  119404. \*********************************************/
  119405. /*! exports provided: TonemappingOperator, TonemapPostProcess */
  119406. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119407. "use strict";
  119408. __webpack_require__.r(__webpack_exports__);
  119409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return TonemappingOperator; });
  119410. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return TonemapPostProcess; });
  119411. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119412. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119413. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119414. /* harmony import */ var _Shaders_tonemap_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/tonemap.fragment */ "./Shaders/tonemap.fragment.ts");
  119415. /** Defines operator used for tonemapping */
  119416. var TonemappingOperator;
  119417. (function (TonemappingOperator) {
  119418. /** Hable */
  119419. TonemappingOperator[TonemappingOperator["Hable"] = 0] = "Hable";
  119420. /** Reinhard */
  119421. TonemappingOperator[TonemappingOperator["Reinhard"] = 1] = "Reinhard";
  119422. /** HejiDawson */
  119423. TonemappingOperator[TonemappingOperator["HejiDawson"] = 2] = "HejiDawson";
  119424. /** Photographic */
  119425. TonemappingOperator[TonemappingOperator["Photographic"] = 3] = "Photographic";
  119426. })(TonemappingOperator || (TonemappingOperator = {}));
  119427. /**
  119428. * Defines a post process to apply tone mapping
  119429. */
  119430. var TonemapPostProcess = /** @class */ (function (_super) {
  119431. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TonemapPostProcess, _super);
  119432. /**
  119433. * Creates a new TonemapPostProcess
  119434. * @param name defines the name of the postprocess
  119435. * @param _operator defines the operator to use
  119436. * @param exposureAdjustment defines the required exposure adjustement
  119437. * @param camera defines the camera to use (can be null)
  119438. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  119439. * @param engine defines the hosting engine (can be ignore if camera is set)
  119440. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119441. */
  119442. function TonemapPostProcess(name, _operator,
  119443. /** Defines the required exposure adjustement */
  119444. exposureAdjustment, camera, samplingMode, engine, textureFormat) {
  119445. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE; }
  119446. if (textureFormat === void 0) { textureFormat = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119447. var _this = _super.call(this, name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, null, textureFormat) || this;
  119448. _this._operator = _operator;
  119449. _this.exposureAdjustment = exposureAdjustment;
  119450. var defines = "#define ";
  119451. if (_this._operator === TonemappingOperator.Hable) {
  119452. defines += "HABLE_TONEMAPPING";
  119453. }
  119454. else if (_this._operator === TonemappingOperator.Reinhard) {
  119455. defines += "REINHARD_TONEMAPPING";
  119456. }
  119457. else if (_this._operator === TonemappingOperator.HejiDawson) {
  119458. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  119459. }
  119460. else if (_this._operator === TonemappingOperator.Photographic) {
  119461. defines += "PHOTOGRAPHIC_TONEMAPPING";
  119462. }
  119463. //sadly a second call to create the effect.
  119464. _this.updateEffect(defines);
  119465. _this.onApply = function (effect) {
  119466. effect.setFloat("_ExposureAdjustment", _this.exposureAdjustment);
  119467. };
  119468. return _this;
  119469. }
  119470. return TonemapPostProcess;
  119471. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  119472. /***/ }),
  119473. /***/ "./PostProcesses/volumetricLightScatteringPostProcess.ts":
  119474. /*!***************************************************************!*\
  119475. !*** ./PostProcesses/volumetricLightScatteringPostProcess.ts ***!
  119476. \***************************************************************/
  119477. /*! exports provided: VolumetricLightScatteringPostProcess */
  119478. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119479. "use strict";
  119480. __webpack_require__.r(__webpack_exports__);
  119481. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return VolumetricLightScatteringPostProcess; });
  119482. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119483. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  119484. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  119485. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119486. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  119487. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  119488. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  119489. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  119490. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  119491. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119492. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  119493. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119494. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119495. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  119496. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  119497. /* harmony import */ var _Shaders_volumetricLightScattering_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/volumetricLightScattering.fragment */ "./Shaders/volumetricLightScattering.fragment.ts");
  119498. /* harmony import */ var _Shaders_volumetricLightScatteringPass_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Shaders/volumetricLightScatteringPass.fragment */ "./Shaders/volumetricLightScatteringPass.fragment.ts");
  119499. /**
  119500. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  119501. */
  119502. var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
  119503. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumetricLightScatteringPostProcess, _super);
  119504. /**
  119505. * @constructor
  119506. * @param name The post-process name
  119507. * @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)
  119508. * @param camera The camera that the post-process will be attached to
  119509. * @param mesh The mesh used to create the light scattering
  119510. * @param samples The post-process quality, default 100
  119511. * @param samplingModeThe post-process filtering mode
  119512. * @param engine The babylon engine
  119513. * @param reusable If the post-process is reusable
  119514. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  119515. */
  119516. function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samples, samplingMode, engine, reusable, scene) {
  119517. if (samples === void 0) { samples = 100; }
  119518. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].BILINEAR_SAMPLINGMODE; }
  119519. 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;
  119520. _this._screenCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  119521. /**
  119522. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  119523. */
  119524. _this.customMeshPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  119525. /**
  119526. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  119527. */
  119528. _this.useCustomMeshPosition = false;
  119529. /**
  119530. * If the post-process should inverse the light scattering direction
  119531. */
  119532. _this.invert = true;
  119533. /**
  119534. * Array containing the excluded meshes not rendered in the internal pass
  119535. */
  119536. _this.excludedMeshes = new Array();
  119537. /**
  119538. * Controls the overall intensity of the post-process
  119539. */
  119540. _this.exposure = 0.3;
  119541. /**
  119542. * Dissipates each sample's contribution in range [0, 1]
  119543. */
  119544. _this.decay = 0.96815;
  119545. /**
  119546. * Controls the overall intensity of each sample
  119547. */
  119548. _this.weight = 0.58767;
  119549. /**
  119550. * Controls the density of each sample
  119551. */
  119552. _this.density = 0.926;
  119553. scene = ((camera === null) ? scene : camera.getScene()); // parameter "scene" can be null.
  119554. engine = scene.getEngine();
  119555. _this._viewPort = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Viewport"](0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  119556. // Configure mesh
  119557. _this.mesh = ((mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));
  119558. // Configure
  119559. _this._createPass(scene, ratio.passRatio || ratio);
  119560. _this.onActivate = function (camera) {
  119561. if (!_this.isSupported) {
  119562. _this.dispose(camera);
  119563. }
  119564. _this.onActivate = null;
  119565. };
  119566. _this.onApplyObservable.add(function (effect) {
  119567. _this._updateMeshScreenCoordinates(scene);
  119568. effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);
  119569. effect.setFloat("exposure", _this.exposure);
  119570. effect.setFloat("decay", _this.decay);
  119571. effect.setFloat("weight", _this.weight);
  119572. effect.setFloat("density", _this.density);
  119573. effect.setVector2("meshPositionOnScreen", _this._screenCoordinates);
  119574. });
  119575. return _this;
  119576. }
  119577. Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
  119578. /**
  119579. * @hidden
  119580. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  119581. */
  119582. get: function () {
  119583. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  119584. return false;
  119585. },
  119586. set: function (useDiffuseColor) {
  119587. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  119588. },
  119589. enumerable: true,
  119590. configurable: true
  119591. });
  119592. /**
  119593. * Returns the string "VolumetricLightScatteringPostProcess"
  119594. * @returns "VolumetricLightScatteringPostProcess"
  119595. */
  119596. VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
  119597. return "VolumetricLightScatteringPostProcess";
  119598. };
  119599. VolumetricLightScatteringPostProcess.prototype._isReady = function (subMesh, useInstances) {
  119600. var mesh = subMesh.getMesh();
  119601. // Render this.mesh as default
  119602. if (mesh === this.mesh && mesh.material) {
  119603. return mesh.material.isReady(mesh);
  119604. }
  119605. var defines = [];
  119606. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  119607. var material = subMesh.getMaterial();
  119608. // Alpha test
  119609. if (material) {
  119610. if (material.needAlphaTesting()) {
  119611. defines.push("#define ALPHATEST");
  119612. }
  119613. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind)) {
  119614. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  119615. defines.push("#define UV1");
  119616. }
  119617. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind)) {
  119618. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  119619. defines.push("#define UV2");
  119620. }
  119621. }
  119622. // Bones
  119623. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  119624. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  119625. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  119626. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  119627. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  119628. }
  119629. else {
  119630. defines.push("#define NUM_BONE_INFLUENCERS 0");
  119631. }
  119632. // Instances
  119633. if (useInstances) {
  119634. defines.push("#define INSTANCES");
  119635. attribs.push("world0");
  119636. attribs.push("world1");
  119637. attribs.push("world2");
  119638. attribs.push("world3");
  119639. }
  119640. // Get correct effect
  119641. var join = defines.join("\n");
  119642. if (this._cachedDefines !== join) {
  119643. this._cachedDefines = join;
  119644. this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join);
  119645. }
  119646. return this._volumetricLightScatteringPass.isReady();
  119647. };
  119648. /**
  119649. * Sets the new light position for light scattering effect
  119650. * @param position The new custom light position
  119651. */
  119652. VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
  119653. this.customMeshPosition = position;
  119654. };
  119655. /**
  119656. * Returns the light position for light scattering effect
  119657. * @return Vector3 The custom light position
  119658. */
  119659. VolumetricLightScatteringPostProcess.prototype.getCustomMeshPosition = function () {
  119660. return this.customMeshPosition;
  119661. };
  119662. /**
  119663. * Disposes the internal assets and detaches the post-process from the camera
  119664. */
  119665. VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
  119666. var rttIndex = camera.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  119667. if (rttIndex !== -1) {
  119668. camera.getScene().customRenderTargets.splice(rttIndex, 1);
  119669. }
  119670. this._volumetricLightScatteringRTT.dispose();
  119671. _super.prototype.dispose.call(this, camera);
  119672. };
  119673. /**
  119674. * Returns the render target texture used by the post-process
  119675. * @return the render target texture used by the post-process
  119676. */
  119677. VolumetricLightScatteringPostProcess.prototype.getPass = function () {
  119678. return this._volumetricLightScatteringRTT;
  119679. };
  119680. // Private methods
  119681. VolumetricLightScatteringPostProcess.prototype._meshExcluded = function (mesh) {
  119682. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  119683. return true;
  119684. }
  119685. return false;
  119686. };
  119687. VolumetricLightScatteringPostProcess.prototype._createPass = function (scene, ratio) {
  119688. var _this = this;
  119689. var engine = scene.getEngine();
  119690. 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);
  119691. this._volumetricLightScatteringRTT.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  119692. this._volumetricLightScatteringRTT.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  119693. this._volumetricLightScatteringRTT.renderList = null;
  119694. this._volumetricLightScatteringRTT.renderParticles = false;
  119695. this._volumetricLightScatteringRTT.ignoreCameraViewport = true;
  119696. var camera = this.getCamera();
  119697. if (camera) {
  119698. camera.customRenderTargets.push(this._volumetricLightScatteringRTT);
  119699. }
  119700. else {
  119701. scene.customRenderTargets.push(this._volumetricLightScatteringRTT);
  119702. }
  119703. // Custom render function for submeshes
  119704. var renderSubMesh = function (subMesh) {
  119705. var mesh = subMesh.getRenderingMesh();
  119706. if (_this._meshExcluded(mesh)) {
  119707. return;
  119708. }
  119709. var material = subMesh.getMaterial();
  119710. if (!material) {
  119711. return;
  119712. }
  119713. var scene = mesh.getScene();
  119714. var engine = scene.getEngine();
  119715. // Culling
  119716. engine.setState(material.backFaceCulling);
  119717. // Managing instances
  119718. var batch = mesh._getInstancesRenderList(subMesh._id);
  119719. if (batch.mustReturn) {
  119720. return;
  119721. }
  119722. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  119723. if (_this._isReady(subMesh, hardwareInstancedRendering)) {
  119724. var effect = _this._volumetricLightScatteringPass;
  119725. if (mesh === _this.mesh) {
  119726. if (subMesh.effect) {
  119727. effect = subMesh.effect;
  119728. }
  119729. else {
  119730. effect = material.getEffect();
  119731. }
  119732. }
  119733. engine.enableEffect(effect);
  119734. mesh._bind(subMesh, effect, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode);
  119735. if (mesh === _this.mesh) {
  119736. material.bind(mesh.getWorldMatrix(), mesh);
  119737. }
  119738. else {
  119739. _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
  119740. // Alpha test
  119741. if (material && material.needAlphaTesting()) {
  119742. var alphaTexture = material.getAlphaTestTexture();
  119743. _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
  119744. if (alphaTexture) {
  119745. _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  119746. }
  119747. }
  119748. // Bones
  119749. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  119750. _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  119751. }
  119752. }
  119753. // Draw
  119754. mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
  119755. }
  119756. };
  119757. // Render target texture callbacks
  119758. var savedSceneClearColor;
  119759. var sceneClearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0.0, 0.0, 0.0, 1.0);
  119760. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function () {
  119761. savedSceneClearColor = scene.clearColor;
  119762. scene.clearColor = sceneClearColor;
  119763. });
  119764. this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function () {
  119765. scene.clearColor = savedSceneClearColor;
  119766. });
  119767. this._volumetricLightScatteringRTT.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  119768. var engine = scene.getEngine();
  119769. var index;
  119770. if (depthOnlySubMeshes.length) {
  119771. engine.setColorWrite(false);
  119772. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  119773. renderSubMesh(depthOnlySubMeshes.data[index]);
  119774. }
  119775. engine.setColorWrite(true);
  119776. }
  119777. for (index = 0; index < opaqueSubMeshes.length; index++) {
  119778. renderSubMesh(opaqueSubMeshes.data[index]);
  119779. }
  119780. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  119781. renderSubMesh(alphaTestSubMeshes.data[index]);
  119782. }
  119783. if (transparentSubMeshes.length) {
  119784. // Sort sub meshes
  119785. for (index = 0; index < transparentSubMeshes.length; index++) {
  119786. var submesh = transparentSubMeshes.data[index];
  119787. var boundingInfo = submesh.getBoundingInfo();
  119788. if (boundingInfo && scene.activeCamera) {
  119789. submesh._alphaIndex = submesh.getMesh().alphaIndex;
  119790. submesh._distanceToCamera = boundingInfo.boundingSphere.centerWorld.subtract(scene.activeCamera.position).length();
  119791. }
  119792. }
  119793. var sortedArray = transparentSubMeshes.data.slice(0, transparentSubMeshes.length);
  119794. sortedArray.sort(function (a, b) {
  119795. // Alpha index first
  119796. if (a._alphaIndex > b._alphaIndex) {
  119797. return 1;
  119798. }
  119799. if (a._alphaIndex < b._alphaIndex) {
  119800. return -1;
  119801. }
  119802. // Then distance to camera
  119803. if (a._distanceToCamera < b._distanceToCamera) {
  119804. return 1;
  119805. }
  119806. if (a._distanceToCamera > b._distanceToCamera) {
  119807. return -1;
  119808. }
  119809. return 0;
  119810. });
  119811. // Render sub meshes
  119812. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE);
  119813. for (index = 0; index < sortedArray.length; index++) {
  119814. renderSubMesh(sortedArray[index]);
  119815. }
  119816. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE);
  119817. }
  119818. };
  119819. };
  119820. VolumetricLightScatteringPostProcess.prototype._updateMeshScreenCoordinates = function (scene) {
  119821. var transform = scene.getTransformMatrix();
  119822. var meshPosition;
  119823. if (this.useCustomMeshPosition) {
  119824. meshPosition = this.customMeshPosition;
  119825. }
  119826. else if (this.attachedNode) {
  119827. meshPosition = this.attachedNode.position;
  119828. }
  119829. else {
  119830. meshPosition = this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  119831. }
  119832. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Project(meshPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity(), transform, this._viewPort);
  119833. this._screenCoordinates.x = pos.x / this._viewPort.width;
  119834. this._screenCoordinates.y = pos.y / this._viewPort.height;
  119835. if (this.invert) {
  119836. this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
  119837. }
  119838. };
  119839. // Static methods
  119840. /**
  119841. * Creates a default mesh for the Volumeric Light Scattering post-process
  119842. * @param name The mesh name
  119843. * @param scene The scene where to create the mesh
  119844. * @return the default mesh
  119845. */
  119846. VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
  119847. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__["Mesh"].CreatePlane(name, 1, scene);
  119848. mesh.billboardMode = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__["AbstractMesh"].BILLBOARDMODE_ALL;
  119849. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"](name + "Material", scene);
  119850. material.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  119851. mesh.material = material;
  119852. return mesh;
  119853. };
  119854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119855. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  119856. ], VolumetricLightScatteringPostProcess.prototype, "customMeshPosition", void 0);
  119857. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119859. ], VolumetricLightScatteringPostProcess.prototype, "useCustomMeshPosition", void 0);
  119860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119862. ], VolumetricLightScatteringPostProcess.prototype, "invert", void 0);
  119863. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119864. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  119865. ], VolumetricLightScatteringPostProcess.prototype, "mesh", void 0);
  119866. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119867. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119868. ], VolumetricLightScatteringPostProcess.prototype, "excludedMeshes", void 0);
  119869. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119870. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119871. ], VolumetricLightScatteringPostProcess.prototype, "exposure", void 0);
  119872. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119873. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119874. ], VolumetricLightScatteringPostProcess.prototype, "decay", void 0);
  119875. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119876. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119877. ], VolumetricLightScatteringPostProcess.prototype, "weight", void 0);
  119878. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119879. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119880. ], VolumetricLightScatteringPostProcess.prototype, "density", void 0);
  119881. return VolumetricLightScatteringPostProcess;
  119882. }(_postProcess__WEBPACK_IMPORTED_MODULE_11__["PostProcess"]));
  119883. /***/ }),
  119884. /***/ "./PostProcesses/vrDistortionCorrectionPostProcess.ts":
  119885. /*!************************************************************!*\
  119886. !*** ./PostProcesses/vrDistortionCorrectionPostProcess.ts ***!
  119887. \************************************************************/
  119888. /*! exports provided: VRDistortionCorrectionPostProcess */
  119889. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119890. "use strict";
  119891. __webpack_require__.r(__webpack_exports__);
  119892. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return VRDistortionCorrectionPostProcess; });
  119893. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119894. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119895. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119896. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119897. /* harmony import */ var _Shaders_vrDistortionCorrection_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/vrDistortionCorrection.fragment */ "./Shaders/vrDistortionCorrection.fragment.ts");
  119898. /**
  119899. * VRDistortionCorrectionPostProcess used for mobile VR
  119900. */
  119901. var VRDistortionCorrectionPostProcess = /** @class */ (function (_super) {
  119902. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDistortionCorrectionPostProcess, _super);
  119903. /**
  119904. * Initializes the VRDistortionCorrectionPostProcess
  119905. * @param name The name of the effect.
  119906. * @param camera The camera to apply the render pass to.
  119907. * @param isRightEye If this is for the right eye distortion
  119908. * @param vrMetrics All the required metrics for the VR camera
  119909. */
  119910. function VRDistortionCorrectionPostProcess(name, camera, isRightEye, vrMetrics) {
  119911. var _this = _super.call(this, name, "vrDistortionCorrection", [
  119912. 'LensCenter',
  119913. 'Scale',
  119914. 'ScaleIn',
  119915. 'HmdWarpParam'
  119916. ], null, vrMetrics.postProcessScaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  119917. _this._isRightEye = isRightEye;
  119918. _this._distortionFactors = vrMetrics.distortionK;
  119919. _this._postProcessScaleFactor = vrMetrics.postProcessScaleFactor;
  119920. _this._lensCenterOffset = vrMetrics.lensCenterOffset;
  119921. _this.adaptScaleToCurrentViewport = true;
  119922. _this.onSizeChangedObservable.add(function () {
  119923. _this._scaleIn = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](2, 2 / _this.aspectRatio);
  119924. _this._scaleFactor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  119925. _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);
  119926. });
  119927. _this.onApplyObservable.add(function (effect) {
  119928. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  119929. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  119930. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  119931. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  119932. });
  119933. return _this;
  119934. }
  119935. return VRDistortionCorrectionPostProcess;
  119936. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  119937. /***/ }),
  119938. /***/ "./Probes/index.ts":
  119939. /*!*************************!*\
  119940. !*** ./Probes/index.ts ***!
  119941. \*************************/
  119942. /*! exports provided: ReflectionProbe */
  119943. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119944. "use strict";
  119945. __webpack_require__.r(__webpack_exports__);
  119946. /* harmony import */ var _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reflectionProbe */ "./Probes/reflectionProbe.ts");
  119947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  119948. /***/ }),
  119949. /***/ "./Probes/reflectionProbe.ts":
  119950. /*!***********************************!*\
  119951. !*** ./Probes/reflectionProbe.ts ***!
  119952. \***********************************/
  119953. /*! exports provided: ReflectionProbe */
  119954. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119955. "use strict";
  119956. __webpack_require__.r(__webpack_exports__);
  119957. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return ReflectionProbe; });
  119958. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119959. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  119960. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  119961. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119962. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  119963. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119964. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.removeReflectionProbe = function (toRemove) {
  119965. if (!this.reflectionProbes) {
  119966. return -1;
  119967. }
  119968. var index = this.reflectionProbes.indexOf(toRemove);
  119969. if (index !== -1) {
  119970. this.reflectionProbes.splice(index, 1);
  119971. }
  119972. return index;
  119973. };
  119974. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.addReflectionProbe = function (newReflectionProbe) {
  119975. if (!this.reflectionProbes) {
  119976. this.reflectionProbes = [];
  119977. }
  119978. this.reflectionProbes.push(newReflectionProbe);
  119979. };
  119980. /**
  119981. * Class used to generate realtime reflection / refraction cube textures
  119982. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119983. */
  119984. var ReflectionProbe = /** @class */ (function () {
  119985. /**
  119986. * Creates a new reflection probe
  119987. * @param name defines the name of the probe
  119988. * @param size defines the texture resolution (for each face)
  119989. * @param scene defines the hosting scene
  119990. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  119991. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  119992. */
  119993. function ReflectionProbe(
  119994. /** defines the name of the probe */
  119995. name, size, scene, generateMipMaps, useFloat) {
  119996. if (generateMipMaps === void 0) { generateMipMaps = true; }
  119997. if (useFloat === void 0) { useFloat = false; }
  119998. var _this = this;
  119999. this.name = name;
  120000. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  120001. this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  120002. this._add = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  120003. this._invertYAxis = false;
  120004. /** Gets or sets probe position (center of the cube map) */
  120005. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  120006. this._scene = scene;
  120007. // Create the scene field if not exist.
  120008. if (!this._scene.reflectionProbes) {
  120009. this._scene.reflectionProbes = new Array();
  120010. }
  120011. this._scene.reflectionProbes.push(this);
  120012. 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);
  120013. this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
  120014. switch (faceIndex) {
  120015. case 0:
  120016. _this._add.copyFromFloats(1, 0, 0);
  120017. break;
  120018. case 1:
  120019. _this._add.copyFromFloats(-1, 0, 0);
  120020. break;
  120021. case 2:
  120022. _this._add.copyFromFloats(0, _this._invertYAxis ? 1 : -1, 0);
  120023. break;
  120024. case 3:
  120025. _this._add.copyFromFloats(0, _this._invertYAxis ? -1 : 1, 0);
  120026. break;
  120027. case 4:
  120028. _this._add.copyFromFloats(0, 0, 1);
  120029. break;
  120030. case 5:
  120031. _this._add.copyFromFloats(0, 0, -1);
  120032. break;
  120033. }
  120034. if (_this._attachedMesh) {
  120035. _this.position.copyFrom(_this._attachedMesh.getAbsolutePosition());
  120036. }
  120037. _this.position.addToRef(_this._add, _this._target);
  120038. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(_this.position, _this._target, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), _this._viewMatrix);
  120039. if (scene.activeCamera) {
  120040. _this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
  120041. scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
  120042. }
  120043. scene._forcedViewPosition = _this.position;
  120044. });
  120045. this._renderTargetTexture.onAfterUnbindObservable.add(function () {
  120046. scene._forcedViewPosition = null;
  120047. scene.updateTransformMatrix(true);
  120048. });
  120049. }
  120050. Object.defineProperty(ReflectionProbe.prototype, "samples", {
  120051. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  120052. get: function () {
  120053. return this._renderTargetTexture.samples;
  120054. },
  120055. set: function (value) {
  120056. this._renderTargetTexture.samples = value;
  120057. },
  120058. enumerable: true,
  120059. configurable: true
  120060. });
  120061. Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
  120062. /** Gets or sets the refresh rate to use (on every frame by default) */
  120063. get: function () {
  120064. return this._renderTargetTexture.refreshRate;
  120065. },
  120066. set: function (value) {
  120067. this._renderTargetTexture.refreshRate = value;
  120068. },
  120069. enumerable: true,
  120070. configurable: true
  120071. });
  120072. /**
  120073. * Gets the hosting scene
  120074. * @returns a Scene
  120075. */
  120076. ReflectionProbe.prototype.getScene = function () {
  120077. return this._scene;
  120078. };
  120079. Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
  120080. /** Gets the internal CubeTexture used to render to */
  120081. get: function () {
  120082. return this._renderTargetTexture;
  120083. },
  120084. enumerable: true,
  120085. configurable: true
  120086. });
  120087. Object.defineProperty(ReflectionProbe.prototype, "renderList", {
  120088. /** Gets the list of meshes to render */
  120089. get: function () {
  120090. return this._renderTargetTexture.renderList;
  120091. },
  120092. enumerable: true,
  120093. configurable: true
  120094. });
  120095. /**
  120096. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  120097. * @param mesh defines the mesh to attach to
  120098. */
  120099. ReflectionProbe.prototype.attachToMesh = function (mesh) {
  120100. this._attachedMesh = mesh;
  120101. };
  120102. /**
  120103. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  120104. * @param renderingGroupId The rendering group id corresponding to its index
  120105. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120106. */
  120107. ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  120108. this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  120109. };
  120110. /**
  120111. * Clean all associated resources
  120112. */
  120113. ReflectionProbe.prototype.dispose = function () {
  120114. var index = this._scene.reflectionProbes.indexOf(this);
  120115. if (index !== -1) {
  120116. // Remove from the scene if found
  120117. this._scene.reflectionProbes.splice(index, 1);
  120118. }
  120119. if (this._renderTargetTexture) {
  120120. this._renderTargetTexture.dispose();
  120121. this._renderTargetTexture = null;
  120122. }
  120123. };
  120124. /**
  120125. * Converts the reflection probe information to a readable string for debug purpose.
  120126. * @param fullDetails Supports for multiple levels of logging within scene loading
  120127. * @returns the human readable reflection probe info
  120128. */
  120129. ReflectionProbe.prototype.toString = function (fullDetails) {
  120130. var ret = "Name: " + this.name;
  120131. if (fullDetails) {
  120132. ret += ", position: " + this.position.toString();
  120133. if (this._attachedMesh) {
  120134. ret += ", attached mesh: " + this._attachedMesh.name;
  120135. }
  120136. }
  120137. return ret;
  120138. };
  120139. /**
  120140. * Get the class name of the relfection probe.
  120141. * @returns "ReflectionProbe"
  120142. */
  120143. ReflectionProbe.prototype.getClassName = function () {
  120144. return "ReflectionProbe";
  120145. };
  120146. /**
  120147. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  120148. * @returns The JSON representation of the texture
  120149. */
  120150. ReflectionProbe.prototype.serialize = function () {
  120151. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, this._renderTargetTexture.serialize());
  120152. serializationObject.isReflectionProbe = true;
  120153. return serializationObject;
  120154. };
  120155. /**
  120156. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  120157. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  120158. * @param scene Define the scene the parsed reflection probe should be instantiated in
  120159. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  120160. * @returns The parsed reflection probe if successful
  120161. */
  120162. ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
  120163. var reflectionProbe = null;
  120164. if (scene.reflectionProbes) {
  120165. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  120166. var rp = scene.reflectionProbes[index];
  120167. if (rp.name === parsedReflectionProbe.name) {
  120168. reflectionProbe = rp;
  120169. break;
  120170. }
  120171. }
  120172. }
  120173. reflectionProbe = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
  120174. reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
  120175. if (parsedReflectionProbe._attachedMesh) {
  120176. reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
  120177. }
  120178. return reflectionProbe;
  120179. };
  120180. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120181. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  120182. ], ReflectionProbe.prototype, "_attachedMesh", void 0);
  120183. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120184. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  120185. ], ReflectionProbe.prototype, "position", void 0);
  120186. return ReflectionProbe;
  120187. }());
  120188. /***/ }),
  120189. /***/ "./Rendering/boundingBoxRenderer.ts":
  120190. /*!******************************************!*\
  120191. !*** ./Rendering/boundingBoxRenderer.ts ***!
  120192. \******************************************/
  120193. /*! exports provided: BoundingBoxRenderer */
  120194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120195. "use strict";
  120196. __webpack_require__.r(__webpack_exports__);
  120197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return BoundingBoxRenderer; });
  120198. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  120199. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120200. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  120201. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  120202. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120203. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  120204. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  120205. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120206. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  120207. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  120208. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  120209. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  120210. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "forceShowBoundingBoxes", {
  120211. get: function () {
  120212. return this._forceShowBoundingBoxes || false;
  120213. },
  120214. set: function (value) {
  120215. this._forceShowBoundingBoxes = value;
  120216. // Lazyly creates a BB renderer if needed.
  120217. if (value) {
  120218. this.getBoundingBoxRenderer();
  120219. }
  120220. },
  120221. enumerable: true,
  120222. configurable: true
  120223. });
  120224. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.getBoundingBoxRenderer = function () {
  120225. if (!this._boundingBoxRenderer) {
  120226. this._boundingBoxRenderer = new BoundingBoxRenderer(this);
  120227. }
  120228. return this._boundingBoxRenderer;
  120229. };
  120230. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "showBoundingBox", {
  120231. get: function () {
  120232. return this._showBoundingBox || false;
  120233. },
  120234. set: function (value) {
  120235. this._showBoundingBox = value;
  120236. // Lazyly creates a BB renderer if needed.
  120237. if (value) {
  120238. this.getScene().getBoundingBoxRenderer();
  120239. }
  120240. },
  120241. enumerable: true,
  120242. configurable: true
  120243. });
  120244. /**
  120245. * Component responsible of rendering the bounding box of the meshes in a scene.
  120246. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  120247. */
  120248. var BoundingBoxRenderer = /** @class */ (function () {
  120249. /**
  120250. * Instantiates a new bounding box renderer in a scene.
  120251. * @param scene the scene the renderer renders in
  120252. */
  120253. function BoundingBoxRenderer(scene) {
  120254. /**
  120255. * The component name helpfull to identify the component in the list of scene components.
  120256. */
  120257. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_BOUNDINGBOXRENDERER;
  120258. /**
  120259. * Color of the bounding box lines placed in front of an object
  120260. */
  120261. this.frontColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  120262. /**
  120263. * Color of the bounding box lines placed behind an object
  120264. */
  120265. this.backColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.1, 0.1, 0.1);
  120266. /**
  120267. * Defines if the renderer should show the back lines or not
  120268. */
  120269. this.showBackLines = true;
  120270. /**
  120271. * @hidden
  120272. */
  120273. this.renderList = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__["SmartArray"](32);
  120274. this._vertexBuffers = {};
  120275. this.scene = scene;
  120276. scene._addComponent(this);
  120277. }
  120278. /**
  120279. * Registers the component in a given scene
  120280. */
  120281. BoundingBoxRenderer.prototype.register = function () {
  120282. this.scene._beforeEvaluateActiveMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
  120283. this.scene._activeMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
  120284. this.scene._evaluateSubMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
  120285. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
  120286. };
  120287. BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
  120288. if (mesh.showSubMeshesBoundingBox) {
  120289. var boundingInfo = subMesh.getBoundingInfo();
  120290. if (boundingInfo !== null && boundingInfo !== undefined) {
  120291. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  120292. this.renderList.push(boundingInfo.boundingBox);
  120293. }
  120294. }
  120295. };
  120296. BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
  120297. if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  120298. var boundingInfo = sourceMesh.getBoundingInfo();
  120299. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  120300. this.renderList.push(boundingInfo.boundingBox);
  120301. }
  120302. };
  120303. BoundingBoxRenderer.prototype._prepareRessources = function () {
  120304. if (this._colorShader) {
  120305. return;
  120306. }
  120307. this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__["ShaderMaterial"]("colorShader", this.scene, "color", {
  120308. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind],
  120309. uniforms: ["world", "viewProjection", "color"]
  120310. });
  120311. var engine = this.scene.getEngine();
  120312. var boxdata = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox({ size: 1.0 });
  120313. 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);
  120314. this._createIndexBuffer();
  120315. };
  120316. BoundingBoxRenderer.prototype._createIndexBuffer = function () {
  120317. var engine = this.scene.getEngine();
  120318. 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]);
  120319. };
  120320. /**
  120321. * Rebuilds the elements related to this component in case of
  120322. * context lost for instance.
  120323. */
  120324. BoundingBoxRenderer.prototype.rebuild = function () {
  120325. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120326. if (vb) {
  120327. vb._rebuild();
  120328. }
  120329. this._createIndexBuffer();
  120330. };
  120331. /**
  120332. * @hidden
  120333. */
  120334. BoundingBoxRenderer.prototype.reset = function () {
  120335. this.renderList.reset();
  120336. };
  120337. /**
  120338. * Render the bounding boxes of a specific rendering group
  120339. * @param renderingGroupId defines the rendering group to render
  120340. */
  120341. BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
  120342. if (this.renderList.length === 0) {
  120343. return;
  120344. }
  120345. this._prepareRessources();
  120346. if (!this._colorShader.isReady()) {
  120347. return;
  120348. }
  120349. var engine = this.scene.getEngine();
  120350. engine.setDepthWrite(false);
  120351. this._colorShader._preBind();
  120352. for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
  120353. var boundingBox = this.renderList.data[boundingBoxIndex];
  120354. if (boundingBox._tag !== renderingGroupId) {
  120355. continue;
  120356. }
  120357. var min = boundingBox.minimum;
  120358. var max = boundingBox.maximum;
  120359. var diff = max.subtract(min);
  120360. var median = min.add(diff.scale(0.5));
  120361. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  120362. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  120363. .multiply(boundingBox.getWorldMatrix());
  120364. // VBOs
  120365. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  120366. if (this.showBackLines) {
  120367. // Back
  120368. engine.setDepthFunctionToGreaterOrEqual();
  120369. this.scene.resetCachedMaterial();
  120370. this._colorShader.setColor4("color", this.backColor.toColor4());
  120371. this._colorShader.bind(worldMatrix);
  120372. // Draw order
  120373. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  120374. }
  120375. // Front
  120376. engine.setDepthFunctionToLess();
  120377. this.scene.resetCachedMaterial();
  120378. this._colorShader.setColor4("color", this.frontColor.toColor4());
  120379. this._colorShader.bind(worldMatrix);
  120380. // Draw order
  120381. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  120382. }
  120383. this._colorShader.unbind();
  120384. engine.setDepthFunctionToLessOrEqual();
  120385. engine.setDepthWrite(true);
  120386. };
  120387. /**
  120388. * In case of occlusion queries, we can render the occlusion bounding box through this method
  120389. * @param mesh Define the mesh to render the occlusion bounding box for
  120390. */
  120391. BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
  120392. this._prepareRessources();
  120393. if (!this._colorShader.isReady() || !mesh._boundingInfo) {
  120394. return;
  120395. }
  120396. var engine = this.scene.getEngine();
  120397. engine.setDepthWrite(false);
  120398. engine.setColorWrite(false);
  120399. this._colorShader._preBind();
  120400. var boundingBox = mesh._boundingInfo.boundingBox;
  120401. var min = boundingBox.minimum;
  120402. var max = boundingBox.maximum;
  120403. var diff = max.subtract(min);
  120404. var median = min.add(diff.scale(0.5));
  120405. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  120406. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  120407. .multiply(boundingBox.getWorldMatrix());
  120408. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  120409. engine.setDepthFunctionToLess();
  120410. this.scene.resetCachedMaterial();
  120411. this._colorShader.bind(worldMatrix);
  120412. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  120413. this._colorShader.unbind();
  120414. engine.setDepthFunctionToLessOrEqual();
  120415. engine.setDepthWrite(true);
  120416. engine.setColorWrite(true);
  120417. };
  120418. /**
  120419. * Dispose and release the resources attached to this renderer.
  120420. */
  120421. BoundingBoxRenderer.prototype.dispose = function () {
  120422. if (!this._colorShader) {
  120423. return;
  120424. }
  120425. this.renderList.dispose();
  120426. this._colorShader.dispose();
  120427. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120428. if (buffer) {
  120429. buffer.dispose();
  120430. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  120431. }
  120432. this.scene.getEngine()._releaseBuffer(this._indexBuffer);
  120433. };
  120434. return BoundingBoxRenderer;
  120435. }());
  120436. /***/ }),
  120437. /***/ "./Rendering/depthRenderer.ts":
  120438. /*!************************************!*\
  120439. !*** ./Rendering/depthRenderer.ts ***!
  120440. \************************************/
  120441. /*! exports provided: DepthRenderer */
  120442. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120443. "use strict";
  120444. __webpack_require__.r(__webpack_exports__);
  120445. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return DepthRenderer; });
  120446. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120447. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120448. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120449. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  120450. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120451. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120452. /* harmony import */ var _Shaders_depth_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/depth.fragment */ "./Shaders/depth.fragment.ts");
  120453. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  120454. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  120455. /**
  120456. * This represents a depth renderer in Babylon.
  120457. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  120458. */
  120459. var DepthRenderer = /** @class */ (function () {
  120460. /**
  120461. * Instantiates a depth renderer
  120462. * @param scene The scene the renderer belongs to
  120463. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  120464. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  120465. */
  120466. function DepthRenderer(scene, type, camera) {
  120467. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT; }
  120468. if (camera === void 0) { camera = null; }
  120469. var _this = this;
  120470. /**
  120471. * Specifiess that the depth renderer will only be used within
  120472. * the camera it is created for.
  120473. * This can help forcing its rendering during the camera processing.
  120474. */
  120475. this.useOnlyInActiveCamera = false;
  120476. this._scene = scene;
  120477. DepthRenderer._SceneComponentInitialization(this._scene);
  120478. this._camera = camera;
  120479. var engine = scene.getEngine();
  120480. // Render target
  120481. this._depthMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type);
  120482. this._depthMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  120483. this._depthMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  120484. this._depthMap.refreshRate = 1;
  120485. this._depthMap.renderParticles = false;
  120486. this._depthMap.renderList = null;
  120487. // Camera to get depth map from to support multiple concurrent cameras
  120488. this._depthMap.activeCamera = this._camera;
  120489. this._depthMap.ignoreCameraViewport = true;
  120490. this._depthMap.useCameraPostProcesses = false;
  120491. // set default depth value to 1.0 (far away)
  120492. this._depthMap.onClearObservable.add(function (engine) {
  120493. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0), true, true, true);
  120494. });
  120495. // Custom render function
  120496. var renderSubMesh = function (subMesh) {
  120497. var mesh = subMesh.getRenderingMesh();
  120498. var scene = _this._scene;
  120499. var engine = scene.getEngine();
  120500. var material = subMesh.getMaterial();
  120501. if (!material) {
  120502. return;
  120503. }
  120504. // Culling and reverse (right handed system)
  120505. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  120506. // Managing instances
  120507. var batch = mesh._getInstancesRenderList(subMesh._id);
  120508. if (batch.mustReturn) {
  120509. return;
  120510. }
  120511. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  120512. var camera = _this._camera || scene.activeCamera;
  120513. if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
  120514. engine.enableEffect(_this._effect);
  120515. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  120516. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  120517. _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
  120518. // Alpha test
  120519. if (material && material.needAlphaTesting()) {
  120520. var alphaTexture = material.getAlphaTestTexture();
  120521. if (alphaTexture) {
  120522. _this._effect.setTexture("diffuseSampler", alphaTexture);
  120523. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  120524. }
  120525. }
  120526. // Bones
  120527. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  120528. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  120529. }
  120530. // Draw
  120531. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  120532. }
  120533. };
  120534. this._depthMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  120535. var index;
  120536. if (depthOnlySubMeshes.length) {
  120537. engine.setColorWrite(false);
  120538. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  120539. renderSubMesh(depthOnlySubMeshes.data[index]);
  120540. }
  120541. engine.setColorWrite(true);
  120542. }
  120543. for (index = 0; index < opaqueSubMeshes.length; index++) {
  120544. renderSubMesh(opaqueSubMeshes.data[index]);
  120545. }
  120546. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  120547. renderSubMesh(alphaTestSubMeshes.data[index]);
  120548. }
  120549. };
  120550. }
  120551. /**
  120552. * Creates the depth rendering effect and checks if the effect is ready.
  120553. * @param subMesh The submesh to be used to render the depth map of
  120554. * @param useInstances If multiple world instances should be used
  120555. * @returns if the depth renderer is ready to render the depth map
  120556. */
  120557. DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
  120558. var material = subMesh.getMaterial();
  120559. if (material.disableDepthWrite) {
  120560. return false;
  120561. }
  120562. var defines = [];
  120563. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120564. var mesh = subMesh.getMesh();
  120565. // Alpha test
  120566. if (material && material.needAlphaTesting() && material.getAlphaTestTexture()) {
  120567. defines.push("#define ALPHATEST");
  120568. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  120569. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  120570. defines.push("#define UV1");
  120571. }
  120572. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  120573. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  120574. defines.push("#define UV2");
  120575. }
  120576. }
  120577. // Bones
  120578. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  120579. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  120580. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  120581. if (mesh.numBoneInfluencers > 4) {
  120582. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  120583. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  120584. }
  120585. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  120586. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  120587. }
  120588. else {
  120589. defines.push("#define NUM_BONE_INFLUENCERS 0");
  120590. }
  120591. // Instances
  120592. if (useInstances) {
  120593. defines.push("#define INSTANCES");
  120594. attribs.push("world0");
  120595. attribs.push("world1");
  120596. attribs.push("world2");
  120597. attribs.push("world3");
  120598. }
  120599. // Get correct effect
  120600. var join = defines.join("\n");
  120601. if (this._cachedDefines !== join) {
  120602. this._cachedDefines = join;
  120603. this._effect = this._scene.getEngine().createEffect("depth", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues"], ["diffuseSampler"], join);
  120604. }
  120605. return this._effect.isReady();
  120606. };
  120607. /**
  120608. * Gets the texture which the depth map will be written to.
  120609. * @returns The depth map texture
  120610. */
  120611. DepthRenderer.prototype.getDepthMap = function () {
  120612. return this._depthMap;
  120613. };
  120614. /**
  120615. * Disposes of the depth renderer.
  120616. */
  120617. DepthRenderer.prototype.dispose = function () {
  120618. this._depthMap.dispose();
  120619. };
  120620. /** @hidden */
  120621. DepthRenderer._SceneComponentInitialization = function (_) {
  120622. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("DepthRendererSceneComponent");
  120623. };
  120624. return DepthRenderer;
  120625. }());
  120626. /***/ }),
  120627. /***/ "./Rendering/depthRendererSceneComponent.ts":
  120628. /*!**************************************************!*\
  120629. !*** ./Rendering/depthRendererSceneComponent.ts ***!
  120630. \**************************************************/
  120631. /*! exports provided: DepthRendererSceneComponent */
  120632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120633. "use strict";
  120634. __webpack_require__.r(__webpack_exports__);
  120635. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return DepthRendererSceneComponent; });
  120636. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  120637. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  120638. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120639. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  120640. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableDepthRenderer = function (camera) {
  120641. camera = camera || this.activeCamera;
  120642. if (!camera) {
  120643. throw "No camera available to enable depth renderer";
  120644. }
  120645. if (!this._depthRenderer) {
  120646. this._depthRenderer = {};
  120647. }
  120648. if (!this._depthRenderer[camera.id]) {
  120649. var textureType = 0;
  120650. if (this.getEngine().getCaps().textureHalfFloatRender) {
  120651. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  120652. }
  120653. else if (this.getEngine().getCaps().textureFloatRender) {
  120654. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  120655. }
  120656. else {
  120657. throw "Depth renderer does not support int texture type";
  120658. }
  120659. this._depthRenderer[camera.id] = new _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"](this, textureType, camera);
  120660. }
  120661. return this._depthRenderer[camera.id];
  120662. };
  120663. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableDepthRenderer = function (camera) {
  120664. camera = camera || this.activeCamera;
  120665. if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {
  120666. return;
  120667. }
  120668. this._depthRenderer[camera.id].dispose();
  120669. delete this._depthRenderer[camera.id];
  120670. };
  120671. /**
  120672. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  120673. * in several rendering techniques.
  120674. */
  120675. var DepthRendererSceneComponent = /** @class */ (function () {
  120676. /**
  120677. * Creates a new instance of the component for the given scene
  120678. * @param scene Defines the scene to register the component in
  120679. */
  120680. function DepthRendererSceneComponent(scene) {
  120681. /**
  120682. * The component name helpfull to identify the component in the list of scene components.
  120683. */
  120684. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER;
  120685. this.scene = scene;
  120686. }
  120687. /**
  120688. * Registers the component in a given scene
  120689. */
  120690. DepthRendererSceneComponent.prototype.register = function () {
  120691. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);
  120692. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
  120693. };
  120694. /**
  120695. * Rebuilds the elements related to this component in case of
  120696. * context lost for instance.
  120697. */
  120698. DepthRendererSceneComponent.prototype.rebuild = function () {
  120699. // Nothing to do for this component
  120700. };
  120701. /**
  120702. * Disposes the component and the associated ressources
  120703. */
  120704. DepthRendererSceneComponent.prototype.dispose = function () {
  120705. for (var key in this.scene._depthRenderer) {
  120706. this.scene._depthRenderer[key].dispose();
  120707. }
  120708. };
  120709. DepthRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  120710. if (this.scene._depthRenderer) {
  120711. for (var key in this.scene._depthRenderer) {
  120712. var depthRenderer = this.scene._depthRenderer[key];
  120713. if (!depthRenderer.useOnlyInActiveCamera) {
  120714. renderTargets.push(depthRenderer.getDepthMap());
  120715. }
  120716. }
  120717. }
  120718. };
  120719. DepthRendererSceneComponent.prototype._gatherActiveCameraRenderTargets = function (renderTargets) {
  120720. if (this.scene._depthRenderer) {
  120721. for (var key in this.scene._depthRenderer) {
  120722. var depthRenderer = this.scene._depthRenderer[key];
  120723. if (depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {
  120724. renderTargets.push(depthRenderer.getDepthMap());
  120725. }
  120726. }
  120727. }
  120728. };
  120729. return DepthRendererSceneComponent;
  120730. }());
  120731. _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]._SceneComponentInitialization = function (scene) {
  120732. // Register the G Buffer component to the scene.
  120733. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER);
  120734. if (!component) {
  120735. component = new DepthRendererSceneComponent(scene);
  120736. scene._addComponent(component);
  120737. }
  120738. };
  120739. /***/ }),
  120740. /***/ "./Rendering/edgesRenderer.ts":
  120741. /*!************************************!*\
  120742. !*** ./Rendering/edgesRenderer.ts ***!
  120743. \************************************/
  120744. /*! exports provided: EdgesRenderer, LineEdgesRenderer */
  120745. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120746. "use strict";
  120747. __webpack_require__.r(__webpack_exports__);
  120748. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return EdgesRenderer; });
  120749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return LineEdgesRenderer; });
  120750. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120751. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120752. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  120753. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  120754. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120755. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120756. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  120757. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  120758. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120759. /* harmony import */ var _Shaders_line_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/line.fragment */ "./Shaders/line.fragment.ts");
  120760. /* harmony import */ var _Shaders_line_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/line.vertex */ "./Shaders/line.vertex.ts");
  120761. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.disableEdgesRendering = function () {
  120762. if (this._edgesRenderer) {
  120763. this._edgesRenderer.dispose();
  120764. this._edgesRenderer = null;
  120765. }
  120766. return this;
  120767. };
  120768. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  120769. if (epsilon === void 0) { epsilon = 0.95; }
  120770. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120771. this.disableEdgesRendering();
  120772. this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  120773. return this;
  120774. };
  120775. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "edgesRenderer", {
  120776. get: function () {
  120777. return this._edgesRenderer;
  120778. },
  120779. enumerable: true,
  120780. configurable: true
  120781. });
  120782. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  120783. if (epsilon === void 0) { epsilon = 0.95; }
  120784. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120785. this.disableEdgesRendering();
  120786. this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  120787. return this;
  120788. };
  120789. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["InstancedLinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  120790. if (epsilon === void 0) { epsilon = 0.95; }
  120791. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120792. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering.apply(this, arguments);
  120793. return this;
  120794. };
  120795. /**
  120796. * FaceAdjacencies Helper class to generate edges
  120797. */
  120798. var FaceAdjacencies = /** @class */ (function () {
  120799. function FaceAdjacencies() {
  120800. this.edges = new Array();
  120801. this.edgesConnectedCount = 0;
  120802. }
  120803. return FaceAdjacencies;
  120804. }());
  120805. /**
  120806. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  120807. */
  120808. var EdgesRenderer = /** @class */ (function () {
  120809. /**
  120810. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  120811. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  120812. * @param source Mesh used to create edges
  120813. * @param epsilon sum of angles in adjacency to check for edge
  120814. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  120815. * @param generateEdgesLines - should generate Lines or only prepare resources.
  120816. */
  120817. function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices, generateEdgesLines) {
  120818. if (epsilon === void 0) { epsilon = 0.95; }
  120819. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  120820. if (generateEdgesLines === void 0) { generateEdgesLines = true; }
  120821. var _this = this;
  120822. /**
  120823. * Define the size of the edges with an orthographic camera
  120824. */
  120825. this.edgesWidthScalerForOrthographic = 1000.0;
  120826. /**
  120827. * Define the size of the edges with a perspective camera
  120828. */
  120829. this.edgesWidthScalerForPerspective = 50.0;
  120830. this._linesPositions = new Array();
  120831. this._linesNormals = new Array();
  120832. this._linesIndices = new Array();
  120833. this._buffers = {};
  120834. this._checkVerticesInsteadOfIndices = false;
  120835. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  120836. this.isEnabled = true;
  120837. this._source = source;
  120838. this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
  120839. this._epsilon = epsilon;
  120840. this._prepareRessources();
  120841. if (generateEdgesLines) {
  120842. this._generateEdgesLines();
  120843. }
  120844. this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
  120845. _this._rebuild();
  120846. });
  120847. this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
  120848. _this.dispose();
  120849. });
  120850. }
  120851. EdgesRenderer.prototype._prepareRessources = function () {
  120852. if (this._lineShader) {
  120853. return;
  120854. }
  120855. this._lineShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("lineShader", this._source.getScene(), "line", {
  120856. attributes: ["position", "normal"],
  120857. uniforms: ["worldViewProjection", "color", "width", "aspectRatio"]
  120858. });
  120859. this._lineShader.disableDepthWrite = true;
  120860. this._lineShader.backFaceCulling = false;
  120861. };
  120862. /** @hidden */
  120863. EdgesRenderer.prototype._rebuild = function () {
  120864. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120865. if (buffer) {
  120866. buffer._rebuild();
  120867. }
  120868. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  120869. if (buffer) {
  120870. buffer._rebuild();
  120871. }
  120872. var scene = this._source.getScene();
  120873. var engine = scene.getEngine();
  120874. this._ib = engine.createIndexBuffer(this._linesIndices);
  120875. };
  120876. /**
  120877. * Releases the required resources for the edges renderer
  120878. */
  120879. EdgesRenderer.prototype.dispose = function () {
  120880. this._source.onRebuildObservable.remove(this._meshRebuildObserver);
  120881. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  120882. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120883. if (buffer) {
  120884. buffer.dispose();
  120885. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  120886. }
  120887. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  120888. if (buffer) {
  120889. buffer.dispose();
  120890. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = null;
  120891. }
  120892. this._source.getScene().getEngine()._releaseBuffer(this._ib);
  120893. this._lineShader.dispose();
  120894. };
  120895. EdgesRenderer.prototype._processEdgeForAdjacencies = function (pa, pb, p0, p1, p2) {
  120896. if (pa === p0 && pb === p1 || pa === p1 && pb === p0) {
  120897. return 0;
  120898. }
  120899. if (pa === p1 && pb === p2 || pa === p2 && pb === p1) {
  120900. return 1;
  120901. }
  120902. if (pa === p2 && pb === p0 || pa === p0 && pb === p2) {
  120903. return 2;
  120904. }
  120905. return -1;
  120906. };
  120907. EdgesRenderer.prototype._processEdgeForAdjacenciesWithVertices = function (pa, pb, p0, p1, p2) {
  120908. if (pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p1) || pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p0)) {
  120909. return 0;
  120910. }
  120911. if (pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p2) || pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p1)) {
  120912. return 1;
  120913. }
  120914. if (pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p0) || pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p2)) {
  120915. return 2;
  120916. }
  120917. return -1;
  120918. };
  120919. /**
  120920. * Checks if the pair of p0 and p1 is en edge
  120921. * @param faceIndex
  120922. * @param edge
  120923. * @param faceNormals
  120924. * @param p0
  120925. * @param p1
  120926. * @private
  120927. */
  120928. EdgesRenderer.prototype._checkEdge = function (faceIndex, edge, faceNormals, p0, p1) {
  120929. var needToCreateLine;
  120930. if (edge === undefined) {
  120931. needToCreateLine = true;
  120932. }
  120933. else {
  120934. var dotProduct = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Dot(faceNormals[faceIndex], faceNormals[edge]);
  120935. needToCreateLine = dotProduct < this._epsilon;
  120936. }
  120937. if (needToCreateLine) {
  120938. this.createLine(p0, p1, this._linesPositions.length / 3);
  120939. }
  120940. };
  120941. /**
  120942. * push line into the position, normal and index buffer
  120943. * @protected
  120944. */
  120945. EdgesRenderer.prototype.createLine = function (p0, p1, offset) {
  120946. // Positions
  120947. 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);
  120948. // Normals
  120949. 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);
  120950. // Indices
  120951. this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);
  120952. };
  120953. /**
  120954. * Generates lines edges from adjacencjes
  120955. * @private
  120956. */
  120957. EdgesRenderer.prototype._generateEdgesLines = function () {
  120958. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  120959. var indices = this._source.getIndices();
  120960. if (!indices || !positions) {
  120961. return;
  120962. }
  120963. // First let's find adjacencies
  120964. var adjacencies = new Array();
  120965. var faceNormals = new Array();
  120966. var index;
  120967. var faceAdjacencies;
  120968. // Prepare faces
  120969. for (index = 0; index < indices.length; index += 3) {
  120970. faceAdjacencies = new FaceAdjacencies();
  120971. var p0Index = indices[index];
  120972. var p1Index = indices[index + 1];
  120973. var p2Index = indices[index + 2];
  120974. faceAdjacencies.p0 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);
  120975. faceAdjacencies.p1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);
  120976. faceAdjacencies.p2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);
  120977. var faceNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));
  120978. faceNormal.normalize();
  120979. faceNormals.push(faceNormal);
  120980. adjacencies.push(faceAdjacencies);
  120981. }
  120982. // Scan
  120983. for (index = 0; index < adjacencies.length; index++) {
  120984. faceAdjacencies = adjacencies[index];
  120985. for (var otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {
  120986. var otherFaceAdjacencies = adjacencies[otherIndex];
  120987. if (faceAdjacencies.edgesConnectedCount === 3) { // Full
  120988. break;
  120989. }
  120990. if (otherFaceAdjacencies.edgesConnectedCount === 3) { // Full
  120991. continue;
  120992. }
  120993. var otherP0 = indices[otherIndex * 3];
  120994. var otherP1 = indices[otherIndex * 3 + 1];
  120995. var otherP2 = indices[otherIndex * 3 + 2];
  120996. for (var edgeIndex = 0; edgeIndex < 3; edgeIndex++) {
  120997. var otherEdgeIndex = 0;
  120998. if (faceAdjacencies.edges[edgeIndex] !== undefined) {
  120999. continue;
  121000. }
  121001. switch (edgeIndex) {
  121002. case 0:
  121003. if (this._checkVerticesInsteadOfIndices) {
  121004. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p0, faceAdjacencies.p1, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  121005. }
  121006. else {
  121007. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);
  121008. }
  121009. break;
  121010. case 1:
  121011. if (this._checkVerticesInsteadOfIndices) {
  121012. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p1, faceAdjacencies.p2, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  121013. }
  121014. else {
  121015. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);
  121016. }
  121017. break;
  121018. case 2:
  121019. if (this._checkVerticesInsteadOfIndices) {
  121020. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p2, faceAdjacencies.p0, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  121021. }
  121022. else {
  121023. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);
  121024. }
  121025. break;
  121026. }
  121027. if (otherEdgeIndex === -1) {
  121028. continue;
  121029. }
  121030. faceAdjacencies.edges[edgeIndex] = otherIndex;
  121031. otherFaceAdjacencies.edges[otherEdgeIndex] = index;
  121032. faceAdjacencies.edgesConnectedCount++;
  121033. otherFaceAdjacencies.edgesConnectedCount++;
  121034. if (faceAdjacencies.edgesConnectedCount === 3) {
  121035. break;
  121036. }
  121037. }
  121038. }
  121039. }
  121040. // Create lines
  121041. for (index = 0; index < adjacencies.length; index++) {
  121042. // 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
  121043. var current = adjacencies[index];
  121044. this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);
  121045. this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);
  121046. this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);
  121047. }
  121048. // Merge into a single mesh
  121049. var engine = this._source.getScene().getEngine();
  121050. 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);
  121051. 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);
  121052. this._ib = engine.createIndexBuffer(this._linesIndices);
  121053. this._indicesCount = this._linesIndices.length;
  121054. };
  121055. /**
  121056. * Checks wether or not the edges renderer is ready to render.
  121057. * @return true if ready, otherwise false.
  121058. */
  121059. EdgesRenderer.prototype.isReady = function () {
  121060. return this._lineShader.isReady();
  121061. };
  121062. /**
  121063. * Renders the edges of the attached mesh,
  121064. */
  121065. EdgesRenderer.prototype.render = function () {
  121066. var scene = this._source.getScene();
  121067. if (!this.isReady() || !scene.activeCamera) {
  121068. return;
  121069. }
  121070. var engine = scene.getEngine();
  121071. this._lineShader._preBind();
  121072. if (this._source.edgesColor.a !== 1) {
  121073. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE);
  121074. }
  121075. else {
  121076. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  121077. }
  121078. // VBOs
  121079. engine.bindBuffers(this._buffers, this._ib, this._lineShader.getEffect());
  121080. scene.resetCachedMaterial();
  121081. this._lineShader.setColor4("color", this._source.edgesColor);
  121082. if (scene.activeCamera.mode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__["Camera"].ORTHOGRAPHIC_CAMERA) {
  121083. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);
  121084. }
  121085. else {
  121086. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
  121087. }
  121088. this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
  121089. this._lineShader.bind(this._source.getWorldMatrix());
  121090. // Draw order
  121091. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, this._indicesCount);
  121092. this._lineShader.unbind();
  121093. };
  121094. return EdgesRenderer;
  121095. }());
  121096. /**
  121097. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  121098. */
  121099. var LineEdgesRenderer = /** @class */ (function (_super) {
  121100. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LineEdgesRenderer, _super);
  121101. /**
  121102. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  121103. * @param source LineMesh used to generate edges
  121104. * @param epsilon not important (specified angle for edge detection)
  121105. * @param checkVerticesInsteadOfIndices not important for LineMesh
  121106. */
  121107. function LineEdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
  121108. if (epsilon === void 0) { epsilon = 0.95; }
  121109. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  121110. var _this = _super.call(this, source, epsilon, checkVerticesInsteadOfIndices, false) || this;
  121111. _this._generateEdgesLines();
  121112. return _this;
  121113. }
  121114. /**
  121115. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  121116. */
  121117. LineEdgesRenderer.prototype._generateEdgesLines = function () {
  121118. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  121119. var indices = this._source.getIndices();
  121120. if (!indices || !positions) {
  121121. return;
  121122. }
  121123. var p0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  121124. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  121125. var len = indices.length - 1;
  121126. for (var i = 0, offset = 0; i < len; i += 2, offset += 4) {
  121127. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i], p0);
  121128. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i + 1], p1);
  121129. this.createLine(p0, p1, offset);
  121130. }
  121131. // Merge into a single mesh
  121132. var engine = this._source.getScene().getEngine();
  121133. 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);
  121134. 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);
  121135. this._ib = engine.createIndexBuffer(this._linesIndices);
  121136. this._indicesCount = this._linesIndices.length;
  121137. };
  121138. return LineEdgesRenderer;
  121139. }(EdgesRenderer));
  121140. /***/ }),
  121141. /***/ "./Rendering/geometryBufferRenderer.ts":
  121142. /*!*********************************************!*\
  121143. !*** ./Rendering/geometryBufferRenderer.ts ***!
  121144. \*********************************************/
  121145. /*! exports provided: GeometryBufferRenderer */
  121146. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121147. "use strict";
  121148. __webpack_require__.r(__webpack_exports__);
  121149. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return GeometryBufferRenderer; });
  121150. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121151. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  121152. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121153. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121154. /* harmony import */ var _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  121155. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  121156. /* harmony import */ var _Shaders_geometry_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/geometry.fragment */ "./Shaders/geometry.fragment.ts");
  121157. /* harmony import */ var _Shaders_geometry_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/geometry.vertex */ "./Shaders/geometry.vertex.ts");
  121158. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  121159. /**
  121160. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  121161. */
  121162. var GeometryBufferRenderer = /** @class */ (function () {
  121163. /**
  121164. * Creates a new G Buffer for the scene
  121165. * @param scene The scene the buffer belongs to
  121166. * @param ratio How big is the buffer related to the main canvas.
  121167. */
  121168. function GeometryBufferRenderer(scene, ratio) {
  121169. if (ratio === void 0) { ratio = 1; }
  121170. /**
  121171. * Dictionary used to store the previous transformation matrices of each rendered mesh
  121172. * in order to compute objects velocities when enableVelocity is set to "true"
  121173. * @hidden
  121174. */
  121175. this._previousTransformationMatrices = {};
  121176. this._enablePosition = false;
  121177. this._enableVelocity = false;
  121178. this._positionIndex = -1;
  121179. this._velocityIndex = -1;
  121180. this._scene = scene;
  121181. this._ratio = ratio;
  121182. GeometryBufferRenderer._SceneComponentInitialization(this._scene);
  121183. // Render target
  121184. this._createRenderTargets();
  121185. }
  121186. Object.defineProperty(GeometryBufferRenderer.prototype, "renderList", {
  121187. /**
  121188. * Set the render list (meshes to be rendered) used in the G buffer.
  121189. */
  121190. set: function (meshes) {
  121191. this._multiRenderTarget.renderList = meshes;
  121192. },
  121193. enumerable: true,
  121194. configurable: true
  121195. });
  121196. Object.defineProperty(GeometryBufferRenderer.prototype, "isSupported", {
  121197. /**
  121198. * Gets wether or not G buffer are supported by the running hardware.
  121199. * This requires draw buffer supports
  121200. */
  121201. get: function () {
  121202. return this._multiRenderTarget.isSupported;
  121203. },
  121204. enumerable: true,
  121205. configurable: true
  121206. });
  121207. /**
  121208. * Returns the index of the given texture type in the G-Buffer textures array
  121209. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  121210. * @returns the index of the given texture type in the G-Buffer textures array
  121211. */
  121212. GeometryBufferRenderer.prototype.getTextureIndex = function (textureType) {
  121213. switch (textureType) {
  121214. case GeometryBufferRenderer.POSITION_TEXTURE_TYPE: return this._positionIndex;
  121215. case GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE: return this._velocityIndex;
  121216. default: return -1;
  121217. }
  121218. };
  121219. Object.defineProperty(GeometryBufferRenderer.prototype, "enablePosition", {
  121220. /**
  121221. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  121222. */
  121223. get: function () {
  121224. return this._enablePosition;
  121225. },
  121226. /**
  121227. * Sets whether or not objects positions are enabled for the G buffer.
  121228. */
  121229. set: function (enable) {
  121230. this._enablePosition = enable;
  121231. this.dispose();
  121232. this._createRenderTargets();
  121233. },
  121234. enumerable: true,
  121235. configurable: true
  121236. });
  121237. Object.defineProperty(GeometryBufferRenderer.prototype, "enableVelocity", {
  121238. /**
  121239. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  121240. */
  121241. get: function () {
  121242. return this._enableVelocity;
  121243. },
  121244. /**
  121245. * Sets wether or not objects velocities are enabled for the G buffer.
  121246. */
  121247. set: function (enable) {
  121248. this._enableVelocity = enable;
  121249. this.dispose();
  121250. this._createRenderTargets();
  121251. },
  121252. enumerable: true,
  121253. configurable: true
  121254. });
  121255. Object.defineProperty(GeometryBufferRenderer.prototype, "scene", {
  121256. /**
  121257. * Gets the scene associated with the buffer.
  121258. */
  121259. get: function () {
  121260. return this._scene;
  121261. },
  121262. enumerable: true,
  121263. configurable: true
  121264. });
  121265. Object.defineProperty(GeometryBufferRenderer.prototype, "ratio", {
  121266. /**
  121267. * Gets the ratio used by the buffer during its creation.
  121268. * How big is the buffer related to the main canvas.
  121269. */
  121270. get: function () {
  121271. return this._ratio;
  121272. },
  121273. enumerable: true,
  121274. configurable: true
  121275. });
  121276. /**
  121277. * Checks wether everything is ready to render a submesh to the G buffer.
  121278. * @param subMesh the submesh to check readiness for
  121279. * @param useInstances is the mesh drawn using instance or not
  121280. * @returns true if ready otherwise false
  121281. */
  121282. GeometryBufferRenderer.prototype.isReady = function (subMesh, useInstances) {
  121283. var material = subMesh.getMaterial();
  121284. if (material && material.disableDepthWrite) {
  121285. return false;
  121286. }
  121287. var defines = [];
  121288. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  121289. var mesh = subMesh.getMesh();
  121290. // Alpha test
  121291. if (material && material.needAlphaTesting()) {
  121292. defines.push("#define ALPHATEST");
  121293. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  121294. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  121295. defines.push("#define UV1");
  121296. }
  121297. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  121298. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  121299. defines.push("#define UV2");
  121300. }
  121301. }
  121302. // Buffers
  121303. if (this._enablePosition) {
  121304. defines.push("#define POSITION");
  121305. defines.push("#define POSITION_INDEX " + this._positionIndex);
  121306. }
  121307. if (this._enableVelocity) {
  121308. defines.push("#define VELOCITY");
  121309. defines.push("#define VELOCITY_INDEX " + this._velocityIndex);
  121310. }
  121311. // Bones
  121312. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  121313. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  121314. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  121315. if (mesh.numBoneInfluencers > 4) {
  121316. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  121317. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  121318. }
  121319. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  121320. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  121321. }
  121322. else {
  121323. defines.push("#define NUM_BONE_INFLUENCERS 0");
  121324. }
  121325. // Instances
  121326. if (useInstances) {
  121327. defines.push("#define INSTANCES");
  121328. attribs.push("world0");
  121329. attribs.push("world1");
  121330. attribs.push("world2");
  121331. attribs.push("world3");
  121332. }
  121333. // Setup textures count
  121334. defines.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  121335. // Get correct effect
  121336. var join = defines.join("\n");
  121337. if (this._cachedDefines !== join) {
  121338. this._cachedDefines = join;
  121339. this._effect = this._scene.getEngine().createEffect("geometry", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorldViewProjection"], ["diffuseSampler"], join, undefined, undefined, undefined, { buffersCount: this._enablePosition ? 3 : 2 });
  121340. }
  121341. return this._effect.isReady();
  121342. };
  121343. /**
  121344. * Gets the current underlying G Buffer.
  121345. * @returns the buffer
  121346. */
  121347. GeometryBufferRenderer.prototype.getGBuffer = function () {
  121348. return this._multiRenderTarget;
  121349. };
  121350. Object.defineProperty(GeometryBufferRenderer.prototype, "samples", {
  121351. /**
  121352. * Gets the number of samples used to render the buffer (anti aliasing).
  121353. */
  121354. get: function () {
  121355. return this._multiRenderTarget.samples;
  121356. },
  121357. /**
  121358. * Sets the number of samples used to render the buffer (anti aliasing).
  121359. */
  121360. set: function (value) {
  121361. this._multiRenderTarget.samples = value;
  121362. },
  121363. enumerable: true,
  121364. configurable: true
  121365. });
  121366. /**
  121367. * Disposes the renderer and frees up associated resources.
  121368. */
  121369. GeometryBufferRenderer.prototype.dispose = function () {
  121370. this.getGBuffer().dispose();
  121371. };
  121372. GeometryBufferRenderer.prototype._createRenderTargets = function () {
  121373. var _this = this;
  121374. var engine = this._scene.getEngine();
  121375. var count = 2;
  121376. if (this._enablePosition) {
  121377. this._positionIndex = count;
  121378. count++;
  121379. }
  121380. if (this._enableVelocity) {
  121381. this._velocityIndex = count;
  121382. count++;
  121383. }
  121384. 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 });
  121385. if (!this.isSupported) {
  121386. return;
  121387. }
  121388. this._multiRenderTarget.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  121389. this._multiRenderTarget.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  121390. this._multiRenderTarget.refreshRate = 1;
  121391. this._multiRenderTarget.renderParticles = false;
  121392. this._multiRenderTarget.renderList = null;
  121393. // set default depth value to 1.0 (far away)
  121394. this._multiRenderTarget.onClearObservable.add(function (engine) {
  121395. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0.0, 0.0, 0.0, 1.0), true, true, true);
  121396. });
  121397. // Custom render function
  121398. var renderSubMesh = function (subMesh) {
  121399. var mesh = subMesh.getRenderingMesh();
  121400. var scene = _this._scene;
  121401. var engine = scene.getEngine();
  121402. var material = subMesh.getMaterial();
  121403. if (!material) {
  121404. return;
  121405. }
  121406. // Velocity
  121407. if (!_this._previousTransformationMatrices[mesh.uniqueId]) {
  121408. _this._previousTransformationMatrices[mesh.uniqueId] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  121409. }
  121410. // Culling
  121411. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  121412. // Managing instances
  121413. var batch = mesh._getInstancesRenderList(subMesh._id);
  121414. if (batch.mustReturn) {
  121415. return;
  121416. }
  121417. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  121418. if (_this.isReady(subMesh, hardwareInstancedRendering)) {
  121419. engine.enableEffect(_this._effect);
  121420. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  121421. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  121422. _this._effect.setMatrix("view", scene.getViewMatrix());
  121423. // Alpha test
  121424. if (material && material.needAlphaTesting()) {
  121425. var alphaTexture = material.getAlphaTestTexture();
  121426. if (alphaTexture) {
  121427. _this._effect.setTexture("diffuseSampler", alphaTexture);
  121428. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  121429. }
  121430. }
  121431. // Bones
  121432. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  121433. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  121434. }
  121435. // Velocity
  121436. _this._effect.setMatrix("previousWorldViewProjection", _this._previousTransformationMatrices[mesh.uniqueId]);
  121437. // Draw
  121438. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  121439. }
  121440. // Velocity
  121441. _this._previousTransformationMatrices[mesh.uniqueId] = mesh.getWorldMatrix().multiply(_this._scene.getTransformMatrix());
  121442. };
  121443. this._multiRenderTarget.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  121444. var index;
  121445. if (depthOnlySubMeshes.length) {
  121446. engine.setColorWrite(false);
  121447. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  121448. renderSubMesh(depthOnlySubMeshes.data[index]);
  121449. }
  121450. engine.setColorWrite(true);
  121451. }
  121452. for (index = 0; index < opaqueSubMeshes.length; index++) {
  121453. renderSubMesh(opaqueSubMeshes.data[index]);
  121454. }
  121455. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  121456. renderSubMesh(alphaTestSubMeshes.data[index]);
  121457. }
  121458. };
  121459. };
  121460. /**
  121461. * Constant used to retrieve the position texture index in the G-Buffer textures array
  121462. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  121463. */
  121464. GeometryBufferRenderer.POSITION_TEXTURE_TYPE = 1;
  121465. /**
  121466. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  121467. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  121468. */
  121469. GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE = 2;
  121470. /** @hidden */
  121471. GeometryBufferRenderer._SceneComponentInitialization = function (_) {
  121472. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("GeometryBufferRendererSceneComponent");
  121473. };
  121474. return GeometryBufferRenderer;
  121475. }());
  121476. /***/ }),
  121477. /***/ "./Rendering/geometryBufferRendererSceneComponent.ts":
  121478. /*!***********************************************************!*\
  121479. !*** ./Rendering/geometryBufferRendererSceneComponent.ts ***!
  121480. \***********************************************************/
  121481. /*! exports provided: GeometryBufferRendererSceneComponent */
  121482. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121483. "use strict";
  121484. __webpack_require__.r(__webpack_exports__);
  121485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return GeometryBufferRendererSceneComponent; });
  121486. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  121487. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  121488. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  121489. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "geometryBufferRenderer", {
  121490. get: function () {
  121491. this._geometryBufferRenderer;
  121492. },
  121493. set: function (value) {
  121494. if (value && value.isSupported) {
  121495. this._geometryBufferRenderer = value;
  121496. }
  121497. },
  121498. enumerable: true,
  121499. configurable: true
  121500. });
  121501. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableGeometryBufferRenderer = function (ratio) {
  121502. if (ratio === void 0) { ratio = 1; }
  121503. if (this._geometryBufferRenderer) {
  121504. return this._geometryBufferRenderer;
  121505. }
  121506. this._geometryBufferRenderer = new _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"](this, ratio);
  121507. if (!this._geometryBufferRenderer.isSupported) {
  121508. this._geometryBufferRenderer = null;
  121509. }
  121510. return this._geometryBufferRenderer;
  121511. };
  121512. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableGeometryBufferRenderer = function () {
  121513. if (!this._geometryBufferRenderer) {
  121514. return;
  121515. }
  121516. this._geometryBufferRenderer.dispose();
  121517. this._geometryBufferRenderer = null;
  121518. };
  121519. /**
  121520. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  121521. * in several rendering techniques.
  121522. */
  121523. var GeometryBufferRendererSceneComponent = /** @class */ (function () {
  121524. /**
  121525. * Creates a new instance of the component for the given scene
  121526. * @param scene Defines the scene to register the component in
  121527. */
  121528. function GeometryBufferRendererSceneComponent(scene) {
  121529. /**
  121530. * The component name helpful to identify the component in the list of scene components.
  121531. */
  121532. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER;
  121533. this.scene = scene;
  121534. }
  121535. /**
  121536. * Registers the component in a given scene
  121537. */
  121538. GeometryBufferRendererSceneComponent.prototype.register = function () {
  121539. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
  121540. };
  121541. /**
  121542. * Rebuilds the elements related to this component in case of
  121543. * context lost for instance.
  121544. */
  121545. GeometryBufferRendererSceneComponent.prototype.rebuild = function () {
  121546. // Nothing to do for this component
  121547. };
  121548. /**
  121549. * Disposes the component and the associated ressources
  121550. */
  121551. GeometryBufferRendererSceneComponent.prototype.dispose = function () {
  121552. // Nothing to do for this component
  121553. };
  121554. GeometryBufferRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  121555. if (this.scene._geometryBufferRenderer) {
  121556. renderTargets.push(this.scene._geometryBufferRenderer.getGBuffer());
  121557. }
  121558. };
  121559. return GeometryBufferRendererSceneComponent;
  121560. }());
  121561. _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"]._SceneComponentInitialization = function (scene) {
  121562. // Register the G Buffer component to the scene.
  121563. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER);
  121564. if (!component) {
  121565. component = new GeometryBufferRendererSceneComponent(scene);
  121566. scene._addComponent(component);
  121567. }
  121568. };
  121569. /***/ }),
  121570. /***/ "./Rendering/index.ts":
  121571. /*!****************************!*\
  121572. !*** ./Rendering/index.ts ***!
  121573. \****************************/
  121574. /*! exports provided: BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer */
  121575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121576. "use strict";
  121577. __webpack_require__.r(__webpack_exports__);
  121578. /* harmony import */ var _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBoxRenderer */ "./Rendering/boundingBoxRenderer.ts");
  121579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  121580. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  121581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]; });
  121582. /* harmony import */ var _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./depthRendererSceneComponent */ "./Rendering/depthRendererSceneComponent.ts");
  121583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__["DepthRendererSceneComponent"]; });
  121584. /* harmony import */ var _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edgesRenderer */ "./Rendering/edgesRenderer.ts");
  121585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["EdgesRenderer"]; });
  121586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["LineEdgesRenderer"]; });
  121587. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  121588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__["GeometryBufferRenderer"]; });
  121589. /* harmony import */ var _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  121590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRendererSceneComponent"]; });
  121591. /* harmony import */ var _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./outlineRenderer */ "./Rendering/outlineRenderer.ts");
  121592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__["OutlineRenderer"]; });
  121593. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  121594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _renderingGroup__WEBPACK_IMPORTED_MODULE_7__["RenderingGroup"]; });
  121595. /* harmony import */ var _renderingManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderingManager */ "./Rendering/renderingManager.ts");
  121596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingGroupInfo"]; });
  121597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingManager"]; });
  121598. /* harmony import */ var _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  121599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"]; });
  121600. /***/ }),
  121601. /***/ "./Rendering/outlineRenderer.ts":
  121602. /*!**************************************!*\
  121603. !*** ./Rendering/outlineRenderer.ts ***!
  121604. \**************************************/
  121605. /*! exports provided: OutlineRenderer */
  121606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121607. "use strict";
  121608. __webpack_require__.r(__webpack_exports__);
  121609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return OutlineRenderer; });
  121610. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  121611. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  121612. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  121613. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121614. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  121615. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  121616. /* harmony import */ var _Shaders_outline_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/outline.fragment */ "./Shaders/outline.fragment.ts");
  121617. /* harmony import */ var _Shaders_outline_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/outline.vertex */ "./Shaders/outline.vertex.ts");
  121618. /**
  121619. * Gets the outline renderer associated with the scene
  121620. * @returns a OutlineRenderer
  121621. */
  121622. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype.getOutlineRenderer = function () {
  121623. if (!this._outlineRenderer) {
  121624. this._outlineRenderer = new OutlineRenderer(this);
  121625. }
  121626. return this._outlineRenderer;
  121627. };
  121628. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOutline", {
  121629. get: function () {
  121630. return this._renderOutline;
  121631. },
  121632. set: function (value) {
  121633. if (value) {
  121634. // Lazy Load the component.
  121635. this.getScene().getOutlineRenderer();
  121636. }
  121637. this._renderOutline = value;
  121638. },
  121639. enumerable: true,
  121640. configurable: true
  121641. });
  121642. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOverlay", {
  121643. get: function () {
  121644. return this._renderOverlay;
  121645. },
  121646. set: function (value) {
  121647. if (value) {
  121648. // Lazy Load the component.
  121649. this.getScene().getOutlineRenderer();
  121650. }
  121651. this._renderOverlay = value;
  121652. },
  121653. enumerable: true,
  121654. configurable: true
  121655. });
  121656. /**
  121657. * This class is responsible to draw bothe outline/overlay of meshes.
  121658. * It should not be used directly but through the available method on mesh.
  121659. */
  121660. var OutlineRenderer = /** @class */ (function () {
  121661. /**
  121662. * Instantiates a new outline renderer. (There could be only one per scene).
  121663. * @param scene Defines the scene it belongs to
  121664. */
  121665. function OutlineRenderer(scene) {
  121666. /**
  121667. * The name of the component. Each component must have a unique name.
  121668. */
  121669. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OUTLINERENDERER;
  121670. /**
  121671. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  121672. */
  121673. this.zOffset = 1;
  121674. this.scene = scene;
  121675. this._engine = scene.getEngine();
  121676. this.scene._addComponent(this);
  121677. }
  121678. /**
  121679. * Register the component to one instance of a scene.
  121680. */
  121681. OutlineRenderer.prototype.register = function () {
  121682. this.scene._beforeRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh);
  121683. this.scene._afterRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
  121684. };
  121685. /**
  121686. * Rebuilds the elements related to this component in case of
  121687. * context lost for instance.
  121688. */
  121689. OutlineRenderer.prototype.rebuild = function () {
  121690. // Nothing to do here.
  121691. };
  121692. /**
  121693. * Disposes the component and the associated ressources.
  121694. */
  121695. OutlineRenderer.prototype.dispose = function () {
  121696. // Nothing to do here.
  121697. };
  121698. /**
  121699. * Renders the outline in the canvas.
  121700. * @param subMesh Defines the sumesh to render
  121701. * @param batch Defines the batch of meshes in case of instances
  121702. * @param useOverlay Defines if the rendering is for the overlay or the outline
  121703. */
  121704. OutlineRenderer.prototype.render = function (subMesh, batch, useOverlay) {
  121705. var _this = this;
  121706. if (useOverlay === void 0) { useOverlay = false; }
  121707. var scene = this.scene;
  121708. var engine = scene.getEngine();
  121709. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  121710. if (!this.isReady(subMesh, hardwareInstancedRendering)) {
  121711. return;
  121712. }
  121713. var mesh = subMesh.getRenderingMesh();
  121714. var material = subMesh.getMaterial();
  121715. if (!material || !scene.activeCamera) {
  121716. return;
  121717. }
  121718. engine.enableEffect(this._effect);
  121719. // Logarithmic depth
  121720. if (material.useLogarithmicDepth) {
  121721. this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  121722. }
  121723. this._effect.setFloat("offset", useOverlay ? 0 : mesh.outlineWidth);
  121724. this._effect.setColor4("color", useOverlay ? mesh.overlayColor : mesh.outlineColor, useOverlay ? mesh.overlayAlpha : material.alpha);
  121725. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  121726. // Bones
  121727. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  121728. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  121729. }
  121730. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  121731. // Alpha test
  121732. if (material && material.needAlphaTesting()) {
  121733. var alphaTexture = material.getAlphaTestTexture();
  121734. if (alphaTexture) {
  121735. this._effect.setTexture("diffuseSampler", alphaTexture);
  121736. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  121737. }
  121738. }
  121739. engine.setZOffset(-this.zOffset);
  121740. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
  121741. engine.setZOffset(0);
  121742. };
  121743. /**
  121744. * Returns whether or not the outline renderer is ready for a given submesh.
  121745. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  121746. * @param subMesh Defines the submesh to check readyness for
  121747. * @param useInstances Defines wheter wee are trying to render instances or not
  121748. * @returns true if ready otherwise false
  121749. */
  121750. OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
  121751. var defines = [];
  121752. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind];
  121753. var mesh = subMesh.getMesh();
  121754. var material = subMesh.getMaterial();
  121755. if (material) {
  121756. // Alpha test
  121757. if (material.needAlphaTesting()) {
  121758. defines.push("#define ALPHATEST");
  121759. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind)) {
  121760. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  121761. defines.push("#define UV1");
  121762. }
  121763. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind)) {
  121764. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  121765. defines.push("#define UV2");
  121766. }
  121767. }
  121768. //Logarithmic depth
  121769. if (material.useLogarithmicDepth) {
  121770. defines.push("#define LOGARITHMICDEPTH");
  121771. }
  121772. }
  121773. // Bones
  121774. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  121775. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  121776. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  121777. if (mesh.numBoneInfluencers > 4) {
  121778. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  121779. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  121780. }
  121781. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  121782. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  121783. }
  121784. else {
  121785. defines.push("#define NUM_BONE_INFLUENCERS 0");
  121786. }
  121787. // Instances
  121788. if (useInstances) {
  121789. defines.push("#define INSTANCES");
  121790. attribs.push("world0");
  121791. attribs.push("world1");
  121792. attribs.push("world2");
  121793. attribs.push("world3");
  121794. }
  121795. // Get correct effect
  121796. var join = defines.join("\n");
  121797. if (this._cachedDefines !== join) {
  121798. this._cachedDefines = join;
  121799. this._effect = this.scene.getEngine().createEffect("outline", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant"], ["diffuseSampler"], join);
  121800. }
  121801. return this._effect.isReady();
  121802. };
  121803. OutlineRenderer.prototype._beforeRenderingMesh = function (mesh, subMesh, batch) {
  121804. // Outline - step 1
  121805. this._savedDepthWrite = this._engine.getDepthWrite();
  121806. if (mesh.renderOutline) {
  121807. this._engine.setDepthWrite(false);
  121808. this.render(subMesh, batch);
  121809. this._engine.setDepthWrite(this._savedDepthWrite);
  121810. }
  121811. };
  121812. OutlineRenderer.prototype._afterRenderingMesh = function (mesh, subMesh, batch) {
  121813. // Outline - step 2
  121814. if (mesh.renderOutline && this._savedDepthWrite) {
  121815. this._engine.setDepthWrite(true);
  121816. this._engine.setColorWrite(false);
  121817. this.render(subMesh, batch);
  121818. this._engine.setColorWrite(true);
  121819. }
  121820. // Overlay
  121821. if (mesh.renderOverlay) {
  121822. var currentMode = this._engine.getAlphaMode();
  121823. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_COMBINE);
  121824. this.render(subMesh, batch, true);
  121825. this._engine.setAlphaMode(currentMode);
  121826. }
  121827. };
  121828. return OutlineRenderer;
  121829. }());
  121830. /***/ }),
  121831. /***/ "./Rendering/renderingGroup.ts":
  121832. /*!*************************************!*\
  121833. !*** ./Rendering/renderingGroup.ts ***!
  121834. \*************************************/
  121835. /*! exports provided: RenderingGroup */
  121836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121837. "use strict";
  121838. __webpack_require__.r(__webpack_exports__);
  121839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return RenderingGroup; });
  121840. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  121841. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121842. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121843. /**
  121844. * This represents the object necessary to create a rendering group.
  121845. * This is exclusively used and created by the rendering manager.
  121846. * To modify the behavior, you use the available helpers in your scene or meshes.
  121847. * @hidden
  121848. */
  121849. var RenderingGroup = /** @class */ (function () {
  121850. /**
  121851. * Creates a new rendering group.
  121852. * @param index The rendering group index
  121853. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  121854. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  121855. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  121856. */
  121857. function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  121858. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  121859. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  121860. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  121861. this.index = index;
  121862. this._opaqueSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121863. this._transparentSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121864. this._alphaTestSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121865. this._depthOnlySubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121866. this._particleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121867. this._spriteManagers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  121868. this._edgesRenderers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  121869. this._scene = scene;
  121870. this.opaqueSortCompareFn = opaqueSortCompareFn;
  121871. this.alphaTestSortCompareFn = alphaTestSortCompareFn;
  121872. this.transparentSortCompareFn = transparentSortCompareFn;
  121873. }
  121874. Object.defineProperty(RenderingGroup.prototype, "opaqueSortCompareFn", {
  121875. /**
  121876. * Set the opaque sort comparison function.
  121877. * If null the sub meshes will be render in the order they were created
  121878. */
  121879. set: function (value) {
  121880. this._opaqueSortCompareFn = value;
  121881. if (value) {
  121882. this._renderOpaque = this.renderOpaqueSorted;
  121883. }
  121884. else {
  121885. this._renderOpaque = RenderingGroup.renderUnsorted;
  121886. }
  121887. },
  121888. enumerable: true,
  121889. configurable: true
  121890. });
  121891. Object.defineProperty(RenderingGroup.prototype, "alphaTestSortCompareFn", {
  121892. /**
  121893. * Set the alpha test sort comparison function.
  121894. * If null the sub meshes will be render in the order they were created
  121895. */
  121896. set: function (value) {
  121897. this._alphaTestSortCompareFn = value;
  121898. if (value) {
  121899. this._renderAlphaTest = this.renderAlphaTestSorted;
  121900. }
  121901. else {
  121902. this._renderAlphaTest = RenderingGroup.renderUnsorted;
  121903. }
  121904. },
  121905. enumerable: true,
  121906. configurable: true
  121907. });
  121908. Object.defineProperty(RenderingGroup.prototype, "transparentSortCompareFn", {
  121909. /**
  121910. * Set the transparent sort comparison function.
  121911. * If null the sub meshes will be render in the order they were created
  121912. */
  121913. set: function (value) {
  121914. if (value) {
  121915. this._transparentSortCompareFn = value;
  121916. }
  121917. else {
  121918. this._transparentSortCompareFn = RenderingGroup.defaultTransparentSortCompare;
  121919. }
  121920. this._renderTransparent = this.renderTransparentSorted;
  121921. },
  121922. enumerable: true,
  121923. configurable: true
  121924. });
  121925. /**
  121926. * Render all the sub meshes contained in the group.
  121927. * @param customRenderFunction Used to override the default render behaviour of the group.
  121928. * @returns true if rendered some submeshes.
  121929. */
  121930. RenderingGroup.prototype.render = function (customRenderFunction, renderSprites, renderParticles, activeMeshes) {
  121931. if (customRenderFunction) {
  121932. customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  121933. return;
  121934. }
  121935. var engine = this._scene.getEngine();
  121936. // Depth only
  121937. if (this._depthOnlySubMeshes.length !== 0) {
  121938. engine.setColorWrite(false);
  121939. this._renderAlphaTest(this._depthOnlySubMeshes);
  121940. engine.setColorWrite(true);
  121941. }
  121942. // Opaque
  121943. if (this._opaqueSubMeshes.length !== 0) {
  121944. this._renderOpaque(this._opaqueSubMeshes);
  121945. }
  121946. // Alpha test
  121947. if (this._alphaTestSubMeshes.length !== 0) {
  121948. this._renderAlphaTest(this._alphaTestSubMeshes);
  121949. }
  121950. var stencilState = engine.getStencilBuffer();
  121951. engine.setStencilBuffer(false);
  121952. // Sprites
  121953. if (renderSprites) {
  121954. this._renderSprites();
  121955. }
  121956. // Particles
  121957. if (renderParticles) {
  121958. this._renderParticles(activeMeshes);
  121959. }
  121960. if (this.onBeforeTransparentRendering) {
  121961. this.onBeforeTransparentRendering();
  121962. }
  121963. // Transparent
  121964. if (this._transparentSubMeshes.length !== 0) {
  121965. this._renderTransparent(this._transparentSubMeshes);
  121966. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  121967. }
  121968. // Set back stencil to false in case it changes before the edge renderer.
  121969. engine.setStencilBuffer(false);
  121970. // Edges
  121971. if (this._edgesRenderers.length) {
  121972. for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
  121973. this._edgesRenderers.data[edgesRendererIndex].render();
  121974. }
  121975. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  121976. }
  121977. // Restore Stencil state.
  121978. engine.setStencilBuffer(stencilState);
  121979. };
  121980. /**
  121981. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  121982. * @param subMeshes The submeshes to render
  121983. */
  121984. RenderingGroup.prototype.renderOpaqueSorted = function (subMeshes) {
  121985. return RenderingGroup.renderSorted(subMeshes, this._opaqueSortCompareFn, this._scene.activeCamera, false);
  121986. };
  121987. /**
  121988. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  121989. * @param subMeshes The submeshes to render
  121990. */
  121991. RenderingGroup.prototype.renderAlphaTestSorted = function (subMeshes) {
  121992. return RenderingGroup.renderSorted(subMeshes, this._alphaTestSortCompareFn, this._scene.activeCamera, false);
  121993. };
  121994. /**
  121995. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  121996. * @param subMeshes The submeshes to render
  121997. */
  121998. RenderingGroup.prototype.renderTransparentSorted = function (subMeshes) {
  121999. return RenderingGroup.renderSorted(subMeshes, this._transparentSortCompareFn, this._scene.activeCamera, true);
  122000. };
  122001. /**
  122002. * Renders the submeshes in a specified order.
  122003. * @param subMeshes The submeshes to sort before render
  122004. * @param sortCompareFn The comparison function use to sort
  122005. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  122006. * @param transparent Specifies to activate blending if true
  122007. */
  122008. RenderingGroup.renderSorted = function (subMeshes, sortCompareFn, camera, transparent) {
  122009. var subIndex = 0;
  122010. var subMesh;
  122011. var cameraPosition = camera ? camera.globalPosition : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  122012. for (; subIndex < subMeshes.length; subIndex++) {
  122013. subMesh = subMeshes.data[subIndex];
  122014. subMesh._alphaIndex = subMesh.getMesh().alphaIndex;
  122015. subMesh._distanceToCamera = subMesh.getBoundingInfo().boundingSphere.centerWorld.subtract(cameraPosition).length();
  122016. }
  122017. var sortedArray = subMeshes.data.slice(0, subMeshes.length);
  122018. if (sortCompareFn) {
  122019. sortedArray.sort(sortCompareFn);
  122020. }
  122021. for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
  122022. subMesh = sortedArray[subIndex];
  122023. if (transparent) {
  122024. var material = subMesh.getMaterial();
  122025. if (material && material.needDepthPrePass) {
  122026. var engine = material.getScene().getEngine();
  122027. engine.setColorWrite(false);
  122028. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  122029. subMesh.render(false);
  122030. engine.setColorWrite(true);
  122031. }
  122032. }
  122033. subMesh.render(transparent);
  122034. }
  122035. };
  122036. /**
  122037. * Renders the submeshes in the order they were dispatched (no sort applied).
  122038. * @param subMeshes The submeshes to render
  122039. */
  122040. RenderingGroup.renderUnsorted = function (subMeshes) {
  122041. for (var subIndex = 0; subIndex < subMeshes.length; subIndex++) {
  122042. var submesh = subMeshes.data[subIndex];
  122043. submesh.render(false);
  122044. }
  122045. };
  122046. /**
  122047. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  122048. * are rendered back to front if in the same alpha index.
  122049. *
  122050. * @param a The first submesh
  122051. * @param b The second submesh
  122052. * @returns The result of the comparison
  122053. */
  122054. RenderingGroup.defaultTransparentSortCompare = function (a, b) {
  122055. // Alpha index first
  122056. if (a._alphaIndex > b._alphaIndex) {
  122057. return 1;
  122058. }
  122059. if (a._alphaIndex < b._alphaIndex) {
  122060. return -1;
  122061. }
  122062. // Then distance to camera
  122063. return RenderingGroup.backToFrontSortCompare(a, b);
  122064. };
  122065. /**
  122066. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  122067. * are rendered back to front.
  122068. *
  122069. * @param a The first submesh
  122070. * @param b The second submesh
  122071. * @returns The result of the comparison
  122072. */
  122073. RenderingGroup.backToFrontSortCompare = function (a, b) {
  122074. // Then distance to camera
  122075. if (a._distanceToCamera < b._distanceToCamera) {
  122076. return 1;
  122077. }
  122078. if (a._distanceToCamera > b._distanceToCamera) {
  122079. return -1;
  122080. }
  122081. return 0;
  122082. };
  122083. /**
  122084. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  122085. * are rendered front to back (prevent overdraw).
  122086. *
  122087. * @param a The first submesh
  122088. * @param b The second submesh
  122089. * @returns The result of the comparison
  122090. */
  122091. RenderingGroup.frontToBackSortCompare = function (a, b) {
  122092. // Then distance to camera
  122093. if (a._distanceToCamera < b._distanceToCamera) {
  122094. return -1;
  122095. }
  122096. if (a._distanceToCamera > b._distanceToCamera) {
  122097. return 1;
  122098. }
  122099. return 0;
  122100. };
  122101. /**
  122102. * Resets the different lists of submeshes to prepare a new frame.
  122103. */
  122104. RenderingGroup.prototype.prepare = function () {
  122105. this._opaqueSubMeshes.reset();
  122106. this._transparentSubMeshes.reset();
  122107. this._alphaTestSubMeshes.reset();
  122108. this._depthOnlySubMeshes.reset();
  122109. this._particleSystems.reset();
  122110. this._spriteManagers.reset();
  122111. this._edgesRenderers.reset();
  122112. };
  122113. RenderingGroup.prototype.dispose = function () {
  122114. this._opaqueSubMeshes.dispose();
  122115. this._transparentSubMeshes.dispose();
  122116. this._alphaTestSubMeshes.dispose();
  122117. this._depthOnlySubMeshes.dispose();
  122118. this._particleSystems.dispose();
  122119. this._spriteManagers.dispose();
  122120. this._edgesRenderers.dispose();
  122121. };
  122122. /**
  122123. * Inserts the submesh in its correct queue depending on its material.
  122124. * @param subMesh The submesh to dispatch
  122125. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  122126. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  122127. */
  122128. RenderingGroup.prototype.dispatch = function (subMesh, mesh, material) {
  122129. // Get mesh and materials if not provided
  122130. if (mesh === undefined) {
  122131. mesh = subMesh.getMesh();
  122132. }
  122133. if (material === undefined) {
  122134. material = subMesh.getMaterial();
  122135. }
  122136. if (material === null || material === undefined) {
  122137. return;
  122138. }
  122139. if (material.needAlphaBlendingForMesh(mesh)) { // Transparent
  122140. this._transparentSubMeshes.push(subMesh);
  122141. }
  122142. else if (material.needAlphaTesting()) { // Alpha test
  122143. if (material.needDepthPrePass) {
  122144. this._depthOnlySubMeshes.push(subMesh);
  122145. }
  122146. this._alphaTestSubMeshes.push(subMesh);
  122147. }
  122148. else {
  122149. if (material.needDepthPrePass) {
  122150. this._depthOnlySubMeshes.push(subMesh);
  122151. }
  122152. this._opaqueSubMeshes.push(subMesh); // Opaque
  122153. }
  122154. if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
  122155. this._edgesRenderers.push(mesh._edgesRenderer);
  122156. }
  122157. };
  122158. RenderingGroup.prototype.dispatchSprites = function (spriteManager) {
  122159. this._spriteManagers.push(spriteManager);
  122160. };
  122161. RenderingGroup.prototype.dispatchParticles = function (particleSystem) {
  122162. this._particleSystems.push(particleSystem);
  122163. };
  122164. RenderingGroup.prototype._renderParticles = function (activeMeshes) {
  122165. if (this._particleSystems.length === 0) {
  122166. return;
  122167. }
  122168. // Particles
  122169. var activeCamera = this._scene.activeCamera;
  122170. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  122171. for (var particleIndex = 0; particleIndex < this._particleSystems.length; particleIndex++) {
  122172. var particleSystem = this._particleSystems.data[particleIndex];
  122173. if ((activeCamera && activeCamera.layerMask & particleSystem.layerMask) === 0) {
  122174. continue;
  122175. }
  122176. var emitter = particleSystem.emitter;
  122177. if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
  122178. this._scene._activeParticles.addCount(particleSystem.render(), false);
  122179. }
  122180. }
  122181. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
  122182. };
  122183. RenderingGroup.prototype._renderSprites = function () {
  122184. if (!this._scene.spritesEnabled || this._spriteManagers.length === 0) {
  122185. return;
  122186. }
  122187. // Sprites
  122188. var activeCamera = this._scene.activeCamera;
  122189. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  122190. for (var id = 0; id < this._spriteManagers.length; id++) {
  122191. var spriteManager = this._spriteManagers.data[id];
  122192. if (((activeCamera && activeCamera.layerMask & spriteManager.layerMask) !== 0)) {
  122193. spriteManager.render();
  122194. }
  122195. }
  122196. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
  122197. };
  122198. return RenderingGroup;
  122199. }());
  122200. /***/ }),
  122201. /***/ "./Rendering/renderingManager.ts":
  122202. /*!***************************************!*\
  122203. !*** ./Rendering/renderingManager.ts ***!
  122204. \***************************************/
  122205. /*! exports provided: RenderingGroupInfo, RenderingManager */
  122206. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122207. "use strict";
  122208. __webpack_require__.r(__webpack_exports__);
  122209. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return RenderingGroupInfo; });
  122210. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return RenderingManager; });
  122211. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  122212. /**
  122213. * This class is used by the onRenderingGroupObservable
  122214. */
  122215. var RenderingGroupInfo = /** @class */ (function () {
  122216. function RenderingGroupInfo() {
  122217. }
  122218. return RenderingGroupInfo;
  122219. }());
  122220. /**
  122221. * This is the manager responsible of all the rendering for meshes sprites and particles.
  122222. * It is enable to manage the different groups as well as the different necessary sort functions.
  122223. * This should not be used directly aside of the few static configurations
  122224. */
  122225. var RenderingManager = /** @class */ (function () {
  122226. /**
  122227. * Instantiates a new rendering group for a particular scene
  122228. * @param scene Defines the scene the groups belongs to
  122229. */
  122230. function RenderingManager(scene) {
  122231. /**
  122232. * @hidden
  122233. */
  122234. this._useSceneAutoClearSetup = false;
  122235. this._renderingGroups = new Array();
  122236. this._autoClearDepthStencil = {};
  122237. this._customOpaqueSortCompareFn = {};
  122238. this._customAlphaTestSortCompareFn = {};
  122239. this._customTransparentSortCompareFn = {};
  122240. this._renderingGroupInfo = new RenderingGroupInfo();
  122241. this._scene = scene;
  122242. for (var i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
  122243. this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
  122244. }
  122245. }
  122246. RenderingManager.prototype._clearDepthStencilBuffer = function (depth, stencil) {
  122247. if (depth === void 0) { depth = true; }
  122248. if (stencil === void 0) { stencil = true; }
  122249. if (this._depthStencilBufferAlreadyCleaned) {
  122250. return;
  122251. }
  122252. this._scene.getEngine().clear(null, false, depth, stencil);
  122253. this._depthStencilBufferAlreadyCleaned = true;
  122254. };
  122255. /**
  122256. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  122257. * @hidden
  122258. */
  122259. RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
  122260. // Update the observable context (not null as it only goes away on dispose)
  122261. var info = this._renderingGroupInfo;
  122262. info.scene = this._scene;
  122263. info.camera = this._scene.activeCamera;
  122264. // Dispatch sprites
  122265. if (this._scene.spriteManagers && renderSprites) {
  122266. for (var index = 0; index < this._scene.spriteManagers.length; index++) {
  122267. var manager = this._scene.spriteManagers[index];
  122268. this.dispatchSprites(manager);
  122269. }
  122270. }
  122271. // Render
  122272. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  122273. this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;
  122274. var renderingGroup = this._renderingGroups[index];
  122275. if (!renderingGroup) {
  122276. continue;
  122277. }
  122278. var renderingGroupMask = Math.pow(2, index);
  122279. info.renderingGroupId = index;
  122280. // Before Observable
  122281. this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  122282. // Clear depth/stencil if needed
  122283. if (RenderingManager.AUTOCLEAR) {
  122284. var autoClear = this._useSceneAutoClearSetup ?
  122285. this._scene.getAutoClearDepthStencilSetup(index) :
  122286. this._autoClearDepthStencil[index];
  122287. if (autoClear && autoClear.autoClear) {
  122288. this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);
  122289. }
  122290. }
  122291. // Render
  122292. for (var _i = 0, _a = this._scene._beforeRenderingGroupDrawStage; _i < _a.length; _i++) {
  122293. var step = _a[_i];
  122294. step.action(index);
  122295. }
  122296. renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
  122297. for (var _b = 0, _c = this._scene._afterRenderingGroupDrawStage; _b < _c.length; _b++) {
  122298. var step = _c[_b];
  122299. step.action(index);
  122300. }
  122301. // After Observable
  122302. this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  122303. }
  122304. };
  122305. /**
  122306. * Resets the different information of the group to prepare a new frame
  122307. * @hidden
  122308. */
  122309. RenderingManager.prototype.reset = function () {
  122310. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  122311. var renderingGroup = this._renderingGroups[index];
  122312. if (renderingGroup) {
  122313. renderingGroup.prepare();
  122314. }
  122315. }
  122316. };
  122317. /**
  122318. * Dispose and release the group and its associated resources.
  122319. * @hidden
  122320. */
  122321. RenderingManager.prototype.dispose = function () {
  122322. this.freeRenderingGroups();
  122323. this._renderingGroups.length = 0;
  122324. this._renderingGroupInfo = null;
  122325. };
  122326. /**
  122327. * Clear the info related to rendering groups preventing retention points during dispose.
  122328. */
  122329. RenderingManager.prototype.freeRenderingGroups = function () {
  122330. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  122331. var renderingGroup = this._renderingGroups[index];
  122332. if (renderingGroup) {
  122333. renderingGroup.dispose();
  122334. }
  122335. }
  122336. };
  122337. RenderingManager.prototype._prepareRenderingGroup = function (renderingGroupId) {
  122338. if (this._renderingGroups[renderingGroupId] === undefined) {
  122339. this._renderingGroups[renderingGroupId] = new _renderingGroup__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"](renderingGroupId, this._scene, this._customOpaqueSortCompareFn[renderingGroupId], this._customAlphaTestSortCompareFn[renderingGroupId], this._customTransparentSortCompareFn[renderingGroupId]);
  122340. }
  122341. };
  122342. /**
  122343. * Add a sprite manager to the rendering manager in order to render it this frame.
  122344. * @param spriteManager Define the sprite manager to render
  122345. */
  122346. RenderingManager.prototype.dispatchSprites = function (spriteManager) {
  122347. var renderingGroupId = spriteManager.renderingGroupId || 0;
  122348. this._prepareRenderingGroup(renderingGroupId);
  122349. this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
  122350. };
  122351. /**
  122352. * Add a particle system to the rendering manager in order to render it this frame.
  122353. * @param particleSystem Define the particle system to render
  122354. */
  122355. RenderingManager.prototype.dispatchParticles = function (particleSystem) {
  122356. var renderingGroupId = particleSystem.renderingGroupId || 0;
  122357. this._prepareRenderingGroup(renderingGroupId);
  122358. this._renderingGroups[renderingGroupId].dispatchParticles(particleSystem);
  122359. };
  122360. /**
  122361. * Add a submesh to the manager in order to render it this frame
  122362. * @param subMesh The submesh to dispatch
  122363. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  122364. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  122365. */
  122366. RenderingManager.prototype.dispatch = function (subMesh, mesh, material) {
  122367. if (mesh === undefined) {
  122368. mesh = subMesh.getMesh();
  122369. }
  122370. var renderingGroupId = mesh.renderingGroupId || 0;
  122371. this._prepareRenderingGroup(renderingGroupId);
  122372. this._renderingGroups[renderingGroupId].dispatch(subMesh, mesh, material);
  122373. };
  122374. /**
  122375. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  122376. * This allowed control for front to back rendering or reversly depending of the special needs.
  122377. *
  122378. * @param renderingGroupId The rendering group id corresponding to its index
  122379. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  122380. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  122381. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  122382. */
  122383. RenderingManager.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  122384. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  122385. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  122386. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  122387. this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;
  122388. this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;
  122389. this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;
  122390. if (this._renderingGroups[renderingGroupId]) {
  122391. var group = this._renderingGroups[renderingGroupId];
  122392. group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];
  122393. group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];
  122394. group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];
  122395. }
  122396. };
  122397. /**
  122398. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  122399. *
  122400. * @param renderingGroupId The rendering group id corresponding to its index
  122401. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  122402. * @param depth Automatically clears depth between groups if true and autoClear is true.
  122403. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  122404. */
  122405. RenderingManager.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  122406. if (depth === void 0) { depth = true; }
  122407. if (stencil === void 0) { stencil = true; }
  122408. this._autoClearDepthStencil[renderingGroupId] = {
  122409. autoClear: autoClearDepthStencil,
  122410. depth: depth,
  122411. stencil: stencil
  122412. };
  122413. };
  122414. /**
  122415. * Gets the current auto clear configuration for one rendering group of the rendering
  122416. * manager.
  122417. * @param index the rendering group index to get the information for
  122418. * @returns The auto clear setup for the requested rendering group
  122419. */
  122420. RenderingManager.prototype.getAutoClearDepthStencilSetup = function (index) {
  122421. return this._autoClearDepthStencil[index];
  122422. };
  122423. /**
  122424. * The max id used for rendering groups (not included)
  122425. */
  122426. RenderingManager.MAX_RENDERINGGROUPS = 4;
  122427. /**
  122428. * The min id used for rendering groups (included)
  122429. */
  122430. RenderingManager.MIN_RENDERINGGROUPS = 0;
  122431. /**
  122432. * Used to globally prevent autoclearing scenes.
  122433. */
  122434. RenderingManager.AUTOCLEAR = true;
  122435. return RenderingManager;
  122436. }());
  122437. /***/ }),
  122438. /***/ "./Rendering/utilityLayerRenderer.ts":
  122439. /*!*******************************************!*\
  122440. !*** ./Rendering/utilityLayerRenderer.ts ***!
  122441. \*******************************************/
  122442. /*! exports provided: UtilityLayerRenderer */
  122443. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122444. "use strict";
  122445. __webpack_require__.r(__webpack_exports__);
  122446. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return UtilityLayerRenderer; });
  122447. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  122448. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  122449. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  122450. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  122451. /**
  122452. * Renders a layer on top of an existing scene
  122453. */
  122454. var UtilityLayerRenderer = /** @class */ (function () {
  122455. /**
  122456. * Instantiates a UtilityLayerRenderer
  122457. * @param originalScene the original scene that will be rendered on top of
  122458. * @param handleEvents boolean indicating if the utility layer should handle events
  122459. */
  122460. function UtilityLayerRenderer(
  122461. /** the original scene that will be rendered on top of */
  122462. originalScene, handleEvents) {
  122463. if (handleEvents === void 0) { handleEvents = true; }
  122464. var _this = this;
  122465. this.originalScene = originalScene;
  122466. this._pointerCaptures = {};
  122467. this._lastPointerEvents = {};
  122468. /**
  122469. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  122470. */
  122471. this.pickUtilitySceneFirst = true;
  122472. /**
  122473. * If the utility layer should automatically be rendered on top of existing scene
  122474. */
  122475. this.shouldRender = true;
  122476. /**
  122477. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  122478. */
  122479. this.onlyCheckPointerDownEvents = true;
  122480. /**
  122481. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  122482. */
  122483. this.processAllEvents = false;
  122484. /**
  122485. * Observable raised when the pointer move from the utility layer scene to the main scene
  122486. */
  122487. this.onPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  122488. // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
  122489. this.utilityLayerScene = new _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"](originalScene.getEngine());
  122490. this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
  122491. this.utilityLayerScene._allowPostProcessClearColor = false;
  122492. originalScene.getEngine().scenes.pop();
  122493. // Detach controls on utility scene, events will be fired by logic below to handle picking priority
  122494. this.utilityLayerScene.detachControl();
  122495. if (handleEvents) {
  122496. this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
  122497. if (!_this.utilityLayerScene.activeCamera) {
  122498. return;
  122499. }
  122500. if (!_this.processAllEvents) {
  122501. if (prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE
  122502. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP
  122503. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  122504. return;
  122505. }
  122506. }
  122507. _this.utilityLayerScene.pointerX = originalScene.pointerX;
  122508. _this.utilityLayerScene.pointerY = originalScene.pointerY;
  122509. var pointerEvent = (prePointerInfo.event);
  122510. if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
  122511. _this._pointerCaptures[pointerEvent.pointerId] = false;
  122512. return;
  122513. }
  122514. var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
  122515. if (!prePointerInfo.ray && utilityScenePick) {
  122516. prePointerInfo.ray = utilityScenePick.ray;
  122517. }
  122518. // always fire the prepointer oversvable
  122519. _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
  122520. // allow every non pointer down event to flow to the utility layer
  122521. if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  122522. if (!prePointerInfo.skipOnPointerObservable) {
  122523. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  122524. }
  122525. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
  122526. _this._pointerCaptures[pointerEvent.pointerId] = false;
  122527. }
  122528. return;
  122529. }
  122530. if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
  122531. // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
  122532. if (utilityScenePick && utilityScenePick.hit) {
  122533. if (!prePointerInfo.skipOnPointerObservable) {
  122534. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  122535. }
  122536. prePointerInfo.skipOnPointerObservable = true;
  122537. }
  122538. }
  122539. else {
  122540. var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
  122541. var pointerEvent_1 = (prePointerInfo.event);
  122542. // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
  122543. if (originalScenePick && utilityScenePick) {
  122544. // No pick in utility scene
  122545. if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
  122546. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  122547. // We touched an utility mesh present in the main scene
  122548. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  122549. prePointerInfo.skipOnPointerObservable = true;
  122550. }
  122551. else if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  122552. _this._pointerCaptures[pointerEvent_1.pointerId] = true;
  122553. }
  122554. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  122555. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  122556. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  122557. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  122558. }
  122559. }
  122560. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
  122561. // We pick something in utility scene or the pick in utility is closer than the one in main scene
  122562. _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
  122563. // If a previous utility layer set this, do not unset this
  122564. if (!prePointerInfo.skipOnPointerObservable) {
  122565. prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
  122566. }
  122567. }
  122568. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
  122569. // We have a pick in both scenes but main is closer than utility
  122570. // We touched an utility mesh present in the main scene
  122571. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  122572. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  122573. prePointerInfo.skipOnPointerObservable = true;
  122574. }
  122575. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  122576. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  122577. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  122578. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  122579. }
  122580. }
  122581. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
  122582. _this._pointerCaptures[pointerEvent_1.pointerId] = false;
  122583. }
  122584. }
  122585. }
  122586. });
  122587. }
  122588. // Render directly on top of existing scene without clearing
  122589. this.utilityLayerScene.autoClear = false;
  122590. this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
  122591. if (_this.shouldRender) {
  122592. _this.render();
  122593. }
  122594. });
  122595. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function () {
  122596. _this.dispose();
  122597. });
  122598. this._updateCamera();
  122599. }
  122600. Object.defineProperty(UtilityLayerRenderer, "DefaultUtilityLayer", {
  122601. /**
  122602. * 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)
  122603. */
  122604. get: function () {
  122605. if (UtilityLayerRenderer._DefaultUtilityLayer == null) {
  122606. UtilityLayerRenderer._DefaultUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  122607. UtilityLayerRenderer._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  122608. UtilityLayerRenderer._DefaultUtilityLayer = null;
  122609. });
  122610. }
  122611. return UtilityLayerRenderer._DefaultUtilityLayer;
  122612. },
  122613. enumerable: true,
  122614. configurable: true
  122615. });
  122616. Object.defineProperty(UtilityLayerRenderer, "DefaultKeepDepthUtilityLayer", {
  122617. /**
  122618. * 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)
  122619. */
  122620. get: function () {
  122621. if (UtilityLayerRenderer._DefaultKeepDepthUtilityLayer == null) {
  122622. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  122623. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  122624. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  122625. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  122626. });
  122627. }
  122628. return UtilityLayerRenderer._DefaultKeepDepthUtilityLayer;
  122629. },
  122630. enumerable: true,
  122631. configurable: true
  122632. });
  122633. UtilityLayerRenderer.prototype._notifyObservers = function (prePointerInfo, pickInfo, pointerEvent) {
  122634. if (!prePointerInfo.skipOnPointerObservable) {
  122635. this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, pickInfo));
  122636. this._lastPointerEvents[pointerEvent.pointerId] = true;
  122637. }
  122638. };
  122639. /**
  122640. * Renders the utility layers scene on top of the original scene
  122641. */
  122642. UtilityLayerRenderer.prototype.render = function () {
  122643. this._updateCamera();
  122644. if (this.utilityLayerScene.activeCamera) {
  122645. // Set the camera's scene to utility layers scene
  122646. var oldScene = this.utilityLayerScene.activeCamera.getScene();
  122647. var camera = this.utilityLayerScene.activeCamera;
  122648. camera._scene = this.utilityLayerScene;
  122649. if (camera.leftCamera) {
  122650. camera.leftCamera._scene = this.utilityLayerScene;
  122651. }
  122652. if (camera.rightCamera) {
  122653. camera.rightCamera._scene = this.utilityLayerScene;
  122654. }
  122655. this.utilityLayerScene.render(false);
  122656. // Reset camera's scene back to original
  122657. camera._scene = oldScene;
  122658. if (camera.leftCamera) {
  122659. camera.leftCamera._scene = oldScene;
  122660. }
  122661. if (camera.rightCamera) {
  122662. camera.rightCamera._scene = oldScene;
  122663. }
  122664. }
  122665. };
  122666. /**
  122667. * Disposes of the renderer
  122668. */
  122669. UtilityLayerRenderer.prototype.dispose = function () {
  122670. this.onPointerOutObservable.clear();
  122671. if (this._afterRenderObserver) {
  122672. this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver);
  122673. }
  122674. if (this._sceneDisposeObserver) {
  122675. this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver);
  122676. }
  122677. if (this._originalPointerObserver) {
  122678. this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver);
  122679. }
  122680. this.utilityLayerScene.dispose();
  122681. };
  122682. UtilityLayerRenderer.prototype._updateCamera = function () {
  122683. if (this.originalScene.activeCameras.length > 1) {
  122684. this.utilityLayerScene.activeCamera = this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1];
  122685. }
  122686. else {
  122687. this.utilityLayerScene.activeCamera = this.originalScene.activeCamera;
  122688. }
  122689. };
  122690. UtilityLayerRenderer._DefaultUtilityLayer = null;
  122691. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  122692. return UtilityLayerRenderer;
  122693. }());
  122694. /***/ }),
  122695. /***/ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts":
  122696. /*!*****************************************************************!*\
  122697. !*** ./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts ***!
  122698. \*****************************************************************/
  122699. /*! exports provided: backgroundFragmentDeclaration */
  122700. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122701. "use strict";
  122702. __webpack_require__.r(__webpack_exports__);
  122703. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundFragmentDeclaration", function() { return backgroundFragmentDeclaration; });
  122704. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122705. var name = 'backgroundFragmentDeclaration';
  122706. 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";
  122707. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122708. /** @hidden */
  122709. var backgroundFragmentDeclaration = { name: name, shader: shader };
  122710. /***/ }),
  122711. /***/ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts":
  122712. /*!************************************************************!*\
  122713. !*** ./Shaders/ShadersInclude/backgroundUboDeclaration.ts ***!
  122714. \************************************************************/
  122715. /*! exports provided: backgroundUboDeclaration */
  122716. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122717. "use strict";
  122718. __webpack_require__.r(__webpack_exports__);
  122719. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundUboDeclaration", function() { return backgroundUboDeclaration; });
  122720. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122721. var name = 'backgroundUboDeclaration';
  122722. 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};";
  122723. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122724. /** @hidden */
  122725. var backgroundUboDeclaration = { name: name, shader: shader };
  122726. /***/ }),
  122727. /***/ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts":
  122728. /*!***************************************************************!*\
  122729. !*** ./Shaders/ShadersInclude/backgroundVertexDeclaration.ts ***!
  122730. \***************************************************************/
  122731. /*! exports provided: backgroundVertexDeclaration */
  122732. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122733. "use strict";
  122734. __webpack_require__.r(__webpack_exports__);
  122735. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexDeclaration", function() { return backgroundVertexDeclaration; });
  122736. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122737. var name = 'backgroundVertexDeclaration';
  122738. 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";
  122739. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122740. /** @hidden */
  122741. var backgroundVertexDeclaration = { name: name, shader: shader };
  122742. /***/ }),
  122743. /***/ "./Shaders/ShadersInclude/bonesDeclaration.ts":
  122744. /*!****************************************************!*\
  122745. !*** ./Shaders/ShadersInclude/bonesDeclaration.ts ***!
  122746. \****************************************************/
  122747. /*! exports provided: bonesDeclaration */
  122748. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122749. "use strict";
  122750. __webpack_require__.r(__webpack_exports__);
  122751. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesDeclaration", function() { return bonesDeclaration; });
  122752. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122753. var name = 'bonesDeclaration';
  122754. 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";
  122755. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122756. /** @hidden */
  122757. var bonesDeclaration = { name: name, shader: shader };
  122758. /***/ }),
  122759. /***/ "./Shaders/ShadersInclude/bonesVertex.ts":
  122760. /*!***********************************************!*\
  122761. !*** ./Shaders/ShadersInclude/bonesVertex.ts ***!
  122762. \***********************************************/
  122763. /*! exports provided: bonesVertex */
  122764. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122765. "use strict";
  122766. __webpack_require__.r(__webpack_exports__);
  122767. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesVertex", function() { return bonesVertex; });
  122768. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122769. var name = 'bonesVertex';
  122770. 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";
  122771. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122772. /** @hidden */
  122773. var bonesVertex = { name: name, shader: shader };
  122774. /***/ }),
  122775. /***/ "./Shaders/ShadersInclude/bumpFragment.ts":
  122776. /*!************************************************!*\
  122777. !*** ./Shaders/ShadersInclude/bumpFragment.ts ***!
  122778. \************************************************/
  122779. /*! exports provided: bumpFragment */
  122780. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122781. "use strict";
  122782. __webpack_require__.r(__webpack_exports__);
  122783. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragment", function() { return bumpFragment; });
  122784. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122785. var name = 'bumpFragment';
  122786. var shader = "vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\n#ifdef NORMALXYSCALE\nfloat normalScale=1.0;\n#else\nfloat normalScale=vBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV);\n#endif\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef BUMP\n#ifdef OBJECTSPACE_NORMALMAP\nnormalW=normalize(texture2D(bumpSampler,vBumpUV).xyz*2.0-1.0);\nnormalW=normalize(mat3(normalMatrix)*normalW);\n#else\nnormalW=perturbNormal(TBN,vBumpUV+uvOffset);\n#endif\n#endif";
  122787. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122788. /** @hidden */
  122789. var bumpFragment = { name: name, shader: shader };
  122790. /***/ }),
  122791. /***/ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts":
  122792. /*!*********************************************************!*\
  122793. !*** ./Shaders/ShadersInclude/bumpFragmentFunctions.ts ***!
  122794. \*********************************************************/
  122795. /*! exports provided: bumpFragmentFunctions */
  122796. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122797. "use strict";
  122798. __webpack_require__.r(__webpack_exports__);
  122799. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragmentFunctions", function() { return bumpFragmentFunctions; });
  122800. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122801. var name = 'bumpFragmentFunctions';
  122802. var shader = "#ifdef BUMP\n#if BUMPDIRECTUV == 1\n#define vBumpUV vMainUV1\n#elif BUMPDIRECTUV == 2\n#define vBumpUV vMainUV2\n#else\nvarying vec2 vBumpUV;\n#endif\nuniform sampler2D bumpSampler;\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat4 normalMatrix;\n#endif\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\n\nuv=gl_FrontFacing ? uv : -uv;\n\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\n\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;\n\ntangent*=vTangentSpaceParams.x;\nbitangent*=vTangentSpaceParams.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));\nreturn mat3(tangent*invmax,bitangent*invmax,normal);\n}\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv)\n{\nvec3 map=texture2D(bumpSampler,uv).xyz;\nmap=map*2.0-1.0;\n#ifdef NORMALXYSCALE\nmap=normalize(map*vec3(vBumpInfos.y,vBumpInfos.y,1.0));\n#endif\nreturn normalize(cotangentFrame*map);\n}\n#ifdef PARALLAX\nconst float minSamples=4.;\nconst float maxSamples=15.;\nconst int iMaxSamples=15;\n\nvec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {\nfloat parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;\nparallaxLimit*=parallaxScale;\nvec2 vOffsetDir=normalize(vViewDirCoT.xy);\nvec2 vMaxOffset=vOffsetDir*parallaxLimit;\nfloat numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));\nfloat stepSize=1.0/numSamples;\n\nfloat currRayHeight=1.0;\nvec2 vCurrOffset=vec2(0,0);\nvec2 vLastOffset=vec2(0,0);\nfloat lastSampledHeight=1.0;\nfloat currSampledHeight=1.0;\nfor (int i=0; i<iMaxSamples; i++)\n{\ncurrSampledHeight=texture2D(bumpSampler,vBumpUV+vCurrOffset).w;\n\nif (currSampledHeight>currRayHeight)\n{\nfloat delta1=currSampledHeight-currRayHeight;\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\nfloat ratio=delta1/(delta1+delta2);\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\n\nbreak;\n}\nelse\n{\ncurrRayHeight-=stepSize;\nvLastOffset=vCurrOffset;\nvCurrOffset+=stepSize*vMaxOffset;\nlastSampledHeight=currSampledHeight;\n}\n}\nreturn vCurrOffset;\n}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{\n\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif\n#endif";
  122803. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122804. /** @hidden */
  122805. var bumpFragmentFunctions = { name: name, shader: shader };
  122806. /***/ }),
  122807. /***/ "./Shaders/ShadersInclude/bumpVertex.ts":
  122808. /*!**********************************************!*\
  122809. !*** ./Shaders/ShadersInclude/bumpVertex.ts ***!
  122810. \**********************************************/
  122811. /*! exports provided: bumpVertex */
  122812. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122813. "use strict";
  122814. __webpack_require__.r(__webpack_exports__);
  122815. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertex", function() { return bumpVertex; });
  122816. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122817. var name = 'bumpVertex';
  122818. var shader = "#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nvec3 tbnNormal=normalize(normalUpdated);\nvec3 tbnTangent=normalize(tangentUpdated.xyz);\nvec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;\nvTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);\n#endif\n#endif";
  122819. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122820. /** @hidden */
  122821. var bumpVertex = { name: name, shader: shader };
  122822. /***/ }),
  122823. /***/ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts":
  122824. /*!*********************************************************!*\
  122825. !*** ./Shaders/ShadersInclude/bumpVertexDeclaration.ts ***!
  122826. \*********************************************************/
  122827. /*! exports provided: bumpVertexDeclaration */
  122828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122829. "use strict";
  122830. __webpack_require__.r(__webpack_exports__);
  122831. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertexDeclaration", function() { return bumpVertexDeclaration; });
  122832. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122833. var name = 'bumpVertexDeclaration';
  122834. var shader = "#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";
  122835. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122836. /** @hidden */
  122837. var bumpVertexDeclaration = { name: name, shader: shader };
  122838. /***/ }),
  122839. /***/ "./Shaders/ShadersInclude/clipPlaneFragment.ts":
  122840. /*!*****************************************************!*\
  122841. !*** ./Shaders/ShadersInclude/clipPlaneFragment.ts ***!
  122842. \*****************************************************/
  122843. /*! exports provided: clipPlaneFragment */
  122844. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122845. "use strict";
  122846. __webpack_require__.r(__webpack_exports__);
  122847. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragment", function() { return clipPlaneFragment; });
  122848. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122849. var name = 'clipPlaneFragment';
  122850. 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";
  122851. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122852. /** @hidden */
  122853. var clipPlaneFragment = { name: name, shader: shader };
  122854. /***/ }),
  122855. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts":
  122856. /*!****************************************************************!*\
  122857. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts ***!
  122858. \****************************************************************/
  122859. /*! exports provided: clipPlaneFragmentDeclaration */
  122860. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122861. "use strict";
  122862. __webpack_require__.r(__webpack_exports__);
  122863. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration", function() { return clipPlaneFragmentDeclaration; });
  122864. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122865. var name = 'clipPlaneFragmentDeclaration';
  122866. 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";
  122867. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122868. /** @hidden */
  122869. var clipPlaneFragmentDeclaration = { name: name, shader: shader };
  122870. /***/ }),
  122871. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts":
  122872. /*!*****************************************************************!*\
  122873. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts ***!
  122874. \*****************************************************************/
  122875. /*! exports provided: clipPlaneFragmentDeclaration2 */
  122876. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122877. "use strict";
  122878. __webpack_require__.r(__webpack_exports__);
  122879. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration2", function() { return clipPlaneFragmentDeclaration2; });
  122880. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122881. var name = 'clipPlaneFragmentDeclaration2';
  122882. 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";
  122883. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122884. /** @hidden */
  122885. var clipPlaneFragmentDeclaration2 = { name: name, shader: shader };
  122886. /***/ }),
  122887. /***/ "./Shaders/ShadersInclude/clipPlaneVertex.ts":
  122888. /*!***************************************************!*\
  122889. !*** ./Shaders/ShadersInclude/clipPlaneVertex.ts ***!
  122890. \***************************************************/
  122891. /*! exports provided: clipPlaneVertex */
  122892. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122893. "use strict";
  122894. __webpack_require__.r(__webpack_exports__);
  122895. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertex", function() { return clipPlaneVertex; });
  122896. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122897. var name = 'clipPlaneVertex';
  122898. 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";
  122899. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122900. /** @hidden */
  122901. var clipPlaneVertex = { name: name, shader: shader };
  122902. /***/ }),
  122903. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts":
  122904. /*!**************************************************************!*\
  122905. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts ***!
  122906. \**************************************************************/
  122907. /*! exports provided: clipPlaneVertexDeclaration */
  122908. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122909. "use strict";
  122910. __webpack_require__.r(__webpack_exports__);
  122911. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration", function() { return clipPlaneVertexDeclaration; });
  122912. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122913. var name = 'clipPlaneVertexDeclaration';
  122914. 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";
  122915. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122916. /** @hidden */
  122917. var clipPlaneVertexDeclaration = { name: name, shader: shader };
  122918. /***/ }),
  122919. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts":
  122920. /*!***************************************************************!*\
  122921. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts ***!
  122922. \***************************************************************/
  122923. /*! exports provided: clipPlaneVertexDeclaration2 */
  122924. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122925. "use strict";
  122926. __webpack_require__.r(__webpack_exports__);
  122927. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration2", function() { return clipPlaneVertexDeclaration2; });
  122928. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122929. var name = 'clipPlaneVertexDeclaration2';
  122930. 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";
  122931. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122932. /** @hidden */
  122933. var clipPlaneVertexDeclaration2 = { name: name, shader: shader };
  122934. /***/ }),
  122935. /***/ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts":
  122936. /*!**************************************************************!*\
  122937. !*** ./Shaders/ShadersInclude/defaultFragmentDeclaration.ts ***!
  122938. \**************************************************************/
  122939. /*! exports provided: defaultFragmentDeclaration */
  122940. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122941. "use strict";
  122942. __webpack_require__.r(__webpack_exports__);
  122943. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultFragmentDeclaration", function() { return defaultFragmentDeclaration; });
  122944. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122945. var name = 'defaultFragmentDeclaration';
  122946. 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";
  122947. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122948. /** @hidden */
  122949. var defaultFragmentDeclaration = { name: name, shader: shader };
  122950. /***/ }),
  122951. /***/ "./Shaders/ShadersInclude/defaultUboDeclaration.ts":
  122952. /*!*********************************************************!*\
  122953. !*** ./Shaders/ShadersInclude/defaultUboDeclaration.ts ***!
  122954. \*********************************************************/
  122955. /*! exports provided: defaultUboDeclaration */
  122956. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122957. "use strict";
  122958. __webpack_require__.r(__webpack_exports__);
  122959. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultUboDeclaration", function() { return defaultUboDeclaration; });
  122960. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122961. var name = 'defaultUboDeclaration';
  122962. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor;\nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix;\nvec4 vTangentSpaceParams;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nfloat pointSize;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";
  122963. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122964. /** @hidden */
  122965. var defaultUboDeclaration = { name: name, shader: shader };
  122966. /***/ }),
  122967. /***/ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts":
  122968. /*!************************************************************!*\
  122969. !*** ./Shaders/ShadersInclude/defaultVertexDeclaration.ts ***!
  122970. \************************************************************/
  122971. /*! exports provided: defaultVertexDeclaration */
  122972. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122973. "use strict";
  122974. __webpack_require__.r(__webpack_exports__);
  122975. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexDeclaration", function() { return defaultVertexDeclaration; });
  122976. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122977. var name = 'defaultVertexDeclaration';
  122978. 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";
  122979. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122980. /** @hidden */
  122981. var defaultVertexDeclaration = { name: name, shader: shader };
  122982. /***/ }),
  122983. /***/ "./Shaders/ShadersInclude/depthPrePass.ts":
  122984. /*!************************************************!*\
  122985. !*** ./Shaders/ShadersInclude/depthPrePass.ts ***!
  122986. \************************************************/
  122987. /*! exports provided: depthPrePass */
  122988. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122989. "use strict";
  122990. __webpack_require__.r(__webpack_exports__);
  122991. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPrePass", function() { return depthPrePass; });
  122992. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122993. var name = 'depthPrePass';
  122994. var shader = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  122995. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122996. /** @hidden */
  122997. var depthPrePass = { name: name, shader: shader };
  122998. /***/ }),
  122999. /***/ "./Shaders/ShadersInclude/fogFragment.ts":
  123000. /*!***********************************************!*\
  123001. !*** ./Shaders/ShadersInclude/fogFragment.ts ***!
  123002. \***********************************************/
  123003. /*! exports provided: fogFragment */
  123004. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123005. "use strict";
  123006. __webpack_require__.r(__webpack_exports__);
  123007. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragment", function() { return fogFragment; });
  123008. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123009. var name = 'fogFragment';
  123010. var shader = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  123011. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123012. /** @hidden */
  123013. var fogFragment = { name: name, shader: shader };
  123014. /***/ }),
  123015. /***/ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts":
  123016. /*!**********************************************************!*\
  123017. !*** ./Shaders/ShadersInclude/fogFragmentDeclaration.ts ***!
  123018. \**********************************************************/
  123019. /*! exports provided: fogFragmentDeclaration */
  123020. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123021. "use strict";
  123022. __webpack_require__.r(__webpack_exports__);
  123023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragmentDeclaration", function() { return fogFragmentDeclaration; });
  123024. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123025. var name = 'fogFragmentDeclaration';
  123026. 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";
  123027. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123028. /** @hidden */
  123029. var fogFragmentDeclaration = { name: name, shader: shader };
  123030. /***/ }),
  123031. /***/ "./Shaders/ShadersInclude/fogVertex.ts":
  123032. /*!*********************************************!*\
  123033. !*** ./Shaders/ShadersInclude/fogVertex.ts ***!
  123034. \*********************************************/
  123035. /*! exports provided: fogVertex */
  123036. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123037. "use strict";
  123038. __webpack_require__.r(__webpack_exports__);
  123039. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertex", function() { return fogVertex; });
  123040. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123041. var name = 'fogVertex';
  123042. var shader = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  123043. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123044. /** @hidden */
  123045. var fogVertex = { name: name, shader: shader };
  123046. /***/ }),
  123047. /***/ "./Shaders/ShadersInclude/fogVertexDeclaration.ts":
  123048. /*!********************************************************!*\
  123049. !*** ./Shaders/ShadersInclude/fogVertexDeclaration.ts ***!
  123050. \********************************************************/
  123051. /*! exports provided: fogVertexDeclaration */
  123052. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123053. "use strict";
  123054. __webpack_require__.r(__webpack_exports__);
  123055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertexDeclaration", function() { return fogVertexDeclaration; });
  123056. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123057. var name = 'fogVertexDeclaration';
  123058. var shader = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  123059. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123060. /** @hidden */
  123061. var fogVertexDeclaration = { name: name, shader: shader };
  123062. /***/ }),
  123063. /***/ "./Shaders/ShadersInclude/fresnelFunction.ts":
  123064. /*!***************************************************!*\
  123065. !*** ./Shaders/ShadersInclude/fresnelFunction.ts ***!
  123066. \***************************************************/
  123067. /*! exports provided: fresnelFunction */
  123068. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123069. "use strict";
  123070. __webpack_require__.r(__webpack_exports__);
  123071. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fresnelFunction", function() { return fresnelFunction; });
  123072. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123073. var name = 'fresnelFunction';
  123074. 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";
  123075. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123076. /** @hidden */
  123077. var fresnelFunction = { name: name, shader: shader };
  123078. /***/ }),
  123079. /***/ "./Shaders/ShadersInclude/harmonicsFunctions.ts":
  123080. /*!******************************************************!*\
  123081. !*** ./Shaders/ShadersInclude/harmonicsFunctions.ts ***!
  123082. \******************************************************/
  123083. /*! exports provided: harmonicsFunctions */
  123084. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123085. "use strict";
  123086. __webpack_require__.r(__webpack_exports__);
  123087. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "harmonicsFunctions", function() { return harmonicsFunctions; });
  123088. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123089. var name = 'harmonicsFunctions';
  123090. 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";
  123091. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123092. /** @hidden */
  123093. var harmonicsFunctions = { name: name, shader: shader };
  123094. /***/ }),
  123095. /***/ "./Shaders/ShadersInclude/helperFunctions.ts":
  123096. /*!***************************************************!*\
  123097. !*** ./Shaders/ShadersInclude/helperFunctions.ts ***!
  123098. \***************************************************/
  123099. /*! exports provided: helperFunctions */
  123100. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123101. "use strict";
  123102. __webpack_require__.r(__webpack_exports__);
  123103. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "helperFunctions", function() { return helperFunctions; });
  123104. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123105. var name = 'helperFunctions';
  123106. 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}";
  123107. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123108. /** @hidden */
  123109. var helperFunctions = { name: name, shader: shader };
  123110. /***/ }),
  123111. /***/ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts":
  123112. /*!**************************************************************!*\
  123113. !*** ./Shaders/ShadersInclude/imageProcessingDeclaration.ts ***!
  123114. \**************************************************************/
  123115. /*! exports provided: imageProcessingDeclaration */
  123116. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123117. "use strict";
  123118. __webpack_require__.r(__webpack_exports__);
  123119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingDeclaration", function() { return imageProcessingDeclaration; });
  123120. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123121. var name = 'imageProcessingDeclaration';
  123122. 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";
  123123. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123124. /** @hidden */
  123125. var imageProcessingDeclaration = { name: name, shader: shader };
  123126. /***/ }),
  123127. /***/ "./Shaders/ShadersInclude/imageProcessingFunctions.ts":
  123128. /*!************************************************************!*\
  123129. !*** ./Shaders/ShadersInclude/imageProcessingFunctions.ts ***!
  123130. \************************************************************/
  123131. /*! exports provided: imageProcessingFunctions */
  123132. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123133. "use strict";
  123134. __webpack_require__.r(__webpack_exports__);
  123135. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingFunctions", function() { return imageProcessingFunctions; });
  123136. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123137. var name = 'imageProcessingFunctions';
  123138. 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}";
  123139. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123140. /** @hidden */
  123141. var imageProcessingFunctions = { name: name, shader: shader };
  123142. /***/ }),
  123143. /***/ "./Shaders/ShadersInclude/instancesDeclaration.ts":
  123144. /*!********************************************************!*\
  123145. !*** ./Shaders/ShadersInclude/instancesDeclaration.ts ***!
  123146. \********************************************************/
  123147. /*! exports provided: instancesDeclaration */
  123148. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123149. "use strict";
  123150. __webpack_require__.r(__webpack_exports__);
  123151. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesDeclaration", function() { return instancesDeclaration; });
  123152. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123153. var name = 'instancesDeclaration';
  123154. var shader = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  123155. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123156. /** @hidden */
  123157. var instancesDeclaration = { name: name, shader: shader };
  123158. /***/ }),
  123159. /***/ "./Shaders/ShadersInclude/instancesVertex.ts":
  123160. /*!***************************************************!*\
  123161. !*** ./Shaders/ShadersInclude/instancesVertex.ts ***!
  123162. \***************************************************/
  123163. /*! exports provided: instancesVertex */
  123164. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123165. "use strict";
  123166. __webpack_require__.r(__webpack_exports__);
  123167. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesVertex", function() { return instancesVertex; });
  123168. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123169. var name = 'instancesVertex';
  123170. var shader = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  123171. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123172. /** @hidden */
  123173. var instancesVertex = { name: name, shader: shader };
  123174. /***/ }),
  123175. /***/ "./Shaders/ShadersInclude/kernelBlurFragment.ts":
  123176. /*!******************************************************!*\
  123177. !*** ./Shaders/ShadersInclude/kernelBlurFragment.ts ***!
  123178. \******************************************************/
  123179. /*! exports provided: kernelBlurFragment */
  123180. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123181. "use strict";
  123182. __webpack_require__.r(__webpack_exports__);
  123183. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment", function() { return kernelBlurFragment; });
  123184. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123185. var name = 'kernelBlurFragment';
  123186. 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";
  123187. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123188. /** @hidden */
  123189. var kernelBlurFragment = { name: name, shader: shader };
  123190. /***/ }),
  123191. /***/ "./Shaders/ShadersInclude/kernelBlurFragment2.ts":
  123192. /*!*******************************************************!*\
  123193. !*** ./Shaders/ShadersInclude/kernelBlurFragment2.ts ***!
  123194. \*******************************************************/
  123195. /*! exports provided: kernelBlurFragment2 */
  123196. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123197. "use strict";
  123198. __webpack_require__.r(__webpack_exports__);
  123199. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment2", function() { return kernelBlurFragment2; });
  123200. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123201. var name = 'kernelBlurFragment2';
  123202. 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";
  123203. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123204. /** @hidden */
  123205. var kernelBlurFragment2 = { name: name, shader: shader };
  123206. /***/ }),
  123207. /***/ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts":
  123208. /*!****************************************************************!*\
  123209. !*** ./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts ***!
  123210. \****************************************************************/
  123211. /*! exports provided: kernelBlurVaryingDeclaration */
  123212. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123213. "use strict";
  123214. __webpack_require__.r(__webpack_exports__);
  123215. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVaryingDeclaration", function() { return kernelBlurVaryingDeclaration; });
  123216. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123217. var name = 'kernelBlurVaryingDeclaration';
  123218. var shader = "varying vec2 sampleCoord{X};";
  123219. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123220. /** @hidden */
  123221. var kernelBlurVaryingDeclaration = { name: name, shader: shader };
  123222. /***/ }),
  123223. /***/ "./Shaders/ShadersInclude/kernelBlurVertex.ts":
  123224. /*!****************************************************!*\
  123225. !*** ./Shaders/ShadersInclude/kernelBlurVertex.ts ***!
  123226. \****************************************************/
  123227. /*! exports provided: kernelBlurVertex */
  123228. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123229. "use strict";
  123230. __webpack_require__.r(__webpack_exports__);
  123231. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertex", function() { return kernelBlurVertex; });
  123232. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123233. var name = 'kernelBlurVertex';
  123234. var shader = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  123235. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123236. /** @hidden */
  123237. var kernelBlurVertex = { name: name, shader: shader };
  123238. /***/ }),
  123239. /***/ "./Shaders/ShadersInclude/lightFragment.ts":
  123240. /*!*************************************************!*\
  123241. !*** ./Shaders/ShadersInclude/lightFragment.ts ***!
  123242. \*************************************************/
  123243. /*! exports provided: lightFragment */
  123244. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123245. "use strict";
  123246. __webpack_require__.r(__webpack_exports__);
  123247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragment", function() { return lightFragment; });
  123248. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123249. var name = 'lightFragment';
  123250. var shader = "#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || (defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}))\n\n#else\n#ifdef PBR\n#ifdef SPOTLIGHT{X}\nspotInfo=computeSpotLightingInfo(light{X}.vLightData);\n#ifdef LIGHT_FALLOFF_GLTF{X}\nspotInfo.attenuation=computeDistanceLightFalloff_GLTF(spotInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\nspotInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\nspotInfo.attenuation=computeDistanceLightFalloff_Physical(spotInfo.lightDistanceSquared);\nspotInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\nspotInfo.attenuation=computeDistanceLightFalloff_Standard(spotInfo.lightOffset,light{X}.vLightFalloff.x);\nspotInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#else\nspotInfo.attenuation=computeDistanceLightFalloff(spotInfo.lightOffset,spotInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\nspotInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\ninfo=computeSpotLighting(spotInfo,viewDirectionW,normalW,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(POINTLIGHT{X})\npointInfo=computePointLightingInfo(light{X}.vLightData);\n#ifdef LIGHT_FALLOFF_GLTF{X}\npointInfo.attenuation=computeDistanceLightFalloff_GLTF(pointInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npointInfo.attenuation=computeDistanceLightFalloff_Physical(pointInfo.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npointInfo.attenuation=computeDistanceLightFalloff_Standard(pointInfo.lightOffset,light{X}.vLightFalloff.x);\n#else\npointInfo.attenuation=computeDistanceLightFalloff(pointInfo.lightOffset,pointInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\ninfo=computePointLighting(pointInfo,viewDirectionW,normalW,light{X}.vLightDiffuse.rgb,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(DIRLIGHT{X})\ninfo=computeDirectionalLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,glossiness);\n#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\ninfo.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X});\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCLOSEESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWESM{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPOISSON{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow;\nshadowLightCount+=1.0;\n#endif\n#else\nshadow=1.;\n#endif\n#ifndef SHADOWONLY\n#ifdef CUSTOMUSERLIGHTING\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\n#ifdef SPECULARTERM\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\n#endif\n#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#endif\n#endif\n#endif";
  123251. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123252. /** @hidden */
  123253. var lightFragment = { name: name, shader: shader };
  123254. /***/ }),
  123255. /***/ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts":
  123256. /*!************************************************************!*\
  123257. !*** ./Shaders/ShadersInclude/lightFragmentDeclaration.ts ***!
  123258. \************************************************************/
  123259. /*! exports provided: lightFragmentDeclaration */
  123260. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123261. "use strict";
  123262. __webpack_require__.r(__webpack_exports__);
  123263. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragmentDeclaration", function() { return lightFragmentDeclaration; });
  123264. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123265. var name = 'lightFragmentDeclaration';
  123266. 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";
  123267. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123268. /** @hidden */
  123269. var lightFragmentDeclaration = { name: name, shader: shader };
  123270. /***/ }),
  123271. /***/ "./Shaders/ShadersInclude/lightUboDeclaration.ts":
  123272. /*!*******************************************************!*\
  123273. !*** ./Shaders/ShadersInclude/lightUboDeclaration.ts ***!
  123274. \*******************************************************/
  123275. /*! exports provided: lightUboDeclaration */
  123276. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123277. "use strict";
  123278. __webpack_require__.r(__webpack_exports__);
  123279. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightUboDeclaration", function() { return lightUboDeclaration; });
  123280. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123281. var name = 'lightUboDeclaration';
  123282. 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";
  123283. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123284. /** @hidden */
  123285. var lightUboDeclaration = { name: name, shader: shader };
  123286. /***/ }),
  123287. /***/ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts":
  123288. /*!***********************************************************!*\
  123289. !*** ./Shaders/ShadersInclude/lightsFragmentFunctions.ts ***!
  123290. \***********************************************************/
  123291. /*! exports provided: lightsFragmentFunctions */
  123292. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123293. "use strict";
  123294. __webpack_require__.r(__webpack_exports__);
  123295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightsFragmentFunctions", function() { return lightsFragmentFunctions; });
  123296. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123297. var name = 'lightsFragmentFunctions';
  123298. 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}";
  123299. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123300. /** @hidden */
  123301. var lightsFragmentFunctions = { name: name, shader: shader };
  123302. /***/ }),
  123303. /***/ "./Shaders/ShadersInclude/logDepthDeclaration.ts":
  123304. /*!*******************************************************!*\
  123305. !*** ./Shaders/ShadersInclude/logDepthDeclaration.ts ***!
  123306. \*******************************************************/
  123307. /*! exports provided: logDepthDeclaration */
  123308. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123309. "use strict";
  123310. __webpack_require__.r(__webpack_exports__);
  123311. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthDeclaration", function() { return logDepthDeclaration; });
  123312. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123313. var name = 'logDepthDeclaration';
  123314. var shader = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  123315. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123316. /** @hidden */
  123317. var logDepthDeclaration = { name: name, shader: shader };
  123318. /***/ }),
  123319. /***/ "./Shaders/ShadersInclude/logDepthFragment.ts":
  123320. /*!****************************************************!*\
  123321. !*** ./Shaders/ShadersInclude/logDepthFragment.ts ***!
  123322. \****************************************************/
  123323. /*! exports provided: logDepthFragment */
  123324. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123325. "use strict";
  123326. __webpack_require__.r(__webpack_exports__);
  123327. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthFragment", function() { return logDepthFragment; });
  123328. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123329. var name = 'logDepthFragment';
  123330. var shader = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  123331. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123332. /** @hidden */
  123333. var logDepthFragment = { name: name, shader: shader };
  123334. /***/ }),
  123335. /***/ "./Shaders/ShadersInclude/logDepthVertex.ts":
  123336. /*!**************************************************!*\
  123337. !*** ./Shaders/ShadersInclude/logDepthVertex.ts ***!
  123338. \**************************************************/
  123339. /*! exports provided: logDepthVertex */
  123340. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123341. "use strict";
  123342. __webpack_require__.r(__webpack_exports__);
  123343. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthVertex", function() { return logDepthVertex; });
  123344. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123345. var name = 'logDepthVertex';
  123346. var shader = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  123347. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123348. /** @hidden */
  123349. var logDepthVertex = { name: name, shader: shader };
  123350. /***/ }),
  123351. /***/ "./Shaders/ShadersInclude/morphTargetsVertex.ts":
  123352. /*!******************************************************!*\
  123353. !*** ./Shaders/ShadersInclude/morphTargetsVertex.ts ***!
  123354. \******************************************************/
  123355. /*! exports provided: morphTargetsVertex */
  123356. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123357. "use strict";
  123358. __webpack_require__.r(__webpack_exports__);
  123359. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertex", function() { return morphTargetsVertex; });
  123360. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123361. var name = 'morphTargetsVertex';
  123362. 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";
  123363. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123364. /** @hidden */
  123365. var morphTargetsVertex = { name: name, shader: shader };
  123366. /***/ }),
  123367. /***/ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts":
  123368. /*!*****************************************************************!*\
  123369. !*** ./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts ***!
  123370. \*****************************************************************/
  123371. /*! exports provided: morphTargetsVertexDeclaration */
  123372. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123373. "use strict";
  123374. __webpack_require__.r(__webpack_exports__);
  123375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexDeclaration", function() { return morphTargetsVertexDeclaration; });
  123376. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123377. var name = 'morphTargetsVertexDeclaration';
  123378. 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";
  123379. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123380. /** @hidden */
  123381. var morphTargetsVertexDeclaration = { name: name, shader: shader };
  123382. /***/ }),
  123383. /***/ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts":
  123384. /*!***********************************************************************!*\
  123385. !*** ./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts ***!
  123386. \***********************************************************************/
  123387. /*! exports provided: morphTargetsVertexGlobalDeclaration */
  123388. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123389. "use strict";
  123390. __webpack_require__.r(__webpack_exports__);
  123391. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexGlobalDeclaration", function() { return morphTargetsVertexGlobalDeclaration; });
  123392. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123393. var name = 'morphTargetsVertexGlobalDeclaration';
  123394. var shader = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  123395. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123396. /** @hidden */
  123397. var morphTargetsVertexGlobalDeclaration = { name: name, shader: shader };
  123398. /***/ }),
  123399. /***/ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts":
  123400. /*!**********************************************************!*\
  123401. !*** ./Shaders/ShadersInclude/mrtFragmentDeclaration.ts ***!
  123402. \**********************************************************/
  123403. /*! exports provided: mrtFragmentDeclaration */
  123404. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123405. "use strict";
  123406. __webpack_require__.r(__webpack_exports__);
  123407. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mrtFragmentDeclaration", function() { return mrtFragmentDeclaration; });
  123408. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123409. var name = 'mrtFragmentDeclaration';
  123410. var shader = "#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  123411. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123412. /** @hidden */
  123413. var mrtFragmentDeclaration = { name: name, shader: shader };
  123414. /***/ }),
  123415. /***/ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts":
  123416. /*!**********************************************************!*\
  123417. !*** ./Shaders/ShadersInclude/pbrFragmentDeclaration.ts ***!
  123418. \**********************************************************/
  123419. /*! exports provided: pbrFragmentDeclaration */
  123420. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123421. "use strict";
  123422. __webpack_require__.r(__webpack_exports__);
  123423. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentDeclaration", function() { return pbrFragmentDeclaration; });
  123424. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123425. var name = 'pbrFragmentDeclaration';
  123426. 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";
  123427. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123428. /** @hidden */
  123429. var pbrFragmentDeclaration = { name: name, shader: shader };
  123430. /***/ }),
  123431. /***/ "./Shaders/ShadersInclude/pbrFunctions.ts":
  123432. /*!************************************************!*\
  123433. !*** ./Shaders/ShadersInclude/pbrFunctions.ts ***!
  123434. \************************************************/
  123435. /*! exports provided: pbrFunctions */
  123436. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123437. "use strict";
  123438. __webpack_require__.r(__webpack_exports__);
  123439. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFunctions", function() { return pbrFunctions; });
  123440. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123441. var name = 'pbrFunctions';
  123442. var shader = "\n#define RECIPROCAL_PI2 0.15915494\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\nconst float kRougnhessToAlphaScale=0.1;\nconst float kRougnhessToAlphaOffset=0.29248125;\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nconst float kMinimumVariance=0.0005;\nfloat alphaG=square(roughness)+kMinimumVariance;\nreturn alphaG;\n}\n\nfloat smithVisibilityG1_TrowbridgeReitzGGX(float dot,float alphaG)\n{\nfloat tanSquared=(1.0-dot*dot)/(dot*dot);\nreturn 2.0/(1.0+sqrt(1.0+alphaG*alphaG*tanSquared));\n}\nfloat smithVisibilityG_TrowbridgeReitzGGX_Walter(float NdotL,float NdotV,float alphaG)\n{\nreturn smithVisibilityG1_TrowbridgeReitzGGX(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGX(NdotV,alphaG);\n}\n\n\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\n\n\n\nfloat a2=square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow(clamp(1.0-VdotH,0.,1.),5.0);\n}\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n\nvec3 computeSpecularTerm(float NdotH,float NdotL,float NdotV,float VdotH,float roughness,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor)\n{\nroughness=max(roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\nfloat visibility=smithVisibilityG_TrowbridgeReitzGGX_Walter(NdotL,NdotV,alphaG);\nvisibility/=(4.0*NdotL*NdotV);\nfloat specTerm=max(0.,visibility*distribution)*NdotL;\nvec3 fresnel=fresnelSchlickGGX(VdotH,reflectance0,reflectance90);\nreturn fresnel*specTerm;\n}\nfloat computeDiffuseTerm(float NdotL,float NdotV,float VdotH,float roughness)\n{\n\n\nfloat diffuseFresnelNV=pow(clamp(1.0-NdotL,0.000001,1.),5.0);\nfloat diffuseFresnelNL=pow(clamp(1.0-NdotV,0.000001,1.),5.0);\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel*NdotL/PI;\n}\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance)\n{\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=clamp(lightRoughness+roughness,0.,1.);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n\n\nfloat fresnelGrazingReflectance(float reflectance0) {\nfloat reflectance90=clamp(reflectance0*25.0,0.0,1.0);\nreturn reflectance90;\n}\n\n\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\n\n\n\n\n\n\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nfloat microsurfaceAverageSlopeTexels=microsurfaceAverageSlope*cubeMapDimensionPixels;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn clamp(square(temp)-1.0+ambientOcclusion,0.0,1.0);\n}\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=clamp( 1.0+1.1*dot(reflection,normal),0.0,1.0);\nreturn square(temp);\n}";
  123443. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123444. /** @hidden */
  123445. var pbrFunctions = { name: name, shader: shader };
  123446. /***/ }),
  123447. /***/ "./Shaders/ShadersInclude/pbrLightFunctions.ts":
  123448. /*!*****************************************************!*\
  123449. !*** ./Shaders/ShadersInclude/pbrLightFunctions.ts ***!
  123450. \*****************************************************/
  123451. /*! exports provided: pbrLightFunctions */
  123452. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123453. "use strict";
  123454. __webpack_require__.r(__webpack_exports__);
  123455. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrLightFunctions", function() { return pbrLightFunctions; });
  123456. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123457. var name = 'pbrLightFunctions';
  123458. var shader = "\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n};\nstruct pointLightingInfo\n{\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat attenuation;\n};\nstruct spotLightingInfo\n{\nvec3 lightOffset;\nfloat lightDistanceSquared;\nvec3 directionToLightCenterW;\nfloat attenuation;\n};\nfloat computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)\n{\nreturn max(0.,1.0-length(lightOffset)/range);\n}\nfloat computeDistanceLightFalloff_Physical(float lightDistanceSquared)\n{\nreturn 1.0/((lightDistanceSquared+0.001));\n}\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\n{\nconst float minDistanceSquared=0.01*0.01;\nfloat lightDistanceFalloff=1.0/(max(lightDistanceSquared,minDistanceSquared));\nfloat factor=lightDistanceSquared*inverseSquaredRange;\nfloat attenuation=clamp(1.0-factor*factor,0.,1.);\nattenuation*=attenuation;\n\nlightDistanceFalloff*=attenuation;\nreturn lightDistanceFalloff;\n}\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDistanceLightFalloff_Physical(lightDistanceSquared);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);\n#else\nreturn computeDistanceLightFalloff_Standard(lightOffset,range);\n#endif\n}\nfloat computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)\n{\nfloat falloff=0.0;\nfloat cosAngle=max(0.000000000000001,dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=cosHalfAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)\n{\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977;\n\n\n\n\n\nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\n\n\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfloat falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)\n{\n\n\n\nfloat cd=dot(-lightDirection,directionToLightCenterW);\nfloat falloff=clamp(cd*lightAngleScale+lightAngleOffset,0.,1.);\n\nfalloff*=falloff;\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);\n#else\nreturn computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);\n#endif\n}\npointLightingInfo computePointLightingInfo(vec4 lightData) {\npointLightingInfo result;\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\nreturn result;\n}\nspotLightingInfo computeSpotLightingInfo(vec4 lightData) {\nspotLightingInfo result;\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.directionToLightCenterW=normalize(result.lightOffset);\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\nreturn result;\n}\nlightingInfo computePointLighting(pointLightingInfo info,vec3 viewDirectionW,vec3 vNormal,vec3 diffuseColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\nfloat lightDistance=sqrt(info.lightDistanceSquared);\nvec3 lightDirection=normalize(info.lightOffset);\n\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+lightDirection);\nNdotL=clamp(dot(vNormal,lightDirection),0.00000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*info.attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor*info.attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(spotLightingInfo info,vec3 viewDirectionW,vec3 vNormal,vec4 lightDirection,vec3 diffuseColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\n\nfloat lightDistance=sqrt(info.lightDistanceSquared);\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+info.directionToLightCenterW);\nNdotL=clamp(dot(vNormal,info.directionToLightCenterW),0.000000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*info.attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor*info.attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeDirectionalLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\nfloat lightDistance=length(-lightData.xyz);\nvec3 lightDirection=normalize(-lightData.xyz);\n\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+lightDirection);\nNdotL=clamp(dot(vNormal,lightDirection),0.00000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\n\n\n\nNdotL=dot(vNormal,lightData.xyz)*0.5+0.5;\nresult.diffuse=mix(groundColor,diffuseColor,NdotL);\n#ifdef SPECULARTERM\n\nvec3 lightVectorW=normalize(lightData.xyz);\nvec3 H=normalize(viewDirectionW+lightVectorW);\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nNdotL=clamp(NdotL,0.000000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor;\n#endif\nreturn result;\n}\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn toLinearSpace(textureColor);\n}";
  123459. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123460. /** @hidden */
  123461. var pbrLightFunctions = { name: name, shader: shader };
  123462. /***/ }),
  123463. /***/ "./Shaders/ShadersInclude/pbrUboDeclaration.ts":
  123464. /*!*****************************************************!*\
  123465. !*** ./Shaders/ShadersInclude/pbrUboDeclaration.ts ***!
  123466. \*****************************************************/
  123467. /*! exports provided: pbrUboDeclaration */
  123468. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123469. "use strict";
  123470. __webpack_require__.r(__webpack_exports__);
  123471. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrUboDeclaration", function() { return pbrUboDeclaration; });
  123472. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123473. var name = 'pbrUboDeclaration';
  123474. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec2 vAlbedoInfos;\nuniform vec4 vAmbientInfos;\nuniform vec2 vOpacityInfos;\nuniform vec2 vEmissiveInfos;\nuniform vec2 vLightmapInfos;\nuniform vec3 vReflectivityInfos;\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform vec4 vRefractionInfos;\nuniform vec2 vReflectionInfos;\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\nuniform vec3 vBumpInfos;\nuniform mat4 albedoMatrix;\nuniform mat4 ambientMatrix;\nuniform mat4 opacityMatrix;\nuniform mat4 emissiveMatrix;\nuniform mat4 lightmapMatrix;\nuniform mat4 reflectivityMatrix;\nuniform mat4 microSurfaceSamplerMatrix;\nuniform mat4 bumpMatrix;\nuniform vec2 vTangentSpaceParams;\nuniform mat4 refractionMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float pointSize;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";
  123475. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123476. /** @hidden */
  123477. var pbrUboDeclaration = { name: name, shader: shader };
  123478. /***/ }),
  123479. /***/ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts":
  123480. /*!********************************************************!*\
  123481. !*** ./Shaders/ShadersInclude/pbrVertexDeclaration.ts ***!
  123482. \********************************************************/
  123483. /*! exports provided: pbrVertexDeclaration */
  123484. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123485. "use strict";
  123486. __webpack_require__.r(__webpack_exports__);
  123487. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexDeclaration", function() { return pbrVertexDeclaration; });
  123488. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123489. var name = 'pbrVertexDeclaration';
  123490. 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";
  123491. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123492. /** @hidden */
  123493. var pbrVertexDeclaration = { name: name, shader: shader };
  123494. /***/ }),
  123495. /***/ "./Shaders/ShadersInclude/pointCloudVertex.ts":
  123496. /*!****************************************************!*\
  123497. !*** ./Shaders/ShadersInclude/pointCloudVertex.ts ***!
  123498. \****************************************************/
  123499. /*! exports provided: pointCloudVertex */
  123500. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123501. "use strict";
  123502. __webpack_require__.r(__webpack_exports__);
  123503. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pointCloudVertex", function() { return pointCloudVertex; });
  123504. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123505. var name = 'pointCloudVertex';
  123506. var shader = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  123507. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123508. /** @hidden */
  123509. var pointCloudVertex = { name: name, shader: shader };
  123510. /***/ }),
  123511. /***/ "./Shaders/ShadersInclude/reflectionFunction.ts":
  123512. /*!******************************************************!*\
  123513. !*** ./Shaders/ShadersInclude/reflectionFunction.ts ***!
  123514. \******************************************************/
  123515. /*! exports provided: reflectionFunction */
  123516. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123517. "use strict";
  123518. __webpack_require__.r(__webpack_exports__);
  123519. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reflectionFunction", function() { return reflectionFunction; });
  123520. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123521. var name = 'reflectionFunction';
  123522. 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}";
  123523. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123524. /** @hidden */
  123525. var reflectionFunction = { name: name, shader: shader };
  123526. /***/ }),
  123527. /***/ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts":
  123528. /*!************************************************************!*\
  123529. !*** ./Shaders/ShadersInclude/shadowsFragmentFunctions.ts ***!
  123530. \************************************************************/
  123531. /*! exports provided: shadowsFragmentFunctions */
  123532. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123533. "use strict";
  123534. __webpack_require__.r(__webpack_exports__);
  123535. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsFragmentFunctions", function() { return shadowsFragmentFunctions; });
  123536. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123537. var name = 'shadowsFragmentFunctions';
  123538. 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";
  123539. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123540. /** @hidden */
  123541. var shadowsFragmentFunctions = { name: name, shader: shader };
  123542. /***/ }),
  123543. /***/ "./Shaders/ShadersInclude/shadowsVertex.ts":
  123544. /*!*************************************************!*\
  123545. !*** ./Shaders/ShadersInclude/shadowsVertex.ts ***!
  123546. \*************************************************/
  123547. /*! exports provided: shadowsVertex */
  123548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123549. "use strict";
  123550. __webpack_require__.r(__webpack_exports__);
  123551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsVertex", function() { return shadowsVertex; });
  123552. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123553. var name = 'shadowsVertex';
  123554. 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";
  123555. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123556. /** @hidden */
  123557. var shadowsVertex = { name: name, shader: shader };
  123558. /***/ }),
  123559. /***/ "./Shaders/anaglyph.fragment.ts":
  123560. /*!**************************************!*\
  123561. !*** ./Shaders/anaglyph.fragment.ts ***!
  123562. \**************************************/
  123563. /*! exports provided: anaglyphPixelShader */
  123564. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123565. "use strict";
  123566. __webpack_require__.r(__webpack_exports__);
  123567. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "anaglyphPixelShader", function() { return anaglyphPixelShader; });
  123568. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123569. var name = 'anaglyphPixelShader';
  123570. 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}";
  123571. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123572. /** @hidden */
  123573. var anaglyphPixelShader = { name: name, shader: shader };
  123574. /***/ }),
  123575. /***/ "./Shaders/background.fragment.ts":
  123576. /*!****************************************!*\
  123577. !*** ./Shaders/background.fragment.ts ***!
  123578. \****************************************/
  123579. /*! exports provided: backgroundPixelShader */
  123580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123581. "use strict";
  123582. __webpack_require__.r(__webpack_exports__);
  123583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundPixelShader", function() { return backgroundPixelShader; });
  123584. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123585. /* harmony import */ var _ShadersInclude_backgroundFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundFragmentDeclaration */ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts");
  123586. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  123587. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  123588. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123589. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123590. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123591. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123592. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  123593. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  123594. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123595. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  123596. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  123597. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  123598. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  123599. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  123600. var name = 'backgroundPixelShader';
  123601. 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";
  123602. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123603. /** @hidden */
  123604. var backgroundPixelShader = { name: name, shader: shader };
  123605. /***/ }),
  123606. /***/ "./Shaders/background.vertex.ts":
  123607. /*!**************************************!*\
  123608. !*** ./Shaders/background.vertex.ts ***!
  123609. \**************************************/
  123610. /*! exports provided: backgroundVertexShader */
  123611. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123612. "use strict";
  123613. __webpack_require__.r(__webpack_exports__);
  123614. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexShader", function() { return backgroundVertexShader; });
  123615. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123616. /* harmony import */ var _ShadersInclude_backgroundVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundVertexDeclaration */ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts");
  123617. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  123618. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123619. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123620. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123621. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  123622. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  123623. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123624. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123625. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123626. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123627. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  123628. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  123629. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  123630. var name = 'backgroundVertexShader';
  123631. 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";
  123632. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123633. /** @hidden */
  123634. var backgroundVertexShader = { name: name, shader: shader };
  123635. /***/ }),
  123636. /***/ "./Shaders/blackAndWhite.fragment.ts":
  123637. /*!*******************************************!*\
  123638. !*** ./Shaders/blackAndWhite.fragment.ts ***!
  123639. \*******************************************/
  123640. /*! exports provided: blackAndWhitePixelShader */
  123641. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123642. "use strict";
  123643. __webpack_require__.r(__webpack_exports__);
  123644. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blackAndWhitePixelShader", function() { return blackAndWhitePixelShader; });
  123645. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123646. var name = 'blackAndWhitePixelShader';
  123647. 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}";
  123648. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123649. /** @hidden */
  123650. var blackAndWhitePixelShader = { name: name, shader: shader };
  123651. /***/ }),
  123652. /***/ "./Shaders/bloomMerge.fragment.ts":
  123653. /*!****************************************!*\
  123654. !*** ./Shaders/bloomMerge.fragment.ts ***!
  123655. \****************************************/
  123656. /*! exports provided: bloomMergePixelShader */
  123657. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123658. "use strict";
  123659. __webpack_require__.r(__webpack_exports__);
  123660. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bloomMergePixelShader", function() { return bloomMergePixelShader; });
  123661. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123662. var name = 'bloomMergePixelShader';
  123663. 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";
  123664. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123665. /** @hidden */
  123666. var bloomMergePixelShader = { name: name, shader: shader };
  123667. /***/ }),
  123668. /***/ "./Shaders/chromaticAberration.fragment.ts":
  123669. /*!*************************************************!*\
  123670. !*** ./Shaders/chromaticAberration.fragment.ts ***!
  123671. \*************************************************/
  123672. /*! exports provided: chromaticAberrationPixelShader */
  123673. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123674. "use strict";
  123675. __webpack_require__.r(__webpack_exports__);
  123676. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chromaticAberrationPixelShader", function() { return chromaticAberrationPixelShader; });
  123677. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123678. var name = 'chromaticAberrationPixelShader';
  123679. 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}";
  123680. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123681. /** @hidden */
  123682. var chromaticAberrationPixelShader = { name: name, shader: shader };
  123683. /***/ }),
  123684. /***/ "./Shaders/circleOfConfusion.fragment.ts":
  123685. /*!***********************************************!*\
  123686. !*** ./Shaders/circleOfConfusion.fragment.ts ***!
  123687. \***********************************************/
  123688. /*! exports provided: circleOfConfusionPixelShader */
  123689. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123690. "use strict";
  123691. __webpack_require__.r(__webpack_exports__);
  123692. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "circleOfConfusionPixelShader", function() { return circleOfConfusionPixelShader; });
  123693. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123694. var name = 'circleOfConfusionPixelShader';
  123695. 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";
  123696. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123697. /** @hidden */
  123698. var circleOfConfusionPixelShader = { name: name, shader: shader };
  123699. /***/ }),
  123700. /***/ "./Shaders/color.fragment.ts":
  123701. /*!***********************************!*\
  123702. !*** ./Shaders/color.fragment.ts ***!
  123703. \***********************************/
  123704. /*! exports provided: colorPixelShader */
  123705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123706. "use strict";
  123707. __webpack_require__.r(__webpack_exports__);
  123708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorPixelShader", function() { return colorPixelShader; });
  123709. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123710. var name = 'colorPixelShader';
  123711. 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}";
  123712. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123713. /** @hidden */
  123714. var colorPixelShader = { name: name, shader: shader };
  123715. /***/ }),
  123716. /***/ "./Shaders/color.vertex.ts":
  123717. /*!*********************************!*\
  123718. !*** ./Shaders/color.vertex.ts ***!
  123719. \*********************************/
  123720. /*! exports provided: colorVertexShader */
  123721. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123722. "use strict";
  123723. __webpack_require__.r(__webpack_exports__);
  123724. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorVertexShader", function() { return colorVertexShader; });
  123725. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123726. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123727. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123728. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123729. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123730. var name = 'colorVertexShader';
  123731. 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}";
  123732. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123733. /** @hidden */
  123734. var colorVertexShader = { name: name, shader: shader };
  123735. /***/ }),
  123736. /***/ "./Shaders/colorCorrection.fragment.ts":
  123737. /*!*********************************************!*\
  123738. !*** ./Shaders/colorCorrection.fragment.ts ***!
  123739. \*********************************************/
  123740. /*! exports provided: colorCorrectionPixelShader */
  123741. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123742. "use strict";
  123743. __webpack_require__.r(__webpack_exports__);
  123744. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorCorrectionPixelShader", function() { return colorCorrectionPixelShader; });
  123745. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123746. var name = 'colorCorrectionPixelShader';
  123747. 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}";
  123748. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123749. /** @hidden */
  123750. var colorCorrectionPixelShader = { name: name, shader: shader };
  123751. /***/ }),
  123752. /***/ "./Shaders/convolution.fragment.ts":
  123753. /*!*****************************************!*\
  123754. !*** ./Shaders/convolution.fragment.ts ***!
  123755. \*****************************************/
  123756. /*! exports provided: convolutionPixelShader */
  123757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123758. "use strict";
  123759. __webpack_require__.r(__webpack_exports__);
  123760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convolutionPixelShader", function() { return convolutionPixelShader; });
  123761. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123762. var name = 'convolutionPixelShader';
  123763. 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}";
  123764. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123765. /** @hidden */
  123766. var convolutionPixelShader = { name: name, shader: shader };
  123767. /***/ }),
  123768. /***/ "./Shaders/default.fragment.ts":
  123769. /*!*************************************!*\
  123770. !*** ./Shaders/default.fragment.ts ***!
  123771. \*************************************/
  123772. /*! exports provided: defaultPixelShader */
  123773. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123774. "use strict";
  123775. __webpack_require__.r(__webpack_exports__);
  123776. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultPixelShader", function() { return defaultPixelShader; });
  123777. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123778. /* harmony import */ var _ShadersInclude_defaultFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultFragmentDeclaration */ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts");
  123779. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  123780. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123781. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123782. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123783. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  123784. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  123785. /* harmony import */ var _ShadersInclude_fresnelFunction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fresnelFunction */ "./Shaders/ShadersInclude/fresnelFunction.ts");
  123786. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  123787. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123788. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123789. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  123790. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  123791. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123792. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  123793. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  123794. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  123795. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  123796. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  123797. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  123798. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  123799. var name = 'defaultPixelShader';
  123800. 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";
  123801. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123802. /** @hidden */
  123803. var defaultPixelShader = { name: name, shader: shader };
  123804. /***/ }),
  123805. /***/ "./Shaders/default.vertex.ts":
  123806. /*!***********************************!*\
  123807. !*** ./Shaders/default.vertex.ts ***!
  123808. \***********************************/
  123809. /*! exports provided: defaultVertexShader */
  123810. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123811. "use strict";
  123812. __webpack_require__.r(__webpack_exports__);
  123813. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexShader", function() { return defaultVertexShader; });
  123814. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123815. /* harmony import */ var _ShadersInclude_defaultVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultVertexDeclaration */ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts");
  123816. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  123817. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123818. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123819. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123820. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  123821. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  123822. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  123823. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123824. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123825. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  123826. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  123827. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123828. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  123829. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123830. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123831. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  123832. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  123833. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  123834. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  123835. /* harmony import */ var _ShadersInclude_pointCloudVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/pointCloudVertex */ "./Shaders/ShadersInclude/pointCloudVertex.ts");
  123836. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  123837. var name = 'defaultVertexShader';
  123838. 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";
  123839. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123840. /** @hidden */
  123841. var defaultVertexShader = { name: name, shader: shader };
  123842. /***/ }),
  123843. /***/ "./Shaders/depth.fragment.ts":
  123844. /*!***********************************!*\
  123845. !*** ./Shaders/depth.fragment.ts ***!
  123846. \***********************************/
  123847. /*! exports provided: depthPixelShader */
  123848. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123849. "use strict";
  123850. __webpack_require__.r(__webpack_exports__);
  123851. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPixelShader", function() { return depthPixelShader; });
  123852. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123853. var name = 'depthPixelShader';
  123854. 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}";
  123855. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123856. /** @hidden */
  123857. var depthPixelShader = { name: name, shader: shader };
  123858. /***/ }),
  123859. /***/ "./Shaders/depth.vertex.ts":
  123860. /*!*********************************!*\
  123861. !*** ./Shaders/depth.vertex.ts ***!
  123862. \*********************************/
  123863. /*! exports provided: depthVertexShader */
  123864. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123865. "use strict";
  123866. __webpack_require__.r(__webpack_exports__);
  123867. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthVertexShader", function() { return depthVertexShader; });
  123868. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123869. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123870. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123871. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123872. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123873. var name = 'depthVertexShader';
  123874. 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}";
  123875. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123876. /** @hidden */
  123877. var depthVertexShader = { name: name, shader: shader };
  123878. /***/ }),
  123879. /***/ "./Shaders/depthBoxBlur.fragment.ts":
  123880. /*!******************************************!*\
  123881. !*** ./Shaders/depthBoxBlur.fragment.ts ***!
  123882. \******************************************/
  123883. /*! exports provided: depthBoxBlurPixelShader */
  123884. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123885. "use strict";
  123886. __webpack_require__.r(__webpack_exports__);
  123887. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthBoxBlurPixelShader", function() { return depthBoxBlurPixelShader; });
  123888. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123889. var name = 'depthBoxBlurPixelShader';
  123890. 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}";
  123891. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123892. /** @hidden */
  123893. var depthBoxBlurPixelShader = { name: name, shader: shader };
  123894. /***/ }),
  123895. /***/ "./Shaders/depthOfField.fragment.ts":
  123896. /*!******************************************!*\
  123897. !*** ./Shaders/depthOfField.fragment.ts ***!
  123898. \******************************************/
  123899. /*! exports provided: depthOfFieldPixelShader */
  123900. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123901. "use strict";
  123902. __webpack_require__.r(__webpack_exports__);
  123903. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldPixelShader", function() { return depthOfFieldPixelShader; });
  123904. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123905. var name = 'depthOfFieldPixelShader';
  123906. 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";
  123907. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123908. /** @hidden */
  123909. var depthOfFieldPixelShader = { name: name, shader: shader };
  123910. /***/ }),
  123911. /***/ "./Shaders/depthOfFieldMerge.fragment.ts":
  123912. /*!***********************************************!*\
  123913. !*** ./Shaders/depthOfFieldMerge.fragment.ts ***!
  123914. \***********************************************/
  123915. /*! exports provided: depthOfFieldMergePixelShader */
  123916. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123917. "use strict";
  123918. __webpack_require__.r(__webpack_exports__);
  123919. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldMergePixelShader", function() { return depthOfFieldMergePixelShader; });
  123920. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123921. var name = 'depthOfFieldMergePixelShader';
  123922. 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";
  123923. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123924. /** @hidden */
  123925. var depthOfFieldMergePixelShader = { name: name, shader: shader };
  123926. /***/ }),
  123927. /***/ "./Shaders/displayPass.fragment.ts":
  123928. /*!*****************************************!*\
  123929. !*** ./Shaders/displayPass.fragment.ts ***!
  123930. \*****************************************/
  123931. /*! exports provided: displayPassPixelShader */
  123932. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123933. "use strict";
  123934. __webpack_require__.r(__webpack_exports__);
  123935. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayPassPixelShader", function() { return displayPassPixelShader; });
  123936. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123937. var name = 'displayPassPixelShader';
  123938. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  123939. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123940. /** @hidden */
  123941. var displayPassPixelShader = { name: name, shader: shader };
  123942. /***/ }),
  123943. /***/ "./Shaders/extractHighlights.fragment.ts":
  123944. /*!***********************************************!*\
  123945. !*** ./Shaders/extractHighlights.fragment.ts ***!
  123946. \***********************************************/
  123947. /*! exports provided: extractHighlightsPixelShader */
  123948. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123949. "use strict";
  123950. __webpack_require__.r(__webpack_exports__);
  123951. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractHighlightsPixelShader", function() { return extractHighlightsPixelShader; });
  123952. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123953. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123954. var name = 'extractHighlightsPixelShader';
  123955. 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}";
  123956. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123957. /** @hidden */
  123958. var extractHighlightsPixelShader = { name: name, shader: shader };
  123959. /***/ }),
  123960. /***/ "./Shaders/filter.fragment.ts":
  123961. /*!************************************!*\
  123962. !*** ./Shaders/filter.fragment.ts ***!
  123963. \************************************/
  123964. /*! exports provided: filterPixelShader */
  123965. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123966. "use strict";
  123967. __webpack_require__.r(__webpack_exports__);
  123968. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterPixelShader", function() { return filterPixelShader; });
  123969. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123970. var name = 'filterPixelShader';
  123971. 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}";
  123972. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123973. /** @hidden */
  123974. var filterPixelShader = { name: name, shader: shader };
  123975. /***/ }),
  123976. /***/ "./Shaders/fxaa.fragment.ts":
  123977. /*!**********************************!*\
  123978. !*** ./Shaders/fxaa.fragment.ts ***!
  123979. \**********************************/
  123980. /*! exports provided: fxaaPixelShader */
  123981. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123982. "use strict";
  123983. __webpack_require__.r(__webpack_exports__);
  123984. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaPixelShader", function() { return fxaaPixelShader; });
  123985. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123986. var name = 'fxaaPixelShader';
  123987. 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}";
  123988. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123989. /** @hidden */
  123990. var fxaaPixelShader = { name: name, shader: shader };
  123991. /***/ }),
  123992. /***/ "./Shaders/fxaa.vertex.ts":
  123993. /*!********************************!*\
  123994. !*** ./Shaders/fxaa.vertex.ts ***!
  123995. \********************************/
  123996. /*! exports provided: fxaaVertexShader */
  123997. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123998. "use strict";
  123999. __webpack_require__.r(__webpack_exports__);
  124000. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaVertexShader", function() { return fxaaVertexShader; });
  124001. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124002. var name = 'fxaaVertexShader';
  124003. 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}";
  124004. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124005. /** @hidden */
  124006. var fxaaVertexShader = { name: name, shader: shader };
  124007. /***/ }),
  124008. /***/ "./Shaders/geometry.fragment.ts":
  124009. /*!**************************************!*\
  124010. !*** ./Shaders/geometry.fragment.ts ***!
  124011. \**************************************/
  124012. /*! exports provided: geometryPixelShader */
  124013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124014. "use strict";
  124015. __webpack_require__.r(__webpack_exports__);
  124016. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryPixelShader", function() { return geometryPixelShader; });
  124017. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124018. /* harmony import */ var _ShadersInclude_mrtFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/mrtFragmentDeclaration */ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts");
  124019. var name = 'geometryPixelShader';
  124020. 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}";
  124021. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124022. /** @hidden */
  124023. var geometryPixelShader = { name: name, shader: shader };
  124024. /***/ }),
  124025. /***/ "./Shaders/geometry.vertex.ts":
  124026. /*!************************************!*\
  124027. !*** ./Shaders/geometry.vertex.ts ***!
  124028. \************************************/
  124029. /*! exports provided: geometryVertexShader */
  124030. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124031. "use strict";
  124032. __webpack_require__.r(__webpack_exports__);
  124033. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryVertexShader", function() { return geometryVertexShader; });
  124034. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124035. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124036. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124037. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124038. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124039. var name = 'geometryVertexShader';
  124040. 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}";
  124041. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124042. /** @hidden */
  124043. var geometryVertexShader = { name: name, shader: shader };
  124044. /***/ }),
  124045. /***/ "./Shaders/glowBlurPostProcess.fragment.ts":
  124046. /*!*************************************************!*\
  124047. !*** ./Shaders/glowBlurPostProcess.fragment.ts ***!
  124048. \*************************************************/
  124049. /*! exports provided: glowBlurPostProcessPixelShader */
  124050. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124051. "use strict";
  124052. __webpack_require__.r(__webpack_exports__);
  124053. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowBlurPostProcessPixelShader", function() { return glowBlurPostProcessPixelShader; });
  124054. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124055. var name = 'glowBlurPostProcessPixelShader';
  124056. 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}";
  124057. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124058. /** @hidden */
  124059. var glowBlurPostProcessPixelShader = { name: name, shader: shader };
  124060. /***/ }),
  124061. /***/ "./Shaders/glowMapGeneration.fragment.ts":
  124062. /*!***********************************************!*\
  124063. !*** ./Shaders/glowMapGeneration.fragment.ts ***!
  124064. \***********************************************/
  124065. /*! exports provided: glowMapGenerationPixelShader */
  124066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124067. "use strict";
  124068. __webpack_require__.r(__webpack_exports__);
  124069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationPixelShader", function() { return glowMapGenerationPixelShader; });
  124070. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124071. var name = 'glowMapGenerationPixelShader';
  124072. 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}";
  124073. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124074. /** @hidden */
  124075. var glowMapGenerationPixelShader = { name: name, shader: shader };
  124076. /***/ }),
  124077. /***/ "./Shaders/glowMapGeneration.vertex.ts":
  124078. /*!*********************************************!*\
  124079. !*** ./Shaders/glowMapGeneration.vertex.ts ***!
  124080. \*********************************************/
  124081. /*! exports provided: glowMapGenerationVertexShader */
  124082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124083. "use strict";
  124084. __webpack_require__.r(__webpack_exports__);
  124085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationVertexShader", function() { return glowMapGenerationVertexShader; });
  124086. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124087. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124088. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  124089. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  124090. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124091. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  124092. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124093. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124094. var name = 'glowMapGenerationVertexShader';
  124095. 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}";
  124096. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124097. /** @hidden */
  124098. var glowMapGenerationVertexShader = { name: name, shader: shader };
  124099. /***/ }),
  124100. /***/ "./Shaders/glowMapMerge.fragment.ts":
  124101. /*!******************************************!*\
  124102. !*** ./Shaders/glowMapMerge.fragment.ts ***!
  124103. \******************************************/
  124104. /*! exports provided: glowMapMergePixelShader */
  124105. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124106. "use strict";
  124107. __webpack_require__.r(__webpack_exports__);
  124108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergePixelShader", function() { return glowMapMergePixelShader; });
  124109. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124110. var name = 'glowMapMergePixelShader';
  124111. 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}";
  124112. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124113. /** @hidden */
  124114. var glowMapMergePixelShader = { name: name, shader: shader };
  124115. /***/ }),
  124116. /***/ "./Shaders/glowMapMerge.vertex.ts":
  124117. /*!****************************************!*\
  124118. !*** ./Shaders/glowMapMerge.vertex.ts ***!
  124119. \****************************************/
  124120. /*! exports provided: glowMapMergeVertexShader */
  124121. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124122. "use strict";
  124123. __webpack_require__.r(__webpack_exports__);
  124124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergeVertexShader", function() { return glowMapMergeVertexShader; });
  124125. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124126. var name = 'glowMapMergeVertexShader';
  124127. 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}";
  124128. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124129. /** @hidden */
  124130. var glowMapMergeVertexShader = { name: name, shader: shader };
  124131. /***/ }),
  124132. /***/ "./Shaders/gpuRenderParticles.fragment.ts":
  124133. /*!************************************************!*\
  124134. !*** ./Shaders/gpuRenderParticles.fragment.ts ***!
  124135. \************************************************/
  124136. /*! exports provided: gpuRenderParticlesPixelShader */
  124137. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124138. "use strict";
  124139. __webpack_require__.r(__webpack_exports__);
  124140. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesPixelShader", function() { return gpuRenderParticlesPixelShader; });
  124141. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124142. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts");
  124143. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124144. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124145. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124146. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  124147. var name = 'gpuRenderParticlesPixelShader';
  124148. 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";
  124149. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124150. /** @hidden */
  124151. var gpuRenderParticlesPixelShader = { name: name, shader: shader };
  124152. /***/ }),
  124153. /***/ "./Shaders/gpuRenderParticles.vertex.ts":
  124154. /*!**********************************************!*\
  124155. !*** ./Shaders/gpuRenderParticles.vertex.ts ***!
  124156. \**********************************************/
  124157. /*! exports provided: gpuRenderParticlesVertexShader */
  124158. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124159. "use strict";
  124160. __webpack_require__.r(__webpack_exports__);
  124161. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesVertexShader", function() { return gpuRenderParticlesVertexShader; });
  124162. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124163. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts");
  124164. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  124165. var name = 'gpuRenderParticlesVertexShader';
  124166. var shader = "#version 300 es\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\n\nin vec3 position;\nin float age;\nin float life;\nin vec3 size;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef BILLBOARDSTRETCHED\nin vec3 direction;\n#endif\nin float angle;\n#ifdef ANIMATESHEET\nin float cellIndex;\n#endif\nin vec2 offset;\nin vec2 uv;\nout vec2 vUV;\nout vec4 vColor;\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nuniform mat4 invView;\n#endif\n#include<clipPlaneVertexDeclaration2>\n#ifdef COLORGRADIENTS\nuniform sampler2D colorGradientSampler;\n#else\nuniform vec4 colorDead;\nin vec4 color;\n#endif\n#ifdef ANIMATESHEET\nuniform vec3 sheetInfos;\n#endif\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#endif\nvoid main() {\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/sheetInfos.z);\nfloat columnOffset=cellIndex-rowOffset*sheetInfos.z;\nvec2 uvScale=sheetInfos.xy;\nvec2 uvOffset=vec2(uv.x ,1.0-uv.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=uv;\n#endif\nfloat ratio=age/life;\n#ifdef COLORGRADIENTS\nvColor=texture(colorGradientSampler,vec2(ratio,0));\n#else\nvColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);\n#endif\nvec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;\n#ifdef BILLBOARD\nvec4 rotatedCorner;\nrotatedCorner.w=0.;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=position-eyePosition;\nyaxis.y=0.;\nvec3 worldPos=rotate(normalize(yaxis),rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0));\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=position-eyePosition;\nvec3 worldPos=rotateAlign(toCamera,rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0));\n#else\n\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nvec4 viewPosition=view*vec4(position,1.0)+rotatedCorner;\n#endif\n#else\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=0.;\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nvec3 yaxis=normalize(initialDirection);\nvec3 worldPos=rotate(yaxis,rotatedCorner);\n\nvec4 viewPosition=view*vec4(worldPos,1.0);\n#endif\ngl_Position=projection*viewPosition;\n\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nvec4 worldPos=invView*viewPosition;\n#endif\n#include<clipPlaneVertex>\n}";
  124167. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124168. /** @hidden */
  124169. var gpuRenderParticlesVertexShader = { name: name, shader: shader };
  124170. /***/ }),
  124171. /***/ "./Shaders/gpuUpdateParticles.fragment.ts":
  124172. /*!************************************************!*\
  124173. !*** ./Shaders/gpuUpdateParticles.fragment.ts ***!
  124174. \************************************************/
  124175. /*! exports provided: gpuUpdateParticlesPixelShader */
  124176. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124177. "use strict";
  124178. __webpack_require__.r(__webpack_exports__);
  124179. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesPixelShader", function() { return gpuUpdateParticlesPixelShader; });
  124180. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124181. var name = 'gpuUpdateParticlesPixelShader';
  124182. var shader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  124183. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124184. /** @hidden */
  124185. var gpuUpdateParticlesPixelShader = { name: name, shader: shader };
  124186. /***/ }),
  124187. /***/ "./Shaders/gpuUpdateParticles.vertex.ts":
  124188. /*!**********************************************!*\
  124189. !*** ./Shaders/gpuUpdateParticles.vertex.ts ***!
  124190. \**********************************************/
  124191. /*! exports provided: gpuUpdateParticlesVertexShader */
  124192. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124193. "use strict";
  124194. __webpack_require__.r(__webpack_exports__);
  124195. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesVertexShader", function() { return gpuUpdateParticlesVertexShader; });
  124196. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124197. var name = 'gpuUpdateParticlesVertexShader';
  124198. 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}";
  124199. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124200. /** @hidden */
  124201. var gpuUpdateParticlesVertexShader = { name: name, shader: shader };
  124202. /***/ }),
  124203. /***/ "./Shaders/grain.fragment.ts":
  124204. /*!***********************************!*\
  124205. !*** ./Shaders/grain.fragment.ts ***!
  124206. \***********************************/
  124207. /*! exports provided: grainPixelShader */
  124208. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124209. "use strict";
  124210. __webpack_require__.r(__webpack_exports__);
  124211. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "grainPixelShader", function() { return grainPixelShader; });
  124212. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124213. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124214. var name = 'grainPixelShader';
  124215. 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}";
  124216. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124217. /** @hidden */
  124218. var grainPixelShader = { name: name, shader: shader };
  124219. /***/ }),
  124220. /***/ "./Shaders/highlights.fragment.ts":
  124221. /*!****************************************!*\
  124222. !*** ./Shaders/highlights.fragment.ts ***!
  124223. \****************************************/
  124224. /*! exports provided: highlightsPixelShader */
  124225. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124226. "use strict";
  124227. __webpack_require__.r(__webpack_exports__);
  124228. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "highlightsPixelShader", function() { return highlightsPixelShader; });
  124229. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124230. var name = 'highlightsPixelShader';
  124231. 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}";
  124232. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124233. /** @hidden */
  124234. var highlightsPixelShader = { name: name, shader: shader };
  124235. /***/ }),
  124236. /***/ "./Shaders/imageProcessing.fragment.ts":
  124237. /*!*********************************************!*\
  124238. !*** ./Shaders/imageProcessing.fragment.ts ***!
  124239. \*********************************************/
  124240. /*! exports provided: imageProcessingPixelShader */
  124241. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124242. "use strict";
  124243. __webpack_require__.r(__webpack_exports__);
  124244. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingPixelShader", function() { return imageProcessingPixelShader; });
  124245. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124246. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124247. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124248. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124249. var name = 'imageProcessingPixelShader';
  124250. 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}";
  124251. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124252. /** @hidden */
  124253. var imageProcessingPixelShader = { name: name, shader: shader };
  124254. /***/ }),
  124255. /***/ "./Shaders/kernelBlur.fragment.ts":
  124256. /*!****************************************!*\
  124257. !*** ./Shaders/kernelBlur.fragment.ts ***!
  124258. \****************************************/
  124259. /*! exports provided: kernelBlurPixelShader */
  124260. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124261. "use strict";
  124262. __webpack_require__.r(__webpack_exports__);
  124263. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurPixelShader", function() { return kernelBlurPixelShader; });
  124264. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124265. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  124266. /* harmony import */ var _ShadersInclude_kernelBlurFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment */ "./Shaders/ShadersInclude/kernelBlurFragment.ts");
  124267. /* harmony import */ var _ShadersInclude_kernelBlurFragment2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment2 */ "./Shaders/ShadersInclude/kernelBlurFragment2.ts");
  124268. var name = 'kernelBlurPixelShader';
  124269. 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}";
  124270. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124271. /** @hidden */
  124272. var kernelBlurPixelShader = { name: name, shader: shader };
  124273. /***/ }),
  124274. /***/ "./Shaders/kernelBlur.vertex.ts":
  124275. /*!**************************************!*\
  124276. !*** ./Shaders/kernelBlur.vertex.ts ***!
  124277. \**************************************/
  124278. /*! exports provided: kernelBlurVertexShader */
  124279. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124280. "use strict";
  124281. __webpack_require__.r(__webpack_exports__);
  124282. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertexShader", function() { return kernelBlurVertexShader; });
  124283. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124284. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  124285. /* harmony import */ var _ShadersInclude_kernelBlurVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVertex */ "./Shaders/ShadersInclude/kernelBlurVertex.ts");
  124286. var name = 'kernelBlurVertexShader';
  124287. 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}";
  124288. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124289. /** @hidden */
  124290. var kernelBlurVertexShader = { name: name, shader: shader };
  124291. /***/ }),
  124292. /***/ "./Shaders/layer.fragment.ts":
  124293. /*!***********************************!*\
  124294. !*** ./Shaders/layer.fragment.ts ***!
  124295. \***********************************/
  124296. /*! exports provided: layerPixelShader */
  124297. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124298. "use strict";
  124299. __webpack_require__.r(__webpack_exports__);
  124300. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerPixelShader", function() { return layerPixelShader; });
  124301. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124302. var name = 'layerPixelShader';
  124303. 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}";
  124304. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124305. /** @hidden */
  124306. var layerPixelShader = { name: name, shader: shader };
  124307. /***/ }),
  124308. /***/ "./Shaders/layer.vertex.ts":
  124309. /*!*********************************!*\
  124310. !*** ./Shaders/layer.vertex.ts ***!
  124311. \*********************************/
  124312. /*! exports provided: layerVertexShader */
  124313. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124314. "use strict";
  124315. __webpack_require__.r(__webpack_exports__);
  124316. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerVertexShader", function() { return layerVertexShader; });
  124317. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124318. var name = 'layerVertexShader';
  124319. 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}";
  124320. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124321. /** @hidden */
  124322. var layerVertexShader = { name: name, shader: shader };
  124323. /***/ }),
  124324. /***/ "./Shaders/lensFlare.fragment.ts":
  124325. /*!***************************************!*\
  124326. !*** ./Shaders/lensFlare.fragment.ts ***!
  124327. \***************************************/
  124328. /*! exports provided: lensFlarePixelShader */
  124329. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124330. "use strict";
  124331. __webpack_require__.r(__webpack_exports__);
  124332. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlarePixelShader", function() { return lensFlarePixelShader; });
  124333. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124334. var name = 'lensFlarePixelShader';
  124335. 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}";
  124336. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124337. /** @hidden */
  124338. var lensFlarePixelShader = { name: name, shader: shader };
  124339. /***/ }),
  124340. /***/ "./Shaders/lensFlare.vertex.ts":
  124341. /*!*************************************!*\
  124342. !*** ./Shaders/lensFlare.vertex.ts ***!
  124343. \*************************************/
  124344. /*! exports provided: lensFlareVertexShader */
  124345. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124346. "use strict";
  124347. __webpack_require__.r(__webpack_exports__);
  124348. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlareVertexShader", function() { return lensFlareVertexShader; });
  124349. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124350. var name = 'lensFlareVertexShader';
  124351. 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}";
  124352. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124353. /** @hidden */
  124354. var lensFlareVertexShader = { name: name, shader: shader };
  124355. /***/ }),
  124356. /***/ "./Shaders/lensHighlights.fragment.ts":
  124357. /*!********************************************!*\
  124358. !*** ./Shaders/lensHighlights.fragment.ts ***!
  124359. \********************************************/
  124360. /*! exports provided: lensHighlightsPixelShader */
  124361. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124362. "use strict";
  124363. __webpack_require__.r(__webpack_exports__);
  124364. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensHighlightsPixelShader", function() { return lensHighlightsPixelShader; });
  124365. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124366. var name = 'lensHighlightsPixelShader';
  124367. 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}";
  124368. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124369. /** @hidden */
  124370. var lensHighlightsPixelShader = { name: name, shader: shader };
  124371. /***/ }),
  124372. /***/ "./Shaders/line.fragment.ts":
  124373. /*!**********************************!*\
  124374. !*** ./Shaders/line.fragment.ts ***!
  124375. \**********************************/
  124376. /*! exports provided: linePixelShader */
  124377. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124378. "use strict";
  124379. __webpack_require__.r(__webpack_exports__);
  124380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linePixelShader", function() { return linePixelShader; });
  124381. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124382. var name = 'linePixelShader';
  124383. var shader = "uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";
  124384. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124385. /** @hidden */
  124386. var linePixelShader = { name: name, shader: shader };
  124387. /***/ }),
  124388. /***/ "./Shaders/line.vertex.ts":
  124389. /*!********************************!*\
  124390. !*** ./Shaders/line.vertex.ts ***!
  124391. \********************************/
  124392. /*! exports provided: lineVertexShader */
  124393. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124394. "use strict";
  124395. __webpack_require__.r(__webpack_exports__);
  124396. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineVertexShader", function() { return lineVertexShader; });
  124397. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124398. var name = 'lineVertexShader';
  124399. 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}";
  124400. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124401. /** @hidden */
  124402. var lineVertexShader = { name: name, shader: shader };
  124403. /***/ }),
  124404. /***/ "./Shaders/motionBlur.fragment.ts":
  124405. /*!****************************************!*\
  124406. !*** ./Shaders/motionBlur.fragment.ts ***!
  124407. \****************************************/
  124408. /*! exports provided: motionBlurPixelShader */
  124409. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124410. "use strict";
  124411. __webpack_require__.r(__webpack_exports__);
  124412. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "motionBlurPixelShader", function() { return motionBlurPixelShader; });
  124413. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124414. var name = 'motionBlurPixelShader';
  124415. 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";
  124416. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124417. /** @hidden */
  124418. var motionBlurPixelShader = { name: name, shader: shader };
  124419. /***/ }),
  124420. /***/ "./Shaders/noise.fragment.ts":
  124421. /*!***********************************!*\
  124422. !*** ./Shaders/noise.fragment.ts ***!
  124423. \***********************************/
  124424. /*! exports provided: noisePixelShader */
  124425. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124426. "use strict";
  124427. __webpack_require__.r(__webpack_exports__);
  124428. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noisePixelShader", function() { return noisePixelShader; });
  124429. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124430. var name = 'noisePixelShader';
  124431. 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";
  124432. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124433. /** @hidden */
  124434. var noisePixelShader = { name: name, shader: shader };
  124435. /***/ }),
  124436. /***/ "./Shaders/outline.fragment.ts":
  124437. /*!*************************************!*\
  124438. !*** ./Shaders/outline.fragment.ts ***!
  124439. \*************************************/
  124440. /*! exports provided: outlinePixelShader */
  124441. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124442. "use strict";
  124443. __webpack_require__.r(__webpack_exports__);
  124444. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlinePixelShader", function() { return outlinePixelShader; });
  124445. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124446. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124447. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  124448. var name = 'outlinePixelShader';
  124449. 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}";
  124450. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124451. /** @hidden */
  124452. var outlinePixelShader = { name: name, shader: shader };
  124453. /***/ }),
  124454. /***/ "./Shaders/outline.vertex.ts":
  124455. /*!***********************************!*\
  124456. !*** ./Shaders/outline.vertex.ts ***!
  124457. \***********************************/
  124458. /*! exports provided: outlineVertexShader */
  124459. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124460. "use strict";
  124461. __webpack_require__.r(__webpack_exports__);
  124462. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlineVertexShader", function() { return outlineVertexShader; });
  124463. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124464. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124465. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124466. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124467. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124468. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124469. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  124470. var name = 'outlineVertexShader';
  124471. 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";
  124472. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124473. /** @hidden */
  124474. var outlineVertexShader = { name: name, shader: shader };
  124475. /***/ }),
  124476. /***/ "./Shaders/particles.fragment.ts":
  124477. /*!***************************************!*\
  124478. !*** ./Shaders/particles.fragment.ts ***!
  124479. \***************************************/
  124480. /*! exports provided: particlesPixelShader */
  124481. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124482. "use strict";
  124483. __webpack_require__.r(__webpack_exports__);
  124484. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesPixelShader", function() { return particlesPixelShader; });
  124485. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124486. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  124487. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124488. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124489. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124490. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  124491. var name = 'particlesPixelShader';
  124492. 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}";
  124493. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124494. /** @hidden */
  124495. var particlesPixelShader = { name: name, shader: shader };
  124496. /***/ }),
  124497. /***/ "./Shaders/particles.vertex.ts":
  124498. /*!*************************************!*\
  124499. !*** ./Shaders/particles.vertex.ts ***!
  124500. \*************************************/
  124501. /*! exports provided: particlesVertexShader */
  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__, "particlesVertexShader", function() { return particlesVertexShader; });
  124506. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124507. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  124508. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  124509. var name = 'particlesVertexShader';
  124510. 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}";
  124511. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124512. /** @hidden */
  124513. var particlesVertexShader = { name: name, shader: shader };
  124514. /***/ }),
  124515. /***/ "./Shaders/pass.fragment.ts":
  124516. /*!**********************************!*\
  124517. !*** ./Shaders/pass.fragment.ts ***!
  124518. \**********************************/
  124519. /*! exports provided: passPixelShader */
  124520. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124521. "use strict";
  124522. __webpack_require__.r(__webpack_exports__);
  124523. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passPixelShader", function() { return passPixelShader; });
  124524. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124525. var name = 'passPixelShader';
  124526. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  124527. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124528. /** @hidden */
  124529. var passPixelShader = { name: name, shader: shader };
  124530. /***/ }),
  124531. /***/ "./Shaders/passCube.fragment.ts":
  124532. /*!**************************************!*\
  124533. !*** ./Shaders/passCube.fragment.ts ***!
  124534. \**************************************/
  124535. /*! exports provided: passCubePixelShader */
  124536. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124537. "use strict";
  124538. __webpack_require__.r(__webpack_exports__);
  124539. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passCubePixelShader", function() { return passCubePixelShader; });
  124540. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124541. var name = 'passCubePixelShader';
  124542. 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}";
  124543. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124544. /** @hidden */
  124545. var passCubePixelShader = { name: name, shader: shader };
  124546. /***/ }),
  124547. /***/ "./Shaders/pbr.fragment.ts":
  124548. /*!*********************************!*\
  124549. !*** ./Shaders/pbr.fragment.ts ***!
  124550. \*********************************/
  124551. /*! exports provided: pbrPixelShader */
  124552. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124553. "use strict";
  124554. __webpack_require__.r(__webpack_exports__);
  124555. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPixelShader", function() { return pbrPixelShader; });
  124556. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124557. /* harmony import */ var _ShadersInclude_pbrFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentDeclaration */ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts");
  124558. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  124559. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  124560. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  124561. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  124562. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124563. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124564. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124565. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  124566. /* harmony import */ var _ShadersInclude_pbrFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/pbrFunctions */ "./Shaders/ShadersInclude/pbrFunctions.ts");
  124567. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  124568. /* harmony import */ var _ShadersInclude_pbrLightFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/pbrLightFunctions */ "./Shaders/ShadersInclude/pbrLightFunctions.ts");
  124569. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  124570. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  124571. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124572. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  124573. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  124574. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  124575. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  124576. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  124577. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  124578. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  124579. var name = 'pbrPixelShader';
  124580. var shader = "#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n#include<__decl__pbrFragment>\nuniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\n\n#include<shadowsFragmentFunctions>\n#include<pbrFunctions>\n#include<harmonicsFunctions>\n#include<pbrLightFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\n\n\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#endif\n#include<bumpFragment>\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalW.xyz);\nvec3 nDfdy=dFdy(normalW.xyz);\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\n\nfloat geometricRoughnessFactor=pow(clamp(slopeSquare ,0.,1.),0.333);\n\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\n#else\nfloat geometricRoughnessFactor=0.;\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#if defined(TWOSIDEDLIGHTING)\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\n#endif\nnormalW*=sign(dot(normalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\nsurfaceAlbedo*=vAlbedoInfos.y;\n#endif\n\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo;\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceAlbedo=mix(baseColor.rgb*(1.0-DefaultSpecularReflectanceDielectric.r),vec3(0.,0.,0.),metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#else\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nsurfaceReflectivityColor*=toLinearSpace(surfaceReflectivityColorMap.rgb);\nsurfaceReflectivityColor*=vReflectivityInfos.y;\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceReflectivityColorMap.a;\nmicroSurface*=vReflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#endif\n#endif\n#endif\n\nmicroSurface=clamp(microSurface,0.,1.);\n\nfloat roughness=1.-microSurface;\n\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\n\n\n\nfloat opacityPerceptual=alpha;\n#ifdef LINEARALPHAFRESNEL\nfloat opacity0=opacityPerceptual;\n#else\nfloat opacity0=opacityPerceptual*opacityPerceptual;\n#endif\nfloat opacity90=fresnelGrazingReflectance(opacity0);\nvec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);\n\nalpha=fresnelSchlickEnvironmentGGX(clamp(dot(viewDirectionW,normalForward),0.0,1.0),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#endif\n\n\nfloat NdotVUnclamped=dot(normalW,viewDirectionW);\nfloat NdotV=clamp(NdotVUnclamped,0.,1.)+0.00001;\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n#ifdef SPECULARAA\n\n\nalphaG+=(0.75*geometricAlphaGFactor);\n#endif\n\n#ifdef REFRACTION\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#ifdef REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#endif\n#ifdef LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,1.0);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef LODINREFRACTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);\nfloat requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);\n#else\nfloat requestedRefractionLOD=refractionLOD;\n#endif\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);\n#else\nfloat lodRefractionNormalized=clamp(refractionLOD/log2(vRefractionMicrosurfaceInfos.x),0.,1.);\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\nvec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);\nif(lodRefractionNormalizedDoubled<1.0){\nenvironmentRefraction=mix(\nsampleRefraction(refractionSamplerHigh,refractionCoords),\nenvironmentRefractionMid,\nlodRefractionNormalizedDoubled\n);\n}else{\nenvironmentRefraction=mix(\nenvironmentRefractionMid,\nsampleRefraction(refractionSamplerLow,refractionCoords),\nlodRefractionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFRACTION\nenvironmentRefraction.rgb=fromRGBD(environmentRefraction);\n#endif\n#ifdef GAMMAREFRACTION\nenvironmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);\n#endif\n\nenvironmentRefraction.rgb*=vRefractionInfos.x;\n#endif\n\n#ifdef REFLECTION\nvec4 environmentRadiance=vec4(0.,0.,0.,0.);\nvec3 environmentIrradiance=vec3(0.,0.,0.);\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,1.);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,requestedReflectionLOD);\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x),0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 environmentSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSpecularMid,\nlodReflectionNormalizedDoubled\n);\n}else{\nenvironmentRadiance=mix(\nenvironmentSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\n#endif\n\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\nenvironmentIrradiance=environmentIrradianceJones(irradianceVector);\n#endif\n#endif\n\nenvironmentRadiance.rgb*=vReflectionInfos.x;\nenvironmentRadiance.rgb*=vReflectionColor.rgb;\nenvironmentIrradiance*=vReflectionColor.rgb;\n#endif\n\n\n\nfloat reflectance=max(max(surfaceReflectivityColor.r,surfaceReflectivityColor.g),surfaceReflectivityColor.b);\nfloat reflectance90=fresnelGrazingReflectance(reflectance);\nvec3 specularEnvironmentR0=surfaceReflectivityColor.rgb;\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0)*reflectance90;\n\nvec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb;\n#ifdef GAMMALIGHTMAP\nlightmapColor=toLinearSpace(lightmapColor);\n#endif\nlightmapColor*=vLightmapInfos.y;\n#endif\nlightingInfo info;\npointLightingInfo pointInfo;\nspotLightingInfo spotInfo;\nfloat shadow=1.;\nfloat NdotL=-1.;\n#include<lightFragment>[0..maxSimultaneousLights]\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec2 brdfSamplerUV=vec2(NdotV,roughness);\n\nvec4 environmentBrdf=texture2D(environmentBrdfSampler,brdfSamplerUV);\nvec3 specularEnvironmentReflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#ifdef RADIANCEOCCLUSION\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\nspecularEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(-viewDirectionW,normalW);\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=fresnelSchlickEnvironmentGGX(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#ifdef REFRACTION\nvec3 refractance=vec3(0.0,0.0,0.0);\nvec3 transmission=vec3(1.0,1.0,1.0);\n#ifdef LINKREFRACTIONTOTRANSPARENCY\n\ntransmission*=(1.0-alpha);\n\n\nvec3 mixedAlbedo=surfaceAlbedo;\nfloat maxChannel=max(max(mixedAlbedo.r,mixedAlbedo.g),mixedAlbedo.b);\nvec3 tint=clamp(maxChannel*mixedAlbedo,0.0,1.0);\n\nsurfaceAlbedo*=alpha;\n\nenvironmentIrradiance*=alpha;\n\nenvironmentRefraction.rgb*=tint;\n\nalpha=1.0;\n#endif\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\nspecularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,alpha);\n\ntransmission*=1.0-specularEnvironmentReflectance;\n\nrefractance=transmission;\n#endif\n\n\n\n\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n\n#ifdef REFLECTION\nvec3 finalIrradiance=environmentIrradiance;\nfinalIrradiance*=surfaceAlbedo.rgb;\n#endif\n\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase;\nfinalSpecular=max(finalSpecular,0.0);\n\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance.rgb;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#endif\n\n#ifdef REFRACTION\nvec3 finalRefraction=environmentRefraction.rgb;\nfinalRefraction*=refractance;\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA)\nalpha=clamp(alpha+luminanceOverAlpha*luminanceOverAlpha,0.,1.);\n#endif\n#endif\n#endif\n\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse.rgb+=vAmbientColor;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\n\nvec3 finalEmissive=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\nfinalEmissive*=vEmissiveInfos.y;\n#endif\n\n#ifdef AMBIENT\nvec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),ambientOcclusionColor,vAmbientInfos.w);\n#else\nvec3 ambientOcclusionForDirectDiffuse=ambientOcclusionColor;\n#endif\n\n\n\nvec4 finalColor=vec4(\nfinalDiffuse*ambientOcclusionForDirectDiffuse*vLightingIntensity.x +\n#ifndef UNLIT\n#ifdef REFLECTION\nfinalIrradiance*ambientOcclusionColor*vLightingIntensity.z +\n#endif\n#ifdef SPECULARTERM\n\n\nfinalSpecularScaled +\n#endif\n#ifdef REFLECTION\n\n\nfinalRadianceScaled +\n#endif\n#ifdef REFRACTION\nfinalRefraction*vLightingIntensity.z +\n#endif\n#endif\nfinalEmissive*vLightingIntensity.y,\nalpha);\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n\nfinalColor=max(finalColor,0.0);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#else\n\nfinalColor=applyImageProcessing(finalColor);\n#endif\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\ngl_FragColor=finalColor;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n}\n";
  124581. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124582. /** @hidden */
  124583. var pbrPixelShader = { name: name, shader: shader };
  124584. /***/ }),
  124585. /***/ "./Shaders/pbr.vertex.ts":
  124586. /*!*******************************!*\
  124587. !*** ./Shaders/pbr.vertex.ts ***!
  124588. \*******************************/
  124589. /*! exports provided: pbrVertexShader */
  124590. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124591. "use strict";
  124592. __webpack_require__.r(__webpack_exports__);
  124593. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexShader", function() { return pbrVertexShader; });
  124594. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124595. /* harmony import */ var _ShadersInclude_pbrVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrVertexDeclaration */ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts");
  124596. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  124597. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124598. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124599. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124600. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  124601. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  124602. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  124603. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  124604. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  124605. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  124606. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  124607. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  124608. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124609. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  124610. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124611. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124612. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  124613. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  124614. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  124615. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  124616. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  124617. var name = 'pbrVertexShader';
  124618. var shader = "precision highp float;\n#include<__decl__pbrVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nvarying vec2 vReflectivityUV;\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#include<harmonicsFunctions>\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(positionUpdated,1.0)).xyz;\n#else\nvPositionUVW=positionUpdated;\n#endif\n#endif\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<bumpVertex>\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include<logDepthVertex>\n}";
  124619. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124620. /** @hidden */
  124621. var pbrVertexShader = { name: name, shader: shader };
  124622. /***/ }),
  124623. /***/ "./Shaders/postprocess.vertex.ts":
  124624. /*!***************************************!*\
  124625. !*** ./Shaders/postprocess.vertex.ts ***!
  124626. \***************************************/
  124627. /*! exports provided: postprocessVertexShader */
  124628. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124629. "use strict";
  124630. __webpack_require__.r(__webpack_exports__);
  124631. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postprocessVertexShader", function() { return postprocessVertexShader; });
  124632. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124633. var name = 'postprocessVertexShader';
  124634. 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}";
  124635. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124636. /** @hidden */
  124637. var postprocessVertexShader = { name: name, shader: shader };
  124638. /***/ }),
  124639. /***/ "./Shaders/procedural.vertex.ts":
  124640. /*!**************************************!*\
  124641. !*** ./Shaders/procedural.vertex.ts ***!
  124642. \**************************************/
  124643. /*! exports provided: proceduralVertexShader */
  124644. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124645. "use strict";
  124646. __webpack_require__.r(__webpack_exports__);
  124647. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "proceduralVertexShader", function() { return proceduralVertexShader; });
  124648. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124649. var name = 'proceduralVertexShader';
  124650. 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}";
  124651. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124652. /** @hidden */
  124653. var proceduralVertexShader = { name: name, shader: shader };
  124654. /***/ }),
  124655. /***/ "./Shaders/refraction.fragment.ts":
  124656. /*!****************************************!*\
  124657. !*** ./Shaders/refraction.fragment.ts ***!
  124658. \****************************************/
  124659. /*! exports provided: refractionPixelShader */
  124660. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124661. "use strict";
  124662. __webpack_require__.r(__webpack_exports__);
  124663. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refractionPixelShader", function() { return refractionPixelShader; });
  124664. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124665. var name = 'refractionPixelShader';
  124666. 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}";
  124667. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124668. /** @hidden */
  124669. var refractionPixelShader = { name: name, shader: shader };
  124670. /***/ }),
  124671. /***/ "./Shaders/rgbdDecode.fragment.ts":
  124672. /*!****************************************!*\
  124673. !*** ./Shaders/rgbdDecode.fragment.ts ***!
  124674. \****************************************/
  124675. /*! exports provided: rgbdDecodePixelShader */
  124676. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124677. "use strict";
  124678. __webpack_require__.r(__webpack_exports__);
  124679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdDecodePixelShader", function() { return rgbdDecodePixelShader; });
  124680. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124681. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124682. var name = 'rgbdDecodePixelShader';
  124683. 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}";
  124684. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124685. /** @hidden */
  124686. var rgbdDecodePixelShader = { name: name, shader: shader };
  124687. /***/ }),
  124688. /***/ "./Shaders/rgbdEncode.fragment.ts":
  124689. /*!****************************************!*\
  124690. !*** ./Shaders/rgbdEncode.fragment.ts ***!
  124691. \****************************************/
  124692. /*! exports provided: rgbdEncodePixelShader */
  124693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124694. "use strict";
  124695. __webpack_require__.r(__webpack_exports__);
  124696. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdEncodePixelShader", function() { return rgbdEncodePixelShader; });
  124697. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124698. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124699. var name = 'rgbdEncodePixelShader';
  124700. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  124701. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124702. /** @hidden */
  124703. var rgbdEncodePixelShader = { name: name, shader: shader };
  124704. /***/ }),
  124705. /***/ "./Shaders/shadowMap.fragment.ts":
  124706. /*!***************************************!*\
  124707. !*** ./Shaders/shadowMap.fragment.ts ***!
  124708. \***************************************/
  124709. /*! exports provided: shadowMapPixelShader */
  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__, "shadowMapPixelShader", function() { return shadowMapPixelShader; });
  124714. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124715. var name = 'shadowMapPixelShader';
  124716. 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}";
  124717. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124718. /** @hidden */
  124719. var shadowMapPixelShader = { name: name, shader: shader };
  124720. /***/ }),
  124721. /***/ "./Shaders/shadowMap.vertex.ts":
  124722. /*!*************************************!*\
  124723. !*** ./Shaders/shadowMap.vertex.ts ***!
  124724. \*************************************/
  124725. /*! exports provided: shadowMapVertexShader */
  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__, "shadowMapVertexShader", function() { return shadowMapVertexShader; });
  124730. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124731. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124732. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  124733. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  124734. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124735. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124736. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  124737. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124738. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124739. var name = 'shadowMapVertexShader';
  124740. 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}";
  124741. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124742. /** @hidden */
  124743. var shadowMapVertexShader = { name: name, shader: shader };
  124744. /***/ }),
  124745. /***/ "./Shaders/sharpen.fragment.ts":
  124746. /*!*************************************!*\
  124747. !*** ./Shaders/sharpen.fragment.ts ***!
  124748. \*************************************/
  124749. /*! exports provided: sharpenPixelShader */
  124750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124751. "use strict";
  124752. __webpack_require__.r(__webpack_exports__);
  124753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharpenPixelShader", function() { return sharpenPixelShader; });
  124754. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124755. var name = 'sharpenPixelShader';
  124756. 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}";
  124757. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124758. /** @hidden */
  124759. var sharpenPixelShader = { name: name, shader: shader };
  124760. /***/ }),
  124761. /***/ "./Shaders/sprites.fragment.ts":
  124762. /*!*************************************!*\
  124763. !*** ./Shaders/sprites.fragment.ts ***!
  124764. \*************************************/
  124765. /*! exports provided: spritesPixelShader */
  124766. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124767. "use strict";
  124768. __webpack_require__.r(__webpack_exports__);
  124769. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesPixelShader", function() { return spritesPixelShader; });
  124770. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124771. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  124772. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  124773. var name = 'spritesPixelShader';
  124774. 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}";
  124775. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124776. /** @hidden */
  124777. var spritesPixelShader = { name: name, shader: shader };
  124778. /***/ }),
  124779. /***/ "./Shaders/sprites.vertex.ts":
  124780. /*!***********************************!*\
  124781. !*** ./Shaders/sprites.vertex.ts ***!
  124782. \***********************************/
  124783. /*! exports provided: spritesVertexShader */
  124784. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124785. "use strict";
  124786. __webpack_require__.r(__webpack_exports__);
  124787. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesVertexShader", function() { return spritesVertexShader; });
  124788. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124789. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  124790. var name = 'spritesVertexShader';
  124791. 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}";
  124792. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124793. /** @hidden */
  124794. var spritesVertexShader = { name: name, shader: shader };
  124795. /***/ }),
  124796. /***/ "./Shaders/ssao.fragment.ts":
  124797. /*!**********************************!*\
  124798. !*** ./Shaders/ssao.fragment.ts ***!
  124799. \**********************************/
  124800. /*! exports provided: ssaoPixelShader */
  124801. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124802. "use strict";
  124803. __webpack_require__.r(__webpack_exports__);
  124804. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoPixelShader", function() { return ssaoPixelShader; });
  124805. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124806. var name = 'ssaoPixelShader';
  124807. 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";
  124808. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124809. /** @hidden */
  124810. var ssaoPixelShader = { name: name, shader: shader };
  124811. /***/ }),
  124812. /***/ "./Shaders/ssao2.fragment.ts":
  124813. /*!***********************************!*\
  124814. !*** ./Shaders/ssao2.fragment.ts ***!
  124815. \***********************************/
  124816. /*! exports provided: ssao2PixelShader */
  124817. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124818. "use strict";
  124819. __webpack_require__.r(__webpack_exports__);
  124820. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssao2PixelShader", function() { return ssao2PixelShader; });
  124821. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124822. var name = 'ssao2PixelShader';
  124823. 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";
  124824. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124825. /** @hidden */
  124826. var ssao2PixelShader = { name: name, shader: shader };
  124827. /***/ }),
  124828. /***/ "./Shaders/ssaoCombine.fragment.ts":
  124829. /*!*****************************************!*\
  124830. !*** ./Shaders/ssaoCombine.fragment.ts ***!
  124831. \*****************************************/
  124832. /*! exports provided: ssaoCombinePixelShader */
  124833. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124834. "use strict";
  124835. __webpack_require__.r(__webpack_exports__);
  124836. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoCombinePixelShader", function() { return ssaoCombinePixelShader; });
  124837. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124838. var name = 'ssaoCombinePixelShader';
  124839. 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";
  124840. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124841. /** @hidden */
  124842. var ssaoCombinePixelShader = { name: name, shader: shader };
  124843. /***/ }),
  124844. /***/ "./Shaders/standard.fragment.ts":
  124845. /*!**************************************!*\
  124846. !*** ./Shaders/standard.fragment.ts ***!
  124847. \**************************************/
  124848. /*! exports provided: standardPixelShader */
  124849. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124850. "use strict";
  124851. __webpack_require__.r(__webpack_exports__);
  124852. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "standardPixelShader", function() { return standardPixelShader; });
  124853. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124854. var name = 'standardPixelShader';
  124855. 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";
  124856. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124857. /** @hidden */
  124858. var standardPixelShader = { name: name, shader: shader };
  124859. /***/ }),
  124860. /***/ "./Shaders/stereoscopicInterlace.fragment.ts":
  124861. /*!***************************************************!*\
  124862. !*** ./Shaders/stereoscopicInterlace.fragment.ts ***!
  124863. \***************************************************/
  124864. /*! exports provided: stereoscopicInterlacePixelShader */
  124865. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124866. "use strict";
  124867. __webpack_require__.r(__webpack_exports__);
  124868. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stereoscopicInterlacePixelShader", function() { return stereoscopicInterlacePixelShader; });
  124869. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124870. var name = 'stereoscopicInterlacePixelShader';
  124871. 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}";
  124872. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124873. /** @hidden */
  124874. var stereoscopicInterlacePixelShader = { name: name, shader: shader };
  124875. /***/ }),
  124876. /***/ "./Shaders/tonemap.fragment.ts":
  124877. /*!*************************************!*\
  124878. !*** ./Shaders/tonemap.fragment.ts ***!
  124879. \*************************************/
  124880. /*! exports provided: tonemapPixelShader */
  124881. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124882. "use strict";
  124883. __webpack_require__.r(__webpack_exports__);
  124884. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tonemapPixelShader", function() { return tonemapPixelShader; });
  124885. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124886. var name = 'tonemapPixelShader';
  124887. 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}";
  124888. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124889. /** @hidden */
  124890. var tonemapPixelShader = { name: name, shader: shader };
  124891. /***/ }),
  124892. /***/ "./Shaders/volumetricLightScattering.fragment.ts":
  124893. /*!*******************************************************!*\
  124894. !*** ./Shaders/volumetricLightScattering.fragment.ts ***!
  124895. \*******************************************************/
  124896. /*! exports provided: volumetricLightScatteringPixelShader */
  124897. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124898. "use strict";
  124899. __webpack_require__.r(__webpack_exports__);
  124900. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPixelShader", function() { return volumetricLightScatteringPixelShader; });
  124901. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124902. var name = 'volumetricLightScatteringPixelShader';
  124903. 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";
  124904. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124905. /** @hidden */
  124906. var volumetricLightScatteringPixelShader = { name: name, shader: shader };
  124907. /***/ }),
  124908. /***/ "./Shaders/volumetricLightScatteringPass.fragment.ts":
  124909. /*!***********************************************************!*\
  124910. !*** ./Shaders/volumetricLightScatteringPass.fragment.ts ***!
  124911. \***********************************************************/
  124912. /*! exports provided: volumetricLightScatteringPassPixelShader */
  124913. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124914. "use strict";
  124915. __webpack_require__.r(__webpack_exports__);
  124916. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPassPixelShader", function() { return volumetricLightScatteringPassPixelShader; });
  124917. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124918. var name = 'volumetricLightScatteringPassPixelShader';
  124919. 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";
  124920. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124921. /** @hidden */
  124922. var volumetricLightScatteringPassPixelShader = { name: name, shader: shader };
  124923. /***/ }),
  124924. /***/ "./Shaders/vrDistortionCorrection.fragment.ts":
  124925. /*!****************************************************!*\
  124926. !*** ./Shaders/vrDistortionCorrection.fragment.ts ***!
  124927. \****************************************************/
  124928. /*! exports provided: vrDistortionCorrectionPixelShader */
  124929. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124930. "use strict";
  124931. __webpack_require__.r(__webpack_exports__);
  124932. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrDistortionCorrectionPixelShader", function() { return vrDistortionCorrectionPixelShader; });
  124933. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124934. var name = 'vrDistortionCorrectionPixelShader';
  124935. 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}";
  124936. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124937. /** @hidden */
  124938. var vrDistortionCorrectionPixelShader = { name: name, shader: shader };
  124939. /***/ }),
  124940. /***/ "./Sprites/index.ts":
  124941. /*!**************************!*\
  124942. !*** ./Sprites/index.ts ***!
  124943. \**************************/
  124944. /*! exports provided: Sprite, SpriteManager, SpriteSceneComponent */
  124945. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124946. "use strict";
  124947. __webpack_require__.r(__webpack_exports__);
  124948. /* harmony import */ var _sprite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprite */ "./Sprites/sprite.ts");
  124949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _sprite__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  124950. /* harmony import */ var _spriteManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./spriteManager */ "./Sprites/spriteManager.ts");
  124951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _spriteManager__WEBPACK_IMPORTED_MODULE_1__["SpriteManager"]; });
  124952. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  124953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__["SpriteSceneComponent"]; });
  124954. /***/ }),
  124955. /***/ "./Sprites/sprite.ts":
  124956. /*!***************************!*\
  124957. !*** ./Sprites/sprite.ts ***!
  124958. \***************************/
  124959. /*! exports provided: Sprite */
  124960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124961. "use strict";
  124962. __webpack_require__.r(__webpack_exports__);
  124963. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return Sprite; });
  124964. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124965. /**
  124966. * Class used to represent a sprite
  124967. * @see http://doc.babylonjs.com/babylon101/sprites
  124968. */
  124969. var Sprite = /** @class */ (function () {
  124970. /**
  124971. * Creates a new Sprite
  124972. * @param name defines the name
  124973. * @param manager defines the manager
  124974. */
  124975. function Sprite(
  124976. /** defines the name */
  124977. name, manager) {
  124978. this.name = name;
  124979. /** Gets or sets the main color */
  124980. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  124981. /** Gets or sets the width */
  124982. this.width = 1.0;
  124983. /** Gets or sets the height */
  124984. this.height = 1.0;
  124985. /** Gets or sets rotation angle */
  124986. this.angle = 0;
  124987. /** Gets or sets the cell index in the sprite sheet */
  124988. this.cellIndex = 0;
  124989. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  124990. this.invertU = 0;
  124991. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  124992. this.invertV = 0;
  124993. /** Gets the list of attached animations */
  124994. this.animations = new Array();
  124995. /** Gets or sets a boolean indicating if the sprite can be picked */
  124996. this.isPickable = false;
  124997. this._animationStarted = false;
  124998. this._loopAnimation = false;
  124999. this._fromIndex = 0;
  125000. this._toIndex = 0;
  125001. this._delay = 0;
  125002. this._direction = 1;
  125003. this._time = 0;
  125004. /**
  125005. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  125006. */
  125007. this.isVisible = true;
  125008. this._manager = manager;
  125009. this._manager.sprites.push(this);
  125010. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  125011. }
  125012. Object.defineProperty(Sprite.prototype, "size", {
  125013. /**
  125014. * Gets or sets the sprite size
  125015. */
  125016. get: function () {
  125017. return this.width;
  125018. },
  125019. set: function (value) {
  125020. this.width = value;
  125021. this.height = value;
  125022. },
  125023. enumerable: true,
  125024. configurable: true
  125025. });
  125026. /**
  125027. * Starts an animation
  125028. * @param from defines the initial key
  125029. * @param to defines the end key
  125030. * @param loop defines if the animation must loop
  125031. * @param delay defines the start delay (in ms)
  125032. * @param onAnimationEnd defines a callback to call when animation ends
  125033. */
  125034. Sprite.prototype.playAnimation = function (from, to, loop, delay, onAnimationEnd) {
  125035. this._fromIndex = from;
  125036. this._toIndex = to;
  125037. this._loopAnimation = loop;
  125038. this._delay = delay;
  125039. this._animationStarted = true;
  125040. this._direction = from < to ? 1 : -1;
  125041. this.cellIndex = from;
  125042. this._time = 0;
  125043. this._onAnimationEnd = onAnimationEnd;
  125044. };
  125045. /** Stops current animation (if any) */
  125046. Sprite.prototype.stopAnimation = function () {
  125047. this._animationStarted = false;
  125048. };
  125049. /** @hidden */
  125050. Sprite.prototype._animate = function (deltaTime) {
  125051. if (!this._animationStarted) {
  125052. return;
  125053. }
  125054. this._time += deltaTime;
  125055. if (this._time > this._delay) {
  125056. this._time = this._time % this._delay;
  125057. this.cellIndex += this._direction;
  125058. if (this.cellIndex > this._toIndex) {
  125059. if (this._loopAnimation) {
  125060. this.cellIndex = this._fromIndex;
  125061. }
  125062. else {
  125063. this.cellIndex = this._toIndex;
  125064. this._animationStarted = false;
  125065. if (this._onAnimationEnd) {
  125066. this._onAnimationEnd();
  125067. }
  125068. if (this.disposeWhenFinishedAnimating) {
  125069. this.dispose();
  125070. }
  125071. }
  125072. }
  125073. }
  125074. };
  125075. /** Release associated resources */
  125076. Sprite.prototype.dispose = function () {
  125077. for (var i = 0; i < this._manager.sprites.length; i++) {
  125078. if (this._manager.sprites[i] == this) {
  125079. this._manager.sprites.splice(i, 1);
  125080. }
  125081. }
  125082. };
  125083. return Sprite;
  125084. }());
  125085. /***/ }),
  125086. /***/ "./Sprites/spriteManager.ts":
  125087. /*!**********************************!*\
  125088. !*** ./Sprites/spriteManager.ts ***!
  125089. \**********************************/
  125090. /*! exports provided: SpriteManager */
  125091. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125092. "use strict";
  125093. __webpack_require__.r(__webpack_exports__);
  125094. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return SpriteManager; });
  125095. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  125096. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  125097. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  125098. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125099. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  125100. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  125101. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125102. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  125103. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  125104. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125105. /* harmony import */ var _Shaders_sprites_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/sprites.fragment */ "./Shaders/sprites.fragment.ts");
  125106. /* harmony import */ var _Shaders_sprites_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/sprites.vertex */ "./Shaders/sprites.vertex.ts");
  125107. /**
  125108. * Class used to manage multiple sprites on the same spritesheet
  125109. * @see http://doc.babylonjs.com/babylon101/sprites
  125110. */
  125111. var SpriteManager = /** @class */ (function () {
  125112. /**
  125113. * Creates a new sprite manager
  125114. * @param name defines the manager's name
  125115. * @param imgUrl defines the sprite sheet url
  125116. * @param capacity defines the maximum allowed number of sprites
  125117. * @param cellSize defines the size of a sprite cell
  125118. * @param scene defines the hosting scene
  125119. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  125120. * @param samplingMode defines the smapling mode to use with spritesheet
  125121. */
  125122. function SpriteManager(
  125123. /** defines the manager's name */
  125124. name, imgUrl, capacity, cellSize, scene, epsilon, samplingMode) {
  125125. if (epsilon === void 0) { epsilon = 0.01; }
  125126. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].TRILINEAR_SAMPLINGMODE; }
  125127. this.name = name;
  125128. /** Gets the list of sprites */
  125129. this.sprites = new Array();
  125130. /** Gets or sets the rendering group id (0 by default) */
  125131. this.renderingGroupId = 0;
  125132. /** Gets or sets camera layer mask */
  125133. this.layerMask = 0x0FFFFFFF;
  125134. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  125135. this.fogEnabled = true;
  125136. /** Gets or sets a boolean indicating if the sprites are pickable */
  125137. this.isPickable = false;
  125138. /**
  125139. * An event triggered when the manager is disposed.
  125140. */
  125141. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  125142. this._vertexBuffers = {};
  125143. if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_8__["SceneComponentConstants"].NAME_SPRITE)) {
  125144. scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__["SpriteSceneComponent"](scene));
  125145. }
  125146. this._capacity = capacity;
  125147. this._spriteTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true, false, samplingMode);
  125148. this._spriteTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  125149. this._spriteTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  125150. if (cellSize.width && cellSize.height) {
  125151. this.cellWidth = cellSize.width;
  125152. this.cellHeight = cellSize.height;
  125153. }
  125154. else if (cellSize !== undefined) {
  125155. this.cellWidth = cellSize;
  125156. this.cellHeight = cellSize;
  125157. }
  125158. else {
  125159. return;
  125160. }
  125161. this._epsilon = epsilon;
  125162. this._scene = scene;
  125163. this._scene.spriteManagers.push(this);
  125164. var indices = [];
  125165. var index = 0;
  125166. for (var count = 0; count < capacity; count++) {
  125167. indices.push(index);
  125168. indices.push(index + 1);
  125169. indices.push(index + 2);
  125170. indices.push(index);
  125171. indices.push(index + 2);
  125172. indices.push(index + 3);
  125173. index += 4;
  125174. }
  125175. this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
  125176. // VBO
  125177. // 16 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color r, color g, color b, color a)
  125178. this._vertexData = new Float32Array(capacity * 16 * 4);
  125179. this._buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["Buffer"](scene.getEngine(), this._vertexData, true, 16);
  125180. var positions = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, 0, 4);
  125181. var options = this._buffer.createVertexBuffer("options", 4, 4);
  125182. var cellInfo = this._buffer.createVertexBuffer("cellInfo", 8, 4);
  125183. var colors = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, 12, 4);
  125184. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = positions;
  125185. this._vertexBuffers["options"] = options;
  125186. this._vertexBuffers["cellInfo"] = cellInfo;
  125187. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind] = colors;
  125188. // Effects
  125189. 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"], "");
  125190. 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");
  125191. }
  125192. Object.defineProperty(SpriteManager.prototype, "onDispose", {
  125193. /**
  125194. * Callback called when the manager is disposed
  125195. */
  125196. set: function (callback) {
  125197. if (this._onDisposeObserver) {
  125198. this.onDisposeObservable.remove(this._onDisposeObserver);
  125199. }
  125200. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  125201. },
  125202. enumerable: true,
  125203. configurable: true
  125204. });
  125205. Object.defineProperty(SpriteManager.prototype, "texture", {
  125206. /**
  125207. * Gets or sets the spritesheet texture
  125208. */
  125209. get: function () {
  125210. return this._spriteTexture;
  125211. },
  125212. set: function (value) {
  125213. this._spriteTexture = value;
  125214. },
  125215. enumerable: true,
  125216. configurable: true
  125217. });
  125218. SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
  125219. var arrayOffset = index * 16;
  125220. if (offsetX === 0) {
  125221. offsetX = this._epsilon;
  125222. }
  125223. else if (offsetX === 1) {
  125224. offsetX = 1 - this._epsilon;
  125225. }
  125226. if (offsetY === 0) {
  125227. offsetY = this._epsilon;
  125228. }
  125229. else if (offsetY === 1) {
  125230. offsetY = 1 - this._epsilon;
  125231. }
  125232. this._vertexData[arrayOffset] = sprite.position.x;
  125233. this._vertexData[arrayOffset + 1] = sprite.position.y;
  125234. this._vertexData[arrayOffset + 2] = sprite.position.z;
  125235. this._vertexData[arrayOffset + 3] = sprite.angle;
  125236. this._vertexData[arrayOffset + 4] = sprite.width;
  125237. this._vertexData[arrayOffset + 5] = sprite.height;
  125238. this._vertexData[arrayOffset + 6] = offsetX;
  125239. this._vertexData[arrayOffset + 7] = offsetY;
  125240. this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;
  125241. this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;
  125242. var offset = (sprite.cellIndex / rowSize) >> 0;
  125243. this._vertexData[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
  125244. this._vertexData[arrayOffset + 11] = offset;
  125245. // Color
  125246. this._vertexData[arrayOffset + 12] = sprite.color.r;
  125247. this._vertexData[arrayOffset + 13] = sprite.color.g;
  125248. this._vertexData[arrayOffset + 14] = sprite.color.b;
  125249. this._vertexData[arrayOffset + 15] = sprite.color.a;
  125250. };
  125251. /**
  125252. * Intersects the sprites with a ray
  125253. * @param ray defines the ray to intersect with
  125254. * @param camera defines the current active camera
  125255. * @param predicate defines a predicate used to select candidate sprites
  125256. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  125257. * @returns null if no hit or a PickingInfo
  125258. */
  125259. SpriteManager.prototype.intersects = function (ray, camera, predicate, fastCheck) {
  125260. var count = Math.min(this._capacity, this.sprites.length);
  125261. var min = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  125262. var max = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  125263. var distance = Number.MAX_VALUE;
  125264. var currentSprite = null;
  125265. var cameraSpacePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  125266. var cameraView = camera.getViewMatrix();
  125267. for (var index = 0; index < count; index++) {
  125268. var sprite = this.sprites[index];
  125269. if (!sprite) {
  125270. continue;
  125271. }
  125272. if (predicate) {
  125273. if (!predicate(sprite)) {
  125274. continue;
  125275. }
  125276. }
  125277. else if (!sprite.isPickable) {
  125278. continue;
  125279. }
  125280. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);
  125281. min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);
  125282. max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);
  125283. if (ray.intersectsBoxMinMax(min, max)) {
  125284. var currentDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(cameraSpacePosition, ray.origin);
  125285. if (distance > currentDistance) {
  125286. distance = currentDistance;
  125287. currentSprite = sprite;
  125288. if (fastCheck) {
  125289. break;
  125290. }
  125291. }
  125292. }
  125293. }
  125294. if (currentSprite) {
  125295. var result = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__["PickingInfo"]();
  125296. result.hit = true;
  125297. result.pickedSprite = currentSprite;
  125298. result.distance = distance;
  125299. return result;
  125300. }
  125301. return null;
  125302. };
  125303. /**
  125304. * Render all child sprites
  125305. */
  125306. SpriteManager.prototype.render = function () {
  125307. // Check
  125308. if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture
  125309. || !this._spriteTexture.isReady() || !this.sprites.length) {
  125310. return;
  125311. }
  125312. var engine = this._scene.getEngine();
  125313. var baseSize = this._spriteTexture.getBaseSize();
  125314. // Sprites
  125315. var deltaTime = engine.getDeltaTime();
  125316. var max = Math.min(this._capacity, this.sprites.length);
  125317. var rowSize = baseSize.width / this.cellWidth;
  125318. var offset = 0;
  125319. for (var index = 0; index < max; index++) {
  125320. var sprite = this.sprites[index];
  125321. if (!sprite || !sprite.isVisible) {
  125322. continue;
  125323. }
  125324. sprite._animate(deltaTime);
  125325. this._appendSpriteVertex(offset++, sprite, 0, 0, rowSize);
  125326. this._appendSpriteVertex(offset++, sprite, 1, 0, rowSize);
  125327. this._appendSpriteVertex(offset++, sprite, 1, 1, rowSize);
  125328. this._appendSpriteVertex(offset++, sprite, 0, 1, rowSize);
  125329. }
  125330. this._buffer.update(this._vertexData);
  125331. // Render
  125332. var effect = this._effectBase;
  125333. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  125334. effect = this._effectFog;
  125335. }
  125336. engine.enableEffect(effect);
  125337. var viewMatrix = this._scene.getViewMatrix();
  125338. effect.setTexture("diffuseSampler", this._spriteTexture);
  125339. effect.setMatrix("view", viewMatrix);
  125340. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  125341. effect.setFloat2("textureInfos", this.cellWidth / baseSize.width, this.cellHeight / baseSize.height);
  125342. // Fog
  125343. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  125344. effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
  125345. effect.setColor3("vFogColor", this._scene.fogColor);
  125346. }
  125347. // VBOs
  125348. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  125349. // Draw order
  125350. engine.setDepthFunctionToLessOrEqual();
  125351. effect.setBool("alphaTest", true);
  125352. engine.setColorWrite(false);
  125353. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  125354. engine.setColorWrite(true);
  125355. effect.setBool("alphaTest", false);
  125356. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE);
  125357. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  125358. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  125359. };
  125360. /**
  125361. * Release associated resources
  125362. */
  125363. SpriteManager.prototype.dispose = function () {
  125364. if (this._buffer) {
  125365. this._buffer.dispose();
  125366. this._buffer = null;
  125367. }
  125368. if (this._indexBuffer) {
  125369. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  125370. this._indexBuffer = null;
  125371. }
  125372. if (this._spriteTexture) {
  125373. this._spriteTexture.dispose();
  125374. this._spriteTexture = null;
  125375. }
  125376. // Remove from scene
  125377. var index = this._scene.spriteManagers.indexOf(this);
  125378. this._scene.spriteManagers.splice(index, 1);
  125379. // Callback
  125380. this.onDisposeObservable.notifyObservers(this);
  125381. this.onDisposeObservable.clear();
  125382. };
  125383. return SpriteManager;
  125384. }());
  125385. /***/ }),
  125386. /***/ "./Sprites/spriteSceneComponent.ts":
  125387. /*!*****************************************!*\
  125388. !*** ./Sprites/spriteSceneComponent.ts ***!
  125389. \*****************************************/
  125390. /*! exports provided: SpriteSceneComponent */
  125391. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125392. "use strict";
  125393. __webpack_require__.r(__webpack_exports__);
  125394. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return SpriteSceneComponent; });
  125395. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  125396. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  125397. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  125398. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  125399. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  125400. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  125401. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125402. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
  125403. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]) {
  125404. return null;
  125405. }
  125406. var pickingInfo = null;
  125407. if (!camera) {
  125408. if (!this.activeCamera) {
  125409. return null;
  125410. }
  125411. camera = this.activeCamera;
  125412. }
  125413. if (this.spriteManagers.length > 0) {
  125414. for (var spriteIndex = 0; spriteIndex < this.spriteManagers.length; spriteIndex++) {
  125415. var spriteManager = this.spriteManagers[spriteIndex];
  125416. if (!spriteManager.isPickable) {
  125417. continue;
  125418. }
  125419. var result = spriteManager.intersects(ray, camera, predicate, fastCheck);
  125420. if (!result || !result.hit) {
  125421. continue;
  125422. }
  125423. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  125424. continue;
  125425. }
  125426. pickingInfo = result;
  125427. if (fastCheck) {
  125428. break;
  125429. }
  125430. }
  125431. }
  125432. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]();
  125433. };
  125434. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSprite = function (x, y, predicate, fastCheck, camera) {
  125435. this.createPickingRayInCameraSpaceToRef(x, y, this._tempSpritePickingRay, camera);
  125436. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  125437. };
  125438. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
  125439. if (!this._tempSpritePickingRay) {
  125440. return null;
  125441. }
  125442. if (!camera) {
  125443. if (!this.activeCamera) {
  125444. return null;
  125445. }
  125446. camera = this.activeCamera;
  125447. }
  125448. _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].TransformToRef(ray, camera.getViewMatrix(), this._tempSpritePickingRay);
  125449. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  125450. };
  125451. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.setPointerOverSprite = function (sprite) {
  125452. if (this._pointerOverSprite === sprite) {
  125453. return;
  125454. }
  125455. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  125456. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  125457. }
  125458. this._pointerOverSprite = sprite;
  125459. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  125460. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  125461. }
  125462. };
  125463. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.getPointerOverSprite = function () {
  125464. return this._pointerOverSprite;
  125465. };
  125466. /**
  125467. * Defines the sprite scene component responsible to manage sprites
  125468. * in a given scene.
  125469. */
  125470. var SpriteSceneComponent = /** @class */ (function () {
  125471. /**
  125472. * Creates a new instance of the component for the given scene
  125473. * @param scene Defines the scene to register the component in
  125474. */
  125475. function SpriteSceneComponent(scene) {
  125476. /**
  125477. * The component name helpfull to identify the component in the list of scene components.
  125478. */
  125479. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_SPRITE;
  125480. this.scene = scene;
  125481. this.scene.spriteManagers = new Array();
  125482. this.scene._tempSpritePickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].Zero() : null;
  125483. this.scene.onBeforeSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  125484. this.scene.onAfterSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  125485. this._spritePredicate = function (sprite) {
  125486. if (!sprite.actionManager) {
  125487. return false;
  125488. }
  125489. return sprite.isPickable && sprite.actionManager.hasPointerTriggers;
  125490. };
  125491. }
  125492. /**
  125493. * Registers the component in a given scene
  125494. */
  125495. SpriteSceneComponent.prototype.register = function () {
  125496. this.scene._pointerMoveStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERMOVE_SPRITE, this, this._pointerMove);
  125497. this.scene._pointerDownStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERDOWN_SPRITE, this, this._pointerDown);
  125498. this.scene._pointerUpStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERUP_SPRITE, this, this._pointerUp);
  125499. };
  125500. /**
  125501. * Rebuilds the elements related to this component in case of
  125502. * context lost for instance.
  125503. */
  125504. SpriteSceneComponent.prototype.rebuild = function () {
  125505. /** Nothing to do for sprites */
  125506. };
  125507. /**
  125508. * Disposes the component and the associated ressources.
  125509. */
  125510. SpriteSceneComponent.prototype.dispose = function () {
  125511. this.scene.onBeforeSpritesRenderingObservable.clear();
  125512. this.scene.onAfterSpritesRenderingObservable.clear();
  125513. var spriteManagers = this.scene.spriteManagers;
  125514. while (spriteManagers.length) {
  125515. spriteManagers[0].dispose();
  125516. }
  125517. };
  125518. SpriteSceneComponent.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, fastCheck, camera) {
  125519. var result = this.scene.pickSprite(x, y, this._spritePredicate, fastCheck, camera);
  125520. if (result) {
  125521. result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
  125522. }
  125523. return result;
  125524. };
  125525. SpriteSceneComponent.prototype._pointerMove = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, isMeshPicked, canvas) {
  125526. var scene = this.scene;
  125527. if (isMeshPicked) {
  125528. scene.setPointerOverSprite(null);
  125529. }
  125530. else {
  125531. pickResult = this._pickSpriteButKeepRay(pickResult, unTranslatedPointerX, unTranslatedPointerY, false, scene.cameraToUseForPointers || undefined);
  125532. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  125533. scene.setPointerOverSprite(pickResult.pickedSprite);
  125534. if (scene._pointerOverSprite && scene._pointerOverSprite.actionManager && scene._pointerOverSprite.actionManager.hoverCursor) {
  125535. canvas.style.cursor = scene._pointerOverSprite.actionManager.hoverCursor;
  125536. }
  125537. else {
  125538. canvas.style.cursor = scene.hoverCursor;
  125539. }
  125540. }
  125541. else {
  125542. scene.setPointerOverSprite(null);
  125543. }
  125544. }
  125545. return pickResult;
  125546. };
  125547. SpriteSceneComponent.prototype._pointerDown = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  125548. var scene = this.scene;
  125549. scene._pickedDownSprite = null;
  125550. if (scene.spriteManagers.length > 0) {
  125551. pickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  125552. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  125553. if (pickResult.pickedSprite.actionManager) {
  125554. scene._pickedDownSprite = pickResult.pickedSprite;
  125555. switch (evt.button) {
  125556. case 0:
  125557. 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));
  125558. break;
  125559. case 1:
  125560. 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));
  125561. break;
  125562. case 2:
  125563. 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));
  125564. break;
  125565. }
  125566. if (pickResult.pickedSprite.actionManager) {
  125567. 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));
  125568. }
  125569. }
  125570. }
  125571. }
  125572. return pickResult;
  125573. };
  125574. SpriteSceneComponent.prototype._pointerUp = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  125575. var scene = this.scene;
  125576. if (scene.spriteManagers.length > 0) {
  125577. var spritePickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  125578. if (spritePickResult) {
  125579. if (spritePickResult.hit && spritePickResult.pickedSprite) {
  125580. if (spritePickResult.pickedSprite.actionManager) {
  125581. 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));
  125582. if (spritePickResult.pickedSprite.actionManager) {
  125583. if (!this.scene._isPointerSwiping()) {
  125584. 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));
  125585. }
  125586. }
  125587. }
  125588. }
  125589. if (scene._pickedDownSprite && scene._pickedDownSprite.actionManager && scene._pickedDownSprite !== spritePickResult.pickedSprite) {
  125590. 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));
  125591. }
  125592. }
  125593. }
  125594. return pickResult;
  125595. };
  125596. return SpriteSceneComponent;
  125597. }());
  125598. /***/ }),
  125599. /***/ "./States/alphaCullingState.ts":
  125600. /*!*************************************!*\
  125601. !*** ./States/alphaCullingState.ts ***!
  125602. \*************************************/
  125603. /*! exports provided: _AlphaState */
  125604. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125605. "use strict";
  125606. __webpack_require__.r(__webpack_exports__);
  125607. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _AlphaState; });
  125608. /**
  125609. * @hidden
  125610. **/
  125611. var _AlphaState = /** @class */ (function () {
  125612. /**
  125613. * Initializes the state.
  125614. */
  125615. function _AlphaState() {
  125616. this._isAlphaBlendDirty = false;
  125617. this._isBlendFunctionParametersDirty = false;
  125618. this._isBlendEquationParametersDirty = false;
  125619. this._isBlendConstantsDirty = false;
  125620. this._alphaBlend = false;
  125621. this._blendFunctionParameters = new Array(4);
  125622. this._blendEquationParameters = new Array(2);
  125623. this._blendConstants = new Array(4);
  125624. this.reset();
  125625. }
  125626. Object.defineProperty(_AlphaState.prototype, "isDirty", {
  125627. get: function () {
  125628. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;
  125629. },
  125630. enumerable: true,
  125631. configurable: true
  125632. });
  125633. Object.defineProperty(_AlphaState.prototype, "alphaBlend", {
  125634. get: function () {
  125635. return this._alphaBlend;
  125636. },
  125637. set: function (value) {
  125638. if (this._alphaBlend === value) {
  125639. return;
  125640. }
  125641. this._alphaBlend = value;
  125642. this._isAlphaBlendDirty = true;
  125643. },
  125644. enumerable: true,
  125645. configurable: true
  125646. });
  125647. _AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {
  125648. if (this._blendConstants[0] === r &&
  125649. this._blendConstants[1] === g &&
  125650. this._blendConstants[2] === b &&
  125651. this._blendConstants[3] === a) {
  125652. return;
  125653. }
  125654. this._blendConstants[0] = r;
  125655. this._blendConstants[1] = g;
  125656. this._blendConstants[2] = b;
  125657. this._blendConstants[3] = a;
  125658. this._isBlendConstantsDirty = true;
  125659. };
  125660. _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
  125661. if (this._blendFunctionParameters[0] === value0 &&
  125662. this._blendFunctionParameters[1] === value1 &&
  125663. this._blendFunctionParameters[2] === value2 &&
  125664. this._blendFunctionParameters[3] === value3) {
  125665. return;
  125666. }
  125667. this._blendFunctionParameters[0] = value0;
  125668. this._blendFunctionParameters[1] = value1;
  125669. this._blendFunctionParameters[2] = value2;
  125670. this._blendFunctionParameters[3] = value3;
  125671. this._isBlendFunctionParametersDirty = true;
  125672. };
  125673. _AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {
  125674. if (this._blendEquationParameters[0] === rgb &&
  125675. this._blendEquationParameters[1] === alpha) {
  125676. return;
  125677. }
  125678. this._blendEquationParameters[0] = rgb;
  125679. this._blendEquationParameters[1] = alpha;
  125680. this._isBlendEquationParametersDirty = true;
  125681. };
  125682. _AlphaState.prototype.reset = function () {
  125683. this._alphaBlend = false;
  125684. this._blendFunctionParameters[0] = null;
  125685. this._blendFunctionParameters[1] = null;
  125686. this._blendFunctionParameters[2] = null;
  125687. this._blendFunctionParameters[3] = null;
  125688. this._blendEquationParameters[0] = null;
  125689. this._blendEquationParameters[1] = null;
  125690. this._blendConstants[0] = null;
  125691. this._blendConstants[1] = null;
  125692. this._blendConstants[2] = null;
  125693. this._blendConstants[3] = null;
  125694. this._isAlphaBlendDirty = true;
  125695. this._isBlendFunctionParametersDirty = false;
  125696. this._isBlendEquationParametersDirty = false;
  125697. this._isBlendConstantsDirty = false;
  125698. };
  125699. _AlphaState.prototype.apply = function (gl) {
  125700. if (!this.isDirty) {
  125701. return;
  125702. }
  125703. // Alpha blend
  125704. if (this._isAlphaBlendDirty) {
  125705. if (this._alphaBlend) {
  125706. gl.enable(gl.BLEND);
  125707. }
  125708. else {
  125709. gl.disable(gl.BLEND);
  125710. }
  125711. this._isAlphaBlendDirty = false;
  125712. }
  125713. // Alpha function
  125714. if (this._isBlendFunctionParametersDirty) {
  125715. gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);
  125716. this._isBlendFunctionParametersDirty = false;
  125717. }
  125718. // Alpha equation
  125719. if (this._isBlendEquationParametersDirty) {
  125720. gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);
  125721. this._isBlendEquationParametersDirty = false;
  125722. }
  125723. // Constants
  125724. if (this._isBlendConstantsDirty) {
  125725. gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);
  125726. this._isBlendConstantsDirty = false;
  125727. }
  125728. };
  125729. return _AlphaState;
  125730. }());
  125731. /***/ }),
  125732. /***/ "./States/depthCullingState.ts":
  125733. /*!*************************************!*\
  125734. !*** ./States/depthCullingState.ts ***!
  125735. \*************************************/
  125736. /*! exports provided: _DepthCullingState */
  125737. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125738. "use strict";
  125739. __webpack_require__.r(__webpack_exports__);
  125740. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _DepthCullingState; });
  125741. /**
  125742. * @hidden
  125743. **/
  125744. var _DepthCullingState = /** @class */ (function () {
  125745. /**
  125746. * Initializes the state.
  125747. */
  125748. function _DepthCullingState() {
  125749. this._isDepthTestDirty = false;
  125750. this._isDepthMaskDirty = false;
  125751. this._isDepthFuncDirty = false;
  125752. this._isCullFaceDirty = false;
  125753. this._isCullDirty = false;
  125754. this._isZOffsetDirty = false;
  125755. this._isFrontFaceDirty = false;
  125756. this.reset();
  125757. }
  125758. Object.defineProperty(_DepthCullingState.prototype, "isDirty", {
  125759. get: function () {
  125760. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
  125761. },
  125762. enumerable: true,
  125763. configurable: true
  125764. });
  125765. Object.defineProperty(_DepthCullingState.prototype, "zOffset", {
  125766. get: function () {
  125767. return this._zOffset;
  125768. },
  125769. set: function (value) {
  125770. if (this._zOffset === value) {
  125771. return;
  125772. }
  125773. this._zOffset = value;
  125774. this._isZOffsetDirty = true;
  125775. },
  125776. enumerable: true,
  125777. configurable: true
  125778. });
  125779. Object.defineProperty(_DepthCullingState.prototype, "cullFace", {
  125780. get: function () {
  125781. return this._cullFace;
  125782. },
  125783. set: function (value) {
  125784. if (this._cullFace === value) {
  125785. return;
  125786. }
  125787. this._cullFace = value;
  125788. this._isCullFaceDirty = true;
  125789. },
  125790. enumerable: true,
  125791. configurable: true
  125792. });
  125793. Object.defineProperty(_DepthCullingState.prototype, "cull", {
  125794. get: function () {
  125795. return this._cull;
  125796. },
  125797. set: function (value) {
  125798. if (this._cull === value) {
  125799. return;
  125800. }
  125801. this._cull = value;
  125802. this._isCullDirty = true;
  125803. },
  125804. enumerable: true,
  125805. configurable: true
  125806. });
  125807. Object.defineProperty(_DepthCullingState.prototype, "depthFunc", {
  125808. get: function () {
  125809. return this._depthFunc;
  125810. },
  125811. set: function (value) {
  125812. if (this._depthFunc === value) {
  125813. return;
  125814. }
  125815. this._depthFunc = value;
  125816. this._isDepthFuncDirty = true;
  125817. },
  125818. enumerable: true,
  125819. configurable: true
  125820. });
  125821. Object.defineProperty(_DepthCullingState.prototype, "depthMask", {
  125822. get: function () {
  125823. return this._depthMask;
  125824. },
  125825. set: function (value) {
  125826. if (this._depthMask === value) {
  125827. return;
  125828. }
  125829. this._depthMask = value;
  125830. this._isDepthMaskDirty = true;
  125831. },
  125832. enumerable: true,
  125833. configurable: true
  125834. });
  125835. Object.defineProperty(_DepthCullingState.prototype, "depthTest", {
  125836. get: function () {
  125837. return this._depthTest;
  125838. },
  125839. set: function (value) {
  125840. if (this._depthTest === value) {
  125841. return;
  125842. }
  125843. this._depthTest = value;
  125844. this._isDepthTestDirty = true;
  125845. },
  125846. enumerable: true,
  125847. configurable: true
  125848. });
  125849. Object.defineProperty(_DepthCullingState.prototype, "frontFace", {
  125850. get: function () {
  125851. return this._frontFace;
  125852. },
  125853. set: function (value) {
  125854. if (this._frontFace === value) {
  125855. return;
  125856. }
  125857. this._frontFace = value;
  125858. this._isFrontFaceDirty = true;
  125859. },
  125860. enumerable: true,
  125861. configurable: true
  125862. });
  125863. _DepthCullingState.prototype.reset = function () {
  125864. this._depthMask = true;
  125865. this._depthTest = true;
  125866. this._depthFunc = null;
  125867. this._cullFace = null;
  125868. this._cull = null;
  125869. this._zOffset = 0;
  125870. this._frontFace = null;
  125871. this._isDepthTestDirty = true;
  125872. this._isDepthMaskDirty = true;
  125873. this._isDepthFuncDirty = false;
  125874. this._isCullFaceDirty = false;
  125875. this._isCullDirty = false;
  125876. this._isZOffsetDirty = false;
  125877. this._isFrontFaceDirty = false;
  125878. };
  125879. _DepthCullingState.prototype.apply = function (gl) {
  125880. if (!this.isDirty) {
  125881. return;
  125882. }
  125883. // Cull
  125884. if (this._isCullDirty) {
  125885. if (this.cull) {
  125886. gl.enable(gl.CULL_FACE);
  125887. }
  125888. else {
  125889. gl.disable(gl.CULL_FACE);
  125890. }
  125891. this._isCullDirty = false;
  125892. }
  125893. // Cull face
  125894. if (this._isCullFaceDirty) {
  125895. gl.cullFace(this.cullFace);
  125896. this._isCullFaceDirty = false;
  125897. }
  125898. // Depth mask
  125899. if (this._isDepthMaskDirty) {
  125900. gl.depthMask(this.depthMask);
  125901. this._isDepthMaskDirty = false;
  125902. }
  125903. // Depth test
  125904. if (this._isDepthTestDirty) {
  125905. if (this.depthTest) {
  125906. gl.enable(gl.DEPTH_TEST);
  125907. }
  125908. else {
  125909. gl.disable(gl.DEPTH_TEST);
  125910. }
  125911. this._isDepthTestDirty = false;
  125912. }
  125913. // Depth func
  125914. if (this._isDepthFuncDirty) {
  125915. gl.depthFunc(this.depthFunc);
  125916. this._isDepthFuncDirty = false;
  125917. }
  125918. // zOffset
  125919. if (this._isZOffsetDirty) {
  125920. if (this.zOffset) {
  125921. gl.enable(gl.POLYGON_OFFSET_FILL);
  125922. gl.polygonOffset(this.zOffset, 0);
  125923. }
  125924. else {
  125925. gl.disable(gl.POLYGON_OFFSET_FILL);
  125926. }
  125927. this._isZOffsetDirty = false;
  125928. }
  125929. // Front face
  125930. if (this._isFrontFaceDirty) {
  125931. gl.frontFace(this.frontFace);
  125932. this._isFrontFaceDirty = false;
  125933. }
  125934. };
  125935. return _DepthCullingState;
  125936. }());
  125937. /***/ }),
  125938. /***/ "./States/index.ts":
  125939. /*!*************************!*\
  125940. !*** ./States/index.ts ***!
  125941. \*************************/
  125942. /*! exports provided: _AlphaState, _DepthCullingState, _StencilState */
  125943. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125944. "use strict";
  125945. __webpack_require__.r(__webpack_exports__);
  125946. /* harmony import */ var _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alphaCullingState */ "./States/alphaCullingState.ts");
  125947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  125948. /* harmony import */ var _depthCullingState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthCullingState */ "./States/depthCullingState.ts");
  125949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _depthCullingState__WEBPACK_IMPORTED_MODULE_1__["_DepthCullingState"]; });
  125950. /* harmony import */ var _stencilState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stencilState */ "./States/stencilState.ts");
  125951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _stencilState__WEBPACK_IMPORTED_MODULE_2__["_StencilState"]; });
  125952. /***/ }),
  125953. /***/ "./States/stencilState.ts":
  125954. /*!********************************!*\
  125955. !*** ./States/stencilState.ts ***!
  125956. \********************************/
  125957. /*! exports provided: _StencilState */
  125958. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125959. "use strict";
  125960. __webpack_require__.r(__webpack_exports__);
  125961. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _StencilState; });
  125962. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125963. /**
  125964. * @hidden
  125965. **/
  125966. var _StencilState = /** @class */ (function () {
  125967. function _StencilState() {
  125968. this._isStencilTestDirty = false;
  125969. this._isStencilMaskDirty = false;
  125970. this._isStencilFuncDirty = false;
  125971. this._isStencilOpDirty = false;
  125972. this.reset();
  125973. }
  125974. Object.defineProperty(_StencilState.prototype, "isDirty", {
  125975. get: function () {
  125976. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
  125977. },
  125978. enumerable: true,
  125979. configurable: true
  125980. });
  125981. Object.defineProperty(_StencilState.prototype, "stencilFunc", {
  125982. get: function () {
  125983. return this._stencilFunc;
  125984. },
  125985. set: function (value) {
  125986. if (this._stencilFunc === value) {
  125987. return;
  125988. }
  125989. this._stencilFunc = value;
  125990. this._isStencilFuncDirty = true;
  125991. },
  125992. enumerable: true,
  125993. configurable: true
  125994. });
  125995. Object.defineProperty(_StencilState.prototype, "stencilFuncRef", {
  125996. get: function () {
  125997. return this._stencilFuncRef;
  125998. },
  125999. set: function (value) {
  126000. if (this._stencilFuncRef === value) {
  126001. return;
  126002. }
  126003. this._stencilFuncRef = value;
  126004. this._isStencilFuncDirty = true;
  126005. },
  126006. enumerable: true,
  126007. configurable: true
  126008. });
  126009. Object.defineProperty(_StencilState.prototype, "stencilFuncMask", {
  126010. get: function () {
  126011. return this._stencilFuncMask;
  126012. },
  126013. set: function (value) {
  126014. if (this._stencilFuncMask === value) {
  126015. return;
  126016. }
  126017. this._stencilFuncMask = value;
  126018. this._isStencilFuncDirty = true;
  126019. },
  126020. enumerable: true,
  126021. configurable: true
  126022. });
  126023. Object.defineProperty(_StencilState.prototype, "stencilOpStencilFail", {
  126024. get: function () {
  126025. return this._stencilOpStencilFail;
  126026. },
  126027. set: function (value) {
  126028. if (this._stencilOpStencilFail === value) {
  126029. return;
  126030. }
  126031. this._stencilOpStencilFail = value;
  126032. this._isStencilOpDirty = true;
  126033. },
  126034. enumerable: true,
  126035. configurable: true
  126036. });
  126037. Object.defineProperty(_StencilState.prototype, "stencilOpDepthFail", {
  126038. get: function () {
  126039. return this._stencilOpDepthFail;
  126040. },
  126041. set: function (value) {
  126042. if (this._stencilOpDepthFail === value) {
  126043. return;
  126044. }
  126045. this._stencilOpDepthFail = value;
  126046. this._isStencilOpDirty = true;
  126047. },
  126048. enumerable: true,
  126049. configurable: true
  126050. });
  126051. Object.defineProperty(_StencilState.prototype, "stencilOpStencilDepthPass", {
  126052. get: function () {
  126053. return this._stencilOpStencilDepthPass;
  126054. },
  126055. set: function (value) {
  126056. if (this._stencilOpStencilDepthPass === value) {
  126057. return;
  126058. }
  126059. this._stencilOpStencilDepthPass = value;
  126060. this._isStencilOpDirty = true;
  126061. },
  126062. enumerable: true,
  126063. configurable: true
  126064. });
  126065. Object.defineProperty(_StencilState.prototype, "stencilMask", {
  126066. get: function () {
  126067. return this._stencilMask;
  126068. },
  126069. set: function (value) {
  126070. if (this._stencilMask === value) {
  126071. return;
  126072. }
  126073. this._stencilMask = value;
  126074. this._isStencilMaskDirty = true;
  126075. },
  126076. enumerable: true,
  126077. configurable: true
  126078. });
  126079. Object.defineProperty(_StencilState.prototype, "stencilTest", {
  126080. get: function () {
  126081. return this._stencilTest;
  126082. },
  126083. set: function (value) {
  126084. if (this._stencilTest === value) {
  126085. return;
  126086. }
  126087. this._stencilTest = value;
  126088. this._isStencilTestDirty = true;
  126089. },
  126090. enumerable: true,
  126091. configurable: true
  126092. });
  126093. _StencilState.prototype.reset = function () {
  126094. this._stencilTest = false;
  126095. this._stencilMask = 0xFF;
  126096. this._stencilFunc = _StencilState.ALWAYS;
  126097. this._stencilFuncRef = 1;
  126098. this._stencilFuncMask = 0xFF;
  126099. this._stencilOpStencilFail = _StencilState.KEEP;
  126100. this._stencilOpDepthFail = _StencilState.KEEP;
  126101. this._stencilOpStencilDepthPass = _StencilState.REPLACE;
  126102. this._isStencilTestDirty = true;
  126103. this._isStencilMaskDirty = true;
  126104. this._isStencilFuncDirty = true;
  126105. this._isStencilOpDirty = true;
  126106. };
  126107. _StencilState.prototype.apply = function (gl) {
  126108. if (!this.isDirty) {
  126109. return;
  126110. }
  126111. // Stencil test
  126112. if (this._isStencilTestDirty) {
  126113. if (this.stencilTest) {
  126114. gl.enable(gl.STENCIL_TEST);
  126115. }
  126116. else {
  126117. gl.disable(gl.STENCIL_TEST);
  126118. }
  126119. this._isStencilTestDirty = false;
  126120. }
  126121. // Stencil mask
  126122. if (this._isStencilMaskDirty) {
  126123. gl.stencilMask(this.stencilMask);
  126124. this._isStencilMaskDirty = false;
  126125. }
  126126. // Stencil func
  126127. if (this._isStencilFuncDirty) {
  126128. gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);
  126129. this._isStencilFuncDirty = false;
  126130. }
  126131. // Stencil op
  126132. if (this._isStencilOpDirty) {
  126133. gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);
  126134. this._isStencilOpDirty = false;
  126135. }
  126136. };
  126137. /** 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 */
  126138. _StencilState.ALWAYS = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ALWAYS;
  126139. /** Passed to stencilOperation to specify that stencil value must be kept */
  126140. _StencilState.KEEP = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].KEEP;
  126141. /** Passed to stencilOperation to specify that stencil value must be replaced */
  126142. _StencilState.REPLACE = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].REPLACE;
  126143. return _StencilState;
  126144. }());
  126145. /***/ }),
  126146. /***/ "./abstractScene.ts":
  126147. /*!**************************!*\
  126148. !*** ./abstractScene.ts ***!
  126149. \**************************/
  126150. /*! exports provided: AbstractScene */
  126151. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126152. "use strict";
  126153. __webpack_require__.r(__webpack_exports__);
  126154. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return AbstractScene; });
  126155. /**
  126156. * Base class of the scene acting as a container for the different elements composing a scene.
  126157. * This class is dynamically extended by the different components of the scene increasing
  126158. * flexibility and reducing coupling
  126159. */
  126160. var AbstractScene = /** @class */ (function () {
  126161. function AbstractScene() {
  126162. /**
  126163. * Gets the list of root nodes (ie. nodes with no parent)
  126164. */
  126165. this.rootNodes = new Array();
  126166. /** All of the cameras added to this scene
  126167. * @see http://doc.babylonjs.com/babylon101/cameras
  126168. */
  126169. this.cameras = new Array();
  126170. /**
  126171. * All of the lights added to this scene
  126172. * @see http://doc.babylonjs.com/babylon101/lights
  126173. */
  126174. this.lights = new Array();
  126175. /**
  126176. * All of the (abstract) meshes added to this scene
  126177. */
  126178. this.meshes = new Array();
  126179. /**
  126180. * The list of skeletons added to the scene
  126181. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  126182. */
  126183. this.skeletons = new Array();
  126184. /**
  126185. * All of the particle systems added to this scene
  126186. * @see http://doc.babylonjs.com/babylon101/particles
  126187. */
  126188. this.particleSystems = new Array();
  126189. /**
  126190. * Gets a list of Animations associated with the scene
  126191. */
  126192. this.animations = [];
  126193. /**
  126194. * All of the animation groups added to this scene
  126195. * @see http://doc.babylonjs.com/how_to/group
  126196. */
  126197. this.animationGroups = new Array();
  126198. /**
  126199. * All of the multi-materials added to this scene
  126200. * @see http://doc.babylonjs.com/how_to/multi_materials
  126201. */
  126202. this.multiMaterials = new Array();
  126203. /**
  126204. * All of the materials added to this scene
  126205. * In the context of a Scene, it is not supposed to be modified manually.
  126206. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  126207. * Note also that the order of the Material wihin the array is not significant and might change.
  126208. * @see http://doc.babylonjs.com/babylon101/materials
  126209. */
  126210. this.materials = new Array();
  126211. /**
  126212. * The list of morph target managers added to the scene
  126213. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  126214. */
  126215. this.morphTargetManagers = new Array();
  126216. /**
  126217. * The list of geometries used in the scene.
  126218. */
  126219. this.geometries = new Array();
  126220. /**
  126221. * All of the tranform nodes added to this scene
  126222. * In the context of a Scene, it is not supposed to be modified manually.
  126223. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  126224. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  126225. * @see http://doc.babylonjs.com/how_to/transformnode
  126226. */
  126227. this.transformNodes = new Array();
  126228. /**
  126229. * ActionManagers available on the scene.
  126230. */
  126231. this.actionManagers = new Array();
  126232. /**
  126233. * Textures to keep.
  126234. */
  126235. this.textures = new Array();
  126236. }
  126237. /**
  126238. * Adds a parser in the list of available ones
  126239. * @param name Defines the name of the parser
  126240. * @param parser Defines the parser to add
  126241. */
  126242. AbstractScene.AddParser = function (name, parser) {
  126243. this._BabylonFileParsers[name] = parser;
  126244. };
  126245. /**
  126246. * Gets a general parser from the list of avaialble ones
  126247. * @param name Defines the name of the parser
  126248. * @returns the requested parser or null
  126249. */
  126250. AbstractScene.GetParser = function (name) {
  126251. if (this._BabylonFileParsers[name]) {
  126252. return this._BabylonFileParsers[name];
  126253. }
  126254. return null;
  126255. };
  126256. /**
  126257. * Adds n individual parser in the list of available ones
  126258. * @param name Defines the name of the parser
  126259. * @param parser Defines the parser to add
  126260. */
  126261. AbstractScene.AddIndividualParser = function (name, parser) {
  126262. this._IndividualBabylonFileParsers[name] = parser;
  126263. };
  126264. /**
  126265. * Gets an individual parser from the list of avaialble ones
  126266. * @param name Defines the name of the parser
  126267. * @returns the requested parser or null
  126268. */
  126269. AbstractScene.GetIndividualParser = function (name) {
  126270. if (this._IndividualBabylonFileParsers[name]) {
  126271. return this._IndividualBabylonFileParsers[name];
  126272. }
  126273. return null;
  126274. };
  126275. /**
  126276. * Parser json data and populate both a scene and its associated container object
  126277. * @param jsonData Defines the data to parse
  126278. * @param scene Defines the scene to parse the data for
  126279. * @param container Defines the container attached to the parsing sequence
  126280. * @param rootUrl Defines the root url of the data
  126281. */
  126282. AbstractScene.Parse = function (jsonData, scene, container, rootUrl) {
  126283. for (var parserName in this._BabylonFileParsers) {
  126284. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  126285. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  126286. }
  126287. }
  126288. };
  126289. /**
  126290. * Stores the list of available parsers in the application.
  126291. */
  126292. AbstractScene._BabylonFileParsers = {};
  126293. /**
  126294. * Stores the list of available individual parsers in the application.
  126295. */
  126296. AbstractScene._IndividualBabylonFileParsers = {};
  126297. return AbstractScene;
  126298. }());
  126299. /***/ }),
  126300. /***/ "./assetContainer.ts":
  126301. /*!***************************!*\
  126302. !*** ./assetContainer.ts ***!
  126303. \***************************/
  126304. /*! exports provided: KeepAssets, AssetContainer */
  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__, "KeepAssets", function() { return KeepAssets; });
  126309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return AssetContainer; });
  126310. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  126311. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  126312. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Meshes/mesh */ "./Meshes/mesh.ts");
  126313. /**
  126314. * Set of assets to keep when moving a scene into an asset container.
  126315. */
  126316. var KeepAssets = /** @class */ (function (_super) {
  126317. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeepAssets, _super);
  126318. function KeepAssets() {
  126319. return _super !== null && _super.apply(this, arguments) || this;
  126320. }
  126321. return KeepAssets;
  126322. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  126323. /**
  126324. * Container with a set of assets that can be added or removed from a scene.
  126325. */
  126326. var AssetContainer = /** @class */ (function (_super) {
  126327. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AssetContainer, _super);
  126328. /**
  126329. * Instantiates an AssetContainer.
  126330. * @param scene The scene the AssetContainer belongs to.
  126331. */
  126332. function AssetContainer(scene) {
  126333. var _this = _super.call(this) || this;
  126334. _this.scene = scene;
  126335. _this["sounds"] = [];
  126336. _this["effectLayers"] = [];
  126337. _this["layers"] = [];
  126338. _this["lensFlareSystems"] = [];
  126339. _this["proceduralTextures"] = [];
  126340. _this["reflectionProbes"] = [];
  126341. return _this;
  126342. }
  126343. /**
  126344. * Adds all the assets from the container to the scene.
  126345. */
  126346. AssetContainer.prototype.addAllToScene = function () {
  126347. var _this = this;
  126348. this.cameras.forEach(function (o) {
  126349. _this.scene.addCamera(o);
  126350. });
  126351. this.lights.forEach(function (o) {
  126352. _this.scene.addLight(o);
  126353. });
  126354. this.meshes.forEach(function (o) {
  126355. _this.scene.addMesh(o);
  126356. });
  126357. this.skeletons.forEach(function (o) {
  126358. _this.scene.addSkeleton(o);
  126359. });
  126360. this.animations.forEach(function (o) {
  126361. _this.scene.addAnimation(o);
  126362. });
  126363. this.animationGroups.forEach(function (o) {
  126364. _this.scene.addAnimationGroup(o);
  126365. });
  126366. this.multiMaterials.forEach(function (o) {
  126367. _this.scene.addMultiMaterial(o);
  126368. });
  126369. this.materials.forEach(function (o) {
  126370. _this.scene.addMaterial(o);
  126371. });
  126372. this.morphTargetManagers.forEach(function (o) {
  126373. _this.scene.addMorphTargetManager(o);
  126374. });
  126375. this.geometries.forEach(function (o) {
  126376. _this.scene.addGeometry(o);
  126377. });
  126378. this.transformNodes.forEach(function (o) {
  126379. _this.scene.addTransformNode(o);
  126380. });
  126381. this.actionManagers.forEach(function (o) {
  126382. _this.scene.addActionManager(o);
  126383. });
  126384. this.textures.forEach(function (o) {
  126385. _this.scene.addTexture(o);
  126386. });
  126387. this.reflectionProbes.forEach(function (o) {
  126388. _this.scene.addReflectionProbe(o);
  126389. });
  126390. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  126391. var component = _a[_i];
  126392. component.addFromContainer(this);
  126393. }
  126394. };
  126395. /**
  126396. * Removes all the assets in the container from the scene
  126397. */
  126398. AssetContainer.prototype.removeAllFromScene = function () {
  126399. var _this = this;
  126400. this.cameras.forEach(function (o) {
  126401. _this.scene.removeCamera(o);
  126402. });
  126403. this.lights.forEach(function (o) {
  126404. _this.scene.removeLight(o);
  126405. });
  126406. this.meshes.forEach(function (o) {
  126407. _this.scene.removeMesh(o);
  126408. });
  126409. this.skeletons.forEach(function (o) {
  126410. _this.scene.removeSkeleton(o);
  126411. });
  126412. this.animations.forEach(function (o) {
  126413. _this.scene.removeAnimation(o);
  126414. });
  126415. this.animationGroups.forEach(function (o) {
  126416. _this.scene.removeAnimationGroup(o);
  126417. });
  126418. this.multiMaterials.forEach(function (o) {
  126419. _this.scene.removeMultiMaterial(o);
  126420. });
  126421. this.materials.forEach(function (o) {
  126422. _this.scene.removeMaterial(o);
  126423. });
  126424. this.morphTargetManagers.forEach(function (o) {
  126425. _this.scene.removeMorphTargetManager(o);
  126426. });
  126427. this.geometries.forEach(function (o) {
  126428. _this.scene.removeGeometry(o);
  126429. });
  126430. this.transformNodes.forEach(function (o) {
  126431. _this.scene.removeTransformNode(o);
  126432. });
  126433. this.actionManagers.forEach(function (o) {
  126434. _this.scene.removeActionManager(o);
  126435. });
  126436. this.textures.forEach(function (o) {
  126437. _this.scene.removeTexture(o);
  126438. });
  126439. this.reflectionProbes.forEach(function (o) {
  126440. _this.scene.removeReflectionProbe(o);
  126441. });
  126442. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  126443. var component = _a[_i];
  126444. component.removeFromContainer(this);
  126445. }
  126446. };
  126447. /**
  126448. * Disposes all the assets in the container
  126449. */
  126450. AssetContainer.prototype.dispose = function () {
  126451. this.cameras.forEach(function (o) {
  126452. o.dispose();
  126453. });
  126454. this.lights.forEach(function (o) {
  126455. o.dispose();
  126456. });
  126457. this.meshes.forEach(function (o) {
  126458. o.dispose();
  126459. });
  126460. this.skeletons.forEach(function (o) {
  126461. o.dispose();
  126462. });
  126463. this.animationGroups.forEach(function (o) {
  126464. o.dispose();
  126465. });
  126466. this.multiMaterials.forEach(function (o) {
  126467. o.dispose();
  126468. });
  126469. this.materials.forEach(function (o) {
  126470. o.dispose();
  126471. });
  126472. this.geometries.forEach(function (o) {
  126473. o.dispose();
  126474. });
  126475. this.transformNodes.forEach(function (o) {
  126476. o.dispose();
  126477. });
  126478. this.actionManagers.forEach(function (o) {
  126479. o.dispose();
  126480. });
  126481. this.textures.forEach(function (o) {
  126482. o.dispose();
  126483. });
  126484. this.reflectionProbes.forEach(function (o) {
  126485. o.dispose();
  126486. });
  126487. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  126488. var component = _a[_i];
  126489. component.dispose();
  126490. }
  126491. };
  126492. AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
  126493. if (!sourceAssets) {
  126494. return;
  126495. }
  126496. for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
  126497. var asset = sourceAssets_1[_i];
  126498. var move = true;
  126499. if (keepAssets) {
  126500. for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
  126501. var keepAsset = keepAssets_1[_a];
  126502. if (asset === keepAsset) {
  126503. move = false;
  126504. break;
  126505. }
  126506. }
  126507. }
  126508. if (move) {
  126509. targetAssets.push(asset);
  126510. }
  126511. }
  126512. };
  126513. /**
  126514. * Removes all the assets contained in the scene and adds them to the container.
  126515. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  126516. */
  126517. AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
  126518. if (keepAssets === undefined) {
  126519. keepAssets = new KeepAssets();
  126520. }
  126521. for (var key in this) {
  126522. if (this.hasOwnProperty(key)) {
  126523. this[key] = this[key] || [];
  126524. this._moveAssets(this.scene[key], this[key], keepAssets[key]);
  126525. }
  126526. }
  126527. this.removeAllFromScene();
  126528. };
  126529. /**
  126530. * 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.
  126531. * @returns the root mesh
  126532. */
  126533. AssetContainer.prototype.createRootMesh = function () {
  126534. var rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("assetContainerRootMesh", this.scene);
  126535. this.meshes.forEach(function (m) {
  126536. if (!m.parent) {
  126537. rootMesh.addChild(m);
  126538. }
  126539. });
  126540. this.meshes.unshift(rootMesh);
  126541. return rootMesh;
  126542. };
  126543. return AssetContainer;
  126544. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  126545. /***/ }),
  126546. /***/ "./index.ts":
  126547. /*!******************!*\
  126548. !*** ./index.ts ***!
  126549. \******************/
  126550. /*! exports provided: AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, BoxBuilder, DiscBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, ReflectionProbe, BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer, Sprite, SpriteManager, SpriteSceneComponent, _AlphaState, _DepthCullingState, _StencilState, AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  126551. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126552. "use strict";
  126553. __webpack_require__.r(__webpack_exports__);
  126554. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  126555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _abstractScene__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  126556. /* harmony import */ var _Actions_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actions/index */ "./Actions/index.ts");
  126557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Action"]; });
  126558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  126559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionManager"]; });
  126560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Condition"]; });
  126561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"]; });
  126562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PredicateCondition"]; });
  126563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StateCondition"]; });
  126564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SwitchBooleanAction"]; });
  126565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetStateAction"]; });
  126566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetValueAction"]; });
  126567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["IncrementValueAction"]; });
  126568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlayAnimationAction"]; });
  126569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopAnimationAction"]; });
  126570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["DoNothingAction"]; });
  126571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["CombineAction"]; });
  126572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ExecuteCodeAction"]; });
  126573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetParentAction"]; });
  126574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlaySoundAction"]; });
  126575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopSoundAction"]; });
  126576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["InterpolateValueAction"]; });
  126577. /* harmony import */ var _Animations_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Animations/index */ "./Animations/index.ts");
  126578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animatable"]; });
  126579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animation"]; });
  126580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  126581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  126582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationPropertiesOverride"]; });
  126583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["EasingFunction"]; });
  126584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CircleEase"]; });
  126585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BackEase"]; });
  126586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BounceEase"]; });
  126587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CubicEase"]; });
  126588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ElasticEase"]; });
  126589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ExponentialEase"]; });
  126590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PowerEase"]; });
  126591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuadraticEase"]; });
  126592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuarticEase"]; });
  126593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuinticEase"]; });
  126594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["SineEase"]; });
  126595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BezierCurveEase"]; });
  126596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["RuntimeAnimation"]; });
  126597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationEvent"]; });
  126598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationKeyInterpolation"]; });
  126599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationRange"]; });
  126600. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assetContainer */ "./assetContainer.ts");
  126601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["KeepAssets"]; });
  126602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["AssetContainer"]; });
  126603. /* harmony import */ var _Audio_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Audio/index */ "./Audio/index.ts");
  126604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Analyser"]; });
  126605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioEngine"]; });
  126606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioSceneComponent"]; });
  126607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Sound"]; });
  126608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  126609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["WeightedSound"]; });
  126610. /* harmony import */ var _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Behaviors/index */ "./Behaviors/index.ts");
  126611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AutoRotationBehavior"]; });
  126612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["BouncingBehavior"]; });
  126613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FramingBehavior"]; });
  126614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AttachToBoxBehavior"]; });
  126615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FadeInOutBehavior"]; });
  126616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["MultiPointerScaleBehavior"]; });
  126617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]; });
  126618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]; });
  126619. /* harmony import */ var _Bones_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Bones/index */ "./Bones/index.ts");
  126620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Bone"]; });
  126621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneIKController"]; });
  126622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneLookController"]; });
  126623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Skeleton"]; });
  126624. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Cameras/index */ "./Cameras/index.ts");
  126625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputTypes"]; });
  126626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputsManager"]; });
  126627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["Camera"]; });
  126628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TargetCamera"]; });
  126629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCamera"]; });
  126630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraInputsManager"]; });
  126631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TouchCamera"]; });
  126632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  126633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraInputsManager"]; });
  126634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["DeviceOrientationCamera"]; });
  126635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCamera"]; });
  126636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraInputsManager"]; });
  126637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCamera"]; });
  126638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcFollowCamera"]; });
  126639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["GamepadCamera"]; });
  126640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["UniversalCamera"]; });
  126641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VirtualJoysticksCamera"]; });
  126642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraGamepadInput"]; });
  126643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraKeyboardMoveInput"]; });
  126644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraMouseWheelInput"]; });
  126645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraPointersInput"]; });
  126646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraVRDeviceOrientationInput"]; });
  126647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraKeyboardInput"]; });
  126648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraMouseInput"]; });
  126649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  126650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraGamepadInput"]; });
  126651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraKeyboardMoveInput"]; });
  126652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraMouseInput"]; });
  126653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraTouchInput"]; });
  126654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraVirtualJoystickInput"]; });
  126655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphArcRotateCamera"]; });
  126656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphFreeCamera"]; });
  126657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphGamepadCamera"]; });
  126658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphUniversalCamera"]; });
  126659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicArcRotateCamera"]; });
  126660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicFreeCamera"]; });
  126661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicGamepadCamera"]; });
  126662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  126663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRCameraMetrics"]; });
  126664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationArcRotateCamera"]; });
  126665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationFreeCamera"]; });
  126666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationGamepadCamera"]; });
  126667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRExperienceHelper"]; });
  126668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]; });
  126669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRCamera"]; });
  126670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIButton"]; });
  126671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIOptions"]; });
  126672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUI"]; });
  126673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRState"]; });
  126674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRExperienceHelper"]; });
  126675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  126676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRInput"]; });
  126677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRManagedOutputCanvas"]; });
  126678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRSessionManager"]; });
  126679. /* harmony import */ var _Collisions_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Collisions/index */ "./Collisions/index.ts");
  126680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["Collider"]; });
  126681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["DefaultCollisionCoordinator"]; });
  126682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]; });
  126683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["IntersectionInfo"]; });
  126684. /* harmony import */ var _Culling_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Culling/index */ "./Culling/index.ts");
  126685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingBox"]; });
  126686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"]; });
  126687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingSphere"]; });
  126688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Ray"]; });
  126689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Octree"]; });
  126690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeBlock"]; });
  126691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeSceneComponent"]; });
  126692. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Debug/index */ "./Debug/index.ts");
  126693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["AxesViewer"]; });
  126694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["BoneAxesViewer"]; });
  126695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["DebugLayer"]; });
  126696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["PhysicsViewer"]; });
  126697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["RayHelper"]; });
  126698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["SkeletonViewer"]; });
  126699. /* harmony import */ var _Engines_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Engines/index */ "./Engines/index.ts");
  126700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Constants"]; });
  126701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["InstancingAttributeInfo"]; });
  126702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["DepthTextureCreationOptions"]; });
  126703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineCapabilities"]; });
  126704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Engine"]; });
  126705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineStore"]; });
  126706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngineOptions"]; });
  126707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngine"]; });
  126708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_OcclusionDataStorage"]; });
  126709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_forceTransformFeedbackToBundle"]; });
  126710. /* harmony import */ var _Events_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Events/index */ "./Events/index.ts");
  126711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardEventTypes"]; });
  126712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfo"]; });
  126713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfoPre"]; });
  126714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerEventTypes"]; });
  126715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoBase"]; });
  126716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoPre"]; });
  126717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfo"]; });
  126718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardEventTypes"]; });
  126719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardInfo"]; });
  126720. /* harmony import */ var _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Gamepads/index */ "./Gamepads/index.ts");
  126721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["DaydreamController"]; });
  126722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GearVRController"]; });
  126723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericController"]; });
  126724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["OculusTouchController"]; });
  126725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerType"]; });
  126726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerHelper"]; });
  126727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledController"]; });
  126728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["ViveController"]; });
  126729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]; });
  126730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WindowsMotionController"]; });
  126731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["StickValues"]; });
  126732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Gamepad"]; });
  126733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericPad"]; });
  126734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadManager"]; });
  126735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadSystemSceneComponent"]; });
  126736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"]; });
  126737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Dpad"]; });
  126738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Pad"]; });
  126739. /* harmony import */ var _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Gizmos/index */ "./Gizmos/index.ts");
  126740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisDragGizmo"]; });
  126741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisScaleGizmo"]; });
  126742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["BoundingBoxGizmo"]; });
  126743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["Gizmo"]; });
  126744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["GizmoManager"]; });
  126745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneRotationGizmo"]; });
  126746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PositionGizmo"]; });
  126747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["RotationGizmo"]; });
  126748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["ScaleGizmo"]; });
  126749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["LightGizmo"]; });
  126750. /* harmony import */ var _Helpers_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Helpers/index */ "./Helpers/index.ts");
  126751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["EnvironmentHelper"]; });
  126752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["PhotoDome"]; });
  126753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["_forceSceneHelpersToBundle"]; });
  126754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["VideoDome"]; });
  126755. /* harmony import */ var _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Instrumentation/index */ "./Instrumentation/index.ts");
  126756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["EngineInstrumentation"]; });
  126757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["SceneInstrumentation"]; });
  126758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["_TimeToken"]; });
  126759. /* harmony import */ var _Layers_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Layers/index */ "./Layers/index.ts");
  126760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayer"]; });
  126761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayerSceneComponent"]; });
  126762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["GlowLayer"]; });
  126763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["HighlightLayer"]; });
  126764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["Layer"]; });
  126765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["LayerSceneComponent"]; });
  126766. /* harmony import */ var _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./LensFlares/index */ "./LensFlares/index.ts");
  126767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlare"]; });
  126768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystem"]; });
  126769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystemSceneComponent"]; });
  126770. /* harmony import */ var _Lights_index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Lights/index */ "./Lights/index.ts");
  126771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["Light"]; });
  126772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowLight"]; });
  126773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["DirectionalLight"]; });
  126774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["HemisphericLight"]; });
  126775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["PointLight"]; });
  126776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["SpotLight"]; });
  126777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGenerator"]; });
  126778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGeneratorSceneComponent"]; });
  126779. /* harmony import */ var _Loading_index__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Loading/index */ "./Loading/index.ts");
  126780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["DefaultLoadingScreen"]; });
  126781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderProgressEvent"]; });
  126782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoader"]; });
  126783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderFlags"]; });
  126784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["_BabylonLoaderRegistered"]; });
  126785. /* harmony import */ var _Materials_index__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Materials/index */ "./Materials/index.ts");
  126786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorCurves"]; });
  126787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectFallbacks"]; });
  126788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectCreationOptions"]; });
  126789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Effect"]; });
  126790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FresnelParameters"]; });
  126791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfigurationDefines"]; });
  126792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfiguration"]; });
  126793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Material"]; });
  126794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialDefines"]; });
  126795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialHelper"]; });
  126796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiMaterial"]; });
  126797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PushMaterial"]; });
  126798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ShaderMaterial"]; });
  126799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterialDefines"]; });
  126800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterial"]; });
  126801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BaseTexture"]; });
  126802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CubeTexture"]; });
  126803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HDRCubeTexture"]; });
  126804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InternalTexture"]; });
  126805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DummyInternalTextureTracker"]; });
  126806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MirrorTexture"]; });
  126807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiRenderTarget"]; });
  126808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture"]; });
  126809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RenderTargetTexture"]; });
  126810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Texture"]; });
  126811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["UniformBuffer"]; });
  126812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialFlags"]; });
  126813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BackgroundMaterial"]; });
  126814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseMaterial"]; });
  126815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseSimpleMaterial"]; });
  126816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterial"]; });
  126817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMetallicRoughnessMaterial"]; });
  126818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRSpecularGlossinessMaterial"]; });
  126819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorGradingTexture"]; });
  126820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DynamicTexture"]; });
  126821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTexture"]; });
  126822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawCubeTexture"]; });
  126823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture3D"]; });
  126824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RefractionTexture"]; });
  126825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VideoTexture"]; });
  126826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_DDSTextureLoader"]; });
  126827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_ENVTextureLoader"]; });
  126828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_KTXTextureLoader"]; });
  126829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_TGATextureLoader"]; });
  126830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CustomProceduralTexture"]; });
  126831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NoiseProceduralTexture"]; });
  126832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTextureSceneComponent"]; });
  126833. /* harmony import */ var _Maths_index__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Maths/index */ "./Maths/index.ts");
  126834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Scalar"]; });
  126835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToGammaSpace"]; });
  126836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToLinearSpace"]; });
  126837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Epsilon"]; });
  126838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color3"]; });
  126839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color4"]; });
  126840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector2"]; });
  126841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector3"]; });
  126842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector4"]; });
  126843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Size"]; });
  126844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Quaternion"]; });
  126845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Matrix"]; });
  126846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Plane"]; });
  126847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Viewport"]; });
  126848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Frustum"]; });
  126849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Space"]; });
  126850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Axis"]; });
  126851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["BezierCurve"]; });
  126852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Orientation"]; });
  126853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Angle"]; });
  126854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Arc2"]; });
  126855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path2"]; });
  126856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path3D"]; });
  126857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Curve3"]; });
  126858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalVertex"]; });
  126859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalTextureVertex"]; });
  126860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Tmp"]; });
  126861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalPolynomial"]; });
  126862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalHarmonics"]; });
  126863. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Meshes/index */ "./Meshes/index.ts");
  126864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["AbstractMesh"]; });
  126865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Buffer"]; });
  126866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexBuffer"]; });
  126867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CSG"]; });
  126868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Geometry"]; });
  126869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundMesh"]; });
  126870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedMesh"]; });
  126871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesMesh"]; });
  126872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedLinesMesh"]; });
  126873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"]; });
  126874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_CreationDataStorage"]; });
  126875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_InstancesBatch"]; });
  126876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Mesh"]; });
  126877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexData"]; });
  126878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshBuilder"]; });
  126879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationSettings"]; });
  126880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationQueue"]; });
  126881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationType"]; });
  126882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplicationQueueSceneComponent"]; });
  126883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Polygon"]; });
  126884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonMeshBuilder"]; });
  126885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BaseSubMesh"]; });
  126886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SubMesh"]; });
  126887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TransformNode"]; });
  126888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BoxBuilder"]; });
  126889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DiscBuilder"]; });
  126890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SphereBuilder"]; });
  126891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CylinderBuilder"]; });
  126892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesBuilder"]; });
  126893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PlaneBuilder"]; });
  126894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DracoCompression"]; });
  126895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["RibbonBuilder"]; });
  126896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusBuilder"]; });
  126897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusKnotBuilder"]; });
  126898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonBuilder"]; });
  126899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["ShapeBuilder"]; });
  126900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LatheBuilder"]; });
  126901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundBuilder"]; });
  126902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TubeBuilder"]; });
  126903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolyhedronBuilder"]; });
  126904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["IcoSphereBuilder"]; });
  126905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DecalBuilder"]; });
  126906. /* harmony import */ var _Morph_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Morph/index */ "./Morph/index.ts");
  126907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTarget"]; });
  126908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTargetManager"]; });
  126909. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./node */ "./node.ts");
  126910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _node__WEBPACK_IMPORTED_MODULE_25__["Node"]; });
  126911. /* harmony import */ var _Offline_index__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Offline/index */ "./Offline/index.ts");
  126912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _Offline_index__WEBPACK_IMPORTED_MODULE_26__["Database"]; });
  126913. /* harmony import */ var _Particles_index__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Particles/index */ "./Particles/index.ts");
  126914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BaseParticleSystem"]; });
  126915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["GPUParticleSystem"]; });
  126916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["Particle"]; });
  126917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleHelper"]; });
  126918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystem"]; });
  126919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["_IDoNeedToBeInTheBuild"]; });
  126920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystemSet"]; });
  126921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticle"]; });
  126922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ModelShape"]; });
  126923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["DepthSortedParticle"]; });
  126924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticleSystem"]; });
  126925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitterType"]; });
  126926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitter"]; });
  126927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BoxParticleEmitter"]; });
  126928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ConeParticleEmitter"]; });
  126929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderParticleEmitter"]; });
  126930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderDirectedParticleEmitter"]; });
  126931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["HemisphericParticleEmitter"]; });
  126932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["PointParticleEmitter"]; });
  126933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereParticleEmitter"]; });
  126934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereDirectedParticleEmitter"]; });
  126935. /* harmony import */ var _Physics_index__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Physics/index */ "./Physics/index.ts");
  126936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngine"]; });
  126937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngineSceneComponent"]; });
  126938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsHelper"]; });
  126939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialExplosionEvent"]; });
  126940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsGravitationalFieldEvent"]; });
  126941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftEvent"]; });
  126942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsVortexEvent"]; });
  126943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialImpulseFalloff"]; });
  126944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftMode"]; });
  126945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsImpostor"]; });
  126946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsJoint"]; });
  126947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["DistanceJoint"]; });
  126948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["MotorEnabledJoint"]; });
  126949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["HingeJoint"]; });
  126950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["Hinge2Joint"]; });
  126951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["CannonJSPlugin"]; });
  126952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["AmmoJSPlugin"]; });
  126953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["OimoJSPlugin"]; });
  126954. /* harmony import */ var _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./PostProcesses/index */ "./PostProcesses/index.ts");
  126955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["AnaglyphPostProcess"]; });
  126956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlackAndWhitePostProcess"]; });
  126957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomEffect"]; });
  126958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomMergePostProcess"]; });
  126959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlurPostProcess"]; });
  126960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ChromaticAberrationPostProcess"]; });
  126961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["CircleOfConfusionPostProcess"]; });
  126962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ColorCorrectionPostProcess"]; });
  126963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ConvolutionPostProcess"]; });
  126964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldBlurPostProcess"]; });
  126965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffectBlurLevel"]; });
  126966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffect"]; });
  126967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcessOptions"]; });
  126968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcess"]; });
  126969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DisplayPassPostProcess"]; });
  126970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ExtractHighlightsPostProcess"]; });
  126971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FilterPostProcess"]; });
  126972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FxaaPostProcess"]; });
  126973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["GrainPostProcess"]; });
  126974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["HighlightsPostProcess"]; });
  126975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ImageProcessingPostProcess"]; });
  126976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["MotionBlurPostProcess"]; });
  126977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassPostProcess"]; });
  126978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassCubePostProcess"]; });
  126979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcess"]; });
  126980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessManager"]; });
  126981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["RefractionPostProcess"]; });
  126982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SharpenPostProcess"]; });
  126983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StereoscopicInterlacePostProcess"]; });
  126984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemappingOperator"]; });
  126985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemapPostProcess"]; });
  126986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VolumetricLightScatteringPostProcess"]; });
  126987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  126988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderEffect"]; });
  126989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipeline"]; });
  126990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManager"]; });
  126991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManagerSceneComponent"]; });
  126992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DefaultRenderingPipeline"]; });
  126993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["LensRenderingPipeline"]; });
  126994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAO2RenderingPipeline"]; });
  126995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAORenderingPipeline"]; });
  126996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StandardRenderingPipeline"]; });
  126997. /* harmony import */ var _Probes_index__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Probes/index */ "./Probes/index.ts");
  126998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _Probes_index__WEBPACK_IMPORTED_MODULE_30__["ReflectionProbe"]; });
  126999. /* harmony import */ var _Rendering_index__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Rendering/index */ "./Rendering/index.ts");
  127000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["BoundingBoxRenderer"]; });
  127001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRenderer"]; });
  127002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRendererSceneComponent"]; });
  127003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["EdgesRenderer"]; });
  127004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["LineEdgesRenderer"]; });
  127005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRenderer"]; });
  127006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRendererSceneComponent"]; });
  127007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["OutlineRenderer"]; });
  127008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroup"]; });
  127009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroupInfo"]; });
  127010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingManager"]; });
  127011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["UtilityLayerRenderer"]; });
  127012. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./scene */ "./scene.ts");
  127013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _scene__WEBPACK_IMPORTED_MODULE_32__["Scene"]; });
  127014. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  127015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["SceneComponentConstants"]; });
  127016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["Stage"]; });
  127017. /* harmony import */ var _Sprites_index__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./Sprites/index */ "./Sprites/index.ts");
  127018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["Sprite"]; });
  127019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteManager"]; });
  127020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteSceneComponent"]; });
  127021. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./States/index */ "./States/index.ts");
  127022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_AlphaState"]; });
  127023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_DepthCullingState"]; });
  127024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_StencilState"]; });
  127025. /* harmony import */ var _Misc_index__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Misc/index */ "./Misc/index.ts");
  127026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AndOrNotEvaluator"]; });
  127027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetTaskState"]; });
  127028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AbstractAssetTask"]; });
  127029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsProgressEvent"]; });
  127030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshAssetTask"]; });
  127031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextFileAssetTask"]; });
  127032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["BinaryFileAssetTask"]; });
  127033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ImageAssetTask"]; });
  127034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureAssetTask"]; });
  127035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeTextureAssetTask"]; });
  127036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRCubeTextureAssetTask"]; });
  127037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsManager"]; });
  127038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DDSTools"]; });
  127039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["expandToProperty"]; });
  127040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serialize"]; });
  127041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsTexture"]; });
  127042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor3"]; });
  127043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsFresnelParameters"]; });
  127044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector2"]; });
  127045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector3"]; });
  127046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMeshReference"]; });
  127047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColorCurves"]; });
  127048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor4"]; });
  127049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsImageProcessingConfiguration"]; });
  127050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsQuaternion"]; });
  127051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsCameraReference"]; });
  127052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SerializationHelper"]; });
  127053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Deferred"]; });
  127054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EnvironmentTextureTools"]; });
  127055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInput"]; });
  127056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["KhronosTextureContainer"]; });
  127057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EventState"]; });
  127058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observer"]; });
  127059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MultiObserver"]; });
  127060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observable"]; });
  127061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerformanceMonitor"]; });
  127062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RollingAverage"]; });
  127063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PromisePolyfill"]; });
  127064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimization"]; });
  127065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureOptimization"]; });
  127066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HardwareScalingOptimization"]; });
  127067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ShadowsOptimization"]; });
  127068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PostProcessesOptimization"]; });
  127069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LensFlaresOptimization"]; });
  127070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CustomOptimization"]; });
  127071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ParticlesOptimization"]; });
  127072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RenderTargetsOptimization"]; });
  127073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MergeMeshesOptimization"]; });
  127074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizerOptions"]; });
  127075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizer"]; });
  127076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneSerializer"]; });
  127077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArray"]; });
  127078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArrayNoDuplicate"]; });
  127079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["StringDictionary"]; });
  127080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tags"]; });
  127081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureTools"]; });
  127082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TGATools"]; });
  127083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ColorGradient"]; });
  127084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Color3Gradient"]; });
  127085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FactorGradient"]; });
  127086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LoadFileError"]; });
  127087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RetryStrategy"]; });
  127088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tools"]; });
  127089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerfCounter"]; });
  127090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["className"]; });
  127091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AsyncLoop"]; });
  127092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VideoRecorder"]; });
  127093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["JoystickAxis"]; });
  127094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VirtualJoystick"]; });
  127095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WorkerPool"]; });
  127096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Logger"]; });
  127097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["_TypeStore"]; });
  127098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInputStore"]; });
  127099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DeepCopier"]; });
  127100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PivotTools"]; });
  127101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PrecisionDate"]; });
  127102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ScreenshotTools"]; });
  127103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeMapToSphericalPolynomialTools"]; });
  127104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRTools"]; });
  127105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PanoramaToCubeMapTools"]; });
  127106. /***/ }),
  127107. /***/ "./node.ts":
  127108. /*!*****************!*\
  127109. !*** ./node.ts ***!
  127110. \*****************/
  127111. /*! exports provided: Node */
  127112. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127113. "use strict";
  127114. __webpack_require__.r(__webpack_exports__);
  127115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return Node; });
  127116. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  127117. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  127118. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/decorators */ "./Misc/decorators.ts");
  127119. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  127120. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  127121. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  127122. /**
  127123. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  127124. */
  127125. var Node = /** @class */ (function () {
  127126. /**
  127127. * Creates a new Node
  127128. * @param name the name and id to be given to this node
  127129. * @param scene the scene this node will be added to
  127130. * @param addToRootNodes the node will be added to scene.rootNodes
  127131. */
  127132. function Node(name, scene, addToRootNodes) {
  127133. if (scene === void 0) { scene = null; }
  127134. if (addToRootNodes === void 0) { addToRootNodes = true; }
  127135. /**
  127136. * Gets or sets a string used to store user defined state for the node
  127137. */
  127138. this.state = "";
  127139. /**
  127140. * Gets or sets an object used to store user defined information for the node
  127141. */
  127142. this.metadata = null;
  127143. /**
  127144. * For internal use only. Please do not use.
  127145. */
  127146. this.reservedDataStore = null;
  127147. /**
  127148. * Gets or sets a boolean used to define if the node must be serialized
  127149. */
  127150. this.doNotSerialize = false;
  127151. /** @hidden */
  127152. this._isDisposed = false;
  127153. /**
  127154. * Gets a list of Animations associated with the node
  127155. */
  127156. this.animations = new Array();
  127157. this._ranges = {};
  127158. this._isEnabled = true;
  127159. this._isParentEnabled = true;
  127160. this._isReady = true;
  127161. /** @hidden */
  127162. this._currentRenderId = -1;
  127163. this._parentRenderId = -1;
  127164. this._childRenderId = -1;
  127165. /** @hidden */
  127166. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  127167. /** @hidden */
  127168. this._worldMatrixDeterminant = 0;
  127169. /** @hidden */
  127170. this._sceneRootNodesIndex = -1;
  127171. this._animationPropertiesOverride = null;
  127172. /** @hidden */
  127173. this._isNode = true;
  127174. /**
  127175. * An event triggered when the mesh is disposed
  127176. */
  127177. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127178. // Behaviors
  127179. this._behaviors = new Array();
  127180. this.name = name;
  127181. this.id = name;
  127182. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene);
  127183. this.uniqueId = this._scene.getUniqueId();
  127184. this._initCache();
  127185. if (addToRootNodes) {
  127186. this.addToSceneRootNodes();
  127187. }
  127188. }
  127189. /**
  127190. * Add a new node constructor
  127191. * @param type defines the type name of the node to construct
  127192. * @param constructorFunc defines the constructor function
  127193. */
  127194. Node.AddNodeConstructor = function (type, constructorFunc) {
  127195. this._NodeConstructors[type] = constructorFunc;
  127196. };
  127197. /**
  127198. * Returns a node constructor based on type name
  127199. * @param type defines the type name
  127200. * @param name defines the new node name
  127201. * @param scene defines the hosting scene
  127202. * @param options defines optional options to transmit to constructors
  127203. * @returns the new constructor or null
  127204. */
  127205. Node.Construct = function (type, name, scene, options) {
  127206. var constructorFunc = this._NodeConstructors[type];
  127207. if (!constructorFunc) {
  127208. return null;
  127209. }
  127210. return constructorFunc(name, scene, options);
  127211. };
  127212. /**
  127213. * Gets a boolean indicating if the node has been disposed
  127214. * @returns true if the node was disposed
  127215. */
  127216. Node.prototype.isDisposed = function () {
  127217. return this._isDisposed;
  127218. };
  127219. Object.defineProperty(Node.prototype, "parent", {
  127220. get: function () {
  127221. return this._parentNode;
  127222. },
  127223. /**
  127224. * Gets or sets the parent of the node
  127225. */
  127226. set: function (parent) {
  127227. if (this._parentNode === parent) {
  127228. return;
  127229. }
  127230. var previousParentNode = this._parentNode;
  127231. // Remove self from list of children of parent
  127232. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  127233. var index = this._parentNode._children.indexOf(this);
  127234. if (index !== -1) {
  127235. this._parentNode._children.splice(index, 1);
  127236. }
  127237. if (!parent && !this._isDisposed) {
  127238. this.addToSceneRootNodes();
  127239. }
  127240. }
  127241. // Store new parent
  127242. this._parentNode = parent;
  127243. // Add as child to new parent
  127244. if (this._parentNode) {
  127245. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  127246. this._parentNode._children = new Array();
  127247. }
  127248. this._parentNode._children.push(this);
  127249. if (!previousParentNode) {
  127250. this.removeFromSceneRootNodes();
  127251. }
  127252. }
  127253. // Enabled state
  127254. this._syncParentEnabledState();
  127255. },
  127256. enumerable: true,
  127257. configurable: true
  127258. });
  127259. Node.prototype.addToSceneRootNodes = function () {
  127260. if (this._sceneRootNodesIndex === -1) {
  127261. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  127262. this._scene.rootNodes.push(this);
  127263. }
  127264. };
  127265. Node.prototype.removeFromSceneRootNodes = function () {
  127266. if (this._sceneRootNodesIndex !== -1) {
  127267. var rootNodes = this._scene.rootNodes;
  127268. var lastIdx = rootNodes.length - 1;
  127269. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  127270. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  127271. this._scene.rootNodes.pop();
  127272. this._sceneRootNodesIndex = -1;
  127273. }
  127274. };
  127275. Object.defineProperty(Node.prototype, "animationPropertiesOverride", {
  127276. /**
  127277. * Gets or sets the animation properties override
  127278. */
  127279. get: function () {
  127280. if (!this._animationPropertiesOverride) {
  127281. return this._scene.animationPropertiesOverride;
  127282. }
  127283. return this._animationPropertiesOverride;
  127284. },
  127285. set: function (value) {
  127286. this._animationPropertiesOverride = value;
  127287. },
  127288. enumerable: true,
  127289. configurable: true
  127290. });
  127291. /**
  127292. * Gets a string idenfifying the name of the class
  127293. * @returns "Node" string
  127294. */
  127295. Node.prototype.getClassName = function () {
  127296. return "Node";
  127297. };
  127298. Object.defineProperty(Node.prototype, "onDispose", {
  127299. /**
  127300. * Sets a callback that will be raised when the node will be disposed
  127301. */
  127302. set: function (callback) {
  127303. if (this._onDisposeObserver) {
  127304. this.onDisposeObservable.remove(this._onDisposeObserver);
  127305. }
  127306. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  127307. },
  127308. enumerable: true,
  127309. configurable: true
  127310. });
  127311. /**
  127312. * Gets the scene of the node
  127313. * @returns a scene
  127314. */
  127315. Node.prototype.getScene = function () {
  127316. return this._scene;
  127317. };
  127318. /**
  127319. * Gets the engine of the node
  127320. * @returns a Engine
  127321. */
  127322. Node.prototype.getEngine = function () {
  127323. return this._scene.getEngine();
  127324. };
  127325. /**
  127326. * Attach a behavior to the node
  127327. * @see http://doc.babylonjs.com/features/behaviour
  127328. * @param behavior defines the behavior to attach
  127329. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  127330. * @returns the current Node
  127331. */
  127332. Node.prototype.addBehavior = function (behavior, attachImmediately) {
  127333. var _this = this;
  127334. if (attachImmediately === void 0) { attachImmediately = false; }
  127335. var index = this._behaviors.indexOf(behavior);
  127336. if (index !== -1) {
  127337. return this;
  127338. }
  127339. behavior.init();
  127340. if (this._scene.isLoading && !attachImmediately) {
  127341. // We defer the attach when the scene will be loaded
  127342. this._scene.onDataLoadedObservable.addOnce(function () {
  127343. behavior.attach(_this);
  127344. });
  127345. }
  127346. else {
  127347. behavior.attach(this);
  127348. }
  127349. this._behaviors.push(behavior);
  127350. return this;
  127351. };
  127352. /**
  127353. * Remove an attached behavior
  127354. * @see http://doc.babylonjs.com/features/behaviour
  127355. * @param behavior defines the behavior to attach
  127356. * @returns the current Node
  127357. */
  127358. Node.prototype.removeBehavior = function (behavior) {
  127359. var index = this._behaviors.indexOf(behavior);
  127360. if (index === -1) {
  127361. return this;
  127362. }
  127363. this._behaviors[index].detach();
  127364. this._behaviors.splice(index, 1);
  127365. return this;
  127366. };
  127367. Object.defineProperty(Node.prototype, "behaviors", {
  127368. /**
  127369. * Gets the list of attached behaviors
  127370. * @see http://doc.babylonjs.com/features/behaviour
  127371. */
  127372. get: function () {
  127373. return this._behaviors;
  127374. },
  127375. enumerable: true,
  127376. configurable: true
  127377. });
  127378. /**
  127379. * Gets an attached behavior by name
  127380. * @param name defines the name of the behavior to look for
  127381. * @see http://doc.babylonjs.com/features/behaviour
  127382. * @returns null if behavior was not found else the requested behavior
  127383. */
  127384. Node.prototype.getBehaviorByName = function (name) {
  127385. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  127386. var behavior = _a[_i];
  127387. if (behavior.name === name) {
  127388. return behavior;
  127389. }
  127390. }
  127391. return null;
  127392. };
  127393. /**
  127394. * Returns the latest update of the World matrix
  127395. * @returns a Matrix
  127396. */
  127397. Node.prototype.getWorldMatrix = function () {
  127398. if (this._currentRenderId !== this._scene.getRenderId()) {
  127399. this.computeWorldMatrix();
  127400. }
  127401. return this._worldMatrix;
  127402. };
  127403. /** @hidden */
  127404. Node.prototype._getWorldMatrixDeterminant = function () {
  127405. return this._worldMatrixDeterminant;
  127406. };
  127407. Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
  127408. /**
  127409. * Returns directly the latest state of the mesh World matrix.
  127410. * A Matrix is returned.
  127411. */
  127412. get: function () {
  127413. return this._worldMatrix;
  127414. },
  127415. enumerable: true,
  127416. configurable: true
  127417. });
  127418. // override it in derived class if you add new variables to the cache
  127419. // and call the parent class method
  127420. /** @hidden */
  127421. Node.prototype._initCache = function () {
  127422. this._cache = {};
  127423. this._cache.parent = undefined;
  127424. };
  127425. /** @hidden */
  127426. Node.prototype.updateCache = function (force) {
  127427. if (!force && this.isSynchronized()) {
  127428. return;
  127429. }
  127430. this._cache.parent = this.parent;
  127431. this._updateCache();
  127432. };
  127433. // override it in derived class if you add new variables to the cache
  127434. // and call the parent class method if !ignoreParentClass
  127435. /** @hidden */
  127436. Node.prototype._updateCache = function (ignoreParentClass) {
  127437. };
  127438. // override it in derived class if you add new variables to the cache
  127439. /** @hidden */
  127440. Node.prototype._isSynchronized = function () {
  127441. return true;
  127442. };
  127443. /** @hidden */
  127444. Node.prototype._markSyncedWithParent = function () {
  127445. if (this._parentNode) {
  127446. this._parentRenderId = this._parentNode._childRenderId;
  127447. }
  127448. };
  127449. /** @hidden */
  127450. Node.prototype.isSynchronizedWithParent = function () {
  127451. if (!this._parentNode) {
  127452. return true;
  127453. }
  127454. if (this._parentRenderId !== this._parentNode._childRenderId) {
  127455. return false;
  127456. }
  127457. return this._parentNode.isSynchronized();
  127458. };
  127459. /** @hidden */
  127460. Node.prototype.isSynchronized = function () {
  127461. if (this._cache.parent != this._parentNode) {
  127462. this._cache.parent = this._parentNode;
  127463. return false;
  127464. }
  127465. if (this._parentNode && !this.isSynchronizedWithParent()) {
  127466. return false;
  127467. }
  127468. return this._isSynchronized();
  127469. };
  127470. /**
  127471. * Is this node ready to be used/rendered
  127472. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  127473. * @return true if the node is ready
  127474. */
  127475. Node.prototype.isReady = function (completeCheck) {
  127476. if (completeCheck === void 0) { completeCheck = false; }
  127477. return this._isReady;
  127478. };
  127479. /**
  127480. * Is this node enabled?
  127481. * 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
  127482. * @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
  127483. * @return whether this node (and its parent) is enabled
  127484. */
  127485. Node.prototype.isEnabled = function (checkAncestors) {
  127486. if (checkAncestors === void 0) { checkAncestors = true; }
  127487. if (checkAncestors === false) {
  127488. return this._isEnabled;
  127489. }
  127490. if (!this._isEnabled) {
  127491. return false;
  127492. }
  127493. return this._isParentEnabled;
  127494. };
  127495. /** @hidden */
  127496. Node.prototype._syncParentEnabledState = function () {
  127497. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  127498. if (this._children) {
  127499. this._children.forEach(function (c) {
  127500. c._syncParentEnabledState(); // Force children to update accordingly
  127501. });
  127502. }
  127503. };
  127504. /**
  127505. * Set the enabled state of this node
  127506. * @param value defines the new enabled state
  127507. */
  127508. Node.prototype.setEnabled = function (value) {
  127509. this._isEnabled = value;
  127510. this._syncParentEnabledState();
  127511. };
  127512. /**
  127513. * Is this node a descendant of the given node?
  127514. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  127515. * @param ancestor defines the parent node to inspect
  127516. * @returns a boolean indicating if this node is a descendant of the given node
  127517. */
  127518. Node.prototype.isDescendantOf = function (ancestor) {
  127519. if (this.parent) {
  127520. if (this.parent === ancestor) {
  127521. return true;
  127522. }
  127523. return this.parent.isDescendantOf(ancestor);
  127524. }
  127525. return false;
  127526. };
  127527. /** @hidden */
  127528. Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  127529. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  127530. if (!this._children) {
  127531. return;
  127532. }
  127533. for (var index = 0; index < this._children.length; index++) {
  127534. var item = this._children[index];
  127535. if (!predicate || predicate(item)) {
  127536. results.push(item);
  127537. }
  127538. if (!directDescendantsOnly) {
  127539. item._getDescendants(results, false, predicate);
  127540. }
  127541. }
  127542. };
  127543. /**
  127544. * Will return all nodes that have this node as ascendant
  127545. * @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
  127546. * @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
  127547. * @return all children nodes of all types
  127548. */
  127549. Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  127550. var results = new Array();
  127551. this._getDescendants(results, directDescendantsOnly, predicate);
  127552. return results;
  127553. };
  127554. /**
  127555. * Get all child-meshes of this node
  127556. * @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)
  127557. * @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
  127558. * @returns an array of AbstractMesh
  127559. */
  127560. Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
  127561. var results = [];
  127562. this._getDescendants(results, directDescendantsOnly, function (node) {
  127563. return ((!predicate || predicate(node)) && (node.cullingStrategy !== undefined));
  127564. });
  127565. return results;
  127566. };
  127567. /**
  127568. * Get all direct children of this node
  127569. * @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
  127570. * @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)
  127571. * @returns an array of Node
  127572. */
  127573. Node.prototype.getChildren = function (predicate, directDescendantsOnly) {
  127574. if (directDescendantsOnly === void 0) { directDescendantsOnly = true; }
  127575. return this.getDescendants(directDescendantsOnly, predicate);
  127576. };
  127577. /** @hidden */
  127578. Node.prototype._setReady = function (state) {
  127579. if (state === this._isReady) {
  127580. return;
  127581. }
  127582. if (!state) {
  127583. this._isReady = false;
  127584. return;
  127585. }
  127586. if (this.onReady) {
  127587. this.onReady(this);
  127588. }
  127589. this._isReady = true;
  127590. };
  127591. /**
  127592. * Get an animation by name
  127593. * @param name defines the name of the animation to look for
  127594. * @returns null if not found else the requested animation
  127595. */
  127596. Node.prototype.getAnimationByName = function (name) {
  127597. for (var i = 0; i < this.animations.length; i++) {
  127598. var animation = this.animations[i];
  127599. if (animation.name === name) {
  127600. return animation;
  127601. }
  127602. }
  127603. return null;
  127604. };
  127605. /**
  127606. * Creates an animation range for this node
  127607. * @param name defines the name of the range
  127608. * @param from defines the starting key
  127609. * @param to defines the end key
  127610. */
  127611. Node.prototype.createAnimationRange = function (name, from, to) {
  127612. // check name not already in use
  127613. if (!this._ranges[name]) {
  127614. this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
  127615. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  127616. if (this.animations[i]) {
  127617. this.animations[i].createRange(name, from, to);
  127618. }
  127619. }
  127620. }
  127621. };
  127622. /**
  127623. * Delete a specific animation range
  127624. * @param name defines the name of the range to delete
  127625. * @param deleteFrames defines if animation frames from the range must be deleted as well
  127626. */
  127627. Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
  127628. if (deleteFrames === void 0) { deleteFrames = true; }
  127629. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  127630. if (this.animations[i]) {
  127631. this.animations[i].deleteRange(name, deleteFrames);
  127632. }
  127633. }
  127634. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  127635. };
  127636. /**
  127637. * Get an animation range by name
  127638. * @param name defines the name of the animation range to look for
  127639. * @returns null if not found else the requested animation range
  127640. */
  127641. Node.prototype.getAnimationRange = function (name) {
  127642. return this._ranges[name];
  127643. };
  127644. /**
  127645. * Will start the animation sequence
  127646. * @param name defines the range frames for animation sequence
  127647. * @param loop defines if the animation should loop (false by default)
  127648. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  127649. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  127650. * @returns the object created for this animation. If range does not exist, it will return null
  127651. */
  127652. Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  127653. var range = this.getAnimationRange(name);
  127654. if (!range) {
  127655. return null;
  127656. }
  127657. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  127658. };
  127659. /**
  127660. * Serialize animation ranges into a JSON compatible object
  127661. * @returns serialization object
  127662. */
  127663. Node.prototype.serializeAnimationRanges = function () {
  127664. var serializationRanges = [];
  127665. for (var name in this._ranges) {
  127666. var localRange = this._ranges[name];
  127667. if (!localRange) {
  127668. continue;
  127669. }
  127670. var range = {};
  127671. range.name = name;
  127672. range.from = localRange.from;
  127673. range.to = localRange.to;
  127674. serializationRanges.push(range);
  127675. }
  127676. return serializationRanges;
  127677. };
  127678. /**
  127679. * Computes the world matrix of the node
  127680. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  127681. * @returns the world matrix
  127682. */
  127683. Node.prototype.computeWorldMatrix = function (force) {
  127684. if (!this._worldMatrix) {
  127685. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  127686. }
  127687. return this._worldMatrix;
  127688. };
  127689. /**
  127690. * Releases resources associated with this node.
  127691. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  127692. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  127693. */
  127694. Node.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  127695. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  127696. this._isDisposed = true;
  127697. if (!doNotRecurse) {
  127698. var nodes = this.getDescendants(true);
  127699. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  127700. var node = nodes_1[_i];
  127701. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  127702. }
  127703. }
  127704. if (!this.parent) {
  127705. this.removeFromSceneRootNodes();
  127706. }
  127707. else {
  127708. this.parent = null;
  127709. }
  127710. // Callback
  127711. this.onDisposeObservable.notifyObservers(this);
  127712. this.onDisposeObservable.clear();
  127713. // Behaviors
  127714. for (var _a = 0, _b = this._behaviors; _a < _b.length; _a++) {
  127715. var behavior = _b[_a];
  127716. behavior.detach();
  127717. }
  127718. this._behaviors = [];
  127719. };
  127720. /**
  127721. * Parse animation range data from a serialization object and store them into a given node
  127722. * @param node defines where to store the animation ranges
  127723. * @param parsedNode defines the serialization object to read data from
  127724. * @param scene defines the hosting scene
  127725. */
  127726. Node.ParseAnimationRanges = function (node, parsedNode, scene) {
  127727. if (parsedNode.ranges) {
  127728. for (var index = 0; index < parsedNode.ranges.length; index++) {
  127729. var data = parsedNode.ranges[index];
  127730. node.createAnimationRange(data.name, data.from, data.to);
  127731. }
  127732. }
  127733. };
  127734. /** @hidden */
  127735. Node._AnimationRangeFactory = function (name, from, to) {
  127736. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AnimationRange");
  127737. };
  127738. Node._NodeConstructors = {};
  127739. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127740. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127741. ], Node.prototype, "name", void 0);
  127742. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127743. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127744. ], Node.prototype, "id", void 0);
  127745. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127746. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127747. ], Node.prototype, "uniqueId", void 0);
  127748. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127749. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127750. ], Node.prototype, "state", void 0);
  127751. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  127752. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  127753. ], Node.prototype, "metadata", void 0);
  127754. return Node;
  127755. }());
  127756. /***/ }),
  127757. /***/ "./scene.ts":
  127758. /*!******************!*\
  127759. !*** ./scene.ts ***!
  127760. \******************/
  127761. /*! exports provided: Scene */
  127762. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127763. "use strict";
  127764. __webpack_require__.r(__webpack_exports__);
  127765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return Scene; });
  127766. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  127767. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  127768. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/precisionDate */ "./Misc/precisionDate.ts");
  127769. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  127770. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Misc/smartArray */ "./Misc/smartArray.ts");
  127771. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  127772. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tags */ "./Misc/tags.ts");
  127773. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  127774. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  127775. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Cameras/camera */ "./Cameras/camera.ts");
  127776. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  127777. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  127778. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  127779. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Lights/light */ "./Lights/light.ts");
  127780. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  127781. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Events/pointerEvents */ "./Events/pointerEvents.ts");
  127782. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  127783. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Actions/actionEvent */ "./Actions/actionEvent.ts");
  127784. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  127785. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  127786. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  127787. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Engines/constants */ "./Engines/constants.ts");
  127788. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Misc/domManagement */ "./Misc/domManagement.ts");
  127789. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Misc/logger */ "./Misc/logger.ts");
  127790. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  127791. /* harmony import */ var _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Actions/abstractActionManager */ "./Actions/abstractActionManager.ts");
  127792. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  127793. /** @hidden */
  127794. var ClickInfo = /** @class */ (function () {
  127795. function ClickInfo() {
  127796. this._singleClick = false;
  127797. this._doubleClick = false;
  127798. this._hasSwiped = false;
  127799. this._ignore = false;
  127800. }
  127801. Object.defineProperty(ClickInfo.prototype, "singleClick", {
  127802. get: function () {
  127803. return this._singleClick;
  127804. },
  127805. set: function (b) {
  127806. this._singleClick = b;
  127807. },
  127808. enumerable: true,
  127809. configurable: true
  127810. });
  127811. Object.defineProperty(ClickInfo.prototype, "doubleClick", {
  127812. get: function () {
  127813. return this._doubleClick;
  127814. },
  127815. set: function (b) {
  127816. this._doubleClick = b;
  127817. },
  127818. enumerable: true,
  127819. configurable: true
  127820. });
  127821. Object.defineProperty(ClickInfo.prototype, "hasSwiped", {
  127822. get: function () {
  127823. return this._hasSwiped;
  127824. },
  127825. set: function (b) {
  127826. this._hasSwiped = b;
  127827. },
  127828. enumerable: true,
  127829. configurable: true
  127830. });
  127831. Object.defineProperty(ClickInfo.prototype, "ignore", {
  127832. get: function () {
  127833. return this._ignore;
  127834. },
  127835. set: function (b) {
  127836. this._ignore = b;
  127837. },
  127838. enumerable: true,
  127839. configurable: true
  127840. });
  127841. return ClickInfo;
  127842. }());
  127843. /**
  127844. * Represents a scene to be rendered by the engine.
  127845. * @see http://doc.babylonjs.com/features/scene
  127846. */
  127847. var Scene = /** @class */ (function (_super) {
  127848. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Scene, _super);
  127849. /**
  127850. * Creates a new Scene
  127851. * @param engine defines the engine to use to render this scene
  127852. * @param options defines the scene options
  127853. */
  127854. function Scene(engine, options) {
  127855. var _this = _super.call(this) || this;
  127856. // Members
  127857. /** @hidden */
  127858. _this._isScene = true;
  127859. /**
  127860. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  127861. */
  127862. _this.autoClear = true;
  127863. /**
  127864. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  127865. */
  127866. _this.autoClearDepthAndStencil = true;
  127867. /**
  127868. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  127869. */
  127870. _this.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color4"](0.2, 0.2, 0.3, 1.0);
  127871. /**
  127872. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  127873. */
  127874. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0, 0, 0);
  127875. _this._forceWireframe = false;
  127876. _this._forcePointsCloud = false;
  127877. /**
  127878. * Gets or sets a boolean indicating if animations are enabled
  127879. */
  127880. _this.animationsEnabled = true;
  127881. _this._animationPropertiesOverride = null;
  127882. /**
  127883. * Gets or sets a boolean indicating if a constant deltatime has to be used
  127884. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  127885. */
  127886. _this.useConstantAnimationDeltaTime = false;
  127887. /**
  127888. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  127889. * Please note that it requires to run a ray cast through the scene on every frame
  127890. */
  127891. _this.constantlyUpdateMeshUnderPointer = false;
  127892. /**
  127893. * Defines the HTML cursor to use when hovering over interactive elements
  127894. */
  127895. _this.hoverCursor = "pointer";
  127896. /**
  127897. * Defines the HTML default cursor to use (empty by default)
  127898. */
  127899. _this.defaultCursor = "";
  127900. /**
  127901. * This is used to call preventDefault() on pointer down
  127902. * in order to block unwanted artifacts like system double clicks
  127903. */
  127904. _this.preventDefaultOnPointerDown = true;
  127905. /**
  127906. * This is used to call preventDefault() on pointer up
  127907. * in order to block unwanted artifacts like system double clicks
  127908. */
  127909. _this.preventDefaultOnPointerUp = true;
  127910. // Metadata
  127911. /**
  127912. * Gets or sets user defined metadata
  127913. */
  127914. _this.metadata = null;
  127915. /**
  127916. * For internal use only. Please do not use.
  127917. */
  127918. _this.reservedDataStore = null;
  127919. /**
  127920. * Use this array to add regular expressions used to disable offline support for specific urls
  127921. */
  127922. _this.disableOfflineSupportExceptionRules = new Array();
  127923. /**
  127924. * An event triggered when the scene is disposed.
  127925. */
  127926. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127927. _this._onDisposeObserver = null;
  127928. /**
  127929. * An event triggered before rendering the scene (right after animations and physics)
  127930. */
  127931. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127932. _this._onBeforeRenderObserver = null;
  127933. /**
  127934. * An event triggered after rendering the scene
  127935. */
  127936. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127937. _this._onAfterRenderObserver = null;
  127938. /**
  127939. * An event triggered before animating the scene
  127940. */
  127941. _this.onBeforeAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127942. /**
  127943. * An event triggered after animations processing
  127944. */
  127945. _this.onAfterAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127946. /**
  127947. * An event triggered before draw calls are ready to be sent
  127948. */
  127949. _this.onBeforeDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127950. /**
  127951. * An event triggered after draw calls have been sent
  127952. */
  127953. _this.onAfterDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127954. /**
  127955. * An event triggered when the scene is ready
  127956. */
  127957. _this.onReadyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127958. /**
  127959. * An event triggered before rendering a camera
  127960. */
  127961. _this.onBeforeCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127962. _this._onBeforeCameraRenderObserver = null;
  127963. /**
  127964. * An event triggered after rendering a camera
  127965. */
  127966. _this.onAfterCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127967. _this._onAfterCameraRenderObserver = null;
  127968. /**
  127969. * An event triggered when active meshes evaluation is about to start
  127970. */
  127971. _this.onBeforeActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127972. /**
  127973. * An event triggered when active meshes evaluation is done
  127974. */
  127975. _this.onAfterActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127976. /**
  127977. * An event triggered when particles rendering is about to start
  127978. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  127979. */
  127980. _this.onBeforeParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127981. /**
  127982. * An event triggered when particles rendering is done
  127983. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  127984. */
  127985. _this.onAfterParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127986. /**
  127987. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  127988. */
  127989. _this.onDataLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127990. /**
  127991. * An event triggered when a camera is created
  127992. */
  127993. _this.onNewCameraAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127994. /**
  127995. * An event triggered when a camera is removed
  127996. */
  127997. _this.onCameraRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127998. /**
  127999. * An event triggered when a light is created
  128000. */
  128001. _this.onNewLightAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128002. /**
  128003. * An event triggered when a light is removed
  128004. */
  128005. _this.onLightRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128006. /**
  128007. * An event triggered when a geometry is created
  128008. */
  128009. _this.onNewGeometryAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128010. /**
  128011. * An event triggered when a geometry is removed
  128012. */
  128013. _this.onGeometryRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128014. /**
  128015. * An event triggered when a transform node is created
  128016. */
  128017. _this.onNewTransformNodeAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128018. /**
  128019. * An event triggered when a transform node is removed
  128020. */
  128021. _this.onTransformNodeRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128022. /**
  128023. * An event triggered when a mesh is created
  128024. */
  128025. _this.onNewMeshAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128026. /**
  128027. * An event triggered when a mesh is removed
  128028. */
  128029. _this.onMeshRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128030. /**
  128031. * An event triggered when a material is created
  128032. */
  128033. _this.onNewMaterialAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128034. /**
  128035. * An event triggered when a material is removed
  128036. */
  128037. _this.onMaterialRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128038. /**
  128039. * An event triggered when a texture is created
  128040. */
  128041. _this.onNewTextureAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128042. /**
  128043. * An event triggered when a texture is removed
  128044. */
  128045. _this.onTextureRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128046. /**
  128047. * An event triggered when render targets are about to be rendered
  128048. * Can happen multiple times per frame.
  128049. */
  128050. _this.onBeforeRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128051. /**
  128052. * An event triggered when render targets were rendered.
  128053. * Can happen multiple times per frame.
  128054. */
  128055. _this.onAfterRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128056. /**
  128057. * An event triggered before calculating deterministic simulation step
  128058. */
  128059. _this.onBeforeStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128060. /**
  128061. * An event triggered after calculating deterministic simulation step
  128062. */
  128063. _this.onAfterStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128064. /**
  128065. * An event triggered when the activeCamera property is updated
  128066. */
  128067. _this.onActiveCameraChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128068. /**
  128069. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  128070. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  128071. * 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)
  128072. */
  128073. _this.onBeforeRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128074. /**
  128075. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  128076. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  128077. * 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)
  128078. */
  128079. _this.onAfterRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128080. /**
  128081. * This Observable will when a mesh has been imported into the scene.
  128082. */
  128083. _this.onMeshImportedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128084. // Animations
  128085. /** @hidden */
  128086. _this._registeredForLateAnimationBindings = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  128087. /**
  128088. * 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).
  128089. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  128090. */
  128091. _this.onPrePointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128092. /**
  128093. * Observable event triggered each time an input event is received from the rendering canvas
  128094. */
  128095. _this.onPointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128096. _this._meshPickProceed = false;
  128097. _this._currentPickResult = null;
  128098. _this._previousPickResult = null;
  128099. _this._totalPointersPressed = 0;
  128100. _this._doubleClickOccured = false;
  128101. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  128102. _this.cameraToUseForPointers = null;
  128103. _this._pointerX = 0;
  128104. _this._pointerY = 0;
  128105. _this._startingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  128106. _this._previousStartingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  128107. _this._startingPointerTime = 0;
  128108. _this._previousStartingPointerTime = 0;
  128109. _this._pointerCaptures = {};
  128110. // Deterministic lockstep
  128111. _this._timeAccumulator = 0;
  128112. _this._currentStepId = 0;
  128113. _this._currentInternalStep = 0;
  128114. // Keyboard
  128115. /**
  128116. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  128117. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  128118. */
  128119. _this.onPreKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128120. /**
  128121. * Observable event triggered each time an keyboard event is received from the hosting window
  128122. */
  128123. _this.onKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128124. // Coordinates system
  128125. _this._useRightHandedSystem = false;
  128126. // Fog
  128127. _this._fogEnabled = true;
  128128. _this._fogMode = Scene.FOGMODE_NONE;
  128129. /**
  128130. * Gets or sets the fog color to use
  128131. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128132. * (Default is Color3(0.2, 0.2, 0.3))
  128133. */
  128134. _this.fogColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0.2, 0.2, 0.3);
  128135. /**
  128136. * Gets or sets the fog density to use
  128137. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128138. * (Default is 0.1)
  128139. */
  128140. _this.fogDensity = 0.1;
  128141. /**
  128142. * Gets or sets the fog start distance to use
  128143. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128144. * (Default is 0)
  128145. */
  128146. _this.fogStart = 0;
  128147. /**
  128148. * Gets or sets the fog end distance to use
  128149. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128150. * (Default is 1000)
  128151. */
  128152. _this.fogEnd = 1000.0;
  128153. // Lights
  128154. _this._shadowsEnabled = true;
  128155. _this._lightsEnabled = true;
  128156. /** All of the active cameras added to this scene. */
  128157. _this.activeCameras = new Array();
  128158. // Textures
  128159. _this._texturesEnabled = true;
  128160. // Particles
  128161. /**
  128162. * Gets or sets a boolean indicating if particles are enabled on this scene
  128163. */
  128164. _this.particlesEnabled = true;
  128165. // Sprites
  128166. /**
  128167. * Gets or sets a boolean indicating if sprites are enabled on this scene
  128168. */
  128169. _this.spritesEnabled = true;
  128170. // Skeletons
  128171. _this._skeletonsEnabled = true;
  128172. // Lens flares
  128173. /**
  128174. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  128175. */
  128176. _this.lensFlaresEnabled = true;
  128177. // Collisions
  128178. /**
  128179. * Gets or sets a boolean indicating if collisions are enabled on this scene
  128180. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  128181. */
  128182. _this.collisionsEnabled = true;
  128183. /**
  128184. * Defines the gravity applied to this scene (used only for collisions)
  128185. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  128186. */
  128187. _this.gravity = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](0, -9.807, 0);
  128188. // Postprocesses
  128189. /**
  128190. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  128191. */
  128192. _this.postProcessesEnabled = true;
  128193. /**
  128194. * The list of postprocesses added to the scene
  128195. */
  128196. _this.postProcesses = new Array();
  128197. // Customs render targets
  128198. /**
  128199. * Gets or sets a boolean indicating if render targets are enabled on this scene
  128200. */
  128201. _this.renderTargetsEnabled = true;
  128202. /**
  128203. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  128204. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  128205. */
  128206. _this.dumpNextRenderTargets = false;
  128207. /**
  128208. * The list of user defined render targets added to the scene
  128209. */
  128210. _this.customRenderTargets = new Array();
  128211. /**
  128212. * Gets the list of meshes imported to the scene through SceneLoader
  128213. */
  128214. _this.importedMeshesFiles = new Array();
  128215. // Probes
  128216. /**
  128217. * Gets or sets a boolean indicating if probes are enabled on this scene
  128218. */
  128219. _this.probesEnabled = true;
  128220. _this._meshesForIntersections = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  128221. // Procedural textures
  128222. /**
  128223. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  128224. */
  128225. _this.proceduralTexturesEnabled = true;
  128226. // Performance counters
  128227. _this._totalVertices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  128228. /** @hidden */
  128229. _this._activeIndices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  128230. /** @hidden */
  128231. _this._activeParticles = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  128232. /** @hidden */
  128233. _this._activeBones = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  128234. /** @hidden */
  128235. _this._animationTime = 0;
  128236. /**
  128237. * Gets or sets a general scale for animation speed
  128238. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  128239. */
  128240. _this.animationTimeScale = 1;
  128241. _this._renderId = 0;
  128242. _this._frameId = 0;
  128243. _this._executeWhenReadyTimeoutId = -1;
  128244. _this._intermediateRendering = false;
  128245. _this._viewUpdateFlag = -1;
  128246. _this._projectionUpdateFlag = -1;
  128247. _this._alternateViewUpdateFlag = -1;
  128248. _this._alternateProjectionUpdateFlag = -1;
  128249. /** @hidden */
  128250. _this._toBeDisposed = new Array(256);
  128251. _this._activeRequests = new Array();
  128252. /** @hidden */
  128253. _this._pendingData = new Array();
  128254. _this._isDisposed = false;
  128255. /**
  128256. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  128257. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  128258. */
  128259. _this.dispatchAllSubMeshesOfActiveMeshes = false;
  128260. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  128261. _this._processedMaterials = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  128262. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  128263. /** @hidden */
  128264. _this._activeParticleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  128265. _this._activeSkeletons = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  128266. _this._softwareSkinnedMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  128267. /** @hidden */
  128268. _this._activeAnimatables = new Array();
  128269. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  128270. _this._useAlternateCameraConfiguration = false;
  128271. _this._alternateRendering = false;
  128272. _this._wheelEventName = "";
  128273. /**
  128274. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  128275. * This is useful if there are more lights that the maximum simulteanous authorized
  128276. */
  128277. _this.requireLightSorting = false;
  128278. /**
  128279. * @hidden
  128280. * Backing store of defined scene components.
  128281. */
  128282. _this._components = [];
  128283. /**
  128284. * @hidden
  128285. * Backing store of defined scene components.
  128286. */
  128287. _this._serializableComponents = [];
  128288. /**
  128289. * List of components to register on the next registration step.
  128290. */
  128291. _this._transientComponents = [];
  128292. /**
  128293. * @hidden
  128294. * Defines the actions happening before camera updates.
  128295. */
  128296. _this._beforeCameraUpdateStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128297. /**
  128298. * @hidden
  128299. * Defines the actions happening before clear the canvas.
  128300. */
  128301. _this._beforeClearStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128302. /**
  128303. * @hidden
  128304. * Defines the actions when collecting render targets for the frame.
  128305. */
  128306. _this._gatherRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128307. /**
  128308. * @hidden
  128309. * Defines the actions happening for one camera in the frame.
  128310. */
  128311. _this._gatherActiveCameraRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128312. /**
  128313. * @hidden
  128314. * Defines the actions happening during the per mesh ready checks.
  128315. */
  128316. _this._isReadyForMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128317. /**
  128318. * @hidden
  128319. * Defines the actions happening before evaluate active mesh checks.
  128320. */
  128321. _this._beforeEvaluateActiveMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128322. /**
  128323. * @hidden
  128324. * Defines the actions happening during the evaluate sub mesh checks.
  128325. */
  128326. _this._evaluateSubMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128327. /**
  128328. * @hidden
  128329. * Defines the actions happening during the active mesh stage.
  128330. */
  128331. _this._activeMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128332. /**
  128333. * @hidden
  128334. * Defines the actions happening during the per camera render target step.
  128335. */
  128336. _this._cameraDrawRenderTargetStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128337. /**
  128338. * @hidden
  128339. * Defines the actions happening just before the active camera is drawing.
  128340. */
  128341. _this._beforeCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128342. /**
  128343. * @hidden
  128344. * Defines the actions happening just before a render target is drawing.
  128345. */
  128346. _this._beforeRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128347. /**
  128348. * @hidden
  128349. * Defines the actions happening just before a rendering group is drawing.
  128350. */
  128351. _this._beforeRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128352. /**
  128353. * @hidden
  128354. * Defines the actions happening just before a mesh is drawing.
  128355. */
  128356. _this._beforeRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128357. /**
  128358. * @hidden
  128359. * Defines the actions happening just after a mesh has been drawn.
  128360. */
  128361. _this._afterRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128362. /**
  128363. * @hidden
  128364. * Defines the actions happening just after a rendering group has been drawn.
  128365. */
  128366. _this._afterRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128367. /**
  128368. * @hidden
  128369. * Defines the actions happening just after the active camera has been drawn.
  128370. */
  128371. _this._afterCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128372. /**
  128373. * @hidden
  128374. * Defines the actions happening just after a render target has been drawn.
  128375. */
  128376. _this._afterRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128377. /**
  128378. * @hidden
  128379. * Defines the actions happening just after rendering all cameras and computing intersections.
  128380. */
  128381. _this._afterRenderStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128382. /**
  128383. * @hidden
  128384. * Defines the actions happening when a pointer move event happens.
  128385. */
  128386. _this._pointerMoveStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128387. /**
  128388. * @hidden
  128389. * Defines the actions happening when a pointer down event happens.
  128390. */
  128391. _this._pointerDownStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128392. /**
  128393. * @hidden
  128394. * Defines the actions happening when a pointer up event happens.
  128395. */
  128396. _this._pointerUpStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128397. /**
  128398. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  128399. */
  128400. _this.geometriesByUniqueId = null;
  128401. _this._defaultMeshCandidates = {
  128402. data: [],
  128403. length: 0
  128404. };
  128405. _this._defaultSubMeshCandidates = {
  128406. data: [],
  128407. length: 0
  128408. };
  128409. _this._preventFreeActiveMeshesAndRenderingGroups = false;
  128410. _this._activeMeshesFrozen = false;
  128411. /** @hidden */
  128412. _this._allowPostProcessClearColor = true;
  128413. /**
  128414. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  128415. */
  128416. _this.getDeterministicFrameTime = function () {
  128417. return 1000.0 / 60.0; // frame time in ms
  128418. };
  128419. _this._blockMaterialDirtyMechanism = false;
  128420. _this._engine = engine || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__["EngineStore"].LastCreatedEngine;
  128421. _this._engine.scenes.push(_this);
  128422. _this._uid = null;
  128423. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__["RenderingManager"](_this);
  128424. if (_PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"]) {
  128425. _this.postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"](_this);
  128426. }
  128427. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__["DomManagement"].IsWindowObjectExist()) {
  128428. _this.attachControl();
  128429. }
  128430. // Uniform Buffer
  128431. _this._createUbo();
  128432. // Default Image processing definition
  128433. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]) {
  128434. _this._imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]();
  128435. }
  128436. _this.setDefaultCandidateProviders();
  128437. if (options && options.useGeometryUniqueIdsMap === true) {
  128438. _this.geometriesByUniqueId = {};
  128439. }
  128440. _this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
  128441. _this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;
  128442. _this._engine.onNewSceneAddedObservable.notifyObservers(_this);
  128443. return _this;
  128444. }
  128445. /**
  128446. * Factory used to create the default material.
  128447. * @param name The name of the material to create
  128448. * @param scene The scene to create the material for
  128449. * @returns The default material
  128450. */
  128451. Scene.DefaultMaterialFactory = function (scene) {
  128452. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("StandardMaterial");
  128453. };
  128454. /**
  128455. * Factory used to create the a collision coordinator.
  128456. * @returns The collision coordinator
  128457. */
  128458. Scene.CollisionCoordinatorFactory = function () {
  128459. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("DefaultCollisionCoordinator");
  128460. };
  128461. Object.defineProperty(Scene.prototype, "environmentTexture", {
  128462. /**
  128463. * Texture used in all pbr material as the reflection texture.
  128464. * As in the majority of the scene they are the same (exception for multi room and so on),
  128465. * this is easier to reference from here than from all the materials.
  128466. */
  128467. get: function () {
  128468. return this._environmentTexture;
  128469. },
  128470. /**
  128471. * Texture used in all pbr material as the reflection texture.
  128472. * As in the majority of the scene they are the same (exception for multi room and so on),
  128473. * this is easier to set here than in all the materials.
  128474. */
  128475. set: function (value) {
  128476. if (this._environmentTexture === value) {
  128477. return;
  128478. }
  128479. this._environmentTexture = value;
  128480. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  128481. },
  128482. enumerable: true,
  128483. configurable: true
  128484. });
  128485. Object.defineProperty(Scene.prototype, "imageProcessingConfiguration", {
  128486. /**
  128487. * Default image processing configuration used either in the rendering
  128488. * Forward main pass or through the imageProcessingPostProcess if present.
  128489. * As in the majority of the scene they are the same (exception for multi camera),
  128490. * this is easier to reference from here than from all the materials and post process.
  128491. *
  128492. * No setter as we it is a shared configuration, you can set the values instead.
  128493. */
  128494. get: function () {
  128495. return this._imageProcessingConfiguration;
  128496. },
  128497. enumerable: true,
  128498. configurable: true
  128499. });
  128500. Object.defineProperty(Scene.prototype, "forceWireframe", {
  128501. get: function () {
  128502. return this._forceWireframe;
  128503. },
  128504. /**
  128505. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  128506. */
  128507. set: function (value) {
  128508. if (this._forceWireframe === value) {
  128509. return;
  128510. }
  128511. this._forceWireframe = value;
  128512. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128513. },
  128514. enumerable: true,
  128515. configurable: true
  128516. });
  128517. Object.defineProperty(Scene.prototype, "forcePointsCloud", {
  128518. get: function () {
  128519. return this._forcePointsCloud;
  128520. },
  128521. /**
  128522. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  128523. */
  128524. set: function (value) {
  128525. if (this._forcePointsCloud === value) {
  128526. return;
  128527. }
  128528. this._forcePointsCloud = value;
  128529. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128530. },
  128531. enumerable: true,
  128532. configurable: true
  128533. });
  128534. Object.defineProperty(Scene.prototype, "animationPropertiesOverride", {
  128535. /**
  128536. * Gets or sets the animation properties override
  128537. */
  128538. get: function () {
  128539. return this._animationPropertiesOverride;
  128540. },
  128541. set: function (value) {
  128542. this._animationPropertiesOverride = value;
  128543. },
  128544. enumerable: true,
  128545. configurable: true
  128546. });
  128547. Object.defineProperty(Scene.prototype, "onDispose", {
  128548. /** Sets a function to be executed when this scene is disposed. */
  128549. set: function (callback) {
  128550. if (this._onDisposeObserver) {
  128551. this.onDisposeObservable.remove(this._onDisposeObserver);
  128552. }
  128553. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  128554. },
  128555. enumerable: true,
  128556. configurable: true
  128557. });
  128558. Object.defineProperty(Scene.prototype, "beforeRender", {
  128559. /** Sets a function to be executed before rendering this scene */
  128560. set: function (callback) {
  128561. if (this._onBeforeRenderObserver) {
  128562. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  128563. }
  128564. if (callback) {
  128565. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  128566. }
  128567. },
  128568. enumerable: true,
  128569. configurable: true
  128570. });
  128571. Object.defineProperty(Scene.prototype, "afterRender", {
  128572. /** Sets a function to be executed after rendering this scene */
  128573. set: function (callback) {
  128574. if (this._onAfterRenderObserver) {
  128575. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  128576. }
  128577. if (callback) {
  128578. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  128579. }
  128580. },
  128581. enumerable: true,
  128582. configurable: true
  128583. });
  128584. Object.defineProperty(Scene.prototype, "beforeCameraRender", {
  128585. /** Sets a function to be executed before rendering a camera*/
  128586. set: function (callback) {
  128587. if (this._onBeforeCameraRenderObserver) {
  128588. this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  128589. }
  128590. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(callback);
  128591. },
  128592. enumerable: true,
  128593. configurable: true
  128594. });
  128595. Object.defineProperty(Scene.prototype, "afterCameraRender", {
  128596. /** Sets a function to be executed after rendering a camera*/
  128597. set: function (callback) {
  128598. if (this._onAfterCameraRenderObserver) {
  128599. this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  128600. }
  128601. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(callback);
  128602. },
  128603. enumerable: true,
  128604. configurable: true
  128605. });
  128606. Object.defineProperty(Scene.prototype, "unTranslatedPointer", {
  128607. /**
  128608. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  128609. */
  128610. get: function () {
  128611. return new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](this._unTranslatedPointerX, this._unTranslatedPointerY);
  128612. },
  128613. enumerable: true,
  128614. configurable: true
  128615. });
  128616. Object.defineProperty(Scene.prototype, "useRightHandedSystem", {
  128617. get: function () {
  128618. return this._useRightHandedSystem;
  128619. },
  128620. /**
  128621. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  128622. */
  128623. set: function (value) {
  128624. if (this._useRightHandedSystem === value) {
  128625. return;
  128626. }
  128627. this._useRightHandedSystem = value;
  128628. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128629. },
  128630. enumerable: true,
  128631. configurable: true
  128632. });
  128633. /**
  128634. * Sets the step Id used by deterministic lock step
  128635. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128636. * @param newStepId defines the step Id
  128637. */
  128638. Scene.prototype.setStepId = function (newStepId) {
  128639. this._currentStepId = newStepId;
  128640. };
  128641. /**
  128642. * Gets the step Id used by deterministic lock step
  128643. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128644. * @returns the step Id
  128645. */
  128646. Scene.prototype.getStepId = function () {
  128647. return this._currentStepId;
  128648. };
  128649. /**
  128650. * Gets the internal step used by deterministic lock step
  128651. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128652. * @returns the internal step
  128653. */
  128654. Scene.prototype.getInternalStep = function () {
  128655. return this._currentInternalStep;
  128656. };
  128657. Object.defineProperty(Scene.prototype, "fogEnabled", {
  128658. get: function () {
  128659. return this._fogEnabled;
  128660. },
  128661. /**
  128662. * Gets or sets a boolean indicating if fog is enabled on this scene
  128663. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128664. * (Default is true)
  128665. */
  128666. set: function (value) {
  128667. if (this._fogEnabled === value) {
  128668. return;
  128669. }
  128670. this._fogEnabled = value;
  128671. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128672. },
  128673. enumerable: true,
  128674. configurable: true
  128675. });
  128676. Object.defineProperty(Scene.prototype, "fogMode", {
  128677. get: function () {
  128678. return this._fogMode;
  128679. },
  128680. /**
  128681. * Gets or sets the fog mode to use
  128682. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128683. * | mode | value |
  128684. * | --- | --- |
  128685. * | FOGMODE_NONE | 0 |
  128686. * | FOGMODE_EXP | 1 |
  128687. * | FOGMODE_EXP2 | 2 |
  128688. * | FOGMODE_LINEAR | 3 |
  128689. */
  128690. set: function (value) {
  128691. if (this._fogMode === value) {
  128692. return;
  128693. }
  128694. this._fogMode = value;
  128695. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  128696. },
  128697. enumerable: true,
  128698. configurable: true
  128699. });
  128700. Object.defineProperty(Scene.prototype, "shadowsEnabled", {
  128701. get: function () {
  128702. return this._shadowsEnabled;
  128703. },
  128704. /**
  128705. * Gets or sets a boolean indicating if shadows are enabled on this scene
  128706. */
  128707. set: function (value) {
  128708. if (this._shadowsEnabled === value) {
  128709. return;
  128710. }
  128711. this._shadowsEnabled = value;
  128712. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  128713. },
  128714. enumerable: true,
  128715. configurable: true
  128716. });
  128717. Object.defineProperty(Scene.prototype, "lightsEnabled", {
  128718. get: function () {
  128719. return this._lightsEnabled;
  128720. },
  128721. /**
  128722. * Gets or sets a boolean indicating if lights are enabled on this scene
  128723. */
  128724. set: function (value) {
  128725. if (this._lightsEnabled === value) {
  128726. return;
  128727. }
  128728. this._lightsEnabled = value;
  128729. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  128730. },
  128731. enumerable: true,
  128732. configurable: true
  128733. });
  128734. Object.defineProperty(Scene.prototype, "activeCamera", {
  128735. /** Gets or sets the current active camera */
  128736. get: function () {
  128737. return this._activeCamera;
  128738. },
  128739. set: function (value) {
  128740. if (value === this._activeCamera) {
  128741. return;
  128742. }
  128743. this._activeCamera = value;
  128744. this.onActiveCameraChanged.notifyObservers(this);
  128745. },
  128746. enumerable: true,
  128747. configurable: true
  128748. });
  128749. Object.defineProperty(Scene.prototype, "defaultMaterial", {
  128750. /** The default material used on meshes when no material is affected */
  128751. get: function () {
  128752. if (!this._defaultMaterial) {
  128753. this._defaultMaterial = Scene.DefaultMaterialFactory(this);
  128754. }
  128755. return this._defaultMaterial;
  128756. },
  128757. /** The default material used on meshes when no material is affected */
  128758. set: function (value) {
  128759. this._defaultMaterial = value;
  128760. },
  128761. enumerable: true,
  128762. configurable: true
  128763. });
  128764. Object.defineProperty(Scene.prototype, "texturesEnabled", {
  128765. get: function () {
  128766. return this._texturesEnabled;
  128767. },
  128768. /**
  128769. * Gets or sets a boolean indicating if textures are enabled on this scene
  128770. */
  128771. set: function (value) {
  128772. if (this._texturesEnabled === value) {
  128773. return;
  128774. }
  128775. this._texturesEnabled = value;
  128776. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  128777. },
  128778. enumerable: true,
  128779. configurable: true
  128780. });
  128781. Object.defineProperty(Scene.prototype, "skeletonsEnabled", {
  128782. get: function () {
  128783. return this._skeletonsEnabled;
  128784. },
  128785. /**
  128786. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  128787. */
  128788. set: function (value) {
  128789. if (this._skeletonsEnabled === value) {
  128790. return;
  128791. }
  128792. this._skeletonsEnabled = value;
  128793. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AttributesDirtyFlag);
  128794. },
  128795. enumerable: true,
  128796. configurable: true
  128797. });
  128798. Object.defineProperty(Scene.prototype, "collisionCoordinator", {
  128799. /** @hidden */
  128800. get: function () {
  128801. if (!this._collisionCoordinator) {
  128802. this._collisionCoordinator = Scene.CollisionCoordinatorFactory();
  128803. this._collisionCoordinator.init(this);
  128804. }
  128805. return this._collisionCoordinator;
  128806. },
  128807. enumerable: true,
  128808. configurable: true
  128809. });
  128810. Object.defineProperty(Scene.prototype, "_isAlternateRenderingEnabled", {
  128811. /** @hidden */
  128812. get: function () {
  128813. return this._alternateRendering;
  128814. },
  128815. enumerable: true,
  128816. configurable: true
  128817. });
  128818. Object.defineProperty(Scene.prototype, "frustumPlanes", {
  128819. /**
  128820. * Gets the list of frustum planes (built from the active camera)
  128821. */
  128822. get: function () {
  128823. return this._frustumPlanes;
  128824. },
  128825. enumerable: true,
  128826. configurable: true
  128827. });
  128828. /**
  128829. * Registers the transient components if needed.
  128830. */
  128831. Scene.prototype._registerTransientComponents = function () {
  128832. // Register components that have been associated lately to the scene.
  128833. if (this._transientComponents.length > 0) {
  128834. for (var _i = 0, _a = this._transientComponents; _i < _a.length; _i++) {
  128835. var component = _a[_i];
  128836. component.register();
  128837. }
  128838. this._transientComponents = [];
  128839. }
  128840. };
  128841. /**
  128842. * @hidden
  128843. * Add a component to the scene.
  128844. * Note that the ccomponent could be registered on th next frame if this is called after
  128845. * the register component stage.
  128846. * @param component Defines the component to add to the scene
  128847. */
  128848. Scene.prototype._addComponent = function (component) {
  128849. this._components.push(component);
  128850. this._transientComponents.push(component);
  128851. var serializableComponent = component;
  128852. if (serializableComponent.addFromContainer) {
  128853. this._serializableComponents.push(serializableComponent);
  128854. }
  128855. };
  128856. /**
  128857. * @hidden
  128858. * Gets a component from the scene.
  128859. * @param name defines the name of the component to retrieve
  128860. * @returns the component or null if not present
  128861. */
  128862. Scene.prototype._getComponent = function (name) {
  128863. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  128864. var component = _a[_i];
  128865. if (component.name === name) {
  128866. return component;
  128867. }
  128868. }
  128869. return null;
  128870. };
  128871. /**
  128872. * @hidden
  128873. */
  128874. Scene.prototype._getDefaultMeshCandidates = function () {
  128875. this._defaultMeshCandidates.data = this.meshes;
  128876. this._defaultMeshCandidates.length = this.meshes.length;
  128877. return this._defaultMeshCandidates;
  128878. };
  128879. /**
  128880. * @hidden
  128881. */
  128882. Scene.prototype._getDefaultSubMeshCandidates = function (mesh) {
  128883. this._defaultSubMeshCandidates.data = mesh.subMeshes;
  128884. this._defaultSubMeshCandidates.length = mesh.subMeshes.length;
  128885. return this._defaultSubMeshCandidates;
  128886. };
  128887. /**
  128888. * Sets the default candidate providers for the scene.
  128889. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  128890. * and getCollidingSubMeshCandidates to their default function
  128891. */
  128892. Scene.prototype.setDefaultCandidateProviders = function () {
  128893. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this);
  128894. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  128895. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  128896. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  128897. };
  128898. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  128899. /**
  128900. * Gets the mesh that is currently under the pointer
  128901. */
  128902. get: function () {
  128903. return this._pointerOverMesh;
  128904. },
  128905. enumerable: true,
  128906. configurable: true
  128907. });
  128908. Object.defineProperty(Scene.prototype, "pointerX", {
  128909. /**
  128910. * Gets or sets the current on-screen X position of the pointer
  128911. */
  128912. get: function () {
  128913. return this._pointerX;
  128914. },
  128915. set: function (value) {
  128916. this._pointerX = value;
  128917. },
  128918. enumerable: true,
  128919. configurable: true
  128920. });
  128921. Object.defineProperty(Scene.prototype, "pointerY", {
  128922. /**
  128923. * Gets or sets the current on-screen Y position of the pointer
  128924. */
  128925. get: function () {
  128926. return this._pointerY;
  128927. },
  128928. set: function (value) {
  128929. this._pointerY = value;
  128930. },
  128931. enumerable: true,
  128932. configurable: true
  128933. });
  128934. /**
  128935. * Gets the cached material (ie. the latest rendered one)
  128936. * @returns the cached material
  128937. */
  128938. Scene.prototype.getCachedMaterial = function () {
  128939. return this._cachedMaterial;
  128940. };
  128941. /**
  128942. * Gets the cached effect (ie. the latest rendered one)
  128943. * @returns the cached effect
  128944. */
  128945. Scene.prototype.getCachedEffect = function () {
  128946. return this._cachedEffect;
  128947. };
  128948. /**
  128949. * Gets the cached visibility state (ie. the latest rendered one)
  128950. * @returns the cached visibility state
  128951. */
  128952. Scene.prototype.getCachedVisibility = function () {
  128953. return this._cachedVisibility;
  128954. };
  128955. /**
  128956. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  128957. * @param material defines the current material
  128958. * @param effect defines the current effect
  128959. * @param visibility defines the current visibility state
  128960. * @returns true if one parameter is not cached
  128961. */
  128962. Scene.prototype.isCachedMaterialInvalid = function (material, effect, visibility) {
  128963. if (visibility === void 0) { visibility = 1; }
  128964. return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
  128965. };
  128966. /**
  128967. * Gets the engine associated with the scene
  128968. * @returns an Engine
  128969. */
  128970. Scene.prototype.getEngine = function () {
  128971. return this._engine;
  128972. };
  128973. /**
  128974. * Gets the total number of vertices rendered per frame
  128975. * @returns the total number of vertices rendered per frame
  128976. */
  128977. Scene.prototype.getTotalVertices = function () {
  128978. return this._totalVertices.current;
  128979. };
  128980. Object.defineProperty(Scene.prototype, "totalVerticesPerfCounter", {
  128981. /**
  128982. * Gets the performance counter for total vertices
  128983. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  128984. */
  128985. get: function () {
  128986. return this._totalVertices;
  128987. },
  128988. enumerable: true,
  128989. configurable: true
  128990. });
  128991. /**
  128992. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  128993. * @returns the total number of active indices rendered per frame
  128994. */
  128995. Scene.prototype.getActiveIndices = function () {
  128996. return this._activeIndices.current;
  128997. };
  128998. Object.defineProperty(Scene.prototype, "totalActiveIndicesPerfCounter", {
  128999. /**
  129000. * Gets the performance counter for active indices
  129001. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  129002. */
  129003. get: function () {
  129004. return this._activeIndices;
  129005. },
  129006. enumerable: true,
  129007. configurable: true
  129008. });
  129009. /**
  129010. * Gets the total number of active particles rendered per frame
  129011. * @returns the total number of active particles rendered per frame
  129012. */
  129013. Scene.prototype.getActiveParticles = function () {
  129014. return this._activeParticles.current;
  129015. };
  129016. Object.defineProperty(Scene.prototype, "activeParticlesPerfCounter", {
  129017. /**
  129018. * Gets the performance counter for active particles
  129019. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  129020. */
  129021. get: function () {
  129022. return this._activeParticles;
  129023. },
  129024. enumerable: true,
  129025. configurable: true
  129026. });
  129027. /**
  129028. * Gets the total number of active bones rendered per frame
  129029. * @returns the total number of active bones rendered per frame
  129030. */
  129031. Scene.prototype.getActiveBones = function () {
  129032. return this._activeBones.current;
  129033. };
  129034. Object.defineProperty(Scene.prototype, "activeBonesPerfCounter", {
  129035. /**
  129036. * Gets the performance counter for active bones
  129037. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  129038. */
  129039. get: function () {
  129040. return this._activeBones;
  129041. },
  129042. enumerable: true,
  129043. configurable: true
  129044. });
  129045. /**
  129046. * Gets the array of active meshes
  129047. * @returns an array of AbstractMesh
  129048. */
  129049. Scene.prototype.getActiveMeshes = function () {
  129050. return this._activeMeshes;
  129051. };
  129052. /**
  129053. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  129054. * @returns a number
  129055. */
  129056. Scene.prototype.getAnimationRatio = function () {
  129057. return this._animationRatio !== undefined ? this._animationRatio : 1;
  129058. };
  129059. /**
  129060. * Gets an unique Id for the current render phase
  129061. * @returns a number
  129062. */
  129063. Scene.prototype.getRenderId = function () {
  129064. return this._renderId;
  129065. };
  129066. /**
  129067. * Gets an unique Id for the current frame
  129068. * @returns a number
  129069. */
  129070. Scene.prototype.getFrameId = function () {
  129071. return this._frameId;
  129072. };
  129073. /** Call this function if you want to manually increment the render Id*/
  129074. Scene.prototype.incrementRenderId = function () {
  129075. this._renderId++;
  129076. };
  129077. Scene.prototype._updatePointerPosition = function (evt) {
  129078. var canvasRect = this._engine.getRenderingCanvasClientRect();
  129079. if (!canvasRect) {
  129080. return;
  129081. }
  129082. this._pointerX = evt.clientX - canvasRect.left;
  129083. this._pointerY = evt.clientY - canvasRect.top;
  129084. this._unTranslatedPointerX = this._pointerX;
  129085. this._unTranslatedPointerY = this._pointerY;
  129086. };
  129087. Scene.prototype._createUbo = function () {
  129088. this._sceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  129089. this._sceneUbo.addUniform("viewProjection", 16);
  129090. this._sceneUbo.addUniform("view", 16);
  129091. };
  129092. Scene.prototype._createAlternateUbo = function () {
  129093. this._alternateSceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  129094. this._alternateSceneUbo.addUniform("viewProjection", 16);
  129095. this._alternateSceneUbo.addUniform("view", 16);
  129096. };
  129097. // Pointers handling
  129098. Scene.prototype._setRayOnPointerInfo = function (pointerInfo) {
  129099. if (pointerInfo.pickInfo && !pointerInfo.pickInfo._pickingUnavailable) {
  129100. if (!pointerInfo.pickInfo.ray) {
  129101. pointerInfo.pickInfo.ray = this.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), this.activeCamera);
  129102. }
  129103. }
  129104. };
  129105. /**
  129106. * Use this method to simulate a pointer move on a mesh
  129107. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  129108. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  129109. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  129110. * @returns the current scene
  129111. */
  129112. Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  129113. var evt = new PointerEvent("pointermove", pointerEventInit);
  129114. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE)) {
  129115. return this;
  129116. }
  129117. return this._processPointerMove(pickResult, evt);
  129118. };
  129119. Scene.prototype._processPointerMove = function (pickResult, evt) {
  129120. var canvas = this._engine.getRenderingCanvas();
  129121. if (!canvas) {
  129122. return this;
  129123. }
  129124. // Restore pointer
  129125. canvas.style.cursor = this.defaultCursor;
  129126. var isMeshPicked = (pickResult && pickResult.hit && pickResult.pickedMesh) ? true : false;
  129127. if (isMeshPicked) {
  129128. this.setPointerOverMesh(pickResult.pickedMesh);
  129129. if (this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers) {
  129130. if (this._pointerOverMesh.actionManager.hoverCursor) {
  129131. canvas.style.cursor = this._pointerOverMesh.actionManager.hoverCursor;
  129132. }
  129133. else {
  129134. canvas.style.cursor = this.hoverCursor;
  129135. }
  129136. }
  129137. }
  129138. else {
  129139. this.setPointerOverMesh(null);
  129140. }
  129141. for (var _i = 0, _a = this._pointerMoveStage; _i < _a.length; _i++) {
  129142. var step = _a[_i];
  129143. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
  129144. }
  129145. if (pickResult) {
  129146. var type = evt.type === this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE;
  129147. if (this.onPointerMove) {
  129148. this.onPointerMove(evt, pickResult, type);
  129149. }
  129150. if (this.onPointerObservable.hasObservers()) {
  129151. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  129152. this._setRayOnPointerInfo(pi);
  129153. this.onPointerObservable.notifyObservers(pi, type);
  129154. }
  129155. }
  129156. return this;
  129157. };
  129158. Scene.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
  129159. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfoPre"](type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
  129160. if (pickResult) {
  129161. pi.ray = pickResult.ray;
  129162. }
  129163. this.onPrePointerObservable.notifyObservers(pi, type);
  129164. if (pi.skipOnPointerObservable) {
  129165. return true;
  129166. }
  129167. else {
  129168. return false;
  129169. }
  129170. };
  129171. /**
  129172. * Use this method to simulate a pointer down on a mesh
  129173. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  129174. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  129175. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  129176. * @returns the current scene
  129177. */
  129178. Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  129179. var evt = new PointerEvent("pointerdown", pointerEventInit);
  129180. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  129181. return this;
  129182. }
  129183. return this._processPointerDown(pickResult, evt);
  129184. };
  129185. Scene.prototype._processPointerDown = function (pickResult, evt) {
  129186. var _this = this;
  129187. if (pickResult && pickResult.hit && pickResult.pickedMesh) {
  129188. this._pickedDownMesh = pickResult.pickedMesh;
  129189. var actionManager = pickResult.pickedMesh.actionManager;
  129190. if (actionManager) {
  129191. if (actionManager.hasPickTriggers) {
  129192. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129193. switch (evt.button) {
  129194. case 0:
  129195. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129196. break;
  129197. case 1:
  129198. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129199. break;
  129200. case 2:
  129201. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129202. break;
  129203. }
  129204. }
  129205. if (actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger)) {
  129206. window.setTimeout(function () {
  129207. 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);
  129208. if (pickResult && pickResult.hit && pickResult.pickedMesh && actionManager) {
  129209. if (_this._totalPointersPressed !== 0 &&
  129210. ((Date.now() - _this._startingPointerTime) > Scene.LongPressDelay) &&
  129211. !_this._isPointerSwiping()) {
  129212. _this._startingPointerTime = 0;
  129213. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129214. }
  129215. }
  129216. }, Scene.LongPressDelay);
  129217. }
  129218. }
  129219. }
  129220. else {
  129221. for (var _i = 0, _a = this._pointerDownStage; _i < _a.length; _i++) {
  129222. var step = _a[_i];
  129223. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  129224. }
  129225. }
  129226. if (pickResult) {
  129227. var type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN;
  129228. if (this.onPointerDown) {
  129229. this.onPointerDown(evt, pickResult, type);
  129230. }
  129231. if (this.onPointerObservable.hasObservers()) {
  129232. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  129233. this._setRayOnPointerInfo(pi);
  129234. this.onPointerObservable.notifyObservers(pi, type);
  129235. }
  129236. }
  129237. return this;
  129238. };
  129239. /**
  129240. * Use this method to simulate a pointer up on a mesh
  129241. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  129242. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  129243. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  129244. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  129245. * @returns the current scene
  129246. */
  129247. Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  129248. var evt = new PointerEvent("pointerup", pointerEventInit);
  129249. var clickInfo = new ClickInfo();
  129250. if (doubleTap) {
  129251. clickInfo.doubleClick = true;
  129252. }
  129253. else {
  129254. clickInfo.singleClick = true;
  129255. }
  129256. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  129257. return this;
  129258. }
  129259. return this._processPointerUp(pickResult, evt, clickInfo);
  129260. };
  129261. Scene.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
  129262. if (pickResult && pickResult && pickResult.pickedMesh) {
  129263. this._pickedUpMesh = pickResult.pickedMesh;
  129264. if (this._pickedDownMesh === this._pickedUpMesh) {
  129265. if (this.onPointerPick) {
  129266. this.onPointerPick(evt, pickResult);
  129267. }
  129268. if (clickInfo.singleClick && !clickInfo.ignore && this.onPointerObservable.hasObservers()) {
  129269. var type_1 = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK;
  129270. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type_1, evt, pickResult);
  129271. this._setRayOnPointerInfo(pi);
  129272. this.onPointerObservable.notifyObservers(pi, type_1);
  129273. }
  129274. }
  129275. if (pickResult.pickedMesh.actionManager && !clickInfo.ignore) {
  129276. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129277. if (!clickInfo.hasSwiped && clickInfo.singleClick) {
  129278. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129279. }
  129280. if (clickInfo.doubleClick && pickResult.pickedMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  129281. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129282. }
  129283. }
  129284. }
  129285. else {
  129286. if (!clickInfo.ignore) {
  129287. for (var _i = 0, _a = this._pointerUpStage; _i < _a.length; _i++) {
  129288. var step = _a[_i];
  129289. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  129290. }
  129291. }
  129292. }
  129293. if (this._pickedDownMesh &&
  129294. this._pickedDownMesh.actionManager &&
  129295. this._pickedDownMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger) &&
  129296. this._pickedDownMesh !== this._pickedUpMesh) {
  129297. this._pickedDownMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pickedDownMesh, evt));
  129298. }
  129299. var type = 0;
  129300. if (this.onPointerObservable.hasObservers()) {
  129301. if (!clickInfo.ignore && !clickInfo.hasSwiped) {
  129302. if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  129303. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP;
  129304. }
  129305. else if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  129306. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP;
  129307. }
  129308. if (type) {
  129309. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  129310. this._setRayOnPointerInfo(pi);
  129311. this.onPointerObservable.notifyObservers(pi, type);
  129312. }
  129313. }
  129314. if (!clickInfo.ignore) {
  129315. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP;
  129316. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  129317. this._setRayOnPointerInfo(pi);
  129318. this.onPointerObservable.notifyObservers(pi, type);
  129319. }
  129320. }
  129321. if (this.onPointerUp && !clickInfo.ignore) {
  129322. this.onPointerUp(evt, pickResult, type);
  129323. }
  129324. return this;
  129325. };
  129326. /**
  129327. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  129328. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  129329. * @returns true if the pointer was captured
  129330. */
  129331. Scene.prototype.isPointerCaptured = function (pointerId) {
  129332. if (pointerId === void 0) { pointerId = 0; }
  129333. return this._pointerCaptures[pointerId];
  129334. };
  129335. /** @hidden */
  129336. Scene.prototype._isPointerSwiping = function () {
  129337. return Math.abs(this._startingPointerPosition.x - this._pointerX) > Scene.DragMovementThreshold ||
  129338. Math.abs(this._startingPointerPosition.y - this._pointerY) > Scene.DragMovementThreshold;
  129339. };
  129340. /**
  129341. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  129342. * @param attachUp defines if you want to attach events to pointerup
  129343. * @param attachDown defines if you want to attach events to pointerdown
  129344. * @param attachMove defines if you want to attach events to pointermove
  129345. */
  129346. Scene.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  129347. var _this = this;
  129348. if (attachUp === void 0) { attachUp = true; }
  129349. if (attachDown === void 0) { attachDown = true; }
  129350. if (attachMove === void 0) { attachMove = true; }
  129351. this._initActionManager = function (act, clickInfo) {
  129352. if (!_this._meshPickProceed) {
  129353. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  129354. _this._currentPickResult = pickResult;
  129355. if (pickResult) {
  129356. act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh.actionManager : null;
  129357. }
  129358. _this._meshPickProceed = true;
  129359. }
  129360. return act;
  129361. };
  129362. this._delayedSimpleClick = function (btn, clickInfo, cb) {
  129363. // double click delay is over and that no double click has been raised since, or the 2 consecutive keys pressed are different
  129364. if ((Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay && !_this._doubleClickOccured) ||
  129365. btn !== _this._previousButtonPressed) {
  129366. _this._doubleClickOccured = false;
  129367. clickInfo.singleClick = true;
  129368. clickInfo.ignore = false;
  129369. cb(clickInfo, _this._currentPickResult);
  129370. }
  129371. };
  129372. this._initClickEvent = function (obs1, obs2, evt, cb) {
  129373. var clickInfo = new ClickInfo();
  129374. _this._currentPickResult = null;
  129375. var act = null;
  129376. var checkPicking = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK)
  129377. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)
  129378. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  129379. if (!checkPicking && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"]) {
  129380. act = _this._initActionManager(act, clickInfo);
  129381. if (act) {
  129382. checkPicking = act.hasPickTriggers;
  129383. }
  129384. }
  129385. var needToIgnoreNext = false;
  129386. if (checkPicking) {
  129387. var btn = evt.button;
  129388. clickInfo.hasSwiped = _this._isPointerSwiping();
  129389. if (!clickInfo.hasSwiped) {
  129390. var checkSingleClickImmediately = !Scene.ExclusiveDoubleClickMode;
  129391. if (!checkSingleClickImmediately) {
  129392. checkSingleClickImmediately = !obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) &&
  129393. !obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  129394. if (checkSingleClickImmediately && !_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  129395. act = _this._initActionManager(act, clickInfo);
  129396. if (act) {
  129397. checkSingleClickImmediately = !act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  129398. }
  129399. }
  129400. }
  129401. if (checkSingleClickImmediately) {
  129402. // single click detected if double click delay is over or two different successive keys pressed without exclusive double click or no double click required
  129403. if (Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay ||
  129404. btn !== _this._previousButtonPressed) {
  129405. clickInfo.singleClick = true;
  129406. cb(clickInfo, _this._currentPickResult);
  129407. needToIgnoreNext = true;
  129408. }
  129409. }
  129410. // at least one double click is required to be check and exclusive double click is enabled
  129411. else {
  129412. // wait that no double click has been raised during the double click delay
  129413. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  129414. _this._delayedSimpleClickTimeout = window.setTimeout(_this._delayedSimpleClick.bind(_this, btn, clickInfo, cb), Scene.DoubleClickDelay);
  129415. }
  129416. var checkDoubleClick = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) ||
  129417. obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  129418. if (!checkDoubleClick && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  129419. act = _this._initActionManager(act, clickInfo);
  129420. if (act) {
  129421. checkDoubleClick = act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  129422. }
  129423. }
  129424. if (checkDoubleClick) {
  129425. // two successive keys pressed are equal, double click delay is not over and double click has not just occurred
  129426. if (btn === _this._previousButtonPressed &&
  129427. Date.now() - _this._previousStartingPointerTime < Scene.DoubleClickDelay &&
  129428. !_this._doubleClickOccured) {
  129429. // pointer has not moved for 2 clicks, it's a double click
  129430. if (!clickInfo.hasSwiped &&
  129431. !_this._isPointerSwiping()) {
  129432. _this._previousStartingPointerTime = 0;
  129433. _this._doubleClickOccured = true;
  129434. clickInfo.doubleClick = true;
  129435. clickInfo.ignore = false;
  129436. if (Scene.ExclusiveDoubleClickMode && _this._previousDelayedSimpleClickTimeout) {
  129437. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  129438. }
  129439. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  129440. cb(clickInfo, _this._currentPickResult);
  129441. }
  129442. // if the two successive clicks are too far, it's just two simple clicks
  129443. else {
  129444. _this._doubleClickOccured = false;
  129445. _this._previousStartingPointerTime = _this._startingPointerTime;
  129446. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  129447. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  129448. _this._previousButtonPressed = btn;
  129449. if (Scene.ExclusiveDoubleClickMode) {
  129450. if (_this._previousDelayedSimpleClickTimeout) {
  129451. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  129452. }
  129453. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  129454. cb(clickInfo, _this._previousPickResult);
  129455. }
  129456. else {
  129457. cb(clickInfo, _this._currentPickResult);
  129458. }
  129459. }
  129460. needToIgnoreNext = true;
  129461. }
  129462. // just the first click of the double has been raised
  129463. else {
  129464. _this._doubleClickOccured = false;
  129465. _this._previousStartingPointerTime = _this._startingPointerTime;
  129466. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  129467. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  129468. _this._previousButtonPressed = btn;
  129469. }
  129470. }
  129471. }
  129472. }
  129473. if (!needToIgnoreNext) {
  129474. cb(clickInfo, _this._currentPickResult);
  129475. }
  129476. };
  129477. this._onPointerMove = function (evt) {
  129478. _this._updatePointerPosition(evt);
  129479. // PreObservable support
  129480. 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)) {
  129481. return;
  129482. }
  129483. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  129484. return;
  129485. }
  129486. if (!_this.pointerMovePredicate) {
  129487. _this.pointerMovePredicate = function (mesh) { return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (mesh.enablePointerMoveEvents || _this.constantlyUpdateMeshUnderPointer || (mesh.actionManager !== null && mesh.actionManager !== undefined)); };
  129488. }
  129489. // Meshes
  129490. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerMovePredicate, false, _this.cameraToUseForPointers);
  129491. _this._processPointerMove(pickResult, evt);
  129492. };
  129493. this._onPointerDown = function (evt) {
  129494. _this._totalPointersPressed++;
  129495. _this._pickedDownMesh = null;
  129496. _this._meshPickProceed = false;
  129497. _this._updatePointerPosition(evt);
  129498. if (_this.preventDefaultOnPointerDown && canvas) {
  129499. evt.preventDefault();
  129500. canvas.focus();
  129501. }
  129502. _this._startingPointerPosition.x = _this._pointerX;
  129503. _this._startingPointerPosition.y = _this._pointerY;
  129504. _this._startingPointerTime = Date.now();
  129505. // PreObservable support
  129506. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  129507. return;
  129508. }
  129509. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  129510. return;
  129511. }
  129512. _this._pointerCaptures[evt.pointerId] = true;
  129513. if (!_this.pointerDownPredicate) {
  129514. _this.pointerDownPredicate = function (mesh) {
  129515. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  129516. };
  129517. }
  129518. // Meshes
  129519. _this._pickedDownMesh = null;
  129520. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  129521. _this._processPointerDown(pickResult, evt);
  129522. };
  129523. this._onPointerUp = function (evt) {
  129524. if (_this._totalPointersPressed === 0) { // We are attaching the pointer up to windows because of a bug in FF
  129525. return; // So we need to test it the pointer down was pressed before.
  129526. }
  129527. _this._totalPointersPressed--;
  129528. _this._pickedUpMesh = null;
  129529. _this._meshPickProceed = false;
  129530. _this._updatePointerPosition(evt);
  129531. if (_this.preventDefaultOnPointerUp && canvas) {
  129532. evt.preventDefault();
  129533. canvas.focus();
  129534. }
  129535. _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
  129536. _this._pointerCaptures[evt.pointerId] = false;
  129537. // PreObservable support
  129538. if (_this.onPrePointerObservable.hasObservers()) {
  129539. if (!clickInfo.ignore) {
  129540. if (!clickInfo.hasSwiped) {
  129541. if (clickInfo.singleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  129542. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  129543. return;
  129544. }
  129545. }
  129546. if (clickInfo.doubleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  129547. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  129548. return;
  129549. }
  129550. }
  129551. }
  129552. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  129553. return;
  129554. }
  129555. }
  129556. }
  129557. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  129558. return;
  129559. }
  129560. if (!_this.pointerUpPredicate) {
  129561. _this.pointerUpPredicate = function (mesh) {
  129562. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  129563. };
  129564. }
  129565. // Meshes
  129566. if (!_this._meshPickProceed && (_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"] && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasTriggers || _this.onPointerObservable.hasObservers())) {
  129567. _this._initActionManager(null, clickInfo);
  129568. }
  129569. if (!pickResult) {
  129570. pickResult = _this._currentPickResult;
  129571. }
  129572. _this._processPointerUp(pickResult, evt, clickInfo);
  129573. _this._previousPickResult = _this._currentPickResult;
  129574. });
  129575. };
  129576. this._onKeyDown = function (evt) {
  129577. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYDOWN;
  129578. if (_this.onPreKeyboardObservable.hasObservers()) {
  129579. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  129580. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  129581. if (pi.skipOnPointerObservable) {
  129582. return;
  129583. }
  129584. }
  129585. if (_this.onKeyboardObservable.hasObservers()) {
  129586. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  129587. _this.onKeyboardObservable.notifyObservers(pi, type);
  129588. }
  129589. if (_this.actionManager) {
  129590. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  129591. }
  129592. };
  129593. this._onKeyUp = function (evt) {
  129594. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYUP;
  129595. if (_this.onPreKeyboardObservable.hasObservers()) {
  129596. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  129597. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  129598. if (pi.skipOnPointerObservable) {
  129599. return;
  129600. }
  129601. }
  129602. if (_this.onKeyboardObservable.hasObservers()) {
  129603. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  129604. _this.onKeyboardObservable.notifyObservers(pi, type);
  129605. }
  129606. if (_this.actionManager) {
  129607. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  129608. }
  129609. };
  129610. var engine = this.getEngine();
  129611. this._onCanvasFocusObserver = engine.onCanvasFocusObservable.add(function () {
  129612. if (!canvas) {
  129613. return;
  129614. }
  129615. canvas.addEventListener("keydown", _this._onKeyDown, false);
  129616. canvas.addEventListener("keyup", _this._onKeyUp, false);
  129617. });
  129618. this._onCanvasBlurObserver = engine.onCanvasBlurObservable.add(function () {
  129619. if (!canvas) {
  129620. return;
  129621. }
  129622. canvas.removeEventListener("keydown", _this._onKeyDown);
  129623. canvas.removeEventListener("keyup", _this._onKeyUp);
  129624. });
  129625. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  129626. var canvas = this._engine.getRenderingCanvas();
  129627. if (!canvas) {
  129628. return;
  129629. }
  129630. if (attachMove) {
  129631. canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
  129632. // Wheel
  129633. this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
  129634. document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
  129635. "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
  129636. canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
  129637. }
  129638. if (attachDown) {
  129639. canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
  129640. }
  129641. if (attachUp) {
  129642. window.addEventListener(eventPrefix + "up", this._onPointerUp, false);
  129643. }
  129644. canvas.tabIndex = 1;
  129645. };
  129646. /** Detaches all event handlers*/
  129647. Scene.prototype.detachControl = function () {
  129648. var engine = this.getEngine();
  129649. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  129650. var canvas = engine.getRenderingCanvas();
  129651. if (!canvas) {
  129652. return;
  129653. }
  129654. canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
  129655. canvas.removeEventListener(eventPrefix + "down", this._onPointerDown);
  129656. window.removeEventListener(eventPrefix + "up", this._onPointerUp);
  129657. if (this._onCanvasBlurObserver) {
  129658. engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  129659. }
  129660. if (this._onCanvasFocusObserver) {
  129661. engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
  129662. }
  129663. // Wheel
  129664. canvas.removeEventListener(this._wheelEventName, this._onPointerMove);
  129665. // Keyboard
  129666. canvas.removeEventListener("keydown", this._onKeyDown);
  129667. canvas.removeEventListener("keyup", this._onKeyUp);
  129668. // Observables
  129669. this.onKeyboardObservable.clear();
  129670. this.onPreKeyboardObservable.clear();
  129671. this.onPointerObservable.clear();
  129672. this.onPrePointerObservable.clear();
  129673. };
  129674. /**
  129675. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  129676. * Delay loaded resources are not taking in account
  129677. * @return true if all required resources are ready
  129678. */
  129679. Scene.prototype.isReady = function () {
  129680. if (this._isDisposed) {
  129681. return false;
  129682. }
  129683. var index;
  129684. var engine = this.getEngine();
  129685. // Effects
  129686. if (!engine.areAllEffectsReady()) {
  129687. return false;
  129688. }
  129689. // Pending data
  129690. if (this._pendingData.length > 0) {
  129691. return false;
  129692. }
  129693. // Meshes
  129694. for (index = 0; index < this.meshes.length; index++) {
  129695. var mesh = this.meshes[index];
  129696. if (!mesh.isEnabled()) {
  129697. continue;
  129698. }
  129699. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  129700. continue;
  129701. }
  129702. if (!mesh.isReady(true)) {
  129703. return false;
  129704. }
  129705. var hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || mesh.getClassName() === "InstancedLinesMesh" || engine.getCaps().instancedArrays && mesh.instances.length > 0;
  129706. // Is Ready For Mesh
  129707. for (var _i = 0, _a = this._isReadyForMeshStage; _i < _a.length; _i++) {
  129708. var step = _a[_i];
  129709. if (!step.action(mesh, hardwareInstancedRendering)) {
  129710. return false;
  129711. }
  129712. }
  129713. }
  129714. // Geometries
  129715. for (index = 0; index < this.geometries.length; index++) {
  129716. var geometry = this.geometries[index];
  129717. if (geometry.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].DELAYLOADSTATE_LOADING) {
  129718. return false;
  129719. }
  129720. }
  129721. // Post-processes
  129722. if (this.activeCameras && this.activeCameras.length > 0) {
  129723. for (var _b = 0, _c = this.activeCameras; _b < _c.length; _b++) {
  129724. var camera = _c[_b];
  129725. if (!camera.isReady(true)) {
  129726. return false;
  129727. }
  129728. }
  129729. }
  129730. else if (this.activeCamera) {
  129731. if (!this.activeCamera.isReady(true)) {
  129732. return false;
  129733. }
  129734. }
  129735. // Particles
  129736. for (var _d = 0, _e = this.particleSystems; _d < _e.length; _d++) {
  129737. var particleSystem = _e[_d];
  129738. if (!particleSystem.isReady()) {
  129739. return false;
  129740. }
  129741. }
  129742. return true;
  129743. };
  129744. /** Resets all cached information relative to material (including effect and visibility) */
  129745. Scene.prototype.resetCachedMaterial = function () {
  129746. this._cachedMaterial = null;
  129747. this._cachedEffect = null;
  129748. this._cachedVisibility = null;
  129749. };
  129750. /**
  129751. * Registers a function to be called before every frame render
  129752. * @param func defines the function to register
  129753. */
  129754. Scene.prototype.registerBeforeRender = function (func) {
  129755. this.onBeforeRenderObservable.add(func);
  129756. };
  129757. /**
  129758. * Unregisters a function called before every frame render
  129759. * @param func defines the function to unregister
  129760. */
  129761. Scene.prototype.unregisterBeforeRender = function (func) {
  129762. this.onBeforeRenderObservable.removeCallback(func);
  129763. };
  129764. /**
  129765. * Registers a function to be called after every frame render
  129766. * @param func defines the function to register
  129767. */
  129768. Scene.prototype.registerAfterRender = function (func) {
  129769. this.onAfterRenderObservable.add(func);
  129770. };
  129771. /**
  129772. * Unregisters a function called after every frame render
  129773. * @param func defines the function to unregister
  129774. */
  129775. Scene.prototype.unregisterAfterRender = function (func) {
  129776. this.onAfterRenderObservable.removeCallback(func);
  129777. };
  129778. Scene.prototype._executeOnceBeforeRender = function (func) {
  129779. var _this = this;
  129780. var execFunc = function () {
  129781. func();
  129782. setTimeout(function () {
  129783. _this.unregisterBeforeRender(execFunc);
  129784. });
  129785. };
  129786. this.registerBeforeRender(execFunc);
  129787. };
  129788. /**
  129789. * The provided function will run before render once and will be disposed afterwards.
  129790. * A timeout delay can be provided so that the function will be executed in N ms.
  129791. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  129792. * @param func The function to be executed.
  129793. * @param timeout optional delay in ms
  129794. */
  129795. Scene.prototype.executeOnceBeforeRender = function (func, timeout) {
  129796. var _this = this;
  129797. if (timeout !== undefined) {
  129798. setTimeout(function () {
  129799. _this._executeOnceBeforeRender(func);
  129800. }, timeout);
  129801. }
  129802. else {
  129803. this._executeOnceBeforeRender(func);
  129804. }
  129805. };
  129806. /** @hidden */
  129807. Scene.prototype._addPendingData = function (data) {
  129808. this._pendingData.push(data);
  129809. };
  129810. /** @hidden */
  129811. Scene.prototype._removePendingData = function (data) {
  129812. var wasLoading = this.isLoading;
  129813. var index = this._pendingData.indexOf(data);
  129814. if (index !== -1) {
  129815. this._pendingData.splice(index, 1);
  129816. }
  129817. if (wasLoading && !this.isLoading) {
  129818. this.onDataLoadedObservable.notifyObservers(this);
  129819. }
  129820. };
  129821. /**
  129822. * Returns the number of items waiting to be loaded
  129823. * @returns the number of items waiting to be loaded
  129824. */
  129825. Scene.prototype.getWaitingItemsCount = function () {
  129826. return this._pendingData.length;
  129827. };
  129828. Object.defineProperty(Scene.prototype, "isLoading", {
  129829. /**
  129830. * Returns a boolean indicating if the scene is still loading data
  129831. */
  129832. get: function () {
  129833. return this._pendingData.length > 0;
  129834. },
  129835. enumerable: true,
  129836. configurable: true
  129837. });
  129838. /**
  129839. * Registers a function to be executed when the scene is ready
  129840. * @param {Function} func - the function to be executed
  129841. */
  129842. Scene.prototype.executeWhenReady = function (func) {
  129843. var _this = this;
  129844. this.onReadyObservable.add(func);
  129845. if (this._executeWhenReadyTimeoutId !== -1) {
  129846. return;
  129847. }
  129848. this._executeWhenReadyTimeoutId = setTimeout(function () {
  129849. _this._checkIsReady();
  129850. }, 150);
  129851. };
  129852. /**
  129853. * Returns a promise that resolves when the scene is ready
  129854. * @returns A promise that resolves when the scene is ready
  129855. */
  129856. Scene.prototype.whenReadyAsync = function () {
  129857. var _this = this;
  129858. return new Promise(function (resolve) {
  129859. _this.executeWhenReady(function () {
  129860. resolve();
  129861. });
  129862. });
  129863. };
  129864. /** @hidden */
  129865. Scene.prototype._checkIsReady = function () {
  129866. var _this = this;
  129867. this._registerTransientComponents();
  129868. if (this.isReady()) {
  129869. this.onReadyObservable.notifyObservers(this);
  129870. this.onReadyObservable.clear();
  129871. this._executeWhenReadyTimeoutId = -1;
  129872. return;
  129873. }
  129874. this._executeWhenReadyTimeoutId = setTimeout(function () {
  129875. _this._checkIsReady();
  129876. }, 150);
  129877. };
  129878. Object.defineProperty(Scene.prototype, "animatables", {
  129879. /**
  129880. * Gets all animatable attached to the scene
  129881. */
  129882. get: function () {
  129883. return this._activeAnimatables;
  129884. },
  129885. enumerable: true,
  129886. configurable: true
  129887. });
  129888. /**
  129889. * Resets the last animation time frame.
  129890. * Useful to override when animations start running when loading a scene for the first time.
  129891. */
  129892. Scene.prototype.resetLastAnimationTimeFrame = function () {
  129893. this._animationTimeLast = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  129894. };
  129895. // Matrix
  129896. /** @hidden */
  129897. Scene.prototype._switchToAlternateCameraConfiguration = function (active) {
  129898. this._useAlternateCameraConfiguration = active;
  129899. };
  129900. /**
  129901. * Gets the current view matrix
  129902. * @returns a Matrix
  129903. */
  129904. Scene.prototype.getViewMatrix = function () {
  129905. return this._useAlternateCameraConfiguration ? this._alternateViewMatrix : this._viewMatrix;
  129906. };
  129907. /**
  129908. * Gets the current projection matrix
  129909. * @returns a Matrix
  129910. */
  129911. Scene.prototype.getProjectionMatrix = function () {
  129912. return this._useAlternateCameraConfiguration ? this._alternateProjectionMatrix : this._projectionMatrix;
  129913. };
  129914. /**
  129915. * Gets the current transform matrix
  129916. * @returns a Matrix made of View * Projection
  129917. */
  129918. Scene.prototype.getTransformMatrix = function () {
  129919. return this._useAlternateCameraConfiguration ? this._alternateTransformMatrix : this._transformMatrix;
  129920. };
  129921. /**
  129922. * Sets the current transform matrix
  129923. * @param view defines the View matrix to use
  129924. * @param projection defines the Projection matrix to use
  129925. */
  129926. Scene.prototype.setTransformMatrix = function (view, projection) {
  129927. if (this._viewUpdateFlag === view.updateFlag && this._projectionUpdateFlag === projection.updateFlag) {
  129928. return;
  129929. }
  129930. this._viewUpdateFlag = view.updateFlag;
  129931. this._projectionUpdateFlag = projection.updateFlag;
  129932. this._viewMatrix = view;
  129933. this._projectionMatrix = projection;
  129934. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  129935. // Update frustum
  129936. if (!this._frustumPlanes) {
  129937. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanes(this._transformMatrix);
  129938. }
  129939. else {
  129940. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  129941. }
  129942. if (this.activeCamera && this.activeCamera._alternateCamera) {
  129943. var otherCamera = this.activeCamera._alternateCamera;
  129944. otherCamera.getViewMatrix().multiplyToRef(otherCamera.getProjectionMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Matrix[0]);
  129945. _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
  129946. }
  129947. if (this._sceneUbo.useUbo) {
  129948. this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  129949. this._sceneUbo.updateMatrix("view", this._viewMatrix);
  129950. this._sceneUbo.update();
  129951. }
  129952. };
  129953. /** @hidden */
  129954. Scene.prototype._setAlternateTransformMatrix = function (view, projection) {
  129955. if (this._alternateViewUpdateFlag === view.updateFlag && this._alternateProjectionUpdateFlag === projection.updateFlag) {
  129956. return;
  129957. }
  129958. this._alternateViewUpdateFlag = view.updateFlag;
  129959. this._alternateProjectionUpdateFlag = projection.updateFlag;
  129960. this._alternateViewMatrix = view;
  129961. this._alternateProjectionMatrix = projection;
  129962. if (!this._alternateTransformMatrix) {
  129963. this._alternateTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  129964. }
  129965. this._alternateViewMatrix.multiplyToRef(this._alternateProjectionMatrix, this._alternateTransformMatrix);
  129966. if (!this._alternateSceneUbo) {
  129967. this._createAlternateUbo();
  129968. }
  129969. if (this._alternateSceneUbo.useUbo) {
  129970. this._alternateSceneUbo.updateMatrix("viewProjection", this._alternateTransformMatrix);
  129971. this._alternateSceneUbo.updateMatrix("view", this._alternateViewMatrix);
  129972. this._alternateSceneUbo.update();
  129973. }
  129974. };
  129975. /**
  129976. * Gets the uniform buffer used to store scene data
  129977. * @returns a UniformBuffer
  129978. */
  129979. Scene.prototype.getSceneUniformBuffer = function () {
  129980. return this._useAlternateCameraConfiguration ? this._alternateSceneUbo : this._sceneUbo;
  129981. };
  129982. /**
  129983. * Gets an unique (relatively to the current scene) Id
  129984. * @returns an unique number for the scene
  129985. */
  129986. Scene.prototype.getUniqueId = function () {
  129987. var result = Scene._uniqueIdCounter;
  129988. Scene._uniqueIdCounter++;
  129989. return result;
  129990. };
  129991. /**
  129992. * Add a mesh to the list of scene's meshes
  129993. * @param newMesh defines the mesh to add
  129994. * @param recursive if all child meshes should also be added to the scene
  129995. */
  129996. Scene.prototype.addMesh = function (newMesh, recursive) {
  129997. var _this = this;
  129998. if (recursive === void 0) { recursive = false; }
  129999. this.meshes.push(newMesh);
  130000. newMesh._resyncLightSources();
  130001. this.onNewMeshAddedObservable.notifyObservers(newMesh);
  130002. if (recursive) {
  130003. newMesh.getChildMeshes().forEach(function (m) {
  130004. _this.addMesh(m);
  130005. });
  130006. }
  130007. };
  130008. /**
  130009. * Remove a mesh for the list of scene's meshes
  130010. * @param toRemove defines the mesh to remove
  130011. * @param recursive if all child meshes should also be removed from the scene
  130012. * @returns the index where the mesh was in the mesh list
  130013. */
  130014. Scene.prototype.removeMesh = function (toRemove, recursive) {
  130015. var _this = this;
  130016. if (recursive === void 0) { recursive = false; }
  130017. var index = this.meshes.indexOf(toRemove);
  130018. if (index !== -1) {
  130019. // Remove from the scene if mesh found
  130020. this.meshes[index] = this.meshes[this.meshes.length - 1];
  130021. this.meshes.pop();
  130022. }
  130023. this.onMeshRemovedObservable.notifyObservers(toRemove);
  130024. if (recursive) {
  130025. toRemove.getChildMeshes().forEach(function (m) {
  130026. _this.removeMesh(m);
  130027. });
  130028. }
  130029. return index;
  130030. };
  130031. /**
  130032. * Add a transform node to the list of scene's transform nodes
  130033. * @param newTransformNode defines the transform node to add
  130034. */
  130035. Scene.prototype.addTransformNode = function (newTransformNode) {
  130036. newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
  130037. this.transformNodes.push(newTransformNode);
  130038. this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
  130039. };
  130040. /**
  130041. * Remove a transform node for the list of scene's transform nodes
  130042. * @param toRemove defines the transform node to remove
  130043. * @returns the index where the transform node was in the transform node list
  130044. */
  130045. Scene.prototype.removeTransformNode = function (toRemove) {
  130046. var index = toRemove._indexInSceneTransformNodesArray;
  130047. if (index !== -1) {
  130048. if (index !== this.transformNodes.length - 1) {
  130049. var lastNode = this.transformNodes[this.transformNodes.length - 1];
  130050. this.transformNodes[index] = lastNode;
  130051. lastNode._indexInSceneTransformNodesArray = index;
  130052. }
  130053. toRemove._indexInSceneTransformNodesArray = -1;
  130054. this.transformNodes.pop();
  130055. }
  130056. this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
  130057. return index;
  130058. };
  130059. /**
  130060. * Remove a skeleton for the list of scene's skeletons
  130061. * @param toRemove defines the skeleton to remove
  130062. * @returns the index where the skeleton was in the skeleton list
  130063. */
  130064. Scene.prototype.removeSkeleton = function (toRemove) {
  130065. var index = this.skeletons.indexOf(toRemove);
  130066. if (index !== -1) {
  130067. // Remove from the scene if found
  130068. this.skeletons.splice(index, 1);
  130069. }
  130070. return index;
  130071. };
  130072. /**
  130073. * Remove a morph target for the list of scene's morph targets
  130074. * @param toRemove defines the morph target to remove
  130075. * @returns the index where the morph target was in the morph target list
  130076. */
  130077. Scene.prototype.removeMorphTargetManager = function (toRemove) {
  130078. var index = this.morphTargetManagers.indexOf(toRemove);
  130079. if (index !== -1) {
  130080. // Remove from the scene if found
  130081. this.morphTargetManagers.splice(index, 1);
  130082. }
  130083. return index;
  130084. };
  130085. /**
  130086. * Remove a light for the list of scene's lights
  130087. * @param toRemove defines the light to remove
  130088. * @returns the index where the light was in the light list
  130089. */
  130090. Scene.prototype.removeLight = function (toRemove) {
  130091. var index = this.lights.indexOf(toRemove);
  130092. if (index !== -1) {
  130093. // Remove from meshes
  130094. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  130095. var mesh = _a[_i];
  130096. mesh._removeLightSource(toRemove);
  130097. }
  130098. // Remove from the scene if mesh found
  130099. this.lights.splice(index, 1);
  130100. this.sortLightsByPriority();
  130101. }
  130102. this.onLightRemovedObservable.notifyObservers(toRemove);
  130103. return index;
  130104. };
  130105. /**
  130106. * Remove a camera for the list of scene's cameras
  130107. * @param toRemove defines the camera to remove
  130108. * @returns the index where the camera was in the camera list
  130109. */
  130110. Scene.prototype.removeCamera = function (toRemove) {
  130111. var index = this.cameras.indexOf(toRemove);
  130112. if (index !== -1) {
  130113. // Remove from the scene if mesh found
  130114. this.cameras.splice(index, 1);
  130115. }
  130116. // Remove from activeCameras
  130117. var index2 = this.activeCameras.indexOf(toRemove);
  130118. if (index2 !== -1) {
  130119. // Remove from the scene if mesh found
  130120. this.activeCameras.splice(index2, 1);
  130121. }
  130122. // Reset the activeCamera
  130123. if (this.activeCamera === toRemove) {
  130124. if (this.cameras.length > 0) {
  130125. this.activeCamera = this.cameras[0];
  130126. }
  130127. else {
  130128. this.activeCamera = null;
  130129. }
  130130. }
  130131. this.onCameraRemovedObservable.notifyObservers(toRemove);
  130132. return index;
  130133. };
  130134. /**
  130135. * Remove a particle system for the list of scene's particle systems
  130136. * @param toRemove defines the particle system to remove
  130137. * @returns the index where the particle system was in the particle system list
  130138. */
  130139. Scene.prototype.removeParticleSystem = function (toRemove) {
  130140. var index = this.particleSystems.indexOf(toRemove);
  130141. if (index !== -1) {
  130142. this.particleSystems.splice(index, 1);
  130143. }
  130144. return index;
  130145. };
  130146. /**
  130147. * Remove a animation for the list of scene's animations
  130148. * @param toRemove defines the animation to remove
  130149. * @returns the index where the animation was in the animation list
  130150. */
  130151. Scene.prototype.removeAnimation = function (toRemove) {
  130152. var index = this.animations.indexOf(toRemove);
  130153. if (index !== -1) {
  130154. this.animations.splice(index, 1);
  130155. }
  130156. return index;
  130157. };
  130158. /**
  130159. * Removes the given animation group from this scene.
  130160. * @param toRemove The animation group to remove
  130161. * @returns The index of the removed animation group
  130162. */
  130163. Scene.prototype.removeAnimationGroup = function (toRemove) {
  130164. var index = this.animationGroups.indexOf(toRemove);
  130165. if (index !== -1) {
  130166. this.animationGroups.splice(index, 1);
  130167. }
  130168. return index;
  130169. };
  130170. /**
  130171. * Removes the given multi-material from this scene.
  130172. * @param toRemove The multi-material to remove
  130173. * @returns The index of the removed multi-material
  130174. */
  130175. Scene.prototype.removeMultiMaterial = function (toRemove) {
  130176. var index = this.multiMaterials.indexOf(toRemove);
  130177. if (index !== -1) {
  130178. this.multiMaterials.splice(index, 1);
  130179. }
  130180. return index;
  130181. };
  130182. /**
  130183. * Removes the given material from this scene.
  130184. * @param toRemove The material to remove
  130185. * @returns The index of the removed material
  130186. */
  130187. Scene.prototype.removeMaterial = function (toRemove) {
  130188. var index = toRemove._indexInSceneMaterialArray;
  130189. if (index !== -1 && index < this.materials.length) {
  130190. if (index !== this.materials.length - 1) {
  130191. var lastMaterial = this.materials[this.materials.length - 1];
  130192. this.materials[index] = lastMaterial;
  130193. lastMaterial._indexInSceneMaterialArray = index;
  130194. }
  130195. toRemove._indexInSceneMaterialArray = -1;
  130196. this.materials.pop();
  130197. }
  130198. this.onMaterialRemovedObservable.notifyObservers(toRemove);
  130199. return index;
  130200. };
  130201. /**
  130202. * Removes the given action manager from this scene.
  130203. * @param toRemove The action manager to remove
  130204. * @returns The index of the removed action manager
  130205. */
  130206. Scene.prototype.removeActionManager = function (toRemove) {
  130207. var index = this.actionManagers.indexOf(toRemove);
  130208. if (index !== -1) {
  130209. this.actionManagers.splice(index, 1);
  130210. }
  130211. return index;
  130212. };
  130213. /**
  130214. * Removes the given texture from this scene.
  130215. * @param toRemove The texture to remove
  130216. * @returns The index of the removed texture
  130217. */
  130218. Scene.prototype.removeTexture = function (toRemove) {
  130219. var index = this.textures.indexOf(toRemove);
  130220. if (index !== -1) {
  130221. this.textures.splice(index, 1);
  130222. }
  130223. this.onTextureRemovedObservable.notifyObservers(toRemove);
  130224. return index;
  130225. };
  130226. /**
  130227. * Adds the given light to this scene
  130228. * @param newLight The light to add
  130229. */
  130230. Scene.prototype.addLight = function (newLight) {
  130231. this.lights.push(newLight);
  130232. this.sortLightsByPriority();
  130233. // Add light to all meshes (To support if the light is removed and then readded)
  130234. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  130235. var mesh = _a[_i];
  130236. if (mesh._lightSources.indexOf(newLight) === -1) {
  130237. mesh._lightSources.push(newLight);
  130238. mesh._resyncLightSources();
  130239. }
  130240. }
  130241. this.onNewLightAddedObservable.notifyObservers(newLight);
  130242. };
  130243. /**
  130244. * Sorts the list list based on light priorities
  130245. */
  130246. Scene.prototype.sortLightsByPriority = function () {
  130247. if (this.requireLightSorting) {
  130248. this.lights.sort(_Lights_light__WEBPACK_IMPORTED_MODULE_13__["Light"].CompareLightsPriority);
  130249. }
  130250. };
  130251. /**
  130252. * Adds the given camera to this scene
  130253. * @param newCamera The camera to add
  130254. */
  130255. Scene.prototype.addCamera = function (newCamera) {
  130256. this.cameras.push(newCamera);
  130257. this.onNewCameraAddedObservable.notifyObservers(newCamera);
  130258. };
  130259. /**
  130260. * Adds the given skeleton to this scene
  130261. * @param newSkeleton The skeleton to add
  130262. */
  130263. Scene.prototype.addSkeleton = function (newSkeleton) {
  130264. this.skeletons.push(newSkeleton);
  130265. };
  130266. /**
  130267. * Adds the given particle system to this scene
  130268. * @param newParticleSystem The particle system to add
  130269. */
  130270. Scene.prototype.addParticleSystem = function (newParticleSystem) {
  130271. this.particleSystems.push(newParticleSystem);
  130272. };
  130273. /**
  130274. * Adds the given animation to this scene
  130275. * @param newAnimation The animation to add
  130276. */
  130277. Scene.prototype.addAnimation = function (newAnimation) {
  130278. this.animations.push(newAnimation);
  130279. };
  130280. /**
  130281. * Adds the given animation group to this scene.
  130282. * @param newAnimationGroup The animation group to add
  130283. */
  130284. Scene.prototype.addAnimationGroup = function (newAnimationGroup) {
  130285. this.animationGroups.push(newAnimationGroup);
  130286. };
  130287. /**
  130288. * Adds the given multi-material to this scene
  130289. * @param newMultiMaterial The multi-material to add
  130290. */
  130291. Scene.prototype.addMultiMaterial = function (newMultiMaterial) {
  130292. this.multiMaterials.push(newMultiMaterial);
  130293. };
  130294. /**
  130295. * Adds the given material to this scene
  130296. * @param newMaterial The material to add
  130297. */
  130298. Scene.prototype.addMaterial = function (newMaterial) {
  130299. newMaterial._indexInSceneMaterialArray = this.materials.length;
  130300. this.materials.push(newMaterial);
  130301. this.onNewMaterialAddedObservable.notifyObservers(newMaterial);
  130302. };
  130303. /**
  130304. * Adds the given morph target to this scene
  130305. * @param newMorphTargetManager The morph target to add
  130306. */
  130307. Scene.prototype.addMorphTargetManager = function (newMorphTargetManager) {
  130308. this.morphTargetManagers.push(newMorphTargetManager);
  130309. };
  130310. /**
  130311. * Adds the given geometry to this scene
  130312. * @param newGeometry The geometry to add
  130313. */
  130314. Scene.prototype.addGeometry = function (newGeometry) {
  130315. if (this.geometriesByUniqueId) {
  130316. this.geometriesByUniqueId[newGeometry.uniqueId] = this.geometries.length;
  130317. }
  130318. this.geometries.push(newGeometry);
  130319. };
  130320. /**
  130321. * Adds the given action manager to this scene
  130322. * @param newActionManager The action manager to add
  130323. */
  130324. Scene.prototype.addActionManager = function (newActionManager) {
  130325. this.actionManagers.push(newActionManager);
  130326. };
  130327. /**
  130328. * Adds the given texture to this scene.
  130329. * @param newTexture The texture to add
  130330. */
  130331. Scene.prototype.addTexture = function (newTexture) {
  130332. this.textures.push(newTexture);
  130333. this.onNewTextureAddedObservable.notifyObservers(newTexture);
  130334. };
  130335. /**
  130336. * Switch active camera
  130337. * @param newCamera defines the new active camera
  130338. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  130339. */
  130340. Scene.prototype.switchActiveCamera = function (newCamera, attachControl) {
  130341. if (attachControl === void 0) { attachControl = true; }
  130342. var canvas = this._engine.getRenderingCanvas();
  130343. if (!canvas) {
  130344. return;
  130345. }
  130346. if (this.activeCamera) {
  130347. this.activeCamera.detachControl(canvas);
  130348. }
  130349. this.activeCamera = newCamera;
  130350. if (attachControl) {
  130351. newCamera.attachControl(canvas);
  130352. }
  130353. };
  130354. /**
  130355. * sets the active camera of the scene using its ID
  130356. * @param id defines the camera's ID
  130357. * @return the new active camera or null if none found.
  130358. */
  130359. Scene.prototype.setActiveCameraByID = function (id) {
  130360. var camera = this.getCameraByID(id);
  130361. if (camera) {
  130362. this.activeCamera = camera;
  130363. return camera;
  130364. }
  130365. return null;
  130366. };
  130367. /**
  130368. * sets the active camera of the scene using its name
  130369. * @param name defines the camera's name
  130370. * @returns the new active camera or null if none found.
  130371. */
  130372. Scene.prototype.setActiveCameraByName = function (name) {
  130373. var camera = this.getCameraByName(name);
  130374. if (camera) {
  130375. this.activeCamera = camera;
  130376. return camera;
  130377. }
  130378. return null;
  130379. };
  130380. /**
  130381. * get an animation group using its name
  130382. * @param name defines the material's name
  130383. * @return the animation group or null if none found.
  130384. */
  130385. Scene.prototype.getAnimationGroupByName = function (name) {
  130386. for (var index = 0; index < this.animationGroups.length; index++) {
  130387. if (this.animationGroups[index].name === name) {
  130388. return this.animationGroups[index];
  130389. }
  130390. }
  130391. return null;
  130392. };
  130393. /**
  130394. * get a material using its id
  130395. * @param id defines the material's ID
  130396. * @return the material or null if none found.
  130397. */
  130398. Scene.prototype.getMaterialByID = function (id) {
  130399. for (var index = 0; index < this.materials.length; index++) {
  130400. if (this.materials[index].id === id) {
  130401. return this.materials[index];
  130402. }
  130403. }
  130404. return null;
  130405. };
  130406. /**
  130407. * Gets a material using its name
  130408. * @param name defines the material's name
  130409. * @return the material or null if none found.
  130410. */
  130411. Scene.prototype.getMaterialByName = function (name) {
  130412. for (var index = 0; index < this.materials.length; index++) {
  130413. if (this.materials[index].name === name) {
  130414. return this.materials[index];
  130415. }
  130416. }
  130417. return null;
  130418. };
  130419. /**
  130420. * Gets a camera using its id
  130421. * @param id defines the id to look for
  130422. * @returns the camera or null if not found
  130423. */
  130424. Scene.prototype.getCameraByID = function (id) {
  130425. for (var index = 0; index < this.cameras.length; index++) {
  130426. if (this.cameras[index].id === id) {
  130427. return this.cameras[index];
  130428. }
  130429. }
  130430. return null;
  130431. };
  130432. /**
  130433. * Gets a camera using its unique id
  130434. * @param uniqueId defines the unique id to look for
  130435. * @returns the camera or null if not found
  130436. */
  130437. Scene.prototype.getCameraByUniqueID = function (uniqueId) {
  130438. for (var index = 0; index < this.cameras.length; index++) {
  130439. if (this.cameras[index].uniqueId === uniqueId) {
  130440. return this.cameras[index];
  130441. }
  130442. }
  130443. return null;
  130444. };
  130445. /**
  130446. * Gets a camera using its name
  130447. * @param name defines the camera's name
  130448. * @return the camera or null if none found.
  130449. */
  130450. Scene.prototype.getCameraByName = function (name) {
  130451. for (var index = 0; index < this.cameras.length; index++) {
  130452. if (this.cameras[index].name === name) {
  130453. return this.cameras[index];
  130454. }
  130455. }
  130456. return null;
  130457. };
  130458. /**
  130459. * Gets a bone using its id
  130460. * @param id defines the bone's id
  130461. * @return the bone or null if not found
  130462. */
  130463. Scene.prototype.getBoneByID = function (id) {
  130464. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  130465. var skeleton = this.skeletons[skeletonIndex];
  130466. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  130467. if (skeleton.bones[boneIndex].id === id) {
  130468. return skeleton.bones[boneIndex];
  130469. }
  130470. }
  130471. }
  130472. return null;
  130473. };
  130474. /**
  130475. * Gets a bone using its id
  130476. * @param name defines the bone's name
  130477. * @return the bone or null if not found
  130478. */
  130479. Scene.prototype.getBoneByName = function (name) {
  130480. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  130481. var skeleton = this.skeletons[skeletonIndex];
  130482. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  130483. if (skeleton.bones[boneIndex].name === name) {
  130484. return skeleton.bones[boneIndex];
  130485. }
  130486. }
  130487. }
  130488. return null;
  130489. };
  130490. /**
  130491. * Gets a light node using its name
  130492. * @param name defines the the light's name
  130493. * @return the light or null if none found.
  130494. */
  130495. Scene.prototype.getLightByName = function (name) {
  130496. for (var index = 0; index < this.lights.length; index++) {
  130497. if (this.lights[index].name === name) {
  130498. return this.lights[index];
  130499. }
  130500. }
  130501. return null;
  130502. };
  130503. /**
  130504. * Gets a light node using its id
  130505. * @param id defines the light's id
  130506. * @return the light or null if none found.
  130507. */
  130508. Scene.prototype.getLightByID = function (id) {
  130509. for (var index = 0; index < this.lights.length; index++) {
  130510. if (this.lights[index].id === id) {
  130511. return this.lights[index];
  130512. }
  130513. }
  130514. return null;
  130515. };
  130516. /**
  130517. * Gets a light node using its scene-generated unique ID
  130518. * @param uniqueId defines the light's unique id
  130519. * @return the light or null if none found.
  130520. */
  130521. Scene.prototype.getLightByUniqueID = function (uniqueId) {
  130522. for (var index = 0; index < this.lights.length; index++) {
  130523. if (this.lights[index].uniqueId === uniqueId) {
  130524. return this.lights[index];
  130525. }
  130526. }
  130527. return null;
  130528. };
  130529. /**
  130530. * Gets a particle system by id
  130531. * @param id defines the particle system id
  130532. * @return the corresponding system or null if none found
  130533. */
  130534. Scene.prototype.getParticleSystemByID = function (id) {
  130535. for (var index = 0; index < this.particleSystems.length; index++) {
  130536. if (this.particleSystems[index].id === id) {
  130537. return this.particleSystems[index];
  130538. }
  130539. }
  130540. return null;
  130541. };
  130542. /**
  130543. * Gets a geometry using its ID
  130544. * @param id defines the geometry's id
  130545. * @return the geometry or null if none found.
  130546. */
  130547. Scene.prototype.getGeometryByID = function (id) {
  130548. for (var index = 0; index < this.geometries.length; index++) {
  130549. if (this.geometries[index].id === id) {
  130550. return this.geometries[index];
  130551. }
  130552. }
  130553. return null;
  130554. };
  130555. Scene.prototype._getGeometryByUniqueID = function (uniqueId) {
  130556. if (this.geometriesByUniqueId) {
  130557. var index_1 = this.geometriesByUniqueId[uniqueId];
  130558. if (index_1 !== undefined) {
  130559. return this.geometries[index_1];
  130560. }
  130561. }
  130562. else {
  130563. for (var index = 0; index < this.geometries.length; index++) {
  130564. if (this.geometries[index].uniqueId === uniqueId) {
  130565. return this.geometries[index];
  130566. }
  130567. }
  130568. }
  130569. return null;
  130570. };
  130571. /**
  130572. * Add a new geometry to this scene
  130573. * @param geometry defines the geometry to be added to the scene.
  130574. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  130575. * @return a boolean defining if the geometry was added or not
  130576. */
  130577. Scene.prototype.pushGeometry = function (geometry, force) {
  130578. if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
  130579. return false;
  130580. }
  130581. this.addGeometry(geometry);
  130582. this.onNewGeometryAddedObservable.notifyObservers(geometry);
  130583. return true;
  130584. };
  130585. /**
  130586. * Removes an existing geometry
  130587. * @param geometry defines the geometry to be removed from the scene
  130588. * @return a boolean defining if the geometry was removed or not
  130589. */
  130590. Scene.prototype.removeGeometry = function (geometry) {
  130591. var index;
  130592. if (this.geometriesByUniqueId) {
  130593. index = this.geometriesByUniqueId[geometry.uniqueId];
  130594. if (index === undefined) {
  130595. return false;
  130596. }
  130597. }
  130598. else {
  130599. index = this.geometries.indexOf(geometry);
  130600. if (index < 0) {
  130601. return false;
  130602. }
  130603. }
  130604. if (index !== this.geometries.length - 1) {
  130605. var lastGeometry = this.geometries[this.geometries.length - 1];
  130606. this.geometries[index] = lastGeometry;
  130607. if (this.geometriesByUniqueId) {
  130608. this.geometriesByUniqueId[lastGeometry.uniqueId] = index;
  130609. this.geometriesByUniqueId[geometry.uniqueId] = undefined;
  130610. }
  130611. }
  130612. this.geometries.pop();
  130613. this.onGeometryRemovedObservable.notifyObservers(geometry);
  130614. return true;
  130615. };
  130616. /**
  130617. * Gets the list of geometries attached to the scene
  130618. * @returns an array of Geometry
  130619. */
  130620. Scene.prototype.getGeometries = function () {
  130621. return this.geometries;
  130622. };
  130623. /**
  130624. * Gets the first added mesh found of a given ID
  130625. * @param id defines the id to search for
  130626. * @return the mesh found or null if not found at all
  130627. */
  130628. Scene.prototype.getMeshByID = function (id) {
  130629. for (var index = 0; index < this.meshes.length; index++) {
  130630. if (this.meshes[index].id === id) {
  130631. return this.meshes[index];
  130632. }
  130633. }
  130634. return null;
  130635. };
  130636. /**
  130637. * Gets a list of meshes using their id
  130638. * @param id defines the id to search for
  130639. * @returns a list of meshes
  130640. */
  130641. Scene.prototype.getMeshesByID = function (id) {
  130642. return this.meshes.filter(function (m) {
  130643. return m.id === id;
  130644. });
  130645. };
  130646. /**
  130647. * Gets the first added transform node found of a given ID
  130648. * @param id defines the id to search for
  130649. * @return the found transform node or null if not found at all.
  130650. */
  130651. Scene.prototype.getTransformNodeByID = function (id) {
  130652. for (var index = 0; index < this.transformNodes.length; index++) {
  130653. if (this.transformNodes[index].id === id) {
  130654. return this.transformNodes[index];
  130655. }
  130656. }
  130657. return null;
  130658. };
  130659. /**
  130660. * Gets a list of transform nodes using their id
  130661. * @param id defines the id to search for
  130662. * @returns a list of transform nodes
  130663. */
  130664. Scene.prototype.getTransformNodesByID = function (id) {
  130665. return this.transformNodes.filter(function (m) {
  130666. return m.id === id;
  130667. });
  130668. };
  130669. /**
  130670. * Gets a mesh with its auto-generated unique id
  130671. * @param uniqueId defines the unique id to search for
  130672. * @return the found mesh or null if not found at all.
  130673. */
  130674. Scene.prototype.getMeshByUniqueID = function (uniqueId) {
  130675. for (var index = 0; index < this.meshes.length; index++) {
  130676. if (this.meshes[index].uniqueId === uniqueId) {
  130677. return this.meshes[index];
  130678. }
  130679. }
  130680. return null;
  130681. };
  130682. /**
  130683. * Gets a the last added mesh using a given id
  130684. * @param id defines the id to search for
  130685. * @return the found mesh or null if not found at all.
  130686. */
  130687. Scene.prototype.getLastMeshByID = function (id) {
  130688. for (var index = this.meshes.length - 1; index >= 0; index--) {
  130689. if (this.meshes[index].id === id) {
  130690. return this.meshes[index];
  130691. }
  130692. }
  130693. return null;
  130694. };
  130695. /**
  130696. * Gets a the last added node (Mesh, Camera, Light) using a given id
  130697. * @param id defines the id to search for
  130698. * @return the found node or null if not found at all
  130699. */
  130700. Scene.prototype.getLastEntryByID = function (id) {
  130701. var index;
  130702. for (index = this.meshes.length - 1; index >= 0; index--) {
  130703. if (this.meshes[index].id === id) {
  130704. return this.meshes[index];
  130705. }
  130706. }
  130707. for (index = this.transformNodes.length - 1; index >= 0; index--) {
  130708. if (this.transformNodes[index].id === id) {
  130709. return this.transformNodes[index];
  130710. }
  130711. }
  130712. for (index = this.cameras.length - 1; index >= 0; index--) {
  130713. if (this.cameras[index].id === id) {
  130714. return this.cameras[index];
  130715. }
  130716. }
  130717. for (index = this.lights.length - 1; index >= 0; index--) {
  130718. if (this.lights[index].id === id) {
  130719. return this.lights[index];
  130720. }
  130721. }
  130722. return null;
  130723. };
  130724. /**
  130725. * Gets a node (Mesh, Camera, Light) using a given id
  130726. * @param id defines the id to search for
  130727. * @return the found node or null if not found at all
  130728. */
  130729. Scene.prototype.getNodeByID = function (id) {
  130730. var mesh = this.getMeshByID(id);
  130731. if (mesh) {
  130732. return mesh;
  130733. }
  130734. var transformNode = this.getTransformNodeByID(id);
  130735. if (transformNode) {
  130736. return transformNode;
  130737. }
  130738. var light = this.getLightByID(id);
  130739. if (light) {
  130740. return light;
  130741. }
  130742. var camera = this.getCameraByID(id);
  130743. if (camera) {
  130744. return camera;
  130745. }
  130746. var bone = this.getBoneByID(id);
  130747. if (bone) {
  130748. return bone;
  130749. }
  130750. return null;
  130751. };
  130752. /**
  130753. * Gets a node (Mesh, Camera, Light) using a given name
  130754. * @param name defines the name to search for
  130755. * @return the found node or null if not found at all.
  130756. */
  130757. Scene.prototype.getNodeByName = function (name) {
  130758. var mesh = this.getMeshByName(name);
  130759. if (mesh) {
  130760. return mesh;
  130761. }
  130762. var transformNode = this.getTransformNodeByName(name);
  130763. if (transformNode) {
  130764. return transformNode;
  130765. }
  130766. var light = this.getLightByName(name);
  130767. if (light) {
  130768. return light;
  130769. }
  130770. var camera = this.getCameraByName(name);
  130771. if (camera) {
  130772. return camera;
  130773. }
  130774. var bone = this.getBoneByName(name);
  130775. if (bone) {
  130776. return bone;
  130777. }
  130778. return null;
  130779. };
  130780. /**
  130781. * Gets a mesh using a given name
  130782. * @param name defines the name to search for
  130783. * @return the found mesh or null if not found at all.
  130784. */
  130785. Scene.prototype.getMeshByName = function (name) {
  130786. for (var index = 0; index < this.meshes.length; index++) {
  130787. if (this.meshes[index].name === name) {
  130788. return this.meshes[index];
  130789. }
  130790. }
  130791. return null;
  130792. };
  130793. /**
  130794. * Gets a transform node using a given name
  130795. * @param name defines the name to search for
  130796. * @return the found transform node or null if not found at all.
  130797. */
  130798. Scene.prototype.getTransformNodeByName = function (name) {
  130799. for (var index = 0; index < this.transformNodes.length; index++) {
  130800. if (this.transformNodes[index].name === name) {
  130801. return this.transformNodes[index];
  130802. }
  130803. }
  130804. return null;
  130805. };
  130806. /**
  130807. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  130808. * @param id defines the id to search for
  130809. * @return the found skeleton or null if not found at all.
  130810. */
  130811. Scene.prototype.getLastSkeletonByID = function (id) {
  130812. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  130813. if (this.skeletons[index].id === id) {
  130814. return this.skeletons[index];
  130815. }
  130816. }
  130817. return null;
  130818. };
  130819. /**
  130820. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  130821. * @param id defines the id to search for
  130822. * @return the found skeleton or null if not found at all.
  130823. */
  130824. Scene.prototype.getSkeletonById = function (id) {
  130825. for (var index = 0; index < this.skeletons.length; index++) {
  130826. if (this.skeletons[index].id === id) {
  130827. return this.skeletons[index];
  130828. }
  130829. }
  130830. return null;
  130831. };
  130832. /**
  130833. * Gets a skeleton using a given name
  130834. * @param name defines the name to search for
  130835. * @return the found skeleton or null if not found at all.
  130836. */
  130837. Scene.prototype.getSkeletonByName = function (name) {
  130838. for (var index = 0; index < this.skeletons.length; index++) {
  130839. if (this.skeletons[index].name === name) {
  130840. return this.skeletons[index];
  130841. }
  130842. }
  130843. return null;
  130844. };
  130845. /**
  130846. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  130847. * @param id defines the id to search for
  130848. * @return the found morph target manager or null if not found at all.
  130849. */
  130850. Scene.prototype.getMorphTargetManagerById = function (id) {
  130851. for (var index = 0; index < this.morphTargetManagers.length; index++) {
  130852. if (this.morphTargetManagers[index].uniqueId === id) {
  130853. return this.morphTargetManagers[index];
  130854. }
  130855. }
  130856. return null;
  130857. };
  130858. /**
  130859. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  130860. * @param id defines the id to search for
  130861. * @return the found morph target or null if not found at all.
  130862. */
  130863. Scene.prototype.getMorphTargetById = function (id) {
  130864. for (var managerIndex = 0; managerIndex < this.morphTargetManagers.length; ++managerIndex) {
  130865. var morphTargetManager = this.morphTargetManagers[managerIndex];
  130866. for (var index = 0; index < morphTargetManager.numTargets; ++index) {
  130867. var target = morphTargetManager.getTarget(index);
  130868. if (target.id === id) {
  130869. return target;
  130870. }
  130871. }
  130872. }
  130873. return null;
  130874. };
  130875. /**
  130876. * Gets a boolean indicating if the given mesh is active
  130877. * @param mesh defines the mesh to look for
  130878. * @returns true if the mesh is in the active list
  130879. */
  130880. Scene.prototype.isActiveMesh = function (mesh) {
  130881. return (this._activeMeshes.indexOf(mesh) !== -1);
  130882. };
  130883. Object.defineProperty(Scene.prototype, "uid", {
  130884. /**
  130885. * Return a unique id as a string which can serve as an identifier for the scene
  130886. */
  130887. get: function () {
  130888. if (!this._uid) {
  130889. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].RandomId();
  130890. }
  130891. return this._uid;
  130892. },
  130893. enumerable: true,
  130894. configurable: true
  130895. });
  130896. /**
  130897. * Add an externaly attached data from its key.
  130898. * This method call will fail and return false, if such key already exists.
  130899. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  130900. * @param key the unique key that identifies the data
  130901. * @param data the data object to associate to the key for this Engine instance
  130902. * @return true if no such key were already present and the data was added successfully, false otherwise
  130903. */
  130904. Scene.prototype.addExternalData = function (key, data) {
  130905. if (!this._externalData) {
  130906. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  130907. }
  130908. return this._externalData.add(key, data);
  130909. };
  130910. /**
  130911. * Get an externaly attached data from its key
  130912. * @param key the unique key that identifies the data
  130913. * @return the associated data, if present (can be null), or undefined if not present
  130914. */
  130915. Scene.prototype.getExternalData = function (key) {
  130916. if (!this._externalData) {
  130917. return null;
  130918. }
  130919. return this._externalData.get(key);
  130920. };
  130921. /**
  130922. * Get an externaly attached data from its key, create it using a factory if it's not already present
  130923. * @param key the unique key that identifies the data
  130924. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  130925. * @return the associated data, can be null if the factory returned null.
  130926. */
  130927. Scene.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  130928. if (!this._externalData) {
  130929. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  130930. }
  130931. return this._externalData.getOrAddWithFactory(key, factory);
  130932. };
  130933. /**
  130934. * Remove an externaly attached data from the Engine instance
  130935. * @param key the unique key that identifies the data
  130936. * @return true if the data was successfully removed, false if it doesn't exist
  130937. */
  130938. Scene.prototype.removeExternalData = function (key) {
  130939. return this._externalData.remove(key);
  130940. };
  130941. Scene.prototype._evaluateSubMesh = function (subMesh, mesh) {
  130942. if (this.dispatchAllSubMeshesOfActiveMeshes || mesh.alwaysSelectAsActiveMesh || mesh.subMeshes.length === 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  130943. for (var _i = 0, _a = this._evaluateSubMeshStage; _i < _a.length; _i++) {
  130944. var step = _a[_i];
  130945. step.action(mesh, subMesh);
  130946. }
  130947. var material = subMesh.getMaterial();
  130948. if (material !== null && material !== undefined) {
  130949. // Render targets
  130950. if (material.hasRenderTargetTextures && material.getRenderTargetTextures !== undefined) {
  130951. if (this._processedMaterials.indexOf(material) === -1) {
  130952. this._processedMaterials.push(material);
  130953. this._renderTargets.concatWithNoDuplicate(material.getRenderTargetTextures());
  130954. }
  130955. }
  130956. // Dispatch
  130957. this._activeIndices.addCount(subMesh.indexCount, false);
  130958. this._renderingManager.dispatch(subMesh, mesh, material);
  130959. }
  130960. }
  130961. };
  130962. /**
  130963. * Clear the processed materials smart array preventing retention point in material dispose.
  130964. */
  130965. Scene.prototype.freeProcessedMaterials = function () {
  130966. this._processedMaterials.dispose();
  130967. };
  130968. Object.defineProperty(Scene.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  130969. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  130970. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  130971. * when disposing several meshes in a row or a hierarchy of meshes.
  130972. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  130973. */
  130974. get: function () {
  130975. return this._preventFreeActiveMeshesAndRenderingGroups;
  130976. },
  130977. set: function (value) {
  130978. if (this._preventFreeActiveMeshesAndRenderingGroups === value) {
  130979. return;
  130980. }
  130981. if (value) {
  130982. this.freeActiveMeshes();
  130983. this.freeRenderingGroups();
  130984. }
  130985. this._preventFreeActiveMeshesAndRenderingGroups = value;
  130986. },
  130987. enumerable: true,
  130988. configurable: true
  130989. });
  130990. /**
  130991. * Clear the active meshes smart array preventing retention point in mesh dispose.
  130992. */
  130993. Scene.prototype.freeActiveMeshes = function () {
  130994. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  130995. return;
  130996. }
  130997. this._activeMeshes.dispose();
  130998. if (this.activeCamera && this.activeCamera._activeMeshes) {
  130999. this.activeCamera._activeMeshes.dispose();
  131000. }
  131001. if (this.activeCameras) {
  131002. for (var i = 0; i < this.activeCameras.length; i++) {
  131003. var activeCamera = this.activeCameras[i];
  131004. if (activeCamera && activeCamera._activeMeshes) {
  131005. activeCamera._activeMeshes.dispose();
  131006. }
  131007. }
  131008. }
  131009. };
  131010. /**
  131011. * Clear the info related to rendering groups preventing retention points during dispose.
  131012. */
  131013. Scene.prototype.freeRenderingGroups = function () {
  131014. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  131015. return;
  131016. }
  131017. if (this._renderingManager) {
  131018. this._renderingManager.freeRenderingGroups();
  131019. }
  131020. if (this.textures) {
  131021. for (var i = 0; i < this.textures.length; i++) {
  131022. var texture = this.textures[i];
  131023. if (texture && texture.renderList) {
  131024. texture.freeRenderingGroups();
  131025. }
  131026. }
  131027. }
  131028. };
  131029. /** @hidden */
  131030. Scene.prototype._isInIntermediateRendering = function () {
  131031. return this._intermediateRendering;
  131032. };
  131033. /**
  131034. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  131035. * @returns the current scene
  131036. */
  131037. Scene.prototype.freezeActiveMeshes = function () {
  131038. if (!this.activeCamera) {
  131039. return this;
  131040. }
  131041. if (!this._frustumPlanes) {
  131042. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  131043. }
  131044. this._evaluateActiveMeshes();
  131045. this._activeMeshesFrozen = true;
  131046. return this;
  131047. };
  131048. /**
  131049. * Use this function to restart evaluating active meshes on every frame
  131050. * @returns the current scene
  131051. */
  131052. Scene.prototype.unfreezeActiveMeshes = function () {
  131053. this._activeMeshesFrozen = false;
  131054. return this;
  131055. };
  131056. Scene.prototype._evaluateActiveMeshes = function () {
  131057. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  131058. return;
  131059. }
  131060. if (!this.activeCamera) {
  131061. return;
  131062. }
  131063. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this);
  131064. this.activeCamera._activeMeshes.reset();
  131065. this._activeMeshes.reset();
  131066. this._renderingManager.reset();
  131067. this._processedMaterials.reset();
  131068. this._activeParticleSystems.reset();
  131069. this._activeSkeletons.reset();
  131070. this._softwareSkinnedMeshes.reset();
  131071. for (var _i = 0, _a = this._beforeEvaluateActiveMeshStage; _i < _a.length; _i++) {
  131072. var step = _a[_i];
  131073. step.action();
  131074. }
  131075. // Determine mesh candidates
  131076. var meshes = this.getActiveMeshCandidates();
  131077. // Check each mesh
  131078. var len = meshes.length;
  131079. for (var i = 0; i < len; i++) {
  131080. var mesh = meshes.data[i];
  131081. if (mesh.isBlocked) {
  131082. continue;
  131083. }
  131084. this._totalVertices.addCount(mesh.getTotalVertices(), false);
  131085. if (!mesh.isReady() || !mesh.isEnabled()) {
  131086. continue;
  131087. }
  131088. mesh.computeWorldMatrix();
  131089. // Intersections
  131090. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger, _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger)) {
  131091. this._meshesForIntersections.pushNoDuplicate(mesh);
  131092. }
  131093. // Switch to current LOD
  131094. var meshLOD = mesh.getLOD(this.activeCamera);
  131095. if (meshLOD === undefined || meshLOD === null) {
  131096. continue;
  131097. }
  131098. mesh._preActivate();
  131099. if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
  131100. this._activeMeshes.push(mesh);
  131101. this.activeCamera._activeMeshes.push(mesh);
  131102. mesh._activate(this._renderId);
  131103. if (meshLOD !== mesh) {
  131104. meshLOD._activate(this._renderId);
  131105. }
  131106. this._activeMesh(mesh, meshLOD);
  131107. }
  131108. }
  131109. this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this);
  131110. // Particle systems
  131111. if (this.particlesEnabled) {
  131112. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  131113. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  131114. var particleSystem = this.particleSystems[particleIndex];
  131115. if (!particleSystem.isStarted() || !particleSystem.emitter) {
  131116. continue;
  131117. }
  131118. var emitter = particleSystem.emitter;
  131119. if (!emitter.position || emitter.isEnabled()) {
  131120. this._activeParticleSystems.push(particleSystem);
  131121. particleSystem.animate();
  131122. this._renderingManager.dispatchParticles(particleSystem);
  131123. }
  131124. }
  131125. this.onAfterParticlesRenderingObservable.notifyObservers(this);
  131126. }
  131127. };
  131128. Scene.prototype._activeMesh = function (sourceMesh, mesh) {
  131129. if (this._skeletonsEnabled && mesh.skeleton !== null && mesh.skeleton !== undefined) {
  131130. if (this._activeSkeletons.pushNoDuplicate(mesh.skeleton)) {
  131131. mesh.skeleton.prepare();
  131132. }
  131133. if (!mesh.computeBonesUsingShaders) {
  131134. this._softwareSkinnedMeshes.pushNoDuplicate(mesh);
  131135. }
  131136. }
  131137. for (var _i = 0, _a = this._activeMeshStage; _i < _a.length; _i++) {
  131138. var step = _a[_i];
  131139. step.action(sourceMesh, mesh);
  131140. }
  131141. if (mesh !== undefined && mesh !== null
  131142. && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0) {
  131143. var subMeshes = this.getActiveSubMeshCandidates(mesh);
  131144. var len = subMeshes.length;
  131145. for (var i = 0; i < len; i++) {
  131146. var subMesh = subMeshes.data[i];
  131147. this._evaluateSubMesh(subMesh, mesh);
  131148. }
  131149. }
  131150. };
  131151. /**
  131152. * Update the transform matrix to update from the current active camera
  131153. * @param force defines a boolean used to force the update even if cache is up to date
  131154. */
  131155. Scene.prototype.updateTransformMatrix = function (force) {
  131156. if (!this.activeCamera) {
  131157. return;
  131158. }
  131159. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  131160. };
  131161. /**
  131162. * 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)
  131163. * @param alternateCamera defines the camera to use
  131164. */
  131165. Scene.prototype.updateAlternateTransformMatrix = function (alternateCamera) {
  131166. this._setAlternateTransformMatrix(alternateCamera.getViewMatrix(), alternateCamera.getProjectionMatrix());
  131167. };
  131168. Scene.prototype._renderForCamera = function (camera, rigParent) {
  131169. if (camera && camera._skipRendering) {
  131170. return;
  131171. }
  131172. var engine = this._engine;
  131173. this.activeCamera = camera;
  131174. if (!this.activeCamera) {
  131175. throw new Error("Active camera not set");
  131176. }
  131177. // Viewport
  131178. engine.setViewport(this.activeCamera.viewport);
  131179. // Camera
  131180. this.resetCachedMaterial();
  131181. this._renderId++;
  131182. this.updateTransformMatrix();
  131183. if (camera._alternateCamera) {
  131184. this.updateAlternateTransformMatrix(camera._alternateCamera);
  131185. this._alternateRendering = true;
  131186. }
  131187. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
  131188. // Meshes
  131189. this._evaluateActiveMeshes();
  131190. // Software skinning
  131191. for (var softwareSkinnedMeshIndex = 0; softwareSkinnedMeshIndex < this._softwareSkinnedMeshes.length; softwareSkinnedMeshIndex++) {
  131192. var mesh = this._softwareSkinnedMeshes.data[softwareSkinnedMeshIndex];
  131193. mesh.applySkeleton(mesh.skeleton);
  131194. }
  131195. // Render targets
  131196. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  131197. if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
  131198. this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
  131199. }
  131200. if (rigParent && rigParent.customRenderTargets && rigParent.customRenderTargets.length > 0) {
  131201. this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
  131202. }
  131203. // Collects render targets from external components.
  131204. for (var _i = 0, _a = this._gatherActiveCameraRenderTargetsStage; _i < _a.length; _i++) {
  131205. var step = _a[_i];
  131206. step.action(this._renderTargets);
  131207. }
  131208. if (this.renderTargetsEnabled) {
  131209. this._intermediateRendering = true;
  131210. if (this._renderTargets.length > 0) {
  131211. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  131212. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  131213. var renderTarget = this._renderTargets.data[renderIndex];
  131214. if (renderTarget._shouldRender()) {
  131215. this._renderId++;
  131216. var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
  131217. renderTarget.render(hasSpecialRenderTargetCamera, this.dumpNextRenderTargets);
  131218. }
  131219. }
  131220. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
  131221. this._renderId++;
  131222. }
  131223. for (var _b = 0, _c = this._cameraDrawRenderTargetStage; _b < _c.length; _b++) {
  131224. var step = _c[_b];
  131225. step.action(this.activeCamera);
  131226. }
  131227. this._intermediateRendering = false;
  131228. if (this.activeCamera.outputRenderTarget) {
  131229. var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
  131230. if (internalTexture) {
  131231. engine.bindFramebuffer(internalTexture);
  131232. }
  131233. else {
  131234. _Misc_logger__WEBPACK_IMPORTED_MODULE_23__["Logger"].Error("Camera contains invalid customDefaultRenderTarget");
  131235. }
  131236. }
  131237. else {
  131238. engine.restoreDefaultFramebuffer(); // Restore back buffer if needed
  131239. }
  131240. }
  131241. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  131242. // Prepare Frame
  131243. if (this.postProcessManager) {
  131244. this.postProcessManager._prepareFrame();
  131245. }
  131246. // Before Camera Draw
  131247. for (var _d = 0, _e = this._beforeCameraDrawStage; _d < _e.length; _d++) {
  131248. var step = _e[_d];
  131249. step.action(this.activeCamera);
  131250. }
  131251. // Render
  131252. this.onBeforeDrawPhaseObservable.notifyObservers(this);
  131253. this._renderingManager.render(null, null, true, true);
  131254. this.onAfterDrawPhaseObservable.notifyObservers(this);
  131255. // After Camera Draw
  131256. for (var _f = 0, _g = this._afterCameraDrawStage; _f < _g.length; _f++) {
  131257. var step = _g[_f];
  131258. step.action(this.activeCamera);
  131259. }
  131260. // Finalize frame
  131261. if (this.postProcessManager) {
  131262. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  131263. }
  131264. // Reset some special arrays
  131265. this._renderTargets.reset();
  131266. this._alternateRendering = false;
  131267. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
  131268. };
  131269. Scene.prototype._processSubCameras = function (camera) {
  131270. if (camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  131271. this._renderForCamera(camera);
  131272. return;
  131273. }
  131274. // rig cameras
  131275. for (var index = 0; index < camera._rigCameras.length; index++) {
  131276. this._renderForCamera(camera._rigCameras[index], camera);
  131277. }
  131278. this.activeCamera = camera;
  131279. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  131280. };
  131281. Scene.prototype._checkIntersections = function () {
  131282. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  131283. var sourceMesh = this._meshesForIntersections.data[index];
  131284. if (!sourceMesh.actionManager) {
  131285. continue;
  131286. }
  131287. for (var actionIndex = 0; actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  131288. var action = sourceMesh.actionManager.actions[actionIndex];
  131289. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  131290. var parameters = action.getTriggerParameter();
  131291. var otherMesh = parameters instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameters : parameters.mesh;
  131292. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, parameters.usePreciseIntersection);
  131293. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  131294. if (areIntersecting && currentIntersectionInProgress === -1) {
  131295. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger) {
  131296. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  131297. sourceMesh._intersectionsInProgress.push(otherMesh);
  131298. }
  131299. else if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  131300. sourceMesh._intersectionsInProgress.push(otherMesh);
  131301. }
  131302. }
  131303. else if (!areIntersecting && currentIntersectionInProgress > -1) {
  131304. //They intersected, and now they don't.
  131305. //is this trigger an exit trigger? execute an event.
  131306. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  131307. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  131308. }
  131309. //if this is an exit trigger, or no exit trigger exists, remove the id from the intersection in progress array.
  131310. if (!sourceMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger, function (parameter) {
  131311. var parameterMesh = parameter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameter : parameter.mesh;
  131312. return otherMesh === parameterMesh;
  131313. }) || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  131314. sourceMesh._intersectionsInProgress.splice(currentIntersectionInProgress, 1);
  131315. }
  131316. }
  131317. }
  131318. }
  131319. }
  131320. };
  131321. /** @hidden */
  131322. Scene.prototype._advancePhysicsEngineStep = function (step) {
  131323. // Do nothing. Code will be replaced if physics engine component is referenced
  131324. };
  131325. /** @hidden */
  131326. Scene.prototype._animate = function () {
  131327. // Nothing to do as long as Animatable have not been imported.
  131328. };
  131329. /**
  131330. * Render the scene
  131331. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  131332. */
  131333. Scene.prototype.render = function (updateCameras) {
  131334. if (updateCameras === void 0) { updateCameras = true; }
  131335. if (this.isDisposed) {
  131336. return;
  131337. }
  131338. this._frameId++;
  131339. // Register components that have been associated lately to the scene.
  131340. this._registerTransientComponents();
  131341. this._activeParticles.fetchNewFrame();
  131342. this._totalVertices.fetchNewFrame();
  131343. this._activeIndices.fetchNewFrame();
  131344. this._activeBones.fetchNewFrame();
  131345. this._meshesForIntersections.reset();
  131346. this.resetCachedMaterial();
  131347. this.onBeforeAnimationsObservable.notifyObservers(this);
  131348. // Actions
  131349. if (this.actionManager) {
  131350. this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnEveryFrameTrigger);
  131351. }
  131352. if (this._engine.isDeterministicLockStep()) {
  131353. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime)) + this._timeAccumulator;
  131354. var defaultFPS = (60.0 / 1000.0);
  131355. var defaultFrameTime = this.getDeterministicFrameTime();
  131356. var stepsTaken = 0;
  131357. var maxSubSteps = this._engine.getLockstepMaxSteps();
  131358. var internalSteps = Math.floor(deltaTime / (1000 * defaultFPS));
  131359. internalSteps = Math.min(internalSteps, maxSubSteps);
  131360. do {
  131361. this.onBeforeStepObservable.notifyObservers(this);
  131362. // Animations
  131363. this._animationRatio = defaultFrameTime * defaultFPS;
  131364. this._animate();
  131365. this.onAfterAnimationsObservable.notifyObservers(this);
  131366. // Physics
  131367. this._advancePhysicsEngineStep(defaultFrameTime);
  131368. this.onAfterStepObservable.notifyObservers(this);
  131369. this._currentStepId++;
  131370. stepsTaken++;
  131371. deltaTime -= defaultFrameTime;
  131372. } while (deltaTime > 0 && stepsTaken < internalSteps);
  131373. this._timeAccumulator = deltaTime < 0 ? 0 : deltaTime;
  131374. }
  131375. else {
  131376. // Animations
  131377. var deltaTime = this.useConstantAnimationDeltaTime ? 16 : Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
  131378. this._animationRatio = deltaTime * (60.0 / 1000.0);
  131379. this._animate();
  131380. this.onAfterAnimationsObservable.notifyObservers(this);
  131381. // Physics
  131382. this._advancePhysicsEngineStep(deltaTime);
  131383. }
  131384. // Before camera update steps
  131385. for (var _i = 0, _a = this._beforeCameraUpdateStage; _i < _a.length; _i++) {
  131386. var step = _a[_i];
  131387. step.action();
  131388. }
  131389. // Update Cameras
  131390. if (updateCameras) {
  131391. if (this.activeCameras.length > 0) {
  131392. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  131393. var camera = this.activeCameras[cameraIndex];
  131394. camera.update();
  131395. if (camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  131396. // rig cameras
  131397. for (var index = 0; index < camera._rigCameras.length; index++) {
  131398. camera._rigCameras[index].update();
  131399. }
  131400. }
  131401. }
  131402. }
  131403. else if (this.activeCamera) {
  131404. this.activeCamera.update();
  131405. if (this.activeCamera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  131406. // rig cameras
  131407. for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
  131408. this.activeCamera._rigCameras[index].update();
  131409. }
  131410. }
  131411. }
  131412. }
  131413. // Before render
  131414. this.onBeforeRenderObservable.notifyObservers(this);
  131415. // Customs render targets
  131416. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  131417. var engine = this.getEngine();
  131418. var currentActiveCamera = this.activeCamera;
  131419. if (this.renderTargetsEnabled) {
  131420. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  131421. this._intermediateRendering = true;
  131422. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  131423. var renderTarget = this.customRenderTargets[customIndex];
  131424. if (renderTarget._shouldRender()) {
  131425. this._renderId++;
  131426. this.activeCamera = renderTarget.activeCamera || this.activeCamera;
  131427. if (!this.activeCamera) {
  131428. throw new Error("Active camera not set");
  131429. }
  131430. // Viewport
  131431. engine.setViewport(this.activeCamera.viewport);
  131432. // Camera
  131433. this.updateTransformMatrix();
  131434. renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
  131435. }
  131436. }
  131437. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  131438. this._intermediateRendering = false;
  131439. this._renderId++;
  131440. }
  131441. // Restore back buffer
  131442. if (this.customRenderTargets.length > 0) {
  131443. engine.restoreDefaultFramebuffer();
  131444. }
  131445. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  131446. this.activeCamera = currentActiveCamera;
  131447. for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
  131448. var step = _c[_b];
  131449. step.action();
  131450. }
  131451. // Clear
  131452. if (this.autoClearDepthAndStencil || this.autoClear) {
  131453. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
  131454. }
  131455. // Collects render targets from external components.
  131456. for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
  131457. var step = _e[_d];
  131458. step.action(this._renderTargets);
  131459. }
  131460. // Multi-cameras?
  131461. if (this.activeCameras.length > 0) {
  131462. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  131463. if (cameraIndex > 0) {
  131464. this._engine.clear(null, false, true, true);
  131465. }
  131466. this._processSubCameras(this.activeCameras[cameraIndex]);
  131467. }
  131468. }
  131469. else {
  131470. if (!this.activeCamera) {
  131471. throw new Error("No camera defined");
  131472. }
  131473. this._processSubCameras(this.activeCamera);
  131474. }
  131475. // Intersection checks
  131476. this._checkIntersections();
  131477. // Executes the after render stage actions.
  131478. for (var _f = 0, _g = this._afterRenderStage; _f < _g.length; _f++) {
  131479. var step = _g[_f];
  131480. step.action();
  131481. }
  131482. // After render
  131483. if (this.afterRender) {
  131484. this.afterRender();
  131485. }
  131486. this.onAfterRenderObservable.notifyObservers(this);
  131487. // Cleaning
  131488. if (this._toBeDisposed.length) {
  131489. for (var index = 0; index < this._toBeDisposed.length; index++) {
  131490. var data = this._toBeDisposed[index];
  131491. if (data) {
  131492. data.dispose();
  131493. }
  131494. }
  131495. this._toBeDisposed = [];
  131496. }
  131497. if (this.dumpNextRenderTargets) {
  131498. this.dumpNextRenderTargets = false;
  131499. }
  131500. this._activeBones.addCount(0, true);
  131501. this._activeIndices.addCount(0, true);
  131502. this._activeParticles.addCount(0, true);
  131503. };
  131504. /**
  131505. * Freeze all materials
  131506. * A frozen material will not be updatable but should be faster to render
  131507. */
  131508. Scene.prototype.freezeMaterials = function () {
  131509. for (var i = 0; i < this.materials.length; i++) {
  131510. this.materials[i].freeze();
  131511. }
  131512. };
  131513. /**
  131514. * Unfreeze all materials
  131515. * A frozen material will not be updatable but should be faster to render
  131516. */
  131517. Scene.prototype.unfreezeMaterials = function () {
  131518. for (var i = 0; i < this.materials.length; i++) {
  131519. this.materials[i].unfreeze();
  131520. }
  131521. };
  131522. /**
  131523. * Releases all held ressources
  131524. */
  131525. Scene.prototype.dispose = function () {
  131526. this.beforeRender = null;
  131527. this.afterRender = null;
  131528. this.skeletons = [];
  131529. this.morphTargetManagers = [];
  131530. this._transientComponents = [];
  131531. this._isReadyForMeshStage.clear();
  131532. this._beforeEvaluateActiveMeshStage.clear();
  131533. this._evaluateSubMeshStage.clear();
  131534. this._activeMeshStage.clear();
  131535. this._cameraDrawRenderTargetStage.clear();
  131536. this._beforeCameraDrawStage.clear();
  131537. this._beforeRenderTargetDrawStage.clear();
  131538. this._beforeRenderingGroupDrawStage.clear();
  131539. this._beforeRenderingMeshStage.clear();
  131540. this._afterRenderingMeshStage.clear();
  131541. this._afterRenderingGroupDrawStage.clear();
  131542. this._afterCameraDrawStage.clear();
  131543. this._afterRenderTargetDrawStage.clear();
  131544. this._afterRenderStage.clear();
  131545. this._beforeCameraUpdateStage.clear();
  131546. this._beforeClearStage.clear();
  131547. this._gatherRenderTargetsStage.clear();
  131548. this._gatherActiveCameraRenderTargetsStage.clear();
  131549. this._pointerMoveStage.clear();
  131550. this._pointerDownStage.clear();
  131551. this._pointerUpStage.clear();
  131552. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  131553. var component = _a[_i];
  131554. component.dispose();
  131555. }
  131556. this.importedMeshesFiles = new Array();
  131557. this.stopAllAnimations();
  131558. this.resetCachedMaterial();
  131559. // Smart arrays
  131560. if (this.activeCamera) {
  131561. this.activeCamera._activeMeshes.dispose();
  131562. this.activeCamera = null;
  131563. }
  131564. this._activeMeshes.dispose();
  131565. this._renderingManager.dispose();
  131566. this._processedMaterials.dispose();
  131567. this._activeParticleSystems.dispose();
  131568. this._activeSkeletons.dispose();
  131569. this._softwareSkinnedMeshes.dispose();
  131570. this._renderTargets.dispose();
  131571. this._registeredForLateAnimationBindings.dispose();
  131572. this._meshesForIntersections.dispose();
  131573. this._toBeDisposed = [];
  131574. // Abort active requests
  131575. for (var _b = 0, _c = this._activeRequests; _b < _c.length; _b++) {
  131576. var request = _c[_b];
  131577. request.abort();
  131578. }
  131579. // Events
  131580. this.onDisposeObservable.notifyObservers(this);
  131581. this.onDisposeObservable.clear();
  131582. this.onBeforeRenderObservable.clear();
  131583. this.onAfterRenderObservable.clear();
  131584. this.onBeforeRenderTargetsRenderObservable.clear();
  131585. this.onAfterRenderTargetsRenderObservable.clear();
  131586. this.onAfterStepObservable.clear();
  131587. this.onBeforeStepObservable.clear();
  131588. this.onBeforeActiveMeshesEvaluationObservable.clear();
  131589. this.onAfterActiveMeshesEvaluationObservable.clear();
  131590. this.onBeforeParticlesRenderingObservable.clear();
  131591. this.onAfterParticlesRenderingObservable.clear();
  131592. this.onBeforeDrawPhaseObservable.clear();
  131593. this.onAfterDrawPhaseObservable.clear();
  131594. this.onBeforeAnimationsObservable.clear();
  131595. this.onAfterAnimationsObservable.clear();
  131596. this.onDataLoadedObservable.clear();
  131597. this.onBeforeRenderingGroupObservable.clear();
  131598. this.onAfterRenderingGroupObservable.clear();
  131599. this.onMeshImportedObservable.clear();
  131600. this.onBeforeCameraRenderObservable.clear();
  131601. this.onAfterCameraRenderObservable.clear();
  131602. this.onReadyObservable.clear();
  131603. this.onNewCameraAddedObservable.clear();
  131604. this.onCameraRemovedObservable.clear();
  131605. this.onNewLightAddedObservable.clear();
  131606. this.onLightRemovedObservable.clear();
  131607. this.onNewGeometryAddedObservable.clear();
  131608. this.onGeometryRemovedObservable.clear();
  131609. this.onNewTransformNodeAddedObservable.clear();
  131610. this.onTransformNodeRemovedObservable.clear();
  131611. this.onNewMeshAddedObservable.clear();
  131612. this.onMeshRemovedObservable.clear();
  131613. this.onNewMaterialAddedObservable.clear();
  131614. this.onMaterialRemovedObservable.clear();
  131615. this.onNewTextureAddedObservable.clear();
  131616. this.onTextureRemovedObservable.clear();
  131617. this.onPrePointerObservable.clear();
  131618. this.onPointerObservable.clear();
  131619. this.onPreKeyboardObservable.clear();
  131620. this.onKeyboardObservable.clear();
  131621. this.onActiveCameraChanged.clear();
  131622. this.detachControl();
  131623. // Detach cameras
  131624. var canvas = this._engine.getRenderingCanvas();
  131625. if (canvas) {
  131626. var index;
  131627. for (index = 0; index < this.cameras.length; index++) {
  131628. this.cameras[index].detachControl(canvas);
  131629. }
  131630. }
  131631. // Release animation groups
  131632. while (this.animationGroups.length) {
  131633. this.animationGroups[0].dispose();
  131634. }
  131635. // Release lights
  131636. while (this.lights.length) {
  131637. this.lights[0].dispose();
  131638. }
  131639. // Release meshes
  131640. while (this.meshes.length) {
  131641. this.meshes[0].dispose(true);
  131642. }
  131643. while (this.transformNodes.length) {
  131644. this.removeTransformNode(this.transformNodes[0]);
  131645. }
  131646. // Release cameras
  131647. while (this.cameras.length) {
  131648. this.cameras[0].dispose();
  131649. }
  131650. // Release materials
  131651. if (this.defaultMaterial) {
  131652. this.defaultMaterial.dispose();
  131653. }
  131654. while (this.multiMaterials.length) {
  131655. this.multiMaterials[0].dispose();
  131656. }
  131657. while (this.materials.length) {
  131658. this.materials[0].dispose();
  131659. }
  131660. // Release particles
  131661. while (this.particleSystems.length) {
  131662. this.particleSystems[0].dispose();
  131663. }
  131664. // Release postProcesses
  131665. while (this.postProcesses.length) {
  131666. this.postProcesses[0].dispose();
  131667. }
  131668. // Release textures
  131669. while (this.textures.length) {
  131670. this.textures[0].dispose();
  131671. }
  131672. // Release UBO
  131673. this._sceneUbo.dispose();
  131674. if (this._alternateSceneUbo) {
  131675. this._alternateSceneUbo.dispose();
  131676. }
  131677. // Post-processes
  131678. this.postProcessManager.dispose();
  131679. // Remove from engine
  131680. index = this._engine.scenes.indexOf(this);
  131681. if (index > -1) {
  131682. this._engine.scenes.splice(index, 1);
  131683. }
  131684. this._engine.wipeCaches(true);
  131685. this._isDisposed = true;
  131686. };
  131687. Object.defineProperty(Scene.prototype, "isDisposed", {
  131688. /**
  131689. * Gets if the scene is already disposed
  131690. */
  131691. get: function () {
  131692. return this._isDisposed;
  131693. },
  131694. enumerable: true,
  131695. configurable: true
  131696. });
  131697. /**
  131698. * Call this function to reduce memory footprint of the scene.
  131699. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  131700. */
  131701. Scene.prototype.clearCachedVertexData = function () {
  131702. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  131703. var mesh = this.meshes[meshIndex];
  131704. var geometry = mesh.geometry;
  131705. if (geometry) {
  131706. geometry._indices = [];
  131707. for (var vbName in geometry._vertexBuffers) {
  131708. if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
  131709. continue;
  131710. }
  131711. geometry._vertexBuffers[vbName]._buffer._data = null;
  131712. }
  131713. }
  131714. }
  131715. };
  131716. /**
  131717. * This function will remove the local cached buffer data from texture.
  131718. * It will save memory but will prevent the texture from being rebuilt
  131719. */
  131720. Scene.prototype.cleanCachedTextureBuffer = function () {
  131721. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  131722. var baseTexture = _a[_i];
  131723. var buffer = baseTexture._buffer;
  131724. if (buffer) {
  131725. baseTexture._buffer = null;
  131726. }
  131727. }
  131728. };
  131729. /**
  131730. * Get the world extend vectors with an optional filter
  131731. *
  131732. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  131733. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  131734. */
  131735. Scene.prototype.getWorldExtends = function (filterPredicate) {
  131736. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  131737. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  131738. filterPredicate = filterPredicate || (function () { return true; });
  131739. this.meshes.filter(filterPredicate).forEach(function (mesh) {
  131740. mesh.computeWorldMatrix(true);
  131741. if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
  131742. return;
  131743. }
  131744. var boundingInfo = mesh.getBoundingInfo();
  131745. var minBox = boundingInfo.boundingBox.minimumWorld;
  131746. var maxBox = boundingInfo.boundingBox.maximumWorld;
  131747. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  131748. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  131749. });
  131750. return {
  131751. min: min,
  131752. max: max
  131753. };
  131754. };
  131755. // Picking
  131756. /**
  131757. * Creates a ray that can be used to pick in the scene
  131758. * @param x defines the x coordinate of the origin (on-screen)
  131759. * @param y defines the y coordinate of the origin (on-screen)
  131760. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  131761. * @param camera defines the camera to use for the picking
  131762. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  131763. * @returns a Ray
  131764. */
  131765. Scene.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  131766. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  131767. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131768. };
  131769. /**
  131770. * Creates a ray that can be used to pick in the scene
  131771. * @param x defines the x coordinate of the origin (on-screen)
  131772. * @param y defines the y coordinate of the origin (on-screen)
  131773. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  131774. * @param result defines the ray where to store the picking ray
  131775. * @param camera defines the camera to use for the picking
  131776. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  131777. * @returns the current scene
  131778. */
  131779. Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  131780. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  131781. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131782. };
  131783. /**
  131784. * Creates a ray that can be used to pick in the scene
  131785. * @param x defines the x coordinate of the origin (on-screen)
  131786. * @param y defines the y coordinate of the origin (on-screen)
  131787. * @param camera defines the camera to use for the picking
  131788. * @returns a Ray
  131789. */
  131790. Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  131791. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131792. };
  131793. /**
  131794. * Creates a ray that can be used to pick in the scene
  131795. * @param x defines the x coordinate of the origin (on-screen)
  131796. * @param y defines the y coordinate of the origin (on-screen)
  131797. * @param result defines the ray where to store the picking ray
  131798. * @param camera defines the camera to use for the picking
  131799. * @returns the current scene
  131800. */
  131801. Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  131802. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131803. };
  131804. /** Launch a ray to try to pick a mesh in the scene
  131805. * @param x position on screen
  131806. * @param y position on screen
  131807. * @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
  131808. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  131809. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131810. * @returns a PickingInfo
  131811. */
  131812. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera) {
  131813. // Dummy info if picking as not been imported
  131814. var pi = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__["PickingInfo"]();
  131815. pi._pickingUnavailable = true;
  131816. return pi;
  131817. };
  131818. /** Use the given ray to pick a mesh in the scene
  131819. * @param ray The ray to use to pick meshes
  131820. * @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
  131821. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  131822. * @returns a PickingInfo
  131823. */
  131824. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck) {
  131825. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131826. };
  131827. /**
  131828. * Launch a ray to try to pick a mesh in the scene
  131829. * @param x X position on screen
  131830. * @param y Y position on screen
  131831. * @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
  131832. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131833. * @returns an array of PickingInfo
  131834. */
  131835. Scene.prototype.multiPick = function (x, y, predicate, camera) {
  131836. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131837. };
  131838. /**
  131839. * Launch a ray to try to pick a mesh in the scene
  131840. * @param ray Ray to use
  131841. * @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
  131842. * @returns an array of PickingInfo
  131843. */
  131844. Scene.prototype.multiPickWithRay = function (ray, predicate) {
  131845. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  131846. };
  131847. /**
  131848. * Force the value of meshUnderPointer
  131849. * @param mesh defines the mesh to use
  131850. */
  131851. Scene.prototype.setPointerOverMesh = function (mesh) {
  131852. if (this._pointerOverMesh === mesh) {
  131853. return;
  131854. }
  131855. if (this._pointerOverMesh && this._pointerOverMesh.actionManager) {
  131856. this._pointerOverMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  131857. }
  131858. this._pointerOverMesh = mesh;
  131859. if (this._pointerOverMesh && this._pointerOverMesh.actionManager) {
  131860. this._pointerOverMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  131861. }
  131862. };
  131863. /**
  131864. * Gets the mesh under the pointer
  131865. * @returns a Mesh or null if no mesh is under the pointer
  131866. */
  131867. Scene.prototype.getPointerOverMesh = function () {
  131868. return this._pointerOverMesh;
  131869. };
  131870. // Misc.
  131871. /** @hidden */
  131872. Scene.prototype._rebuildGeometries = function () {
  131873. for (var _i = 0, _a = this.geometries; _i < _a.length; _i++) {
  131874. var geometry = _a[_i];
  131875. geometry._rebuild();
  131876. }
  131877. for (var _b = 0, _c = this.meshes; _b < _c.length; _b++) {
  131878. var mesh = _c[_b];
  131879. mesh._rebuild();
  131880. }
  131881. if (this.postProcessManager) {
  131882. this.postProcessManager._rebuild();
  131883. }
  131884. for (var _d = 0, _e = this._components; _d < _e.length; _d++) {
  131885. var component = _e[_d];
  131886. component.rebuild();
  131887. }
  131888. for (var _f = 0, _g = this.particleSystems; _f < _g.length; _f++) {
  131889. var system = _g[_f];
  131890. system.rebuild();
  131891. }
  131892. };
  131893. /** @hidden */
  131894. Scene.prototype._rebuildTextures = function () {
  131895. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  131896. var texture = _a[_i];
  131897. texture._rebuild();
  131898. }
  131899. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  131900. };
  131901. // Tags
  131902. Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
  131903. if (tagsQuery === undefined) {
  131904. // returns the complete list (could be done with Tags.MatchesQuery but no need to have a for-loop here)
  131905. return list;
  131906. }
  131907. var listByTags = [];
  131908. forEach = forEach || (function (item) { return; });
  131909. for (var i in list) {
  131910. var item = list[i];
  131911. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"].MatchesQuery(item, tagsQuery)) {
  131912. listByTags.push(item);
  131913. forEach(item);
  131914. }
  131915. }
  131916. return listByTags;
  131917. };
  131918. /**
  131919. * Get a list of meshes by tags
  131920. * @param tagsQuery defines the tags query to use
  131921. * @param forEach defines a predicate used to filter results
  131922. * @returns an array of Mesh
  131923. */
  131924. Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
  131925. return this._getByTags(this.meshes, tagsQuery, forEach);
  131926. };
  131927. /**
  131928. * Get a list of cameras by tags
  131929. * @param tagsQuery defines the tags query to use
  131930. * @param forEach defines a predicate used to filter results
  131931. * @returns an array of Camera
  131932. */
  131933. Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
  131934. return this._getByTags(this.cameras, tagsQuery, forEach);
  131935. };
  131936. /**
  131937. * Get a list of lights by tags
  131938. * @param tagsQuery defines the tags query to use
  131939. * @param forEach defines a predicate used to filter results
  131940. * @returns an array of Light
  131941. */
  131942. Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
  131943. return this._getByTags(this.lights, tagsQuery, forEach);
  131944. };
  131945. /**
  131946. * Get a list of materials by tags
  131947. * @param tagsQuery defines the tags query to use
  131948. * @param forEach defines a predicate used to filter results
  131949. * @returns an array of Material
  131950. */
  131951. Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
  131952. return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
  131953. };
  131954. /**
  131955. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  131956. * This allowed control for front to back rendering or reversly depending of the special needs.
  131957. *
  131958. * @param renderingGroupId The rendering group id corresponding to its index
  131959. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  131960. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  131961. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  131962. */
  131963. Scene.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  131964. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  131965. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  131966. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  131967. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  131968. };
  131969. /**
  131970. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  131971. *
  131972. * @param renderingGroupId The rendering group id corresponding to its index
  131973. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  131974. * @param depth Automatically clears depth between groups if true and autoClear is true.
  131975. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  131976. */
  131977. Scene.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  131978. if (depth === void 0) { depth = true; }
  131979. if (stencil === void 0) { stencil = true; }
  131980. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil);
  131981. };
  131982. /**
  131983. * Gets the current auto clear configuration for one rendering group of the rendering
  131984. * manager.
  131985. * @param index the rendering group index to get the information for
  131986. * @returns The auto clear setup for the requested rendering group
  131987. */
  131988. Scene.prototype.getAutoClearDepthStencilSetup = function (index) {
  131989. return this._renderingManager.getAutoClearDepthStencilSetup(index);
  131990. };
  131991. Object.defineProperty(Scene.prototype, "blockMaterialDirtyMechanism", {
  131992. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  131993. get: function () {
  131994. return this._blockMaterialDirtyMechanism;
  131995. },
  131996. set: function (value) {
  131997. if (this._blockMaterialDirtyMechanism === value) {
  131998. return;
  131999. }
  132000. this._blockMaterialDirtyMechanism = value;
  132001. if (!value) { // Do a complete update
  132002. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AllDirtyFlag);
  132003. }
  132004. },
  132005. enumerable: true,
  132006. configurable: true
  132007. });
  132008. /**
  132009. * Will flag all materials as dirty to trigger new shader compilation
  132010. * @param flag defines the flag used to specify which material part must be marked as dirty
  132011. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  132012. */
  132013. Scene.prototype.markAllMaterialsAsDirty = function (flag, predicate) {
  132014. if (this._blockMaterialDirtyMechanism) {
  132015. return;
  132016. }
  132017. for (var _i = 0, _a = this.materials; _i < _a.length; _i++) {
  132018. var material = _a[_i];
  132019. if (predicate && !predicate(material)) {
  132020. continue;
  132021. }
  132022. material.markAsDirty(flag);
  132023. }
  132024. };
  132025. /** @hidden */
  132026. Scene.prototype._loadFile = function (url, onSuccess, onProgress, useOfflineSupport, useArrayBuffer, onError) {
  132027. var _this = this;
  132028. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(url, onSuccess, onProgress, useOfflineSupport ? this.offlineProvider : undefined, useArrayBuffer, onError);
  132029. this._activeRequests.push(request);
  132030. request.onCompleteObservable.add(function (request) {
  132031. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  132032. });
  132033. return request;
  132034. };
  132035. /** @hidden */
  132036. Scene.prototype._loadFileAsync = function (url, useOfflineSupport, useArrayBuffer) {
  132037. var _this = this;
  132038. return new Promise(function (resolve, reject) {
  132039. _this._loadFile(url, function (data) {
  132040. resolve(data);
  132041. }, undefined, useOfflineSupport, useArrayBuffer, function (request, exception) {
  132042. reject(exception);
  132043. });
  132044. });
  132045. };
  132046. // Statics
  132047. Scene._uniqueIdCounter = 0;
  132048. /** The fog is deactivated */
  132049. Scene.FOGMODE_NONE = 0;
  132050. /** The fog density is following an exponential function */
  132051. Scene.FOGMODE_EXP = 1;
  132052. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  132053. Scene.FOGMODE_EXP2 = 2;
  132054. /** The fog density is following a linear function. */
  132055. Scene.FOGMODE_LINEAR = 3;
  132056. /**
  132057. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  132058. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132059. */
  132060. Scene.MinDeltaTime = 1.0;
  132061. /**
  132062. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  132063. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132064. */
  132065. Scene.MaxDeltaTime = 1000.0;
  132066. /** The distance in pixel that you have to move to prevent some events */
  132067. Scene.DragMovementThreshold = 10; // in pixels
  132068. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  132069. Scene.LongPressDelay = 500; // in milliseconds
  132070. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  132071. Scene.DoubleClickDelay = 300; // in milliseconds
  132072. /** If you need to check double click without raising a single click at first click, enable this flag */
  132073. Scene.ExclusiveDoubleClickMode = false;
  132074. return Scene;
  132075. }(_abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"]));
  132076. /***/ }),
  132077. /***/ "./sceneComponent.ts":
  132078. /*!***************************!*\
  132079. !*** ./sceneComponent.ts ***!
  132080. \***************************/
  132081. /*! exports provided: SceneComponentConstants, Stage */
  132082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132083. "use strict";
  132084. __webpack_require__.r(__webpack_exports__);
  132085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return SceneComponentConstants; });
  132086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; });
  132087. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  132088. /**
  132089. * Groups all the scene component constants in one place to ease maintenance.
  132090. * @hidden
  132091. */
  132092. var SceneComponentConstants = /** @class */ (function () {
  132093. function SceneComponentConstants() {
  132094. }
  132095. SceneComponentConstants.NAME_EFFECTLAYER = "EffectLayer";
  132096. SceneComponentConstants.NAME_LAYER = "Layer";
  132097. SceneComponentConstants.NAME_LENSFLARESYSTEM = "LensFlareSystem";
  132098. SceneComponentConstants.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  132099. SceneComponentConstants.NAME_PARTICLESYSTEM = "ParticleSystem";
  132100. SceneComponentConstants.NAME_GAMEPAD = "Gamepad";
  132101. SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  132102. SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  132103. SceneComponentConstants.NAME_DEPTHRENDERER = "DepthRenderer";
  132104. SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  132105. SceneComponentConstants.NAME_SPRITE = "Sprite";
  132106. SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
  132107. SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  132108. SceneComponentConstants.NAME_SHADOWGENERATOR = "ShadowGenerator";
  132109. SceneComponentConstants.NAME_OCTREE = "Octree";
  132110. SceneComponentConstants.NAME_PHYSICSENGINE = "PhysicsEngine";
  132111. SceneComponentConstants.NAME_AUDIO = "Audio";
  132112. SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  132113. SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  132114. SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  132115. SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  132116. SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  132117. SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0;
  132118. SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER = 1;
  132119. SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER = 0;
  132120. SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE = 0;
  132121. SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE = 0;
  132122. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  132123. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  132124. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  132125. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  132126. SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  132127. SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER = 0;
  132128. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
  132129. SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
  132130. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2;
  132131. SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER = 3;
  132132. SceneComponentConstants.STEP_AFTERRENDER_AUDIO = 0;
  132133. SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 0;
  132134. SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  132135. SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 2;
  132136. SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  132137. SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  132138. SceneComponentConstants.STEP_POINTERMOVE_SPRITE = 0;
  132139. SceneComponentConstants.STEP_POINTERDOWN_SPRITE = 0;
  132140. SceneComponentConstants.STEP_POINTERUP_SPRITE = 0;
  132141. return SceneComponentConstants;
  132142. }());
  132143. /**
  132144. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  132145. * @hidden
  132146. */
  132147. var Stage = /** @class */ (function (_super) {
  132148. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Stage, _super);
  132149. /**
  132150. * Hide ctor from the rest of the world.
  132151. * @param items The items to add.
  132152. */
  132153. function Stage(items) {
  132154. return _super.apply(this, items) || this;
  132155. }
  132156. /**
  132157. * Creates a new Stage.
  132158. * @returns A new instance of a Stage
  132159. */
  132160. Stage.Create = function () {
  132161. return Object.create(Stage.prototype);
  132162. };
  132163. /**
  132164. * Registers a step in an ordered way in the targeted stage.
  132165. * @param index Defines the position to register the step in
  132166. * @param component Defines the component attached to the step
  132167. * @param action Defines the action to launch during the step
  132168. */
  132169. Stage.prototype.registerStep = function (index, component, action) {
  132170. var i = 0;
  132171. var maxIndex = Number.MAX_VALUE;
  132172. for (; i < this.length; i++) {
  132173. var step = this[i];
  132174. maxIndex = step.index;
  132175. if (index < maxIndex) {
  132176. break;
  132177. }
  132178. }
  132179. this.splice(i, 0, { index: index, component: component, action: action.bind(component) });
  132180. };
  132181. /**
  132182. * Clears all the steps from the stage.
  132183. */
  132184. Stage.prototype.clear = function () {
  132185. this.length = 0;
  132186. };
  132187. return Stage;
  132188. }(Array));
  132189. /***/ })
  132190. /******/ });
  132191. });
  132192. //# sourceMappingURL=babylon.max.js.map